Merge pull request #7715 from OTAkeys/pr/can_dev_fix
can/device: improve bus-off management
This commit is contained in:
commit
6404bb75cf
@ -159,7 +159,10 @@ static int power_down(candev_dev_t *candev_dev)
|
|||||||
#endif
|
#endif
|
||||||
canopt_state_t state = CANOPT_STATE_SLEEP;
|
canopt_state_t state = CANOPT_STATE_SLEEP;
|
||||||
int res = dev->driver->set(dev, CANOPT_STATE, &state, sizeof(state));
|
int res = dev->driver->set(dev, CANOPT_STATE, &state, sizeof(state));
|
||||||
|
|
||||||
|
if (dev->state != CAN_STATE_BUS_OFF) {
|
||||||
dev->state = CAN_STATE_SLEEPING;
|
dev->state = CAN_STATE_SLEEPING;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MODULE_CAN_PM
|
#ifdef MODULE_CAN_PM
|
||||||
xtimer_remove(&candev_dev->pm_timer);
|
xtimer_remove(&candev_dev->pm_timer);
|
||||||
@ -211,6 +214,9 @@ static void *_can_device_thread(void *args)
|
|||||||
|
|
||||||
candev_dev->pid = thread_getpid();
|
candev_dev->pid = thread_getpid();
|
||||||
|
|
||||||
|
#ifdef MODULE_CAN_TRX
|
||||||
|
can_trx_init(candev_dev->trx);
|
||||||
|
#endif
|
||||||
#ifdef MODULE_CAN_PM
|
#ifdef MODULE_CAN_PM
|
||||||
if (candev_dev->rx_inactivity_timeout == 0) {
|
if (candev_dev->rx_inactivity_timeout == 0) {
|
||||||
candev_dev->rx_inactivity_timeout = CAN_DEVICE_PM_DEFAULT_RX_TIMEOUT;
|
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;
|
candev_dev->pm_timer.arg = candev_dev;
|
||||||
pm_reset(candev_dev, candev_dev->rx_inactivity_timeout);
|
pm_reset(candev_dev, candev_dev->rx_inactivity_timeout);
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_CAN_TRX
|
|
||||||
can_trx_init(candev_dev->trx);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
can_pkt_t *pkt;
|
can_pkt_t *pkt;
|
||||||
@ -240,7 +243,7 @@ static void *_can_device_thread(void *args)
|
|||||||
candev_dev->ifnum = can_dll_register_candev(candev_dev);
|
candev_dev->ifnum = can_dll_register_candev(candev_dev);
|
||||||
|
|
||||||
dev->driver->init(dev);
|
dev->driver->init(dev);
|
||||||
dev->state = CAN_STATE_ERROR_ACTIVE;
|
power_up(candev_dev);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
msg_receive(&msg);
|
msg_receive(&msg);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user