STM32: CAN: do not overwite BTR register when setting frequency

BTR register has other bits than the ones calculated and set through
the can_speed function, so let's take care to only write to the
right registers.
pull/4932/head
Laurent MEUNIER 2017-08-17 17:00:01 +02:00
parent 759642af8e
commit 57222b604f
1 changed files with 5 additions and 1 deletions

View File

@ -211,7 +211,11 @@ int can_frequency(can_t *obj, int f)
}
}
if (status != 0) {
can->BTR = btr;
/* Do not erase all BTR registers (e.g. silent mode), only the
* ones calculated in can_speed */
can->BTR &= ~(CAN_BTR_TS2 | CAN_BTR_TS1 | CAN_BTR_SJW | CAN_BTR_BRP);
can->BTR |= btr;
can->MCR &= ~(uint32_t)CAN_MCR_INRQ;
/* Get tick */
tickstart = HAL_GetTick();