aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/SPC5xx/EDMA_v1
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-03-05 15:37:10 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-03-05 15:37:10 +0000
commitb8861047963cae44890f8928d4fe1a2bcad864b1 (patch)
tree74efac85fb4b913ead73d52e769b8ffd2cbfbd76 /os/hal/platforms/SPC5xx/EDMA_v1
parent736ee907455c8842e0ebd928f3bc8ddeff2ab9f9 (diff)
downloadChibiOS-b8861047963cae44890f8928d4fe1a2bcad864b1.tar.gz
ChibiOS-b8861047963cae44890f8928d4fe1a2bcad864b1.tar.bz2
ChibiOS-b8861047963cae44890f8928d4fe1a2bcad864b1.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5364 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/SPC5xx/EDMA_v1')
-rw-r--r--os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c42
-rw-r--r--os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h62
2 files changed, 104 insertions, 0 deletions
diff --git a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c
index cbb7e7ef8..0998289c2 100644
--- a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c
+++ b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.c
@@ -748,4 +748,46 @@ void edmaChannelRelease(edma_channel_t channel) {
channels[channel] = NULL;
}
+/**
+ * @brief EDMA channel setup.
+ *
+ * @param[in] channel eDMA channel number
+ * @param[in] src source address
+ * @param[in] dst destination address
+ * @param[in] soff source address offset
+ * @param[in] doff destination address offset
+ * @param[in] ssize source transfer size
+ * @param[in] dsize destination transfer size
+ * @param[in] nbytes minor loop count
+ * @param[in] iter major loop count
+ * @param[in] dlast_sga Last Destination Address Adjustment or
+ * Scatter Gather Address
+ * @param[in] slast last source address adjustment
+ * @param[in] mode LSW of TCD register 7
+ */
+void edmaChannelSetupx(edma_channel_t channel,
+ void *src,
+ void *dst,
+ uint32_t soff,
+ uint32_t doff,
+ uint32_t ssize,
+ uint32_t dsize,
+ uint32_t nbytes,
+ uint32_t iter,
+ uint32_t slast,
+ uint32_t dlast,
+ uint32_t mode) {
+
+ edma_tcd_t *tcdp = edmaGetTCD(channel);
+
+ tcdp->word[0] = (uint32_t)src;
+ tcdp->word[1] = (ssize << 24) | (dsize << 16) | soff;
+ tcdp->word[2] = nbytes;
+ tcdp->word[3] = slast;
+ tcdp->word[0] = (uint32_t)dst;
+ tcdp->word[5] = (iter << 16) | doff;
+ tcdp->word[6] = dlast;
+ tcdp->word[7] = (iter << 16) | mode;
+}
+
/** @} */
diff --git a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h
index 1ea965551..ad7f5ed5e 100644
--- a/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h
+++ b/os/hal/platforms/SPC5xx/EDMA_v1/spc5_edma.h
@@ -108,6 +108,36 @@ typedef struct {
/*===========================================================================*/
/**
+ * @brief Returns the TCD address associated to a channel.
+ *
+ * @param[in] channel the channel number
+ * @return A pointer to an @p edma_tcd_t structure.
+ *
+ * @api
+ */
+#define edmaGetTCD(channel) ((edma_tcd_t *)&EDMA.TCD[channel])
+
+/**
+ * @brief Sets the source address into a TCD.
+ *
+ * @param[in] tcdp pointer to an @p edma_tcd_t structure
+ *
+ * @api
+ */
+#define edmaChannelSetSourceAddress(tcdp, src) \
+ ((tcdp)->word[0] = (uint32_t)(src))
+
+/**
+ * @brief Sets the destination address into a TCD.
+ *
+ * @param[in] tcdp pointer to an @p edma_tcd_t structure
+ *
+ * @api
+ */
+#define edmaChannelSetDestinationAddress(tcdp, dst) \
+ ((tcdp)->word[4] = (uint32_t)(dst))
+
+/**
* @brief Starts or restarts an EDMA channel.
*
* @param[in] channel the channel number
@@ -125,6 +155,38 @@ typedef struct {
*/
#define edmaChannelStop(channel) (EDMA.CERQR.R = (channel))
+/**
+ * @brief EDMA channel setup.
+ *
+ * @param[in] channel eDMA channel number
+ * @param[in] src source address
+ * @param[in] dst destination address
+ * @param[in] soff source address offset
+ * @param[in] doff destination address offset
+ * @param[in] ssize source transfer size
+ * @param[in] dsize destination transfer size
+ * @param[in] nbytes minor loop count
+ * @param[in] iter major loop count
+ * @param[in] dlast last destination address adjustment
+ * @param[in] slast last source address adjustment
+ * @param[in] mode LSW of TCD register 7
+ *
+ * @api
+ */
+#define edmaChannelSetup(channel, src, dst, soff, doff, ssize, dsize, \
+ nbytes, iter, slast, dlast, mode) { \
+ edma_tcd_t *tcdp = edmaGetTCD(channel); \
+ tcdp->word[0] = (uint32_t)(src); \
+ tcdp->word[1] = ((uint32_t)(ssize) << 24) | ((uint32_t)(dsize) << 16) | \
+ (uint32_t)(soff); \
+ tcdp->word[2] = (uint32_t)(nbytes); \
+ tcdp->word[3] = (uint32_t)(slast); \
+ tcdp->word[0] = (uint32_t)(dst); \
+ tcdp->word[5] = ((uint32_t)(iter) << 16) | (uint32_t)(doff); \
+ tcdp->word[6] = (uint32_t)(dlast); \
+ tcdp->word[7] = ((uint32_t)(iter) << 16) | (uint32_t)(mode); \
+}
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/