mirror of https://github.com/rusefi/ChibiOS.git
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5377 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
09d8d2dfdc
commit
ba2057b89e
|
@ -711,7 +711,7 @@ edma_channel_t edmaChannelAllocate(const edma_channel_config_t *ccfg) {
|
|||
/* Associating the configuration to the channel.*/
|
||||
channels[channel] = ccfg;
|
||||
|
||||
/* If an error callback is defined then the erro interrupt source is
|
||||
/* If an error callback is defined then the error interrupt source is
|
||||
enabled for the channel.*/
|
||||
if (ccfg->dma_error_func != NULL)
|
||||
EDMA.SEEIR.R = channel;
|
||||
|
|
|
@ -93,7 +93,6 @@ typedef int32_t edma_channel_t;
|
|||
typedef struct {
|
||||
union {
|
||||
uint32_t word[8];
|
||||
uint32_t hword[16];
|
||||
};
|
||||
} edma_tcd_t;
|
||||
|
||||
|
@ -148,116 +147,100 @@ typedef struct {
|
|||
#define edmaGetTCD(channel) ((edma_tcd_t *)&EDMA.TCD[channel])
|
||||
|
||||
/**
|
||||
* @brief Sets the source address into a TCD.
|
||||
* @brief Sets the word 0 fields into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] dst the source address
|
||||
* @param[in] src the source address
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetSourceAddress(tcdp, src) \
|
||||
#define edmaTCDSetWord0(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
|
||||
* @param[in] dst the destination address
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetDestinationAddress(tcdp, dst) \
|
||||
((tcdp)->word[4] = (uint32_t)(dst))
|
||||
|
||||
/**
|
||||
* @brief Sets the transfer widths into a TCD.
|
||||
* @brief Sets the word 1 fields into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] ssize the source width
|
||||
* @param[in] dst the destination width
|
||||
* @param[in] soff the source increment value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetTransferWidths(tcdp, ssize, dsize) \
|
||||
((tcdp)->hword[2] = ((uint16_t)((ssize) << 8) | (uint16_t)(dsize)))
|
||||
#define edmaTCDSetWord1(tcdp, ssize, dsize, soff) \
|
||||
((tcdp)->word[1] = (((uint32_t)(ssize) << 24) | \
|
||||
((uint32_t)(dsize) << 16) | \
|
||||
((uint32_t)(soff) << 0)))
|
||||
|
||||
/**
|
||||
* @brief Sets the inner loop counter value into a TCD.
|
||||
* @brief Sets the word 2 fields into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] nbytes the inner counter value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetInnnerLoopCount(tcdp, nbytes) \
|
||||
#define edmaTCDSetWord2(tcdp, nbytes) \
|
||||
((tcdp)->word[2] = (uint32_t)(nbytes))
|
||||
|
||||
/**
|
||||
* @brief Sets the source address increment value into a TCD.
|
||||
* @brief Sets the word 3 fields into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] soff the source increment value
|
||||
* @param[in] slast the adjustment value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetSetSourceIncrement(tcdp, soff) \
|
||||
((tcdp)->hword[3] = (uint16_t)(soff))
|
||||
|
||||
/**
|
||||
* @brief Sets the destination address increment value into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] soff the source increment value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetSetDestinationIncrement(tcdp, doff) \
|
||||
((tcdp)->hword[3] = (uint16_t)(doff))
|
||||
|
||||
/**
|
||||
* @brief Sets the outer loop counter value into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] iter the outer counter value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetOuterLoopCount(tcdp, iter) { \
|
||||
((tcdp)->hword[10] = (uint16_t)(iter)); \
|
||||
((tcdp)->hword[14] = (uint16_t)(iter)); \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the source address adjustment into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] slast the adjustment value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetSourceAdjustment(tcdp, slast) \
|
||||
#define edmaTCDSetWord3(tcdp, slast) \
|
||||
((tcdp)->word[3] = (uint32_t)(slast))
|
||||
|
||||
/**
|
||||
* @brief Sets the destination address adjustment into a TCD.
|
||||
* @brief Sets the word 4 fields into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] dst the destination address
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetWord4(tcdp, dst) \
|
||||
((tcdp)->word[4] = (uint32_t)(dst))
|
||||
|
||||
/**
|
||||
* @brief Sets the word 5 fields into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] citer the current outer counter value
|
||||
* @param[in] doff the destination increment value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetWord5(tcdp, citer, doff) \
|
||||
((tcdp)->word[5] = (((uint32_t)(citer) << 16) | \
|
||||
((uint32_t)(doff) << 0)))
|
||||
|
||||
/**
|
||||
* @brief Sets the word 6 fields into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] dlast the adjustment value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetDestinationAdjustment(tcdp, dlast) \
|
||||
#define edmaTCDSetWord6(tcdp, dlast) \
|
||||
((tcdp)->word[6] = (uint32_t)(dlast))
|
||||
|
||||
/**
|
||||
* @brief Sets the channel mode bits into a TCD.
|
||||
* @brief Sets the word 7 fields into a TCD.
|
||||
*
|
||||
* @param[in] tcdp pointer to an @p edma_tcd_t structure
|
||||
* @param[in] biter the base outer counter value
|
||||
* @param[in] mode the mode value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define edmaTCDSetMode(tcdp, mode) ((tcdp)->hword[15] = (uint16_t)(mode))
|
||||
#define edmaTCDSetWord7(tcdp, biter, mode) \
|
||||
((tcdp)->word[7] = (((uint32_t)(biter) << 16) | \
|
||||
((uint32_t)(mode) << 0)))
|
||||
|
||||
/**
|
||||
* @brief Starts or restarts an EDMA channel.
|
||||
|
@ -301,16 +284,14 @@ typedef struct {
|
|||
#define edmaChannelSetup(channel, src, dst, soff, doff, ssize, dsize, \
|
||||
nbytes, iter, slast, dlast, mode) { \
|
||||
edma_tcd_t *tcdp = edmaGetTCD(channel); \
|
||||
edmaTCDSetSourceAddress(tcdp, src); \
|
||||
edmaTCDSetDestinationAddress(tcdp, dst); \
|
||||
edmaTCDSetSetSourceIncrement(tcdp, soff); \
|
||||
edmaTCDSetSetDestinationIncrement(tcdp, doff); \
|
||||
edmaTCDSetTransferWidths(tcdp, ssize, dsize); \
|
||||
edmaTCDSetInnnerLoopCount(tcdp, nbytes); \
|
||||
edmaTCDSetOuterLoopCount(tcdp, iter); \
|
||||
edmaTCDSetSourceAdjustment(tcdp, slast); \
|
||||
edmaTCDSetDestinationAdjustment(tcdp, dlast); \
|
||||
edmaTCDSetMode(tcdp, dlast); \
|
||||
edmaTCDSetWord0(tcdp, src); \
|
||||
edmaTCDSetWord1(tcdp, ssize, dsize, soff); \
|
||||
edmaTCDSetWord2(tcdp, nbytes); \
|
||||
edmaTCDSetWord3(tcdp, slast); \
|
||||
edmaTCDSetWord4(tcdp, dst); \
|
||||
edmaTCDSetWord5(tcdp, iter, doff); \
|
||||
edmaTCDSetWord6(tcdp, dlast); \
|
||||
edmaTCDSetWord7(tcdp, iter, mode); \
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -420,7 +420,7 @@ static void adc_serve_rfifo_irq(edma_channel_t channel, void *p) {
|
|||
edma_tcd_t *tcdp = edmaGetTCD(channel);
|
||||
|
||||
if (adcp->grpp != NULL) {
|
||||
if (tcdp->hword[10] != tcdp->hword[14]) {
|
||||
if ((tcdp->word[5] >> 16) != (tcdp->word[7] >> 16)) {
|
||||
/* Half transfer processing.*/
|
||||
_adc_isr_half_code(adcp);
|
||||
}
|
||||
|
@ -597,34 +597,6 @@ void adc_lld_start(ADCDriver *adcp) {
|
|||
(adcp->rfifo_channel != EDMA_ERROR),
|
||||
"adc_lld_start(), #1", "channel cannot be allocated");
|
||||
|
||||
/* Setting up TCD parameters that will not change during operations,
|
||||
other parameters are set to a temporary value and will be changed
|
||||
when starting a conversion.*/
|
||||
edmaChannelSetup(adcp->cfifo_channel, /* channel. */
|
||||
NULL, /* source, temporary. */
|
||||
CFIFO_PUSH_ADDR(adcp->fifo), /* destination. */
|
||||
4, /* soff, advance by 4. */
|
||||
0, /* doff, do not advance. */
|
||||
2, /* ssize, 32 bits transfers.*/
|
||||
2, /* dsize, 32 bits transfers.*/
|
||||
4, /* nbytes, always four. */
|
||||
0, /* iter, temporary. */
|
||||
0, /* slast, temporary. */
|
||||
0, /* dlast, no dest.adjust. */
|
||||
EDMA_TCD_MODE_DREQ); /* mode. */
|
||||
edmaChannelSetup(adcp->rfifo_channel, /* channel. */
|
||||
RFIFO_POP_ADDR(adcp->fifo), /* source. */
|
||||
NULL, /* destination, temporary. */
|
||||
0, /* soff, do not advance. */
|
||||
2, /* doff, advance by two. */
|
||||
1, /* ssize, 16 bits transfers.*/
|
||||
1, /* dsize, 16 bits transfers.*/
|
||||
2, /* nbytes, always two. */
|
||||
0, /* iter, temporary. */
|
||||
0, /* slast, no source adjust. */
|
||||
0, /* dlast, temporary. */
|
||||
0); /* mode, temporary. */
|
||||
|
||||
/* HW triggers setup.*/
|
||||
SIU.ETISR.R = adcp->config->etisr;
|
||||
SIU.ISEL3.R = adcp->config->isel3;
|
||||
|
@ -659,31 +631,44 @@ void adc_lld_stop(ADCDriver *adcp) {
|
|||
* @notapi
|
||||
*/
|
||||
void adc_lld_start_conversion(ADCDriver *adcp) {
|
||||
edma_tcd_t *ctcdp = edmaGetTCD(adcp->cfifo_channel);
|
||||
edma_tcd_t *rtcdp = edmaGetTCD(adcp->rfifo_channel);
|
||||
|
||||
chDbgAssert(adcp->grpp->num_iterations >= adcp->depth,
|
||||
"adc_lld_start_conversion(), #1", "too many elements");
|
||||
|
||||
/* Updating the variable TCD fields for CFIFO.*/
|
||||
edmaTCDSetSourceAddress(ctcdp, adcp->grpp->commands);
|
||||
edmaTCDSetOuterLoopCount(ctcdp, (uint32_t)adcp->grpp->num_channels *
|
||||
(uint32_t)adcp->depth);
|
||||
edmaTCDSetSourceAdjustment(ctcdp,
|
||||
CPL2((uint32_t)adcp->grpp->num_channels *
|
||||
(uint32_t)adcp->depth *
|
||||
sizeof(adccommand_t)));
|
||||
/* Setting up CFIFO TCD parameters.*/
|
||||
edmaChannelSetup(adcp->cfifo_channel, /* channel. */
|
||||
adcp->grpp->commands, /* src. */
|
||||
CFIFO_PUSH_ADDR(adcp->fifo), /* dst. */
|
||||
4, /* soff, advance by 4. */
|
||||
0, /* doff, do not advance. */
|
||||
2, /* ssize, 32 bits transfers.*/
|
||||
2, /* dsize, 32 bits transfers.*/
|
||||
4, /* nbytes, always four. */
|
||||
(uint32_t)adcp->grpp->num_channels *
|
||||
(uint32_t)adcp->depth, /* iter. */
|
||||
CPL2((uint32_t)adcp->grpp->num_channels *
|
||||
(uint32_t)adcp->depth *
|
||||
sizeof(adccommand_t)), /* slast. */
|
||||
0, /* dlast, no dest.adjust. */
|
||||
EDMA_TCD_MODE_DREQ); /* mode. */
|
||||
|
||||
/* Updating the variable TCD fields for RFIFO.*/
|
||||
edmaTCDSetDestinationAddress(rtcdp, adcp->samples);
|
||||
edmaTCDSetOuterLoopCount(rtcdp, (uint32_t)adcp->grpp->num_channels *
|
||||
(uint32_t)adcp->depth);
|
||||
edmaTCDSetDestinationAdjustment(ctcdp,
|
||||
CPL2((uint32_t)adcp->grpp->num_channels *
|
||||
(uint32_t)adcp->depth *
|
||||
sizeof(adcsample_t)));
|
||||
edmaTCDSetMode(rtcdp, EDMA_TCD_MODE_DREQ | EDMA_TCD_MODE_INT_END |
|
||||
(adcp->depth > 1) ? EDMA_TCD_MODE_INT_HALF: 0);
|
||||
/* Setting up RFIFO TCD parameters.*/
|
||||
edmaChannelSetup(adcp->rfifo_channel, /* channel. */
|
||||
RFIFO_POP_ADDR(adcp->fifo), /* src. */
|
||||
adcp->samples, /* dst. */
|
||||
0, /* soff, do not advance. */
|
||||
2, /* doff, advance by two. */
|
||||
1, /* ssize, 16 bits transfers.*/
|
||||
1, /* dsize, 16 bits transfers.*/
|
||||
2, /* nbytes, always two. */
|
||||
(uint32_t)adcp->grpp->num_channels *
|
||||
(uint32_t)adcp->depth, /* iter. */
|
||||
0, /* slast, no source adjust. */
|
||||
CPL2((uint32_t)adcp->grpp->num_channels *
|
||||
(uint32_t)adcp->depth *
|
||||
sizeof(adcsample_t)), /* dlast. */
|
||||
EDMA_TCD_MODE_DREQ | EDMA_TCD_MODE_INT_END |
|
||||
((adcp->depth > 1) ? EDMA_TCD_MODE_INT_HALF: 0));/* mode.*/
|
||||
|
||||
/* Starting DMA channels.*/
|
||||
edmaChannelStart(adcp->rfifo_channel);
|
||||
|
|
Loading…
Reference in New Issue