diff options
-rw-r--r-- | os/hal/platforms/SPC563Mxx/spc563m_registry.h | 1 | ||||
-rw-r--r-- | os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c | 33 | ||||
-rw-r--r-- | os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h | 4 |
3 files changed, 32 insertions, 6 deletions
diff --git a/os/hal/platforms/SPC563Mxx/spc563m_registry.h b/os/hal/platforms/SPC563Mxx/spc563m_registry.h index 757f88e0c..66a3e74d0 100644 --- a/os/hal/platforms/SPC563Mxx/spc563m_registry.h +++ b/os/hal/platforms/SPC563Mxx/spc563m_registry.h @@ -33,6 +33,7 @@ */
/* eDMA attributes.*/
#define SPC5_EDMA_NCHANNELS 64
+#define SPC5_EDMA_HAS_MUX FALSE
/* eQADC attributes.*/
#define SPC5_HAS_EQADC TRUE
diff --git a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c index 2a1725e0d..94db29da7 100644 --- a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c +++ b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c @@ -41,7 +41,10 @@ /* Driver local variables and types. */
/*===========================================================================*/
-static edma_channel_config_t channels[SPC5_EDMA_NCHANNELS];
+/**
+ * @brief Configurations for the various EDMA channels.
+ */
+static const edma_channel_config_t *channels[SPC5_EDMA_NCHANNELS];
/*===========================================================================*/
/* Driver local functions. */
@@ -73,8 +76,23 @@ void edmaInit(void) { *
* @special
*/
-edma_channel_t edmaAllocChannel(const edma_channel_config_t *ccfg) {
-
+edma_channel_t edmaChannelAllocate(const edma_channel_config_t *ccfg) {
+ edma_channel_t channel;
+
+ chDbgCheck((ccfg != NULL) && (ccfg->dma_func != NULL),
+ "edmaChannelAllocate");
+
+#if SPC5_EDMA_HAS_MUX
+ /* TODO: MUX handling.*/
+ channel = EDMA_ERROR;
+ return channel;
+#else /* !SPC5_EDMA_HAS_MUX */
+ channel = (edma_channel_t)ccfg->dma_periph;
+ if (channels[channel] != NULL)
+ return EDMA_ERROR; /* Already taken.*/
+ channels[channel] = ccfg;
+ return channel;
+#endif /* !SPC5_EDMA_HAS_MUX */
}
/**
@@ -84,8 +102,15 @@ edma_channel_t edmaAllocChannel(const edma_channel_config_t *ccfg) { *
* @special
*/
-void edmaReleaseChannel(edma_channel_t channel) {
+void edmaChannelRelease(edma_channel_t channel) {
+
+ chDbgCheck((channel < 0) && (channel >= SPC5_EDMA_NCHANNELS),
+ "edmaChannelAllocate");
+ chDbgAssert(channels[channel] != NULL,
+ "edmaChannelRelease(), #1",
+ "not allocated");
+ channels[channel] = NULL;
}
/** @} */
diff --git a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h index ab13fc610..03d85b138 100644 --- a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h +++ b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h @@ -92,8 +92,8 @@ typedef struct { extern "C" {
#endif
void edmaInit(void);
- edma_channel_t edmaAllocChannel(const edma_channel_config_t *ccfg);
- void edmaReleaseChannel(edma_channel_t channel);
+ edma_channel_t edmaChannelAllocate(const edma_channel_config_t *ccfg);
+ void edmaChannelRelease(edma_channel_t channel);
#ifdef __cplusplus
}
#endif
|