While I was reading the STM32 HAL drivers for timers I found this macro:
#define __HAL_TIM_DISABLE(__HANDLE__) \
do { \
if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0U) \
{ \
(__HANDLE__)->Instance->CR1 &= ~(TIM_CR1_CEN); \
} \
} while(0)
Since the while part is always wrong there should be basically no loop, and the do-while seems redundant to me. But since they distribute it in the HAL like this, I suppose there is some point? Can anyone point out which?