1.1 --- a/include/init.h Mon Oct 22 21:44:02 2018 +0200
1.2 +++ b/include/init.h Tue Oct 23 00:33:03 2018 +0200
1.3 @@ -70,6 +70,9 @@
1.4
1.5 void dma_set_receive_events(int channel, int enable);
1.6
1.7 +void dma_set_source(int channel,
1.8 + uint32_t source_start_address, uint16_t source_size);
1.9 +
1.10 void dma_set_transfer(int channel,
1.11 uint32_t source_start_address, uint16_t source_size,
1.12 uint32_t destination_start_address, uint16_t destination_size,
2.1 --- a/lib/init.c Mon Oct 22 21:44:02 2018 +0200
2.2 +++ b/lib/init.c Tue Oct 23 00:33:03 2018 +0200
2.3 @@ -194,6 +194,18 @@
2.4 (enable ? SET_REG : CLR_REG)(DMA_REG(channel, DCHxCON), 1 << 6);
2.5 }
2.6
2.7 +/* Set a channel's source. */
2.8 +
2.9 +void dma_set_source(int channel,
2.10 + uint32_t source_start_address, uint16_t source_size)
2.11 +{
2.12 + if ((channel < DCHMIN) || (channel > DCHMAX))
2.13 + return;
2.14 +
2.15 + REG(DMA_REG(channel, DCHxSSIZ)) = source_size;
2.16 + REG(DMA_REG(channel, DCHxSSA)) = source_start_address;
2.17 +}
2.18 +
2.19 /* Set a channel's transfer parameters. */
2.20
2.21 void dma_set_transfer(int channel,
2.22 @@ -204,8 +216,8 @@
2.23 if ((channel < DCHMIN) || (channel > DCHMAX))
2.24 return;
2.25
2.26 - REG(DMA_REG(channel, DCHxSSIZ)) = source_size;
2.27 - REG(DMA_REG(channel, DCHxSSA)) = source_start_address;
2.28 + dma_set_source(channel, source_start_address, source_size);
2.29 +
2.30 REG(DMA_REG(channel, DCHxDSIZ)) = destination_size;
2.31 REG(DMA_REG(channel, DCHxDSA)) = destination_start_address;
2.32 REG(DMA_REG(channel, DCHxCSIZ)) = cell_size;