diff options
author | Jack Humbert <jack.humb@gmail.com> | 2018-06-12 10:59:35 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-06-12 10:59:35 -0400 |
commit | 998ddbb122c9d3e2a77bd4e88c881b225ca0d569 (patch) | |
tree | ca91ff7ad3c4866555d1e623fe9ea05276397e1c /tmk_core/common | |
parent | c0095710a7c7e9bd94aa9f4dd814dc28d718c731 (diff) | |
parent | 06487daaddf923d635e8a528d1eb644b875a73f6 (diff) |
Merge branch 'master' of github.com:qmk/qmk_firmware into hf/shinydox
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/avr/bootloader.c | 8 | ||||
-rw-r--r-- | tmk_core/common/avr/suspend.c | 37 | ||||
-rw-r--r-- | tmk_core/common/chibios/suspend.c | 33 | ||||
-rw-r--r-- | tmk_core/common/keycode.h | 3 | ||||
-rw-r--r-- | tmk_core/common/suspend.h | 5 |
5 files changed, 79 insertions, 7 deletions
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index d89c8d768d..c4b913280e 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c @@ -72,7 +72,7 @@ #define BOOTLOADER_RESET_KEY 0xB007B007 uint32_t reset_key __attribute__ ((section (".noinit"))); -/** \brief initialize MCU status by watchdog reset +/** \brief initialize MCU status by watchdog reset * * FIXME: needs doc */ @@ -81,7 +81,7 @@ void bootloader_jump(void) { #if !defined(BOOTLOADER_SIZE) uint8_t high_fuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); - if (high_fuse & BOOT_SIZE_256) { + if (high_fuse & BOOT_SIZE_256) { bootloader_start = (FLASH_SIZE - 512) >> 1; } else if (high_fuse & BOOT_SIZE_512) { bootloader_start = (FLASH_SIZE - 1024) >> 1; @@ -130,7 +130,7 @@ void bootloader_jump(void) { DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; asm volatile("jmp 0x1FC00"); - #endif + #endif #elif defined(BOOTLOADER_CATERINA) // this block may be optional @@ -151,7 +151,7 @@ void bootloader_jump(void) { #else // Assume remaining boards are DFU, even if the flag isn't set - #ifndef __AVR_ATmega32A__ // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? + #if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? UDCON = 1; USBCON = (1<<FRZCLK); // disable USB UCSR1B = 0; diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 81e4266410..dfa1af273c 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c @@ -72,6 +72,21 @@ void suspend_idle(uint8_t time) */ static uint8_t wdt_timeout = 0; +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_user (void) { } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_kb(void) { + suspend_power_down_user(); +} + /** \brief Power down * * FIXME: needs doc @@ -101,8 +116,10 @@ static void power_down(uint8_t wdto) #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); #endif - rgblight_disable(); + rgblight_disable_noeeprom(); #endif + suspend_power_down_kb(); + // TODO: more power saving // See PicoPower application note // - I/O port input with pullup @@ -144,6 +161,21 @@ bool suspend_wakeup_condition(void) return false; } +/** \brief run user level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_user(void) { } + +/** \brief run keyboard level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_kb(void) { + suspend_wakeup_init_user(); +} /** \brief run immediately after wakeup * * FIXME: needs doc @@ -157,11 +189,12 @@ void suspend_wakeup_init(void) #endif led_set(host_keyboard_leds()); #ifdef RGBLIGHT_SLEEP - rgblight_enable(); + rgblight_enable_noeeprom(); #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_enable(); #endif #endif + suspend_wakeup_init_kb(); } #ifndef NO_SUSPEND_POWER_DOWN diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c index 32ef773e2e..4a119ccefe 100644 --- a/tmk_core/common/chibios/suspend.c +++ b/tmk_core/common/chibios/suspend.c @@ -21,6 +21,21 @@ void suspend_idle(uint8_t time) { wait_ms(time); } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_user (void) { } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_kb(void) { + suspend_power_down_user(); +} + /** \brief suspend power down * * FIXME: needs doc @@ -30,6 +45,7 @@ void suspend_power_down(void) { // shouldn't power down TPM/FTM if we want a breathing LED // also shouldn't power down USB + suspend_power_down_kb(); // on AVR, this enables the watchdog for 15ms (max), and goes to // SLEEP_MODE_PWR_DOWN @@ -53,6 +69,22 @@ bool suspend_wakeup_condition(void) return false; } +/** \brief run user level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_user(void) { } + +/** \brief run keyboard level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_kb(void) { + suspend_power_down_user(); +} + /** \brief suspend wakeup condition * * run immediately after wakeup @@ -79,4 +111,5 @@ void suspend_wakeup_init(void) #ifdef BACKLIGHT_ENABLE backlight_init(); #endif /* BACKLIGHT_ENABLE */ + suspend_wakeup_init_kb(); } diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index 734c9fbff0..9cb4f1e0c1 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -17,7 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. /* * Keycodes based on HID Usage Keyboard/Keypad Page(0x07) plus special codes - * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf + * https://web.archive.org/web/20060218214400/http://www.usb.org/developers/devclass_docs/Hut1_12.pdf + * or http://www.usb.org/developers/hidpage/Hut1_12v2.pdf (older) */ #ifndef KEYCODE_H #define KEYCODE_H diff --git a/tmk_core/common/suspend.h b/tmk_core/common/suspend.h index 80617a8244..c3e4447085 100644 --- a/tmk_core/common/suspend.h +++ b/tmk_core/common/suspend.h @@ -10,4 +10,9 @@ void suspend_power_down(void); bool suspend_wakeup_condition(void); void suspend_wakeup_init(void); +void suspend_wakeup_init_user(void); +void suspend_wakeup_init_kb(void); +void suspend_power_down_user (void); +void suspend_power_down_kb(void); + #endif |