1.1 --- a/lib/init.c Mon Oct 22 21:44:02 2018 +0200
1.2 +++ b/lib/init.c Tue Oct 23 00:33:03 2018 +0200
1.3 @@ -194,6 +194,18 @@
1.4 (enable ? SET_REG : CLR_REG)(DMA_REG(channel, DCHxCON), 1 << 6);
1.5 }
1.6
1.7 +/* Set a channel's source. */
1.8 +
1.9 +void dma_set_source(int channel,
1.10 + uint32_t source_start_address, uint16_t source_size)
1.11 +{
1.12 + if ((channel < DCHMIN) || (channel > DCHMAX))
1.13 + return;
1.14 +
1.15 + REG(DMA_REG(channel, DCHxSSIZ)) = source_size;
1.16 + REG(DMA_REG(channel, DCHxSSA)) = source_start_address;
1.17 +}
1.18 +
1.19 /* Set a channel's transfer parameters. */
1.20
1.21 void dma_set_transfer(int channel,
1.22 @@ -204,8 +216,8 @@
1.23 if ((channel < DCHMIN) || (channel > DCHMAX))
1.24 return;
1.25
1.26 - REG(DMA_REG(channel, DCHxSSIZ)) = source_size;
1.27 - REG(DMA_REG(channel, DCHxSSA)) = source_start_address;
1.28 + dma_set_source(channel, source_start_address, source_size);
1.29 +
1.30 REG(DMA_REG(channel, DCHxDSIZ)) = destination_size;
1.31 REG(DMA_REG(channel, DCHxDSA)) = destination_start_address;
1.32 REG(DMA_REG(channel, DCHxCSIZ)) = cell_size;