Code: Select all
/**
* @brief Returns the request line associated to the specified stream.
* @note In some STM32 manuals the request line is named confusingly
* channel.
*
* @param[in] id the unique numeric stream identifier
* @param[in] c a stream/request association word, one request per
* nibble
* @return Returns the request associated to the stream.
*/
#define STM32_DMA_GETCHANNEL(id, c) (((c) >> (((id) & 7U) * 4U)) & 15U)
This seems reasonable for DMA1 channels, where the least-significant nibble is DMA1,Channel1. The next is DMA1,Channel2, etc.
However for DMA2 it looks like in the picture (attached). So for example this set of definitions for SPI3 won't work:
Code: Select all
#define STM32_SPI3_RX_DMA_MSK (STM32_DMA_STREAM_ID_MSK(2, 1))
#define STM32_SPI3_RX_DMA_CHN 0x00000003
#define STM32_SPI3_TX_DMA_MSK (STM32_DMA_STREAM_ID_MSK(2, 2))
#define STM32_SPI3_TX_DMA_CHN 0x00000030
The "slot" for DMA2,Channel1 is NOT the least-significant nibble. So the code to extract the value:
Code: Select all
#define SPI3_RX_DMA_CHANNEL \
STM32_DMA_GETCHANNEL(STM32_SPI_SPI3_RX_DMA_STREAM, \
STM32_SPI3_RX_DMA_CHN)
...actually returns a zero, and not 3.
Or am I missing something?
Paul.