summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/avr.mk18
-rw-r--r--tmk_core/common/avr/bootloader.c8
-rw-r--r--tmk_core/common/avr/suspend.c37
-rw-r--r--tmk_core/common/chibios/suspend.c33
-rw-r--r--tmk_core/common/keycode.h3
-rw-r--r--tmk_core/common/suspend.h5
6 files changed, 88 insertions, 16 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index bd58bd285f..cf62b0f078 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -252,16 +252,16 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
bootloader:
make -C lib/lufa/Bootloaders/DFU/ clean
- echo -e "#ifndef QMK_KEYBOARD\n#define QMK_KEYBOARD\n" > lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `$(GREP) "MANUFACTURER" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `$(GREP) "PRODUCT" $(ALL_CONFIGS) -h | tail -1` Bootloader >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `$(GREP) "QMK_ESC_OUTPUT" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `$(GREP) "QMK_ESC_INPUT" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `$(GREP) "QMK_LED" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `$(GREP) "QMK_SPEAKER" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e "\n#endif" >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ printf "#ifndef QMK_KEYBOARD\n#define QMK_KEYBOARD\n\n" > lib/lufa/Bootloaders/DFU/Keyboard.h
+ printf "%s\n" "`$(GREP) "MANUFACTURER" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ printf "%s Bootloader\n" "`$(GREP) "PRODUCT" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ printf "%s\n" "`$(GREP) "QMK_ESC_OUTPUT" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ printf "%s\n" "`$(GREP) "QMK_ESC_INPUT" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ printf "%s\n" "`$(GREP) "QMK_LED" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ printf "%s\n" "`$(GREP) "QMK_SPEAKER" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ printf "\n#endif" >> lib/lufa/Bootloaders/DFU/Keyboard.h
make -C lib/lufa/Bootloaders/DFU/
- echo -e "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex"
+ printf "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex\n"
cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex
production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware
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