Browse Source

ChibiOS/kinetis: sending remote wakeup.

tags/v2.9
flabbergast 8 years ago
parent
commit
2e06ccf70a

+ 4
- 4
tmk_core/protocol/chibios/main.c View File

while(USB_DRIVER.state == USB_SUSPENDED) { while(USB_DRIVER.state == USB_SUSPENDED) {
/* Do this in the suspended state */ /* Do this in the suspended state */
suspend_power_down(); // on AVR this deep sleeps for 15ms 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();
// }
/* Remote wakeup */
if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) {
send_remote_wakeup(&USB_DRIVER);
}
} }
/* Woken up */ /* Woken up */
// variables has been already cleared by the wakeup hook // variables has been already cleared by the wakeup hook

+ 17
- 0
tmk_core/protocol/chibios/usb_main.c View File

#endif #endif
} }


/*
* Send remote wakeup packet
* Note: should not be called from ISR
*/
void send_remote_wakeup(USBDriver *usbp) {
(void)usbp;
#if defined(K20x) || defined(KL2x)
#if KINETIS_USB_USE_USB0
USB0->CTL |= USBx_CTL_RESUME;
chThdSleepMilliseconds(15);
USB0->CTL &= ~USBx_CTL_RESUME;
#endif /* KINETIS_USB_USE_USB0 */
#else /* K20x || KL2x */
#warning Sending remote wakeup packet not implemented for your platform.
#endif /* K20x || KL2x */
}

/* --------------------------------------------------------- /* ---------------------------------------------------------
* Keyboard functions * Keyboard functions
* --------------------------------------------------------- * ---------------------------------------------------------

+ 3
- 0
tmk_core/protocol/chibios/usb_main.h View File

/* Initialize the USB driver and bus */ /* Initialize the USB driver and bus */
void init_usb_driver(USBDriver *usbp); void init_usb_driver(USBDriver *usbp);


/* Send remote wakeup packet */
void send_remote_wakeup(USBDriver *usbp);

/* --------------- /* ---------------
* Keyboard header * Keyboard header
* --------------- * ---------------

Loading…
Cancel
Save