diff options
Diffstat (limited to 'tmk_core/common')
| -rw-r--r-- | tmk_core/common/arm_atsam/eeprom.c | 94 | ||||
| -rw-r--r-- | tmk_core/common/avr/suspend.c | 98 | ||||
| -rw-r--r-- | tmk_core/common/chibios/_wait.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/chibios/chibios_config.h | 41 | ||||
| -rw-r--r-- | tmk_core/common/chibios/eeprom_stm32.c | 57 | ||||
| -rw-r--r-- | tmk_core/common/chibios/eeprom_stm32_defs.h | 19 | ||||
| -rw-r--r-- | tmk_core/common/chibios/flash_stm32.c | 41 | ||||
| -rw-r--r-- | tmk_core/common/chibios/suspend.c | 89 | ||||
| -rw-r--r-- | tmk_core/common/host.c | 15 | ||||
| -rw-r--r-- | tmk_core/common/host.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/host_driver.h | 1 | ||||
| -rw-r--r-- | tmk_core/common/report.h | 6 | ||||
| -rw-r--r-- | tmk_core/common/suspend.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/sync_timer.c | 2 | ||||
| -rw-r--r-- | tmk_core/common/sync_timer.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/test/rules.mk | 1 |
16 files changed, 215 insertions, 257 deletions
diff --git a/tmk_core/common/arm_atsam/eeprom.c b/tmk_core/common/arm_atsam/eeprom.c index ccd5d15a5..ff1a69262 100644 --- a/tmk_core/common/arm_atsam/eeprom.c +++ b/tmk_core/common/arm_atsam/eeprom.c | |||
| @@ -13,24 +13,110 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | |||
| 17 | #include "eeprom.h" | 16 | #include "eeprom.h" |
| 17 | #include "debug.h" | ||
| 18 | #include "samd51j18a.h" | ||
| 19 | #include "core_cm4.h" | ||
| 20 | #include "component/nvmctrl.h" | ||
| 18 | 21 | ||
| 19 | #ifndef EEPROM_SIZE | 22 | #ifndef EEPROM_SIZE |
| 20 | # include "eeconfig.h" | 23 | # include "eeconfig.h" |
| 21 | # define EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO | 24 | # define EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO |
| 22 | #endif | 25 | #endif |
| 23 | 26 | ||
| 24 | __attribute__((aligned(4))) static uint8_t buffer[EEPROM_SIZE]; | 27 | #ifndef MAX |
| 28 | # define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #ifndef BUSY_RETRIES | ||
| 32 | # define BUSY_RETRIES 10000 | ||
| 33 | #endif | ||
| 34 | |||
| 35 | // #define DEBUG_EEPROM_OUTPUT | ||
| 36 | |||
| 37 | /* | ||
| 38 | * Debug print utils | ||
| 39 | */ | ||
| 40 | #if defined(DEBUG_EEPROM_OUTPUT) | ||
| 41 | # define eeprom_printf(fmt, ...) xprintf(fmt, ##__VA_ARGS__); | ||
| 42 | #else /* NO_DEBUG */ | ||
| 43 | # define eeprom_printf(fmt, ...) | ||
| 44 | #endif /* NO_DEBUG */ | ||
| 45 | |||
| 46 | __attribute__((aligned(4))) static uint8_t buffer[EEPROM_SIZE] = {0}; | ||
| 47 | volatile uint8_t * SmartEEPROM8 = (uint8_t *)SEEPROM_ADDR; | ||
| 48 | |||
| 49 | static inline bool eeprom_is_busy(void) { | ||
| 50 | int timeout = BUSY_RETRIES; | ||
| 51 | while (NVMCTRL->SEESTAT.bit.BUSY && timeout-- > 0) | ||
| 52 | ; | ||
| 53 | |||
| 54 | return NVMCTRL->SEESTAT.bit.BUSY; | ||
| 55 | } | ||
| 56 | |||
| 57 | static uint32_t get_virtual_eeprom_size(void) { | ||
| 58 | // clang-format off | ||
| 59 | static const uint32_t VIRTUAL_EEPROM_MAP[11][8] = { | ||
| 60 | /* 4 8 16 32 64 128 256 512 */ | ||
| 61 | /* 0*/ { 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 62 | /* 1*/ { 512, 1024, 2048, 4096, 4096, 4096, 4096, 4096 }, | ||
| 63 | /* 2*/ { 512, 1024, 2048, 4096, 8192, 8192, 8192, 8192 }, | ||
| 64 | /* 3*/ { 512, 1024, 2048, 4096, 8192, 16384, 16384, 16384 }, | ||
| 65 | /* 4*/ { 512, 1024, 2048, 4096, 8192, 16384, 16384, 16384 }, | ||
| 66 | /* 5*/ { 512, 1024, 2048, 4096, 8192, 16384, 32768, 32768 }, | ||
| 67 | /* 6*/ { 512, 1024, 2048, 4096, 8192, 16384, 32768, 32768 }, | ||
| 68 | /* 7*/ { 512, 1024, 2048, 4096, 8192, 16384, 32768, 32768 }, | ||
| 69 | /* 8*/ { 512, 1024, 2048, 4096, 8192, 16384, 32768, 32768 }, | ||
| 70 | /* 9*/ { 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }, | ||
| 71 | /*10*/ { 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }, | ||
| 72 | }; | ||
| 73 | // clang-format on | ||
| 74 | |||
| 75 | static uint32_t virtual_eeprom_size = UINT32_MAX; | ||
| 76 | if (virtual_eeprom_size == UINT32_MAX) { | ||
| 77 | virtual_eeprom_size = VIRTUAL_EEPROM_MAP[NVMCTRL->SEESTAT.bit.PSZ][NVMCTRL->SEESTAT.bit.SBLK]; | ||
| 78 | } | ||
| 79 | // eeprom_printf("get_virtual_eeprom_size:: %d:%d:%d\n", NVMCTRL->SEESTAT.bit.PSZ, NVMCTRL->SEESTAT.bit.SBLK, virtual_eeprom_size); | ||
| 80 | return virtual_eeprom_size; | ||
| 81 | } | ||
| 25 | 82 | ||
| 26 | uint8_t eeprom_read_byte(const uint8_t *addr) { | 83 | uint8_t eeprom_read_byte(const uint8_t *addr) { |
| 27 | uintptr_t offset = (uintptr_t)addr; | 84 | uintptr_t offset = (uintptr_t)addr; |
| 28 | return buffer[offset]; | 85 | if (offset >= MAX(EEPROM_SIZE, get_virtual_eeprom_size())) { |
| 86 | eeprom_printf("eeprom_read_byte:: out of bounds\n"); | ||
| 87 | return 0x0; | ||
| 88 | } | ||
| 89 | |||
| 90 | if (get_virtual_eeprom_size() == 0) { | ||
| 91 | return buffer[offset]; | ||
| 92 | } | ||
| 93 | |||
| 94 | if (eeprom_is_busy()) { | ||
| 95 | eeprom_printf("eeprom_write_byte:: timeout\n"); | ||
| 96 | return 0x0; | ||
| 97 | } | ||
| 98 | |||
| 99 | return SmartEEPROM8[offset]; | ||
| 29 | } | 100 | } |
| 30 | 101 | ||
| 31 | void eeprom_write_byte(uint8_t *addr, uint8_t value) { | 102 | void eeprom_write_byte(uint8_t *addr, uint8_t value) { |
| 32 | uintptr_t offset = (uintptr_t)addr; | 103 | uintptr_t offset = (uintptr_t)addr; |
| 33 | buffer[offset] = value; | 104 | if (offset >= MAX(EEPROM_SIZE, get_virtual_eeprom_size())) { |
| 105 | eeprom_printf("eeprom_write_byte:: out of bounds\n"); | ||
| 106 | return; | ||
| 107 | } | ||
| 108 | |||
| 109 | if (get_virtual_eeprom_size() == 0) { | ||
| 110 | buffer[offset] = value; | ||
| 111 | return; | ||
| 112 | } | ||
| 113 | |||
| 114 | if (eeprom_is_busy()) { | ||
| 115 | eeprom_printf("eeprom_write_byte:: timeout\n"); | ||
| 116 | return; | ||
| 117 | } | ||
| 118 | |||
| 119 | SmartEEPROM8[offset] = value; | ||
| 34 | } | 120 | } |
| 35 | 121 | ||
| 36 | uint16_t eeprom_read_word(const uint16_t *addr) { | 122 | uint16_t eeprom_read_word(const uint16_t *addr) { |
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 690d7f38c..b614746e6 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
| @@ -16,25 +16,6 @@ | |||
| 16 | # include "vusb.h" | 16 | # include "vusb.h" |
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | #ifdef BACKLIGHT_ENABLE | ||
| 20 | # include "backlight.h" | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #ifdef AUDIO_ENABLE | ||
| 24 | # include "audio.h" | ||
| 25 | #endif /* AUDIO_ENABLE */ | ||
| 26 | |||
| 27 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 28 | # include "rgblight.h" | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #ifdef LED_MATRIX_ENABLE | ||
| 32 | # include "led_matrix.h" | ||
| 33 | #endif | ||
| 34 | #ifdef RGB_MATRIX_ENABLE | ||
| 35 | # include "rgb_matrix.h" | ||
| 36 | #endif | ||
| 37 | |||
| 38 | /** \brief Suspend idle | 19 | /** \brief Suspend idle |
| 39 | * | 20 | * |
| 40 | * FIXME: needs doc | 21 | * FIXME: needs doc |
| @@ -50,17 +31,6 @@ void suspend_idle(uint8_t time) { | |||
| 50 | 31 | ||
| 51 | // TODO: This needs some cleanup | 32 | // TODO: This needs some cleanup |
| 52 | 33 | ||
| 53 | /** \brief Run keyboard level Power down | ||
| 54 | * | ||
| 55 | * FIXME: needs doc | ||
| 56 | */ | ||
| 57 | __attribute__((weak)) void suspend_power_down_user(void) {} | ||
| 58 | /** \brief Run keyboard level Power down | ||
| 59 | * | ||
| 60 | * FIXME: needs doc | ||
| 61 | */ | ||
| 62 | __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); } | ||
| 63 | |||
| 64 | #if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) | 34 | #if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) |
| 65 | 35 | ||
| 66 | // clang-format off | 36 | // clang-format off |
| @@ -135,41 +105,9 @@ void suspend_power_down(void) { | |||
| 135 | if (!vusb_suspended) return; | 105 | if (!vusb_suspended) return; |
| 136 | #endif | 106 | #endif |
| 137 | 107 | ||
| 138 | suspend_power_down_kb(); | 108 | suspend_power_down_quantum(); |
| 139 | 109 | ||
| 140 | #ifndef NO_SUSPEND_POWER_DOWN | 110 | #ifndef NO_SUSPEND_POWER_DOWN |
| 141 | // Turn off backlight | ||
| 142 | # ifdef BACKLIGHT_ENABLE | ||
| 143 | backlight_set(0); | ||
| 144 | # endif | ||
| 145 | |||
| 146 | // Turn off LED indicators | ||
| 147 | uint8_t leds_off = 0; | ||
| 148 | # if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) | ||
| 149 | if (is_backlight_enabled()) { | ||
| 150 | // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off | ||
| 151 | leds_off |= (1 << USB_LED_CAPS_LOCK); | ||
| 152 | } | ||
| 153 | # endif | ||
| 154 | led_set(leds_off); | ||
| 155 | |||
| 156 | // Turn off audio | ||
| 157 | # ifdef AUDIO_ENABLE | ||
| 158 | stop_all_notes(); | ||
| 159 | # endif | ||
| 160 | |||
| 161 | // Turn off underglow | ||
| 162 | # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 163 | rgblight_suspend(); | ||
| 164 | # endif | ||
| 165 | |||
| 166 | # if defined(LED_MATRIX_ENABLE) | ||
| 167 | led_matrix_set_suspend_state(true); | ||
| 168 | # endif | ||
| 169 | # if defined(RGB_MATRIX_ENABLE) | ||
| 170 | rgb_matrix_set_suspend_state(true); | ||
| 171 | # endif | ||
| 172 | |||
| 173 | // Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt) | 111 | // Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt) |
| 174 | # if defined(WDT_vect) | 112 | # if defined(WDT_vect) |
| 175 | power_down(WDTO_15MS); | 113 | power_down(WDTO_15MS); |
| @@ -189,18 +127,6 @@ bool suspend_wakeup_condition(void) { | |||
| 189 | return false; | 127 | return false; |
| 190 | } | 128 | } |
| 191 | 129 | ||
| 192 | /** \brief run user level code immediately after wakeup | ||
| 193 | * | ||
| 194 | * FIXME: needs doc | ||
| 195 | */ | ||
| 196 | __attribute__((weak)) void suspend_wakeup_init_user(void) {} | ||
| 197 | |||
| 198 | /** \brief run keyboard level code immediately after wakeup | ||
| 199 | * | ||
| 200 | * FIXME: needs doc | ||
| 201 | */ | ||
| 202 | __attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); } | ||
| 203 | |||
| 204 | /** \brief run immediately after wakeup | 130 | /** \brief run immediately after wakeup |
| 205 | * | 131 | * |
| 206 | * FIXME: needs doc | 132 | * FIXME: needs doc |
| @@ -209,27 +135,7 @@ void suspend_wakeup_init(void) { | |||
| 209 | // clear keyboard state | 135 | // clear keyboard state |
| 210 | clear_keyboard(); | 136 | clear_keyboard(); |
| 211 | 137 | ||
| 212 | // Turn on backlight | 138 | suspend_wakeup_init_quantum(); |
| 213 | #ifdef BACKLIGHT_ENABLE | ||
| 214 | backlight_init(); | ||
| 215 | #endif | ||
| 216 | |||
| 217 | // Restore LED indicators | ||
| 218 | led_set(host_keyboard_leds()); | ||
| 219 | |||
| 220 | // Wake up underglow | ||
| 221 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 222 | rgblight_wakeup(); | ||
| 223 | #endif | ||
| 224 | |||
| 225 | #if defined(LED_MATRIX_ENABLE) | ||
| 226 | led_matrix_set_suspend_state(false); | ||
| 227 | #endif | ||
| 228 | #if defined(RGB_MATRIX_ENABLE) | ||
| 229 | rgb_matrix_set_suspend_state(false); | ||
| 230 | #endif | ||
| 231 | |||
| 232 | suspend_wakeup_init_kb(); | ||
| 233 | } | 139 | } |
| 234 | 140 | ||
| 235 | #if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) | 141 | #if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) |
diff --git a/tmk_core/common/chibios/_wait.h b/tmk_core/common/chibios/_wait.h index b740afbd2..2f36c64a2 100644 --- a/tmk_core/common/chibios/_wait.h +++ b/tmk_core/common/chibios/_wait.h | |||
| @@ -43,8 +43,6 @@ void wait_us(uint16_t duration); | |||
| 43 | 43 | ||
| 44 | #include "_wait.c" | 44 | #include "_wait.c" |
| 45 | 45 | ||
| 46 | #define CPU_CLOCK STM32_SYSCLK | ||
| 47 | |||
| 48 | /* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus | 46 | /* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus |
| 49 | * to which the GPIO is connected. | 47 | * to which the GPIO is connected. |
| 50 | * The connected buses differ depending on the various series of MCUs. | 48 | * The connected buses differ depending on the various series of MCUs. |
diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h index 23c65f942..c35f58955 100644 --- a/tmk_core/common/chibios/chibios_config.h +++ b/tmk_core/common/chibios/chibios_config.h | |||
| @@ -19,22 +19,33 @@ | |||
| 19 | # define SPLIT_USB_DETECT // Force this on when dedicated pin is not used | 19 | # define SPLIT_USB_DETECT // Force this on when dedicated pin is not used |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | #if defined(STM32F1XX) | 22 | // STM32 compatibility |
| 23 | # define USE_GPIOV1 | 23 | #if defined(MCU_STM32) |
| 24 | #endif | 24 | # define CPU_CLOCK STM32_SYSCLK |
| 25 | 25 | ||
| 26 | #if defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32L1XX) | 26 | # if defined(STM32F1XX) |
| 27 | # define USE_I2CV1 | 27 | # define USE_GPIOV1 |
| 28 | #endif | 28 | # define PAL_MODE_ALTERNATE_OPENDRAIN PAL_MODE_STM32_ALTERNATE_OPENDRAIN |
| 29 | # define PAL_MODE_ALTERNATE_PUSHPULL PAL_MODE_STM32_ALTERNATE_PUSHPULL | ||
| 30 | # else | ||
| 31 | # define PAL_OUTPUT_TYPE_OPENDRAIN PAL_STM32_OTYPE_OPENDRAIN | ||
| 32 | # define PAL_OUTPUT_TYPE_PUSHPULL PAL_STM32_OTYPE_PUSHPULL | ||
| 33 | # define PAL_OUTPUT_SPEED_HIGHEST PAL_STM32_OSPEED_HIGHEST | ||
| 34 | # define PAL_PUPDR_FLOATING PAL_STM32_PUPDR_FLOATING | ||
| 35 | # endif | ||
| 29 | 36 | ||
| 30 | // teensy | 37 | # if defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32L1XX) |
| 31 | #if defined(K20x) || defined(KL2x) | 38 | # define USE_I2CV1 |
| 32 | # define USE_I2CV1 | 39 | # endif |
| 33 | # define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed | ||
| 34 | # define USE_GPIOV1 | ||
| 35 | # define STM32_SYSCLK KINETIS_SYSCLK_FREQUENCY | ||
| 36 | #endif | 40 | #endif |
| 37 | 41 | ||
| 38 | #if defined(MK66F18) | 42 | // teensy compatibility |
| 39 | # define STM32_SYSCLK KINETIS_SYSCLK_FREQUENCY | 43 | #if defined(MCU_KINETIS) |
| 40 | #endif | 44 | # define CPU_CLOCK KINETIS_SYSCLK_FREQUENCY |
| 45 | |||
| 46 | # if defined(K20x) || defined(KL2x) | ||
| 47 | # define USE_I2CV1 | ||
| 48 | # define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed | ||
| 49 | # define USE_GPIOV1 | ||
| 50 | # endif | ||
| 51 | #endif \ No newline at end of file | ||
diff --git a/tmk_core/common/chibios/eeprom_stm32.c b/tmk_core/common/chibios/eeprom_stm32.c index 1fdf8c1e2..acc6a4851 100644 --- a/tmk_core/common/chibios/eeprom_stm32.c +++ b/tmk_core/common/chibios/eeprom_stm32.c | |||
| @@ -620,48 +620,11 @@ uint16_t EEPROM_ReadDataWord(uint16_t Address) { | |||
| 620 | } | 620 | } |
| 621 | 621 | ||
| 622 | /***************************************************************************** | 622 | /***************************************************************************** |
| 623 | * Wrap library in AVR style functions. | 623 | * Bind to eeprom_driver.c |
| 624 | *******************************************************************************/ | 624 | *******************************************************************************/ |
| 625 | uint8_t eeprom_read_byte(const uint8_t *Address) { return EEPROM_ReadDataByte((const uintptr_t)Address); } | 625 | void eeprom_driver_init(void) { EEPROM_Init(); } |
| 626 | 626 | ||
| 627 | void eeprom_write_byte(uint8_t *Address, uint8_t Value) { EEPROM_WriteDataByte((uintptr_t)Address, Value); } | 627 | void eeprom_driver_erase(void) { EEPROM_Erase(); } |
| 628 | |||
| 629 | void eeprom_update_byte(uint8_t *Address, uint8_t Value) { EEPROM_WriteDataByte((uintptr_t)Address, Value); } | ||
| 630 | |||
| 631 | uint16_t eeprom_read_word(const uint16_t *Address) { return EEPROM_ReadDataWord((const uintptr_t)Address); } | ||
| 632 | |||
| 633 | void eeprom_write_word(uint16_t *Address, uint16_t Value) { EEPROM_WriteDataWord((uintptr_t)Address, Value); } | ||
| 634 | |||
| 635 | void eeprom_update_word(uint16_t *Address, uint16_t Value) { EEPROM_WriteDataWord((uintptr_t)Address, Value); } | ||
| 636 | |||
| 637 | uint32_t eeprom_read_dword(const uint32_t *Address) { | ||
| 638 | const uint16_t p = (const uintptr_t)Address; | ||
| 639 | /* Check word alignment */ | ||
| 640 | if (p % 2) { | ||
| 641 | /* Not aligned */ | ||
| 642 | return (uint32_t)EEPROM_ReadDataByte(p) | (uint32_t)(EEPROM_ReadDataWord(p + 1) << 8) | (uint32_t)(EEPROM_ReadDataByte(p + 3) << 24); | ||
| 643 | } else { | ||
| 644 | /* Aligned */ | ||
| 645 | return EEPROM_ReadDataWord(p) | (EEPROM_ReadDataWord(p + 2) << 16); | ||
| 646 | } | ||
| 647 | } | ||
| 648 | |||
| 649 | void eeprom_write_dword(uint32_t *Address, uint32_t Value) { | ||
| 650 | uint16_t p = (const uintptr_t)Address; | ||
| 651 | /* Check word alignment */ | ||
| 652 | if (p % 2) { | ||
| 653 | /* Not aligned */ | ||
| 654 | EEPROM_WriteDataByte(p, (uint8_t)Value); | ||
| 655 | EEPROM_WriteDataWord(p + 1, (uint16_t)(Value >> 8)); | ||
| 656 | EEPROM_WriteDataByte(p + 3, (uint8_t)(Value >> 24)); | ||
| 657 | } else { | ||
| 658 | /* Aligned */ | ||
| 659 | EEPROM_WriteDataWord(p, (uint16_t)Value); | ||
| 660 | EEPROM_WriteDataWord(p + 2, (uint16_t)(Value >> 16)); | ||
| 661 | } | ||
| 662 | } | ||
| 663 | |||
| 664 | void eeprom_update_dword(uint32_t *Address, uint32_t Value) { eeprom_write_dword(Address, Value); } | ||
| 665 | 628 | ||
| 666 | void eeprom_read_block(void *buf, const void *addr, size_t len) { | 629 | void eeprom_read_block(void *buf, const void *addr, size_t len) { |
| 667 | const uint8_t *src = (const uint8_t *)addr; | 630 | const uint8_t *src = (const uint8_t *)addr; |
| @@ -670,14 +633,14 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) { | |||
| 670 | /* Check word alignment */ | 633 | /* Check word alignment */ |
| 671 | if (len && (uintptr_t)src % 2) { | 634 | if (len && (uintptr_t)src % 2) { |
| 672 | /* Read the unaligned first byte */ | 635 | /* Read the unaligned first byte */ |
| 673 | *dest++ = eeprom_read_byte(src++); | 636 | *dest++ = EEPROM_ReadDataByte((const uintptr_t)src++); |
| 674 | --len; | 637 | --len; |
| 675 | } | 638 | } |
| 676 | 639 | ||
| 677 | uint16_t value; | 640 | uint16_t value; |
| 678 | bool aligned = ((uintptr_t)dest % 2 == 0); | 641 | bool aligned = ((uintptr_t)dest % 2 == 0); |
| 679 | while (len > 1) { | 642 | while (len > 1) { |
| 680 | value = eeprom_read_word((uint16_t *)src); | 643 | value = EEPROM_ReadDataWord((const uintptr_t)((uint16_t *)src)); |
| 681 | if (aligned) { | 644 | if (aligned) { |
| 682 | *(uint16_t *)dest = value; | 645 | *(uint16_t *)dest = value; |
| 683 | dest += 2; | 646 | dest += 2; |
| @@ -689,7 +652,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) { | |||
| 689 | len -= 2; | 652 | len -= 2; |
| 690 | } | 653 | } |
| 691 | if (len) { | 654 | if (len) { |
| 692 | *dest = eeprom_read_byte(src); | 655 | *dest = EEPROM_ReadDataByte((const uintptr_t)src); |
| 693 | } | 656 | } |
| 694 | } | 657 | } |
| 695 | 658 | ||
| @@ -700,7 +663,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
| 700 | /* Check word alignment */ | 663 | /* Check word alignment */ |
| 701 | if (len && (uintptr_t)dest % 2) { | 664 | if (len && (uintptr_t)dest % 2) { |
| 702 | /* Write the unaligned first byte */ | 665 | /* Write the unaligned first byte */ |
| 703 | eeprom_write_byte(dest++, *src++); | 666 | EEPROM_WriteDataByte((uintptr_t)dest++, *src++); |
| 704 | --len; | 667 | --len; |
| 705 | } | 668 | } |
| 706 | 669 | ||
| @@ -712,15 +675,13 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
| 712 | } else { | 675 | } else { |
| 713 | value = *(uint8_t *)src | (*(uint8_t *)(src + 1) << 8); | 676 | value = *(uint8_t *)src | (*(uint8_t *)(src + 1) << 8); |
| 714 | } | 677 | } |
| 715 | eeprom_write_word((uint16_t *)dest, value); | 678 | EEPROM_WriteDataWord((uintptr_t)((uint16_t *)dest), value); |
| 716 | dest += 2; | 679 | dest += 2; |
| 717 | src += 2; | 680 | src += 2; |
| 718 | len -= 2; | 681 | len -= 2; |
| 719 | } | 682 | } |
| 720 | 683 | ||
| 721 | if (len) { | 684 | if (len) { |
| 722 | eeprom_write_byte(dest, *src); | 685 | EEPROM_WriteDataByte((uintptr_t)dest, *src); |
| 723 | } | 686 | } |
| 724 | } | 687 | } |
| 725 | |||
| 726 | void eeprom_update_block(const void *buf, void *addr, size_t len) { eeprom_write_block(buf, addr, len); } | ||
diff --git a/tmk_core/common/chibios/eeprom_stm32_defs.h b/tmk_core/common/chibios/eeprom_stm32_defs.h index 22b4ab858..cc64cda74 100644 --- a/tmk_core/common/chibios/eeprom_stm32_defs.h +++ b/tmk_core/common/chibios/eeprom_stm32_defs.h | |||
| @@ -32,6 +32,13 @@ | |||
| 32 | # ifndef FEE_PAGE_COUNT | 32 | # ifndef FEE_PAGE_COUNT |
| 33 | # define FEE_PAGE_COUNT 4 // How many pages are used | 33 | # define FEE_PAGE_COUNT 4 // How many pages are used |
| 34 | # endif | 34 | # endif |
| 35 | # elif defined(STM32F401xC) || defined(STM32F405xG) || defined(STM32F411xE) | ||
| 36 | # ifndef FEE_PAGE_SIZE | ||
| 37 | # define FEE_PAGE_SIZE 0x4000 // Page size = 16KByte | ||
| 38 | # endif | ||
| 39 | # ifndef FEE_PAGE_COUNT | ||
| 40 | # define FEE_PAGE_COUNT 1 // How many pages are used | ||
| 41 | # endif | ||
| 35 | # endif | 42 | # endif |
| 36 | #endif | 43 | #endif |
| 37 | 44 | ||
| @@ -40,17 +47,21 @@ | |||
| 40 | # define FEE_MCU_FLASH_SIZE 32 // Size in Kb | 47 | # define FEE_MCU_FLASH_SIZE 32 // Size in Kb |
| 41 | # elif defined(STM32F103xB) || defined(STM32F072xB) || defined(STM32F070xB) | 48 | # elif defined(STM32F103xB) || defined(STM32F072xB) || defined(STM32F070xB) |
| 42 | # define FEE_MCU_FLASH_SIZE 128 // Size in Kb | 49 | # define FEE_MCU_FLASH_SIZE 128 // Size in Kb |
| 43 | # elif defined(STM32F303xC) | 50 | # elif defined(STM32F303xC) || defined(STM32F401xC) |
| 44 | # define FEE_MCU_FLASH_SIZE 256 // Size in Kb | 51 | # define FEE_MCU_FLASH_SIZE 256 // Size in Kb |
| 45 | # elif defined(STM32F103xE) | 52 | # elif defined(STM32F103xE) || defined(STM32F411xE) |
| 46 | # define FEE_MCU_FLASH_SIZE 512 // Size in Kb | 53 | # define FEE_MCU_FLASH_SIZE 512 // Size in Kb |
| 54 | # elif defined(STM32F405xG) | ||
| 55 | # define FEE_MCU_FLASH_SIZE 1024 // Size in Kb | ||
| 47 | # endif | 56 | # endif |
| 48 | #endif | 57 | #endif |
| 49 | 58 | ||
| 50 | /* Start of the emulated eeprom */ | 59 | /* Start of the emulated eeprom */ |
| 51 | #if !defined(FEE_PAGE_BASE_ADDRESS) | 60 | #if !defined(FEE_PAGE_BASE_ADDRESS) |
| 52 | # if 0 | 61 | # if defined(STM32F401xC) || defined(STM32F405xG) || defined(STM32F411xE) |
| 53 | /* TODO: Add support for F4 */ | 62 | # ifndef FEE_PAGE_BASE_ADDRESS |
| 63 | # define FEE_PAGE_BASE_ADDRESS 0x08004000 // bodge to force 2nd 16k page | ||
| 64 | # endif | ||
| 54 | # else | 65 | # else |
| 55 | # ifndef FEE_FLASH_BASE | 66 | # ifndef FEE_FLASH_BASE |
| 56 | # define FEE_FLASH_BASE 0x8000000 | 67 | # define FEE_FLASH_BASE 0x8000000 |
diff --git a/tmk_core/common/chibios/flash_stm32.c b/tmk_core/common/chibios/flash_stm32.c index 6b80ff71c..8f10903d3 100644 --- a/tmk_core/common/chibios/flash_stm32.c +++ b/tmk_core/common/chibios/flash_stm32.c | |||
| @@ -23,6 +23,29 @@ | |||
| 23 | # define FLASH_SR_WRPERR FLASH_SR_WRPRTERR | 23 | # define FLASH_SR_WRPERR FLASH_SR_WRPRTERR |
| 24 | #endif | 24 | #endif |
| 25 | 25 | ||
| 26 | #if defined(EEPROM_EMU_STM32F401xC) | ||
| 27 | # define FLASH_SR_PGERR (FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR) | ||
| 28 | |||
| 29 | # define FLASH_KEY1 0x45670123U | ||
| 30 | # define FLASH_KEY2 0xCDEF89ABU | ||
| 31 | |||
| 32 | static uint8_t ADDR2PAGE(uint32_t Page_Address) { | ||
| 33 | switch (Page_Address) { | ||
| 34 | case 0x08000000 ... 0x08003FFF: | ||
| 35 | return 0; | ||
| 36 | case 0x08004000 ... 0x08007FFF: | ||
| 37 | return 1; | ||
| 38 | case 0x08008000 ... 0x0800BFFF: | ||
| 39 | return 2; | ||
| 40 | case 0x0800C000 ... 0x0800FFFF: | ||
| 41 | return 3; | ||
| 42 | } | ||
| 43 | |||
| 44 | // TODO: bad times... | ||
| 45 | return 7; | ||
| 46 | } | ||
| 47 | #endif | ||
| 48 | |||
| 26 | /* Delay definition */ | 49 | /* Delay definition */ |
| 27 | #define EraseTimeout ((uint32_t)0x00000FFF) | 50 | #define EraseTimeout ((uint32_t)0x00000FFF) |
| 28 | #define ProgramTimeout ((uint32_t)0x0000001F) | 51 | #define ProgramTimeout ((uint32_t)0x0000001F) |
| @@ -53,7 +76,9 @@ FLASH_Status FLASH_GetStatus(void) { | |||
| 53 | 76 | ||
| 54 | if ((FLASH->SR & FLASH_SR_WRPERR) != 0) return FLASH_ERROR_WRP; | 77 | if ((FLASH->SR & FLASH_SR_WRPERR) != 0) return FLASH_ERROR_WRP; |
| 55 | 78 | ||
| 79 | #if defined(FLASH_OBR_OPTERR) | ||
| 56 | if ((FLASH->SR & FLASH_OBR_OPTERR) != 0) return FLASH_ERROR_OPT; | 80 | if ((FLASH->SR & FLASH_OBR_OPTERR) != 0) return FLASH_ERROR_OPT; |
| 81 | #endif | ||
| 57 | 82 | ||
| 58 | return FLASH_COMPLETE; | 83 | return FLASH_COMPLETE; |
| 59 | } | 84 | } |
| @@ -95,15 +120,24 @@ FLASH_Status FLASH_ErasePage(uint32_t Page_Address) { | |||
| 95 | 120 | ||
| 96 | if (status == FLASH_COMPLETE) { | 121 | if (status == FLASH_COMPLETE) { |
| 97 | /* if the previous operation is completed, proceed to erase the page */ | 122 | /* if the previous operation is completed, proceed to erase the page */ |
| 123 | #if defined(FLASH_CR_SNB) | ||
| 124 | FLASH->CR &= ~FLASH_CR_SNB; | ||
| 125 | FLASH->CR |= FLASH_CR_SER | (ADDR2PAGE(Page_Address) << FLASH_CR_SNB_Pos); | ||
| 126 | #else | ||
| 98 | FLASH->CR |= FLASH_CR_PER; | 127 | FLASH->CR |= FLASH_CR_PER; |
| 99 | FLASH->AR = Page_Address; | 128 | FLASH->AR = Page_Address; |
| 129 | #endif | ||
| 100 | FLASH->CR |= FLASH_CR_STRT; | 130 | FLASH->CR |= FLASH_CR_STRT; |
| 101 | 131 | ||
| 102 | /* Wait for last operation to be completed */ | 132 | /* Wait for last operation to be completed */ |
| 103 | status = FLASH_WaitForLastOperation(EraseTimeout); | 133 | status = FLASH_WaitForLastOperation(EraseTimeout); |
| 104 | if (status != FLASH_TIMEOUT) { | 134 | if (status != FLASH_TIMEOUT) { |
| 105 | /* if the erase operation is completed, disable the PER Bit */ | 135 | /* if the erase operation is completed, disable the configured Bits */ |
| 136 | #if defined(FLASH_CR_SNB) | ||
| 137 | FLASH->CR &= ~(FLASH_CR_SER | FLASH_CR_SNB); | ||
| 138 | #else | ||
| 106 | FLASH->CR &= ~FLASH_CR_PER; | 139 | FLASH->CR &= ~FLASH_CR_PER; |
| 140 | #endif | ||
| 107 | } | 141 | } |
| 108 | FLASH->SR = (FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPERR); | 142 | FLASH->SR = (FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPERR); |
| 109 | } | 143 | } |
| @@ -126,6 +160,11 @@ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) { | |||
| 126 | status = FLASH_WaitForLastOperation(ProgramTimeout); | 160 | status = FLASH_WaitForLastOperation(ProgramTimeout); |
| 127 | if (status == FLASH_COMPLETE) { | 161 | if (status == FLASH_COMPLETE) { |
| 128 | /* if the previous operation is completed, proceed to program the new data */ | 162 | /* if the previous operation is completed, proceed to program the new data */ |
| 163 | |||
| 164 | #if defined(FLASH_CR_PSIZE) | ||
| 165 | FLASH->CR &= ~FLASH_CR_PSIZE; | ||
| 166 | FLASH->CR |= FLASH_CR_PSIZE_0; | ||
| 167 | #endif | ||
| 129 | FLASH->CR |= FLASH_CR_PG; | 168 | FLASH->CR |= FLASH_CR_PG; |
| 130 | *(__IO uint16_t*)Address = Data; | 169 | *(__IO uint16_t*)Address = Data; |
| 131 | /* Wait for last operation to be completed */ | 170 | /* Wait for last operation to be completed */ |
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c index 38517e06f..9310a9992 100644 --- a/tmk_core/common/chibios/suspend.c +++ b/tmk_core/common/chibios/suspend.c | |||
| @@ -7,30 +7,12 @@ | |||
| 7 | #include "action.h" | 7 | #include "action.h" |
| 8 | #include "action_util.h" | 8 | #include "action_util.h" |
| 9 | #include "mousekey.h" | 9 | #include "mousekey.h" |
| 10 | #include "programmable_button.h" | ||
| 10 | #include "host.h" | 11 | #include "host.h" |
| 11 | #include "suspend.h" | 12 | #include "suspend.h" |
| 12 | #include "led.h" | 13 | #include "led.h" |
| 13 | #include "wait.h" | 14 | #include "wait.h" |
| 14 | 15 | ||
| 15 | #ifdef AUDIO_ENABLE | ||
| 16 | # include "audio.h" | ||
| 17 | #endif /* AUDIO_ENABLE */ | ||
| 18 | |||
| 19 | #ifdef BACKLIGHT_ENABLE | ||
| 20 | # include "backlight.h" | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 24 | # include "rgblight.h" | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #ifdef LED_MATRIX_ENABLE | ||
| 28 | # include "led_matrix.h" | ||
| 29 | #endif | ||
| 30 | #ifdef RGB_MATRIX_ENABLE | ||
| 31 | # include "rgb_matrix.h" | ||
| 32 | #endif | ||
| 33 | |||
| 34 | /** \brief suspend idle | 16 | /** \brief suspend idle |
| 35 | * | 17 | * |
| 36 | * FIXME: needs doc | 18 | * FIXME: needs doc |
| @@ -40,61 +22,12 @@ void suspend_idle(uint8_t time) { | |||
| 40 | wait_ms(time); | 22 | wait_ms(time); |
| 41 | } | 23 | } |
| 42 | 24 | ||
| 43 | /** \brief Run keyboard level Power down | ||
| 44 | * | ||
| 45 | * FIXME: needs doc | ||
| 46 | */ | ||
| 47 | __attribute__((weak)) void suspend_power_down_user(void) {} | ||
| 48 | /** \brief Run keyboard level Power down | ||
| 49 | * | ||
| 50 | * FIXME: needs doc | ||
| 51 | */ | ||
| 52 | __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); } | ||
| 53 | |||
| 54 | /** \brief suspend power down | 25 | /** \brief suspend power down |
| 55 | * | 26 | * |
| 56 | * FIXME: needs doc | 27 | * FIXME: needs doc |
| 57 | */ | 28 | */ |
| 58 | void suspend_power_down(void) { | 29 | void suspend_power_down(void) { |
| 59 | #ifdef BACKLIGHT_ENABLE | 30 | suspend_power_down_quantum(); |
| 60 | backlight_set(0); | ||
| 61 | #endif | ||
| 62 | |||
| 63 | #ifdef LED_MATRIX_ENABLE | ||
| 64 | led_matrix_task(); | ||
| 65 | #endif | ||
| 66 | #ifdef RGB_MATRIX_ENABLE | ||
| 67 | rgb_matrix_task(); | ||
| 68 | #endif | ||
| 69 | |||
| 70 | // Turn off LED indicators | ||
| 71 | uint8_t leds_off = 0; | ||
| 72 | #if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) | ||
| 73 | if (is_backlight_enabled()) { | ||
| 74 | // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off | ||
| 75 | leds_off |= (1 << USB_LED_CAPS_LOCK); | ||
| 76 | } | ||
| 77 | #endif | ||
| 78 | led_set(leds_off); | ||
| 79 | |||
| 80 | // TODO: figure out what to power down and how | ||
| 81 | // shouldn't power down TPM/FTM if we want a breathing LED | ||
| 82 | // also shouldn't power down USB | ||
| 83 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 84 | rgblight_suspend(); | ||
| 85 | #endif | ||
| 86 | |||
| 87 | #if defined(LED_MATRIX_ENABLE) | ||
| 88 | led_matrix_set_suspend_state(true); | ||
| 89 | #endif | ||
| 90 | #if defined(RGB_MATRIX_ENABLE) | ||
| 91 | rgb_matrix_set_suspend_state(true); | ||
| 92 | #endif | ||
| 93 | #ifdef AUDIO_ENABLE | ||
| 94 | stop_all_notes(); | ||
| 95 | #endif /* AUDIO_ENABLE */ | ||
| 96 | |||
| 97 | suspend_power_down_kb(); | ||
| 98 | // on AVR, this enables the watchdog for 15ms (max), and goes to | 31 | // on AVR, this enables the watchdog for 15ms (max), and goes to |
| 99 | // SLEEP_MODE_PWR_DOWN | 32 | // SLEEP_MODE_PWR_DOWN |
| 100 | 33 | ||
| @@ -147,23 +80,13 @@ void suspend_wakeup_init(void) { | |||
| 147 | #ifdef MOUSEKEY_ENABLE | 80 | #ifdef MOUSEKEY_ENABLE |
| 148 | mousekey_clear(); | 81 | mousekey_clear(); |
| 149 | #endif /* MOUSEKEY_ENABLE */ | 82 | #endif /* MOUSEKEY_ENABLE */ |
| 83 | #ifdef PROGRAMMABLE_BUTTON_ENABLE | ||
| 84 | programmable_button_clear(); | ||
| 85 | #endif /* PROGRAMMABLE_BUTTON_ENABLE */ | ||
| 150 | #ifdef EXTRAKEY_ENABLE | 86 | #ifdef EXTRAKEY_ENABLE |
| 151 | host_system_send(0); | 87 | host_system_send(0); |
| 152 | host_consumer_send(0); | 88 | host_consumer_send(0); |
| 153 | #endif /* EXTRAKEY_ENABLE */ | 89 | #endif /* EXTRAKEY_ENABLE */ |
| 154 | #ifdef BACKLIGHT_ENABLE | ||
| 155 | backlight_init(); | ||
| 156 | #endif /* BACKLIGHT_ENABLE */ | ||
| 157 | led_set(host_keyboard_leds()); | ||
| 158 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 159 | rgblight_wakeup(); | ||
| 160 | #endif | ||
| 161 | 90 | ||
| 162 | #if defined(LED_MATRIX_ENABLE) | 91 | suspend_wakeup_init_quantum(); |
| 163 | led_matrix_set_suspend_state(false); | ||
| 164 | #endif | ||
| 165 | #if defined(RGB_MATRIX_ENABLE) | ||
| 166 | rgb_matrix_set_suspend_state(false); | ||
| 167 | #endif | ||
| 168 | suspend_wakeup_init_kb(); | ||
| 169 | } | 92 | } |
diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c index f0c396b18..56d4bb084 100644 --- a/tmk_core/common/host.c +++ b/tmk_core/common/host.c | |||
| @@ -30,8 +30,9 @@ extern keymap_config_t keymap_config; | |||
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | static host_driver_t *driver; | 32 | static host_driver_t *driver; |
| 33 | static uint16_t last_system_report = 0; | 33 | static uint16_t last_system_report = 0; |
| 34 | static uint16_t last_consumer_report = 0; | 34 | static uint16_t last_consumer_report = 0; |
| 35 | static uint32_t last_programmable_button_report = 0; | ||
| 35 | 36 | ||
| 36 | void host_set_driver(host_driver_t *d) { driver = d; } | 37 | void host_set_driver(host_driver_t *d) { driver = d; } |
| 37 | 38 | ||
| @@ -122,6 +123,16 @@ void host_digitizer_send(digitizer_t *digitizer) { | |||
| 122 | 123 | ||
| 123 | __attribute__((weak)) void send_digitizer(report_digitizer_t *report) {} | 124 | __attribute__((weak)) void send_digitizer(report_digitizer_t *report) {} |
| 124 | 125 | ||
| 126 | void host_programmable_button_send(uint32_t report) { | ||
| 127 | if (report == last_programmable_button_report) return; | ||
| 128 | last_programmable_button_report = report; | ||
| 129 | |||
| 130 | if (!driver) return; | ||
| 131 | (*driver->send_programmable_button)(report); | ||
| 132 | } | ||
| 133 | |||
| 125 | uint16_t host_last_system_report(void) { return last_system_report; } | 134 | uint16_t host_last_system_report(void) { return last_system_report; } |
| 126 | 135 | ||
| 127 | uint16_t host_last_consumer_report(void) { return last_consumer_report; } | 136 | uint16_t host_last_consumer_report(void) { return last_consumer_report; } |
| 137 | |||
| 138 | uint32_t host_last_programmable_button_report(void) { return last_programmable_button_report; } | ||
diff --git a/tmk_core/common/host.h b/tmk_core/common/host.h index 2cffef6e1..6b15f0d0c 100644 --- a/tmk_core/common/host.h +++ b/tmk_core/common/host.h | |||
| @@ -47,9 +47,11 @@ void host_keyboard_send(report_keyboard_t *report); | |||
| 47 | void host_mouse_send(report_mouse_t *report); | 47 | void host_mouse_send(report_mouse_t *report); |
| 48 | void host_system_send(uint16_t data); | 48 | void host_system_send(uint16_t data); |
| 49 | void host_consumer_send(uint16_t data); | 49 | void host_consumer_send(uint16_t data); |
| 50 | void host_programmable_button_send(uint32_t data); | ||
| 50 | 51 | ||
| 51 | uint16_t host_last_system_report(void); | 52 | uint16_t host_last_system_report(void); |
| 52 | uint16_t host_last_consumer_report(void); | 53 | uint16_t host_last_consumer_report(void); |
| 54 | uint32_t host_last_programmable_button_report(void); | ||
| 53 | 55 | ||
| 54 | #ifdef __cplusplus | 56 | #ifdef __cplusplus |
| 55 | } | 57 | } |
diff --git a/tmk_core/common/host_driver.h b/tmk_core/common/host_driver.h index 2aebca043..affd0dcb3 100644 --- a/tmk_core/common/host_driver.h +++ b/tmk_core/common/host_driver.h | |||
| @@ -29,6 +29,7 @@ typedef struct { | |||
| 29 | void (*send_mouse)(report_mouse_t *); | 29 | void (*send_mouse)(report_mouse_t *); |
| 30 | void (*send_system)(uint16_t); | 30 | void (*send_system)(uint16_t); |
| 31 | void (*send_consumer)(uint16_t); | 31 | void (*send_consumer)(uint16_t); |
| 32 | void (*send_programmable_button)(uint32_t); | ||
| 32 | } host_driver_t; | 33 | } host_driver_t; |
| 33 | 34 | ||
| 34 | void send_digitizer(report_digitizer_t *report); \ No newline at end of file | 35 | void send_digitizer(report_digitizer_t *report); \ No newline at end of file |
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index f2223e806..1adc892f3 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h | |||
| @@ -29,6 +29,7 @@ enum hid_report_ids { | |||
| 29 | REPORT_ID_MOUSE, | 29 | REPORT_ID_MOUSE, |
| 30 | REPORT_ID_SYSTEM, | 30 | REPORT_ID_SYSTEM, |
| 31 | REPORT_ID_CONSUMER, | 31 | REPORT_ID_CONSUMER, |
| 32 | REPORT_ID_PROGRAMMABLE_BUTTON, | ||
| 32 | REPORT_ID_NKRO, | 33 | REPORT_ID_NKRO, |
| 33 | REPORT_ID_JOYSTICK, | 34 | REPORT_ID_JOYSTICK, |
| 34 | REPORT_ID_DIGITIZER | 35 | REPORT_ID_DIGITIZER |
| @@ -196,6 +197,11 @@ typedef struct { | |||
| 196 | } __attribute__((packed)) report_extra_t; | 197 | } __attribute__((packed)) report_extra_t; |
| 197 | 198 | ||
| 198 | typedef struct { | 199 | typedef struct { |
| 200 | uint8_t report_id; | ||
| 201 | uint32_t usage; | ||
| 202 | } __attribute__((packed)) report_programmable_button_t; | ||
| 203 | |||
| 204 | typedef struct { | ||
| 199 | #ifdef MOUSE_SHARED_EP | 205 | #ifdef MOUSE_SHARED_EP |
| 200 | uint8_t report_id; | 206 | uint8_t report_id; |
| 201 | #endif | 207 | #endif |
diff --git a/tmk_core/common/suspend.h b/tmk_core/common/suspend.h index 95845e4b6..081735f90 100644 --- a/tmk_core/common/suspend.h +++ b/tmk_core/common/suspend.h | |||
| @@ -10,8 +10,10 @@ void suspend_wakeup_init(void); | |||
| 10 | 10 | ||
| 11 | void suspend_wakeup_init_user(void); | 11 | void suspend_wakeup_init_user(void); |
| 12 | void suspend_wakeup_init_kb(void); | 12 | void suspend_wakeup_init_kb(void); |
| 13 | void suspend_wakeup_init_quantum(void); | ||
| 13 | void suspend_power_down_user(void); | 14 | void suspend_power_down_user(void); |
| 14 | void suspend_power_down_kb(void); | 15 | void suspend_power_down_kb(void); |
| 16 | void suspend_power_down_quantum(void); | ||
| 15 | 17 | ||
| 16 | #ifndef USB_SUSPEND_WAKEUP_DELAY | 18 | #ifndef USB_SUSPEND_WAKEUP_DELAY |
| 17 | # define USB_SUSPEND_WAKEUP_DELAY 0 | 19 | # define USB_SUSPEND_WAKEUP_DELAY 0 |
diff --git a/tmk_core/common/sync_timer.c b/tmk_core/common/sync_timer.c index 68b92d8b4..de24b463b 100644 --- a/tmk_core/common/sync_timer.c +++ b/tmk_core/common/sync_timer.c | |||
| @@ -26,7 +26,7 @@ SOFTWARE. | |||
| 26 | #include "sync_timer.h" | 26 | #include "sync_timer.h" |
| 27 | #include "keyboard.h" | 27 | #include "keyboard.h" |
| 28 | 28 | ||
| 29 | #if (defined(SPLIT_KEYBOARD) || defined(SERIAL_LINK_ENABLE)) && !defined(DISABLE_SYNC_TIMER) | 29 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) |
| 30 | volatile int32_t sync_timer_ms; | 30 | volatile int32_t sync_timer_ms; |
| 31 | 31 | ||
| 32 | void sync_timer_init(void) { sync_timer_ms = 0; } | 32 | void sync_timer_init(void) { sync_timer_ms = 0; } |
diff --git a/tmk_core/common/sync_timer.h b/tmk_core/common/sync_timer.h index 744e2b50d..9ddef45bb 100644 --- a/tmk_core/common/sync_timer.h +++ b/tmk_core/common/sync_timer.h | |||
| @@ -32,7 +32,7 @@ SOFTWARE. | |||
| 32 | extern "C" { | 32 | extern "C" { |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #if (defined(SPLIT_KEYBOARD) || defined(SERIAL_LINK_ENABLE)) && !defined(DISABLE_SYNC_TIMER) | 35 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) |
| 36 | void sync_timer_init(void); | 36 | void sync_timer_init(void); |
| 37 | void sync_timer_update(uint32_t time); | 37 | void sync_timer_update(uint32_t time); |
| 38 | uint16_t sync_timer_read(void); | 38 | uint16_t sync_timer_read(void); |
diff --git a/tmk_core/common/test/rules.mk b/tmk_core/common/test/rules.mk index 48632a095..73d2302da 100644 --- a/tmk_core/common/test/rules.mk +++ b/tmk_core/common/test/rules.mk | |||
| @@ -16,6 +16,7 @@ eeprom_stm32_tiny_INC := $(eeprom_stm32_INC) | |||
| 16 | eeprom_stm32_large_INC := $(eeprom_stm32_INC) | 16 | eeprom_stm32_large_INC := $(eeprom_stm32_INC) |
| 17 | 17 | ||
| 18 | eeprom_stm32_SRC := \ | 18 | eeprom_stm32_SRC := \ |
| 19 | $(TOP_DIR)/drivers/eeprom/eeprom_driver.c \ | ||
| 19 | $(TMK_PATH)/common/test/eeprom_stm32_tests.cpp \ | 20 | $(TMK_PATH)/common/test/eeprom_stm32_tests.cpp \ |
| 20 | $(TMK_PATH)/common/test/flash_stm32_mock.c \ | 21 | $(TMK_PATH)/common/test/flash_stm32_mock.c \ |
| 21 | $(TMK_PATH)/common/chibios/eeprom_stm32.c | 22 | $(TMK_PATH)/common/chibios/eeprom_stm32.c |
