stm32: timers: Fix edge polarity setup

The CCxP/CCxNP bits are actually separated by a reserved bit, so the
correct mask is 0xa, (0b1010) not 0x6 (0b0110)

Reported by PyroDevil on the mailinglist
This commit is contained in:
Karl Palsson 2014-07-15 13:28:02 +00:00
parent cf5fb002f6
commit af3389652c

View File

@ -42,12 +42,12 @@ void timer_ic_set_polarity(uint32_t timer_peripheral, enum tim_ic_id ic,
/* Clear CCxP and CCxNP to zero. For both edge trigger both fields are /* Clear CCxP and CCxNP to zero. For both edge trigger both fields are
* set. Case 10 is invalid. * set. Case 10 is invalid.
*/ */
TIM_CCER(timer_peripheral) &= ~(0x6 << (ic * 4)); TIM_CCER(timer_peripheral) &= ~(0xa << (ic * 4));
switch (pol) { switch (pol) {
case TIM_IC_RISING: /* 00 */ case TIM_IC_RISING: /* 00 */
break; break;
case TIM_IC_BOTH: /* 11 */ case TIM_IC_BOTH: /* 11 */
TIM_CCER(timer_peripheral) |= (0x6 << (ic * 4)); TIM_CCER(timer_peripheral) |= (0xa << (ic * 4));
break; break;
case TIM_IC_FALLING: /* 01 */ case TIM_IC_FALLING: /* 01 */
TIM_CCER(timer_peripheral) |= (0x2 << (ic * 4)); TIM_CCER(timer_peripheral) |= (0x2 << (ic * 4));