diff --git a/builddefs/show_options.mk b/builddefs/show_options.mk index 9723b45438a..ac2a1ed931a 100644 --- a/builddefs/show_options.mk +++ b/builddefs/show_options.mk @@ -74,6 +74,7 @@ OTHER_OPTION_NAMES = \ WATCHDOG_ENABLE \ ERGOINU \ NO_USB_STARTUP_CHECK \ + DISABLE_AVR_DEEP_SLEEP \ DISABLE_PROMICRO_LEDs \ MITOSIS_DATAGROK_BOTTOMSPACE \ MITOSIS_DATAGROK_SLOWUART \ diff --git a/data/mappings/info_config.hjson b/data/mappings/info_config.hjson index 46108e6fe6a..4617638d68f 100644 --- a/data/mappings/info_config.hjson +++ b/data/mappings/info_config.hjson @@ -29,6 +29,7 @@ "COMBO_TERM": {"info_key": "combo.term", "value_type": "int"}, "DEBOUNCE": {"info_key": "debounce", "value_type": "int"}, "DIODE_DIRECTION": {"info_key": "diode_direction"}, + "DISABLE_AVR_DEEP_SLEEP": {"info_key": "disable_avr_deep_sleep", "value_type": "bool"}, "DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.double_tap_shift_turns_on", "value_type": "bool"}, "FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "bool"}, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR": {"info_key": "dynamic_keymap.eeprom_max_addr", "value_type": "int"}, diff --git a/docs/config_options.md b/docs/config_options.md index 5bfb7c5d582..e68013ccdef 100644 --- a/docs/config_options.md +++ b/docs/config_options.md @@ -455,6 +455,8 @@ Use these to enable or disable building certain features. The more you have enab * Forces the keyboard to wait for a USB connection to be established before it starts up * `NO_USB_STARTUP_CHECK` * Disables usb suspend check after keyboard startup. Usually the keyboard waits for the host to wake it up before any tasks are performed. This is useful for split keyboards as one half will not get a wakeup call but must send commands to the master. +* `DISABLE_AVR_DEEP_SLEEP` + * Disables AVR deep sleep. Similar to `NO_SUSPEND_POWER_DOWN` with the suspend routines executed, so backlight, audio, and OLED will be still turned off during sleep. * `DEFERRED_EXEC_ENABLE` * Enables deferred executor support -- timed delays before callbacks are invoked. See [deferred execution](custom_quantum_functions.md#deferred-execution) for more information. * `DYNAMIC_TAPPING_TERM_ENABLE` diff --git a/platforms/avr/suspend.c b/platforms/avr/suspend.c index 1a7cd3b4ab8..c9f7581f8ee 100644 --- a/platforms/avr/suspend.c +++ b/platforms/avr/suspend.c @@ -13,9 +13,7 @@ # include "vusb.h" #endif -// TODO: This needs some cleanup - -#if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) +#if !defined(NO_SUSPEND_POWER_DOWN) && !defined(DISABLE_AVR_DEEP_SLEEP) && defined(WDT_vect) // clang-format off #define wdt_intr_enable(value) \ @@ -105,7 +103,7 @@ void suspend_power_down(void) { #ifndef NO_SUSPEND_POWER_DOWN // Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt) -# if defined(WDT_vect) +# if defined(WDT_vect) && !defined(DISABLE_AVR_DEEP_SLEEP) power_down(WDTO_15MS); # endif #endif diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index d3f15c45887..bc44d177f74 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk @@ -68,6 +68,10 @@ ifeq ($(strip $(NO_USB_STARTUP_CHECK)), yes) TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK endif +ifeq ($(strip $(DISABLE_AVR_DEEP_SLEEP)), yes) + TMK_COMMON_DEFS += -DDISABLE_AVR_DEEP_SLEEP +endif + ifeq ($(strip $(JOYSTICK_SHARED_EP)), yes) TMK_COMMON_DEFS += -DJOYSTICK_SHARED_EP SHARED_EP_ENABLE = yes