1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

can/device: improve bus-off management

This commit is contained in:
Vincent Dupont 2017-10-11 10:01:33 +02:00
parent a82930cf60
commit 4e832a7d7e

View File

@ -159,7 +159,10 @@ static int power_down(candev_dev_t *candev_dev)
#endif
canopt_state_t state = CANOPT_STATE_SLEEP;
int res = dev->driver->set(dev, CANOPT_STATE, &state, sizeof(state));
dev->state = CAN_STATE_SLEEPING;
if (dev->state != CAN_STATE_BUS_OFF) {
dev->state = CAN_STATE_SLEEPING;
}
#ifdef MODULE_CAN_PM
xtimer_remove(&candev_dev->pm_timer);
@ -211,6 +214,9 @@ static void *_can_device_thread(void *args)
candev_dev->pid = thread_getpid();
#ifdef MODULE_CAN_TRX
can_trx_init(candev_dev->trx);
#endif
#ifdef MODULE_CAN_PM
if (candev_dev->rx_inactivity_timeout == 0) {
candev_dev->rx_inactivity_timeout = CAN_DEVICE_PM_DEFAULT_RX_TIMEOUT;
@ -222,9 +228,6 @@ static void *_can_device_thread(void *args)
candev_dev->pm_timer.arg = candev_dev;
pm_reset(candev_dev, candev_dev->rx_inactivity_timeout);
#endif
#ifdef MODULE_CAN_TRX
can_trx_init(candev_dev->trx);
#endif
int res;
can_pkt_t *pkt;
@ -240,7 +243,7 @@ static void *_can_device_thread(void *args)
candev_dev->ifnum = can_dll_register_candev(candev_dev);
dev->driver->init(dev);
dev->state = CAN_STATE_ERROR_ACTIVE;
power_up(candev_dev);
while (1) {
msg_receive(&msg);