Skip to content
Snippets Groups Projects
Commit 4e832a7d authored by Vincent Dupont's avatar Vincent Dupont
Browse files

can/device: improve bus-off management

parent a82930cf
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment