diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-06-10 11:43:41 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-06-10 11:43:41 +0000 |
commit | ae1cb6d0d72b16c7d7c8c2a7194aeb51d8c6642f (patch) | |
tree | 3782aa4c9eea5ae0ab1850f651cd1c083a781287 /os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c | |
parent | fad64409ba2a1ff1948578318a01dd0a49aeff4c (diff) | |
download | ChibiOS-ae1cb6d0d72b16c7d7c8c2a7194aeb51d8c6642f.tar.gz ChibiOS-ae1cb6d0d72b16c7d7c8c2a7194aeb51d8c6642f.tar.bz2 ChibiOS-ae1cb6d0d72b16c7d7c8c2a7194aeb51d8c6642f.zip |
DSPI and DMA-MUX support for SPC5xx.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5830 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c')
-rw-r--r-- | os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c index a0538ca78..3561a73e7 100644 --- a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c +++ b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c @@ -1314,12 +1314,22 @@ edma_channel_t edmaChannelAllocate(const edma_channel_config_t *ccfg) { "edmaChannelAllocate");
#if SPC5_EDMA_HAS_MUX
- /* TODO: MUX handling.*/
- channel = 0;
+ /* Searching for a free channel, we have the MUX so any channel is
+ acceptable.*/
+ for (channel = 0; channel < SPC5_EDMA_NCHANNELS; channel++)
+ if (channels[channel] == NULL)
+ break;
+ if (channel >= SPC5_EDMA_NCHANNELS)
+ return EDMA_ERROR; /* No free channels. */
+
+ /* Programming the MUX.*/
+ SPC5_DMAMUX.CHCONFIG[channel].R = (uint8_t)(0x80 | ccfg->dma_periph);
#else /* !SPC5_EDMA_HAS_MUX */
+ /* There is no MUX so we can just check that the specified channels is
+ available.*/
channel = (edma_channel_t)ccfg->dma_periph;
if (channels[channel] != NULL)
- return EDMA_ERROR; /* Already taken.*/
+ return EDMA_ERROR; /* Already taken. */
#endif /* !SPC5_EDMA_HAS_MUX */
/* Associating the configuration to the channel.*/
@@ -1354,6 +1364,11 @@ void edmaChannelRelease(edma_channel_t channel) { /* Enforcing a stop.*/
edmaChannelStop(channel);
+#if SPC5_EDMA_HAS_MUX
+ /* Disabling the MUX slot.*/
+ SPC5_DMAMUX.CHCONFIG[channel].R = 0;
+#endif
+
/* Clearing ISR sources for the channel.*/
SPC5_EDMA.CIRQR.R = channel;
SPC5_EDMA.CEEIR.R = channel;
|