Deep sleep within chibios
Posted: Thu Oct 15, 2015 3:31 pm
I am trying to implement a USB device that would support USB suspend mechanism (e.g. when a PC goes to sleep, it sends "sleep" instruction to the device; when it wakes up it sends a "wakeup" packet). I've got most of this working - I mean I detect these packets OK. The remaining bit for me to figure out is how to decrease the power consumption during the sleep (the official requirement is something ridiculous like 0.5mA I think, which is hard to achieve, but anyway).
At the moment I'm running on kinetis devices, so the kernel uses tick-mode.
Here's what I was thinking that "could" work: upon entering the sleep mode, I would stop the kernel (chSysDisable or chSysSuspend?), disable SysTick, take care of enabled interrupts and subsystems, and enter one of the sleep modes on the MCU. The system would wake up through the USB interrupt on the "wakeup" packet - or every several ms using a timer and check for wakeup. On wakeup, I would re-enable systick and again take care of the subsystems and interrupts, and then enable the OS kernel back.
Is this scenario plausible, and/or what are the OS internals that can get messed up and/or need taking care of? Would this "confuse" the kernel too much? I mean to run this from a thread - should I explicitly "pause" the other thread(s), or would suspending the kernel be enough?
I'm sorry I don't understand the ChibiOS RT kernel internals well enough yet.
Thank you.
At the moment I'm running on kinetis devices, so the kernel uses tick-mode.
Here's what I was thinking that "could" work: upon entering the sleep mode, I would stop the kernel (chSysDisable or chSysSuspend?), disable SysTick, take care of enabled interrupts and subsystems, and enter one of the sleep modes on the MCU. The system would wake up through the USB interrupt on the "wakeup" packet - or every several ms using a timer and check for wakeup. On wakeup, I would re-enable systick and again take care of the subsystems and interrupts, and then enable the OS kernel back.
Is this scenario plausible, and/or what are the OS internals that can get messed up and/or need taking care of? Would this "confuse" the kernel too much? I mean to run this from a thread - should I explicitly "pause" the other thread(s), or would suspending the kernel be enough?
I'm sorry I don't understand the ChibiOS RT kernel internals well enough yet.
Thank you.