Kaynağa Gözat

Improve behavior of suspend

- Add suspend action for user defined suspend behavior
- Disable softpwm led when suspending
old_master
Kai Ryu 9 yıl önce
ebeveyn
işleme
e6237c39cd
2 değiştirilmiş dosya ile 29 ekleme ve 1 silme
  1. 24
    1
      common/avr/suspend.c
  2. 5
    0
      common/suspend.h

+ 24
- 1
common/avr/suspend.c Dosyayı Görüntüle

#include "matrix.h" #include "matrix.h"
#include "action.h" #include "action.h"
#include "backlight.h" #include "backlight.h"
#include "softpwm_led.h"
#include "suspend_avr.h" #include "suspend_avr.h"
#include "suspend.h" #include "suspend.h"
#ifdef PROTOCOL_LUFA #ifdef PROTOCOL_LUFA
: "r0" \ : "r0" \
) )



void suspend_idle(uint8_t time) void suspend_idle(uint8_t time)
{ {
cli(); cli();
// - BOD disable // - BOD disable
// - Power Reduction Register PRR // - 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); set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable(); sleep_enable();
sei(); sei();
{ {
// clear keyboard state // clear keyboard state
clear_keyboard(); clear_keyboard();
#ifdef SUSPEND_ACTION
suspend_wakeup_init_action();
#endif
#ifdef BACKLIGHT_ENABLE #ifdef BACKLIGHT_ENABLE
backlight_init(); backlight_init();
#endif #endif
*/ */
} }
#endif #endif

#ifdef SUSPEND_ACTION
__attribute__ ((weak))
void suspend_power_down_action(void)
{
}

__attribute__ ((weak))
void suspend_wakeup_init_action(void)
{
}
#endif

+ 5
- 0
common/suspend.h Dosyayı Görüntüle

bool suspend_wakeup_condition(void); bool suspend_wakeup_condition(void);
void suspend_wakeup_init(void); void suspend_wakeup_init(void);


#ifdef SUSPEND_ACTION
void suspend_power_down_action(void);
void suspend_wakeup_init_action(void);
#endif

#endif #endif