diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-03-04 08:57:20 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-03-04 08:57:20 +0000 |
commit | 7519de606e9e527da746cf84f10bb48b1e5b99d9 (patch) | |
tree | a55ceefe289198f85a172ea1af7ce3dcb5189ef5 | |
parent | f9a52f29e05620f3ba4a849072f861faefd028eb (diff) | |
download | ChibiOS-7519de606e9e527da746cf84f10bb48b1e5b99d9.tar.gz ChibiOS-7519de606e9e527da746cf84f10bb48b1e5b99d9.tar.bz2 ChibiOS-7519de606e9e527da746cf84f10bb48b1e5b99d9.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5353 35acf78f-673a-0410-8e92-d51de3d6d3f4
-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
|