/* Specifies the ouput polarity of the PWM at the specified state of counter.  */
void TMR2_PWM_SetPolarity(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint8_t u8CountState, uint32_t u32Polarity)
/* Specifies the ouput polarity of the PWM at the specified state of counter.  */
void TMR2_PWM_SetPolarity(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint8_t u8CountState, uint32_t u32Polarity)
{
    uint32_t u32PolarityPos;
    DDL_ASSERT(IS_TMR2_UNIT(TMR2x));
    DDL_ASSERT(IS_TMR2_CH(u32Ch));
    DDL_ASSERT(IS_TMR2_PWM_POLARITY(u8CountState, u32Polarity));
    u32PolarityPos = ((uint32_t)u8CountState * TMR2_PWM_POLARITY_OFFSET) + (u32Ch * TMR2_CH_OFFSET);
    MODIFY_REG32(TMR2x->PCONR, TMR2_PCONR_STACA << u32PolarityPos, u32Polarity << u32PolarityPos);
}