Question
Shouldn't DMA_HandleTypeDef State be volatile?
Current structure is:
typedef struct __DMA_HandleTypeDef
{
...
HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
...
} DMA_HandleTypeDef;Interrupts can change the State value, but it's not volatile, so the compiler is unaware.
Polling the handler state until it changes to HAL_DMA_STATE_READY will fail when optimizations are enabled.
This works perfectly:
typedef struct __DMA_HandleTypeDef
{
...
__IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
...
} DMA_HandleTypeDef;