From 74397b510eec8b08f36feffac2466eeb33126872 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Mon, 5 Jan 2015 10:43:32 +0900 Subject: [PATCH] Improve behavior of suspend - Add suspend action for user defined suspend behavior - Disable softpwm led when suspending --- common/avr/suspend.c | 25 ++++++++++++++++++++++++- common/suspend.h | 5 +++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/common/avr/suspend.c b/common/avr/suspend.c index 66a579fd..0d881f0f 100644 --- a/common/avr/suspend.c +++ b/common/avr/suspend.c @@ -5,6 +5,7 @@ #include "matrix.h" #include "action.h" #include "backlight.h" +#include "softpwm_led.h" #include "suspend_avr.h" #include "suspend.h" #ifdef PROTOCOL_LUFA @@ -28,7 +29,6 @@ __asm__ __volatile__ ( \ : "r0" \ ) - void suspend_idle(uint8_t time) { cli(); @@ -68,6 +68,14 @@ void suspend_power_down(uint8_t wdto) // - BOD disable // - Power Reduction Register PRR +#ifdef SUSPEND_ACTION + suspend_power_down_action(); +#endif + +#ifdef SOFTPWM_LED_ENABLE + softpwm_led_disable(); +#endif + set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); sei(); @@ -94,6 +102,9 @@ void suspend_wakeup_init(void) { // clear keyboard state clear_keyboard(); +#ifdef SUSPEND_ACTION + suspend_wakeup_init_action(); +#endif #ifdef BACKLIGHT_ENABLE backlight_init(); #endif @@ -115,3 +126,15 @@ ISR(WDT_vect) */ } #endif + +#ifdef SUSPEND_ACTION +__attribute__ ((weak)) +void suspend_power_down_action(void) +{ +} + +__attribute__ ((weak)) +void suspend_wakeup_init_action(void) +{ +} +#endif diff --git a/common/suspend.h b/common/suspend.h index f339c670..fb368b54 100644 --- a/common/suspend.h +++ b/common/suspend.h @@ -10,4 +10,9 @@ void suspend_power_down(uint8_t timeout); bool suspend_wakeup_condition(void); void suspend_wakeup_init(void); +#ifdef SUSPEND_ACTION +void suspend_power_down_action(void); +void suspend_wakeup_init_action(void); +#endif + #endif