diff --git a/sys/can/device.c b/sys/can/device.c index def5273d6b..e9ef162dac 100644 --- a/sys/can/device.c +++ b/sys/can/device.c @@ -40,14 +40,12 @@ #ifdef MODULE_CAN_PM #define CAN_DEVICE_PM_DEFAULT_RX_TIMEOUT (10 * US_PER_SEC) #define CAN_DEVICE_PM_DEFAULT_TX_TIMEOUT (2 * US_PER_SEC) +static void pm_cb(void *arg); +static void pm_reset(candev_dev_t *candev_dev, uint32_t value); #endif static int power_up(candev_dev_t *candev_dev); static int power_down(candev_dev_t *candev_dev); -#ifdef MODULE_CAN_PM -static void pm_cb(void *arg); -static void pm_reset(candev_dev_t *candev_dev, uint32_t value); -#endif static void _can_event(candev_t *dev, candev_event_t event, void *arg) { @@ -157,11 +155,11 @@ static int power_down(candev_dev_t *candev_dev) #ifdef MODULE_CAN_PM static void pm_cb(void *arg) { - candev_dev_t *dev = arg; + candev_dev_t *candev_dev = (candev_dev_t *)arg; msg_t msg; msg.type = CAN_MSG_PM; - msg_send(&msg, dev->pid); + msg_send(&msg, candev_dev->pid); } static void pm_reset(candev_dev_t *candev_dev, uint32_t value) @@ -307,7 +305,7 @@ static void *_can_device_thread(void *args) DEBUG("can device: CAN_MSG_POWER_UP received\n"); res = power_up(candev_dev); #ifdef MODULE_CAN_PM - pm_reset(candev_dev, 0); + pm_reset(candev_dev, candev_dev->tx_wakeup_timeout); #endif /* send reply to calling thread */ reply.type = CAN_MSG_ACK; @@ -317,6 +315,9 @@ static void *_can_device_thread(void *args) case CAN_MSG_POWER_DOWN: DEBUG("can device: CAN_MSG_POWER_DOWN received\n"); res = power_down(candev_dev); +#ifdef MODULE_CAN_PM + pm_reset(candev_dev, 0); +#endif /* send reply to calling thread */ reply.type = CAN_MSG_ACK; reply.content.value = (uint32_t)res;