aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c30
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udc.h2
2 files changed, 20 insertions, 12 deletions
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index 54d056a14..d3dc272ee 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -62,6 +62,12 @@ void send_keyboard(report_keyboard_t *report)
{
uint32_t irqflags;
+ if (usb_state == USB_STATE_POWERDOWN)
+ {
+ udc_remotewakeup();
+ return;
+ }
+
#ifdef NKRO_ENABLE
if (!keymap_config.nkro)
{
@@ -156,25 +162,27 @@ void send_consumer(uint16_t data)
}
uint8_t g_drvid;
+uint8_t g_usb_sleeping = 0;
void main_subtask_usb_state(void)
{
if (usb_state == USB_STATE_POWERDOWN)
{
- uint32_t timer_led = timer_read32();
-
- led_on;
- if (led_enabled)
+ if (!g_usb_sleeping)
{
- for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
+ g_usb_sleeping = 1;
+ if (led_enabled)
{
- I2C3733_Control_Set(0);
+ for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
+ {
+ I2C3733_Control_Set(0);
+ }
}
}
- while (usb_state == USB_STATE_POWERDOWN)
- {
- if (timer_read32() - timer_led > 1000) led_off; //Good to indicate went to sleep, but only for a second
- }
+ }
+ else if (g_usb_sleeping)
+ {
+ g_usb_sleeping = 0;
if (led_enabled)
{
for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
@@ -182,12 +190,12 @@ void main_subtask_usb_state(void)
I2C3733_Control_Set(1);
}
}
- led_off;
}
}
void main_subtask_led(void)
{
+ if (g_usb_sleeping) return;
led_matrix_task();
}
diff --git a/tmk_core/protocol/arm_atsam/usb/udc.h b/tmk_core/protocol/arm_atsam/usb/udc.h
index c88a442cb..33335d186 100644
--- a/tmk_core/protocol/arm_atsam/usb/udc.h
+++ b/tmk_core/protocol/arm_atsam/usb/udc.h
@@ -210,7 +210,7 @@ static inline void udc_detach(void)
/*! \brief The USB driver sends a resume signal called \e "Upstream Resume"
* This is authorized only when the remote wakeup feature is enabled by host.
*/
-static inline void udc_remotewakeup(void)
+inline void udc_remotewakeup(void)
{
udd_send_remotewakeup();
}