Chibios: use WFI in idle. WIP suspend stuff.
This commit is contained in:
parent
c61210cfff
commit
c1c8e079ca
9 changed files with 102 additions and 12 deletions
|
|
@ -26,6 +26,8 @@
|
|||
#include "host_driver.h"
|
||||
#include "keyboard.h"
|
||||
#include "action.h"
|
||||
#include "action_util.h"
|
||||
#include "mousekey.h"
|
||||
#include "led.h"
|
||||
#include "sendchar.h"
|
||||
#include "debug.h"
|
||||
|
|
@ -113,7 +115,24 @@ int main(void) {
|
|||
|
||||
/* Main loop */
|
||||
while(true) {
|
||||
/* TODO: check for suspended event */
|
||||
|
||||
if(USB_DRIVER.state == USB_SUSPENDED) {
|
||||
print("[s]");
|
||||
while(USB_DRIVER.state == USB_SUSPENDED) {
|
||||
/* Do this in the suspended state */
|
||||
suspend_power_down(); // on AVR this deep sleeps for 15ms
|
||||
// TODO: remote wakeup
|
||||
// if(USB_Device_RemoteWakeupEnabled (USB_DRIVER.status & 2) && suspend_wakeup_condition()) {
|
||||
// USB_Device_SendRemoteWakeup();
|
||||
// }
|
||||
}
|
||||
/* Woken up */
|
||||
// variables has been already cleared by the wakeup hook
|
||||
send_keyboard_report();
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
mousekey_send();
|
||||
#endif /* MOUSEKEY_ENABLE */
|
||||
}
|
||||
|
||||
keyboard_task();
|
||||
chThdSleepMilliseconds(5);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "host.h"
|
||||
#include "debug.h"
|
||||
#include "suspend.h"
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
#include "sleep_led.h"
|
||||
#include "led.h"
|
||||
|
|
@ -356,8 +357,8 @@ static const uint8_t hid_configuration_descriptor_data[] = {
|
|||
NUM_INTERFACES, // bNumInterfaces
|
||||
1, // bConfigurationValue
|
||||
0, // iConfiguration
|
||||
0xA0, // bmAttributes
|
||||
50), // bMaxPower (100mA)
|
||||
0xA0, // bmAttributes (RESERVED|REMOTEWAKEUP)
|
||||
50), // bMaxPower (50mA)
|
||||
|
||||
/* Interface Descriptor (9 bytes) USB spec 9.6.5, page 267-269, Table 9-12 */
|
||||
USB_DESC_INTERFACE(KBD_INTERFACE, // bInterfaceNumber
|
||||
|
|
@ -793,7 +794,6 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
|
|||
|
||||
case USB_EVENT_SUSPEND:
|
||||
//TODO: from ISR! print("[S]");
|
||||
//TODO: signal suspend?
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_enable();
|
||||
#endif /* SLEEP_LED_ENABLE */
|
||||
|
|
@ -801,7 +801,7 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
|
|||
|
||||
case USB_EVENT_WAKEUP:
|
||||
//TODO: from ISR! print("[W]");
|
||||
//TODO: suspend_wakeup_init();
|
||||
suspend_wakeup_init();
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_disable();
|
||||
// NOTE: converters may not accept this
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue