Skip to content

Commit

Permalink
core: Add suspend mode options
Browse files Browse the repository at this point in the history
  • Loading branch information
tmk committed Oct 4, 2016
1 parent 9818d54 commit 8f969d6
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions tmk_core/common/avr/suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ __asm__ __volatile__ ( \
)


void suspend_idle(uint8_t time)
{
cli();
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable();
sei();
sleep_cpu();
sleep_disable();
}

/* Power down MCU with watchdog timer
* wdto: watchdog timer timeout defined in <avr/wdt.h>
* WDTO_15MS
Expand Down Expand Up @@ -80,9 +70,39 @@ static void power_down(uint8_t wdto)
wdt_disable();
}

static void standby(void)
{
set_sleep_mode(SLEEP_MODE_STANDBY);
sleep_enable();
sei();
sleep_cpu();
sleep_disable();
}

static void idle(void)
{
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable();
sei();
sleep_cpu();
sleep_disable();
}


void suspend_idle(uint8_t time)
{
idle();
}

void suspend_power_down(void)
{
#ifdef SUSPEND_MODE_STANDBY
standby();
#elif defined(SUSPEND_MODE_IDLE)
idle();
#else
power_down(WDTO_15MS);
#endif
}

__attribute__ ((weak)) void matrix_power_up(void) {}
Expand Down

0 comments on commit 8f969d6

Please sign in to comment.