diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common.mk | 5 | ||||
| -rw-r--r-- | tmk_core/common/action.c | 2 | ||||
| -rw-r--r-- | tmk_core/common/action_layer.c | 4 | ||||
| -rw-r--r-- | tmk_core/common/action_layer.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/action_util.c | 88 | ||||
| -rw-r--r-- | tmk_core/common/action_util.h | 11 | ||||
| -rw-r--r-- | tmk_core/common/avr/suspend.c | 76 | ||||
| -rwxr-xr-x | tmk_core/common/chibios/eeprom_stm32.c | 29 | ||||
| -rwxr-xr-x | tmk_core/common/chibios/eeprom_stm32.h | 6 | ||||
| -rwxr-xr-x | tmk_core/common/chibios/flash_stm32.c | 5 | ||||
| -rw-r--r-- | tmk_core/common/command.h | 3 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 36 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.h | 5 | ||||
| -rw-r--r-- | tmk_core/protocol/arm_atsam/adc.c | 6 | ||||
| -rw-r--r-- | tmk_core/protocol/bluefruit/main.c | 15 | ||||
| -rw-r--r-- | tmk_core/protocol/chibios/main.c | 2 | ||||
| -rw-r--r-- | tmk_core/protocol/usb_hid/test/config.h | 12 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/main.c | 1 | ||||
| -rw-r--r-- | tmk_core/rules.mk | 13 |
19 files changed, 225 insertions, 96 deletions
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 063115acb..94f3c2380 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
| @@ -41,6 +41,11 @@ ifeq ($(PLATFORM),CHIBIOS) | |||
| 41 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c | 41 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c |
| 42 | TMK_COMMON_DEFS += -DEEPROM_EMU_STM32F103xB | 42 | TMK_COMMON_DEFS += -DEEPROM_EMU_STM32F103xB |
| 43 | TMK_COMMON_DEFS += -DSTM32_EEPROM_ENABLE | 43 | TMK_COMMON_DEFS += -DSTM32_EEPROM_ENABLE |
| 44 | else ifeq ($(MCU_SERIES)_$(MCU_LDSCRIPT), STM32F0xx_STM32F072xB) | ||
| 45 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c | ||
| 46 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c | ||
| 47 | TMK_COMMON_DEFS += -DEEPROM_EMU_STM32F072xB | ||
| 48 | TMK_COMMON_DEFS += -DSTM32_EEPROM_ENABLE | ||
| 44 | else | 49 | else |
| 45 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom_teensy.c | 50 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom_teensy.c |
| 46 | endif | 51 | endif |
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index ec8d6ed7b..d4d4ac28d 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -537,7 +537,7 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 537 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); | 537 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); |
| 538 | break; | 538 | break; |
| 539 | #endif | 539 | #endif |
| 540 | #ifdef BACKLIGHT_ENABLE | 540 | #if defined(BACKLIGHT_ENABLE) | defined(LED_MATRIX_ENABLE) |
| 541 | case ACT_BACKLIGHT: | 541 | case ACT_BACKLIGHT: |
| 542 | if (!event.pressed) { | 542 | if (!event.pressed) { |
| 543 | switch (action.backlight.opt) { | 543 | switch (action.backlight.opt) { |
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index 6ff8c5549..47cad996a 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c | |||
| @@ -296,7 +296,7 @@ action_t store_or_get_action(bool pressed, keypos_t key) { | |||
| 296 | * | 296 | * |
| 297 | * Gets the layer based on key info | 297 | * Gets the layer based on key info |
| 298 | */ | 298 | */ |
| 299 | int8_t layer_switch_get_layer(keypos_t key) { | 299 | uint8_t layer_switch_get_layer(keypos_t key) { |
| 300 | #ifndef NO_ACTION_LAYER | 300 | #ifndef NO_ACTION_LAYER |
| 301 | action_t action; | 301 | action_t action; |
| 302 | action.code = ACTION_TRANSPARENT; | 302 | action.code = ACTION_TRANSPARENT; |
| @@ -304,7 +304,7 @@ int8_t layer_switch_get_layer(keypos_t key) { | |||
| 304 | uint32_t layers = layer_state | default_layer_state; | 304 | uint32_t layers = layer_state | default_layer_state; |
| 305 | /* check top layer first */ | 305 | /* check top layer first */ |
| 306 | for (int8_t i = 31; i >= 0; i--) { | 306 | for (int8_t i = 31; i >= 0; i--) { |
| 307 | if (layers & (1UL<<i)) { | 307 | if (layers & (1UL << i)) { |
| 308 | action = action_for_key(i, key); | 308 | action = action_for_key(i, key); |
| 309 | if (action.code != ACTION_TRANSPARENT) { | 309 | if (action.code != ACTION_TRANSPARENT) { |
| 310 | return i; | 310 | return i; |
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index f1551d251..6e2f35d90 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h | |||
| @@ -97,7 +97,7 @@ uint8_t read_source_layers_cache(keypos_t key); | |||
| 97 | action_t store_or_get_action(bool pressed, keypos_t key); | 97 | action_t store_or_get_action(bool pressed, keypos_t key); |
| 98 | 98 | ||
| 99 | /* return the topmost non-transparent layer currently associated with key */ | 99 | /* return the topmost non-transparent layer currently associated with key */ |
| 100 | int8_t layer_switch_get_layer(keypos_t key); | 100 | uint8_t layer_switch_get_layer(keypos_t key); |
| 101 | 101 | ||
| 102 | /* return action depending on current layer status */ | 102 | /* return action depending on current layer status */ |
| 103 | action_t layer_switch_get_action(keypos_t key); | 103 | action_t layer_switch_get_action(keypos_t key); |
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index 58401ace5..365ed6a1d 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c | |||
| @@ -48,11 +48,21 @@ extern inline void del_key(uint8_t key); | |||
| 48 | extern inline void clear_keys(void); | 48 | extern inline void clear_keys(void); |
| 49 | 49 | ||
| 50 | #ifndef NO_ACTION_ONESHOT | 50 | #ifndef NO_ACTION_ONESHOT |
| 51 | static int8_t oneshot_mods = 0; | 51 | static uint8_t oneshot_mods = 0; |
| 52 | static int8_t oneshot_locked_mods = 0; | 52 | static uint8_t oneshot_locked_mods = 0; |
| 53 | int8_t get_oneshot_locked_mods(void) { return oneshot_locked_mods; } | 53 | uint8_t get_oneshot_locked_mods(void) { return oneshot_locked_mods; } |
| 54 | void set_oneshot_locked_mods(int8_t mods) { oneshot_locked_mods = mods; } | 54 | void set_oneshot_locked_mods(uint8_t mods) { |
| 55 | void clear_oneshot_locked_mods(void) { oneshot_locked_mods = 0; } | 55 | if (mods != oneshot_locked_mods) { |
| 56 | oneshot_locked_mods = mods; | ||
| 57 | oneshot_locked_mods_changed_kb(oneshot_locked_mods); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | void clear_oneshot_locked_mods(void) { | ||
| 61 | if (oneshot_locked_mods) { | ||
| 62 | oneshot_locked_mods = 0; | ||
| 63 | oneshot_locked_mods_changed_kb(oneshot_locked_mods); | ||
| 64 | } | ||
| 65 | } | ||
| 56 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 66 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 57 | static uint16_t oneshot_time = 0; | 67 | static uint16_t oneshot_time = 0; |
| 58 | bool has_oneshot_mods_timed_out(void) { | 68 | bool has_oneshot_mods_timed_out(void) { |
| @@ -97,6 +107,7 @@ void set_oneshot_layer(uint8_t layer, uint8_t state) | |||
| 97 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 107 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 98 | oneshot_layer_time = timer_read(); | 108 | oneshot_layer_time = timer_read(); |
| 99 | #endif | 109 | #endif |
| 110 | oneshot_layer_changed_kb(get_oneshot_layer()); | ||
| 100 | } | 111 | } |
| 101 | /** \brief Reset oneshot layer | 112 | /** \brief Reset oneshot layer |
| 102 | * | 113 | * |
| @@ -107,6 +118,7 @@ void reset_oneshot_layer(void) { | |||
| 107 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 118 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 108 | oneshot_layer_time = 0; | 119 | oneshot_layer_time = 0; |
| 109 | #endif | 120 | #endif |
| 121 | oneshot_layer_changed_kb(get_oneshot_layer()); | ||
| 110 | } | 122 | } |
| 111 | /** \brief Clear oneshot layer | 123 | /** \brief Clear oneshot layer |
| 112 | * | 124 | * |
| @@ -118,9 +130,7 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state) | |||
| 118 | oneshot_layer_data &= ~state; | 130 | oneshot_layer_data &= ~state; |
| 119 | if (!get_oneshot_layer_state() && start_state != oneshot_layer_data) { | 131 | if (!get_oneshot_layer_state() && start_state != oneshot_layer_data) { |
| 120 | layer_off(get_oneshot_layer()); | 132 | layer_off(get_oneshot_layer()); |
| 121 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 133 | reset_oneshot_layer(); |
| 122 | oneshot_layer_time = 0; | ||
| 123 | #endif | ||
| 124 | } | 134 | } |
| 125 | } | 135 | } |
| 126 | /** \brief Is oneshot layer active | 136 | /** \brief Is oneshot layer active |
| @@ -243,23 +253,27 @@ void clear_macro_mods(void) { macro_mods = 0; } | |||
| 243 | * | 253 | * |
| 244 | * FIXME: needs doc | 254 | * FIXME: needs doc |
| 245 | */ | 255 | */ |
| 246 | void set_oneshot_mods(uint8_t mods) | 256 | void set_oneshot_mods(uint8_t mods) { |
| 247 | { | 257 | if (oneshot_mods != mods) { |
| 248 | oneshot_mods = mods; | ||
| 249 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 258 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 250 | oneshot_time = timer_read(); | 259 | oneshot_time = timer_read(); |
| 251 | #endif | 260 | #endif |
| 261 | oneshot_mods = mods; | ||
| 262 | oneshot_mods_changed_kb(mods); | ||
| 263 | } | ||
| 252 | } | 264 | } |
| 253 | /** \brief clear oneshot mods | 265 | /** \brief clear oneshot mods |
| 254 | * | 266 | * |
| 255 | * FIXME: needs doc | 267 | * FIXME: needs doc |
| 256 | */ | 268 | */ |
| 257 | void clear_oneshot_mods(void) | 269 | void clear_oneshot_mods(void) { |
| 258 | { | 270 | if (oneshot_mods) { |
| 259 | oneshot_mods = 0; | 271 | oneshot_mods = 0; |
| 260 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 272 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 261 | oneshot_time = 0; | 273 | oneshot_time = 0; |
| 262 | #endif | 274 | #endif |
| 275 | oneshot_mods_changed_kb(oneshot_mods); | ||
| 276 | } | ||
| 263 | } | 277 | } |
| 264 | /** \brief get oneshot mods | 278 | /** \brief get oneshot mods |
| 265 | * | 279 | * |
| @@ -271,6 +285,54 @@ uint8_t get_oneshot_mods(void) | |||
| 271 | } | 285 | } |
| 272 | #endif | 286 | #endif |
| 273 | 287 | ||
| 288 | /** \brief Called when the one shot modifiers have been changed. | ||
| 289 | * | ||
| 290 | * \param mods Contains the active modifiers active after the change. | ||
| 291 | */ | ||
| 292 | __attribute__((weak)) | ||
| 293 | void oneshot_locked_mods_changed_user(uint8_t mods) { } | ||
| 294 | |||
| 295 | /** \brief Called when the locked one shot modifiers have been changed. | ||
| 296 | * | ||
| 297 | * \param mods Contains the active modifiers active after the change. | ||
| 298 | */ | ||
| 299 | __attribute__((weak)) | ||
| 300 | void oneshot_locked_mods_changed_kb(uint8_t mods) { | ||
| 301 | oneshot_locked_mods_changed_user(mods); | ||
| 302 | } | ||
| 303 | |||
| 304 | /** \brief Called when the one shot modifiers have been changed. | ||
| 305 | * | ||
| 306 | * \param mods Contains the active modifiers active after the change. | ||
| 307 | */ | ||
| 308 | __attribute__((weak)) | ||
| 309 | void oneshot_mods_changed_user(uint8_t mods) { } | ||
| 310 | |||
| 311 | /** \brief Called when the one shot modifiers have been changed. | ||
| 312 | * | ||
| 313 | * \param mods Contains the active modifiers active after the change. | ||
| 314 | */ | ||
| 315 | __attribute__((weak)) | ||
| 316 | void oneshot_mods_changed_kb(uint8_t mods) { | ||
| 317 | oneshot_mods_changed_user(mods); | ||
| 318 | } | ||
| 319 | |||
| 320 | /** \brief Called when the one shot layers have been changed. | ||
| 321 | * | ||
| 322 | * \param layer Contains the layer that is toggled on, or zero when toggled off. | ||
| 323 | */ | ||
| 324 | __attribute__((weak)) | ||
| 325 | void oneshot_layer_changed_user(uint8_t layer) { } | ||
| 326 | |||
| 327 | /** \brief Called when the one shot layers have been changed. | ||
| 328 | * | ||
| 329 | * \param layer Contains the layer that is toggled on, or zero when toggled off. | ||
| 330 | */ | ||
| 331 | __attribute__((weak)) | ||
| 332 | void oneshot_layer_changed_kb(uint8_t layer) { | ||
| 333 | oneshot_layer_changed_user(layer); | ||
| 334 | } | ||
| 335 | |||
| 274 | /** \brief inspect keyboard state | 336 | /** \brief inspect keyboard state |
| 275 | * | 337 | * |
| 276 | * FIXME: needs doc | 338 | * FIXME: needs doc |
diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h index 345893151..d03f5682a 100644 --- a/tmk_core/common/action_util.h +++ b/tmk_core/common/action_util.h | |||
| @@ -71,8 +71,8 @@ void oneshot_enable(void); | |||
| 71 | void oneshot_disable(void); | 71 | void oneshot_disable(void); |
| 72 | bool has_oneshot_mods_timed_out(void); | 72 | bool has_oneshot_mods_timed_out(void); |
| 73 | 73 | ||
| 74 | int8_t get_oneshot_locked_mods(void); | 74 | uint8_t get_oneshot_locked_mods(void); |
| 75 | void set_oneshot_locked_mods(int8_t mods); | 75 | void set_oneshot_locked_mods(uint8_t mods); |
| 76 | void clear_oneshot_locked_mods(void); | 76 | void clear_oneshot_locked_mods(void); |
| 77 | 77 | ||
| 78 | typedef enum { | 78 | typedef enum { |
| @@ -89,6 +89,13 @@ bool is_oneshot_layer_active(void); | |||
| 89 | uint8_t get_oneshot_layer_state(void); | 89 | uint8_t get_oneshot_layer_state(void); |
| 90 | bool has_oneshot_layer_timed_out(void); | 90 | bool has_oneshot_layer_timed_out(void); |
| 91 | 91 | ||
| 92 | void oneshot_locked_mods_changed_user(uint8_t mods); | ||
| 93 | void oneshot_locked_mods_changed_kb(uint8_t mods); | ||
| 94 | void oneshot_mods_changed_user(uint8_t mods); | ||
| 95 | void oneshot_mods_changed_kb(uint8_t mods); | ||
| 96 | void oneshot_layer_changed_user(uint8_t layer); | ||
| 97 | void oneshot_layer_changed_kb(uint8_t layer); | ||
| 98 | |||
| 92 | /* inspect */ | 99 | /* inspect */ |
| 93 | uint8_t has_anymod(void); | 100 | uint8_t has_anymod(void); |
| 94 | 101 | ||
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 5bca64685..b29447ac4 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
| @@ -11,6 +11,9 @@ | |||
| 11 | #include "led.h" | 11 | #include "led.h" |
| 12 | #include "host.h" | 12 | #include "host.h" |
| 13 | #include "rgblight_reconfig.h" | 13 | #include "rgblight_reconfig.h" |
| 14 | #ifdef SPLIT_KEYBOARD | ||
| 15 | #include "split_flags.h" | ||
| 16 | #endif | ||
| 14 | 17 | ||
| 15 | #ifdef PROTOCOL_LUFA | 18 | #ifdef PROTOCOL_LUFA |
| 16 | #include "lufa.h" | 19 | #include "lufa.h" |
| @@ -22,6 +25,9 @@ | |||
| 22 | 25 | ||
| 23 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 26 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 24 | #include "rgblight.h" | 27 | #include "rgblight.h" |
| 28 | extern rgblight_config_t rgblight_config; | ||
| 29 | static bool rgblight_enabled; | ||
| 30 | static bool is_suspended; | ||
| 25 | #endif | 31 | #endif |
| 26 | 32 | ||
| 27 | 33 | ||
| @@ -46,8 +52,7 @@ __asm__ __volatile__ ( \ | |||
| 46 | * | 52 | * |
| 47 | * FIXME: needs doc | 53 | * FIXME: needs doc |
| 48 | */ | 54 | */ |
| 49 | void suspend_idle(uint8_t time) | 55 | void suspend_idle(uint8_t time) { |
| 50 | { | ||
| 51 | cli(); | 56 | cli(); |
| 52 | set_sleep_mode(SLEEP_MODE_IDLE); | 57 | set_sleep_mode(SLEEP_MODE_IDLE); |
| 53 | sleep_enable(); | 58 | sleep_enable(); |
| @@ -95,32 +100,45 @@ static uint8_t wdt_timeout = 0; | |||
| 95 | * | 100 | * |
| 96 | * FIXME: needs doc | 101 | * FIXME: needs doc |
| 97 | */ | 102 | */ |
| 98 | static void power_down(uint8_t wdto) | 103 | static void power_down(uint8_t wdto) { |
| 99 | { | ||
| 100 | #ifdef PROTOCOL_LUFA | 104 | #ifdef PROTOCOL_LUFA |
| 101 | if (USB_DeviceState == DEVICE_STATE_Configured) return; | 105 | if (USB_DeviceState == DEVICE_STATE_Configured) return; |
| 102 | #endif | 106 | #endif |
| 103 | wdt_timeout = wdto; | 107 | wdt_timeout = wdto; |
| 104 | 108 | ||
| 105 | // Watchdog Interrupt Mode | 109 | // Watchdog Interrupt Mode |
| 106 | wdt_intr_enable(wdto); | 110 | wdt_intr_enable(wdto); |
| 107 | 111 | ||
| 108 | #ifdef BACKLIGHT_ENABLE | 112 | #ifdef BACKLIGHT_ENABLE |
| 109 | backlight_set(0); | 113 | backlight_set(0); |
| 110 | #endif | 114 | #endif |
| 111 | 115 | ||
| 112 | // Turn off LED indicators | 116 | // Turn off LED indicators |
| 113 | led_set(0); | 117 | uint8_t leds_off = 0; |
| 118 | #if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) | ||
| 119 | if (is_backlight_enabled()) { | ||
| 120 | // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off | ||
| 121 | leds_off |= (1<<USB_LED_CAPS_LOCK); | ||
| 122 | } | ||
| 123 | #endif | ||
| 124 | led_set(leds_off); | ||
| 114 | 125 | ||
| 115 | #ifdef AUDIO_ENABLE | 126 | #ifdef AUDIO_ENABLE |
| 116 | // This sometimes disables the start-up noise, so it's been disabled | 127 | // This sometimes disables the start-up noise, so it's been disabled |
| 117 | // stop_all_notes(); | 128 | // stop_all_notes(); |
| 118 | #endif /* AUDIO_ENABLE */ | 129 | #endif /* AUDIO_ENABLE */ |
| 119 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 130 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 120 | #ifdef RGBLIGHT_ANIMATIONS | 131 | #ifdef RGBLIGHT_ANIMATIONS |
| 121 | rgblight_timer_disable(); | 132 | rgblight_timer_disable(); |
| 122 | #endif | 133 | #endif |
| 123 | rgblight_disable_noeeprom(); | 134 | if (!is_suspended) { |
| 135 | is_suspended = true; | ||
| 136 | rgblight_enabled = rgblight_config.enable; | ||
| 137 | rgblight_disable_noeeprom(); | ||
| 138 | #ifdef SPLIT_KEYBOARD | ||
| 139 | RGB_DIRTY = true; | ||
| 140 | #endif | ||
| 141 | } | ||
| 124 | #endif | 142 | #endif |
| 125 | suspend_power_down_kb(); | 143 | suspend_power_down_kb(); |
| 126 | 144 | ||
| @@ -145,8 +163,7 @@ static void power_down(uint8_t wdto) | |||
| 145 | * | 163 | * |
| 146 | * FIXME: needs doc | 164 | * FIXME: needs doc |
| 147 | */ | 165 | */ |
| 148 | void suspend_power_down(void) | 166 | void suspend_power_down(void) { |
| 149 | { | ||
| 150 | suspend_power_down_kb(); | 167 | suspend_power_down_kb(); |
| 151 | 168 | ||
| 152 | #ifndef NO_SUSPEND_POWER_DOWN | 169 | #ifndef NO_SUSPEND_POWER_DOWN |
| @@ -156,8 +173,7 @@ void suspend_power_down(void) | |||
| 156 | 173 | ||
| 157 | __attribute__ ((weak)) void matrix_power_up(void) {} | 174 | __attribute__ ((weak)) void matrix_power_up(void) {} |
| 158 | __attribute__ ((weak)) void matrix_power_down(void) {} | 175 | __attribute__ ((weak)) void matrix_power_down(void) {} |
| 159 | bool suspend_wakeup_condition(void) | 176 | bool suspend_wakeup_condition(void) { |
| 160 | { | ||
| 161 | matrix_power_up(); | 177 | matrix_power_up(); |
| 162 | matrix_scan(); | 178 | matrix_scan(); |
| 163 | matrix_power_down(); | 179 | matrix_power_down(); |
| @@ -186,8 +202,7 @@ void suspend_wakeup_init_kb(void) { | |||
| 186 | * | 202 | * |
| 187 | * FIXME: needs doc | 203 | * FIXME: needs doc |
| 188 | */ | 204 | */ |
| 189 | void suspend_wakeup_init(void) | 205 | void suspend_wakeup_init(void) { |
| 190 | { | ||
| 191 | // clear keyboard state | 206 | // clear keyboard state |
| 192 | clear_keyboard(); | 207 | clear_keyboard(); |
| 193 | #ifdef BACKLIGHT_ENABLE | 208 | #ifdef BACKLIGHT_ENABLE |
| @@ -195,10 +210,16 @@ void suspend_wakeup_init(void) | |||
| 195 | #endif | 210 | #endif |
| 196 | led_set(host_keyboard_leds()); | 211 | led_set(host_keyboard_leds()); |
| 197 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 212 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 198 | #ifdef BOOTLOADER_TEENSY | 213 | is_suspended = false; |
| 199 | wait_ms(10); | 214 | if (rgblight_enabled) { |
| 200 | #endif | 215 | #ifdef BOOTLOADER_TEENSY |
| 201 | rgblight_enable_noeeprom(); | 216 | wait_ms(10); |
| 217 | #endif | ||
| 218 | rgblight_enable_noeeprom(); | ||
| 219 | #ifdef SPLIT_KEYBOARD | ||
| 220 | RGB_DIRTY = true; | ||
| 221 | #endif | ||
| 222 | } | ||
| 202 | #ifdef RGBLIGHT_ANIMATIONS | 223 | #ifdef RGBLIGHT_ANIMATIONS |
| 203 | rgblight_timer_enable(); | 224 | rgblight_timer_enable(); |
| 204 | #endif | 225 | #endif |
| @@ -208,8 +229,7 @@ void suspend_wakeup_init(void) | |||
| 208 | 229 | ||
| 209 | #ifndef NO_SUSPEND_POWER_DOWN | 230 | #ifndef NO_SUSPEND_POWER_DOWN |
| 210 | /* watchdog timeout */ | 231 | /* watchdog timeout */ |
| 211 | ISR(WDT_vect) | 232 | ISR(WDT_vect) { |
| 212 | { | ||
| 213 | // compensate timer for sleep | 233 | // compensate timer for sleep |
| 214 | switch (wdt_timeout) { | 234 | switch (wdt_timeout) { |
| 215 | case WDTO_15MS: | 235 | case WDTO_15MS: |
diff --git a/tmk_core/common/chibios/eeprom_stm32.c b/tmk_core/common/chibios/eeprom_stm32.c index a15430d67..4b1abc968 100755 --- a/tmk_core/common/chibios/eeprom_stm32.c +++ b/tmk_core/common/chibios/eeprom_stm32.c | |||
| @@ -75,17 +75,13 @@ uint16_t EEPROM_WriteDataByte (uint16_t Address, uint8_t DataByte) { | |||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | // calculate which page is affected (Pagenum1/Pagenum2...PagenumN) | 77 | // calculate which page is affected (Pagenum1/Pagenum2...PagenumN) |
| 78 | page = (FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address)) & 0x00000FFF; | 78 | page = FEE_ADDR_OFFSET(Address) / FEE_PAGE_SIZE; |
| 79 | |||
| 80 | if (page % FEE_PAGE_SIZE) page = page + FEE_PAGE_SIZE; | ||
| 81 | page = (page / FEE_PAGE_SIZE) - 1; | ||
| 82 | 79 | ||
| 83 | // if current data is 0xFF, the byte is empty, just overwrite with the new one | 80 | // if current data is 0xFF, the byte is empty, just overwrite with the new one |
| 84 | if ((*(__IO uint16_t*)(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address))) == FEE_EMPTY_WORD) { | 81 | if ((*(__IO uint16_t*)(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address))) == FEE_EMPTY_WORD) { |
| 85 | 82 | ||
| 86 | FlashStatus = FLASH_ProgramHalfWord(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address), (uint16_t)(0x00FF & DataByte)); | 83 | FlashStatus = FLASH_ProgramHalfWord(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address), (uint16_t)(0x00FF & DataByte)); |
| 87 | } | 84 | } else { |
| 88 | else { | ||
| 89 | 85 | ||
| 90 | // Copy Page to a buffer | 86 | // Copy Page to a buffer |
| 91 | memcpy(DataBuf, (uint8_t*)FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE), FEE_PAGE_SIZE); // !!! Calculate base address for the desired page | 87 | memcpy(DataBuf, (uint8_t*)FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE), FEE_PAGE_SIZE); // !!! Calculate base address for the desired page |
| @@ -96,18 +92,17 @@ uint16_t EEPROM_WriteDataByte (uint16_t Address, uint8_t DataByte) { | |||
| 96 | } | 92 | } |
| 97 | 93 | ||
| 98 | // manipulate desired data byte in temp data array if new byte is differ to the current | 94 | // manipulate desired data byte in temp data array if new byte is differ to the current |
| 99 | DataBuf[FEE_ADDR_OFFSET(Address)] = DataByte; | 95 | DataBuf[FEE_ADDR_OFFSET(Address) % FEE_PAGE_SIZE] = DataByte; |
| 100 | 96 | ||
| 101 | //Erase Page | 97 | //Erase Page |
| 102 | FlashStatus = FLASH_ErasePage(FEE_PAGE_BASE_ADDRESS + page); | 98 | FlashStatus = FLASH_ErasePage(FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE)); |
| 103 | 99 | ||
| 104 | // Write new data (whole page) to flash if data has beed changed | 100 | // Write new data (whole page) to flash if data has been changed |
| 105 | for(i = 0; i < (FEE_PAGE_SIZE / 2); i++) { | 101 | for(i = 0; i < (FEE_PAGE_SIZE / 2); i++) { |
| 106 | if ((__IO uint16_t)(0xFF00 | DataBuf[FEE_ADDR_OFFSET(i)]) != 0xFFFF) { | 102 | if ((__IO uint16_t)(0xFF00 | DataBuf[FEE_ADDR_OFFSET(i)]) != 0xFFFF) { |
| 107 | FlashStatus = FLASH_ProgramHalfWord((FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE)) + (i * 2), (uint16_t)(0xFF00 | DataBuf[FEE_ADDR_OFFSET(i)])); | 103 | FlashStatus = FLASH_ProgramHalfWord((FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE)) + (i * 2), (uint16_t)(0xFF00 | DataBuf[FEE_ADDR_OFFSET(i)])); |
| 108 | } | 104 | } |
| 109 | } | 105 | } |
| 110 | |||
| 111 | } | 106 | } |
| 112 | return FlashStatus; | 107 | return FlashStatus; |
| 113 | } | 108 | } |
| @@ -168,7 +163,7 @@ void eeprom_update_word (uint16_t *Address, uint16_t Value) | |||
| 168 | uint32_t eeprom_read_dword (const uint32_t *Address) | 163 | uint32_t eeprom_read_dword (const uint32_t *Address) |
| 169 | { | 164 | { |
| 170 | const uint16_t p = (const uint32_t) Address; | 165 | const uint16_t p = (const uint32_t) Address; |
| 171 | return EEPROM_ReadDataByte(p) | (EEPROM_ReadDataByte(p+1) << 8) | 166 | return EEPROM_ReadDataByte(p) | (EEPROM_ReadDataByte(p+1) << 8) |
| 172 | | (EEPROM_ReadDataByte(p+2) << 16) | (EEPROM_ReadDataByte(p+3) << 24); | 167 | | (EEPROM_ReadDataByte(p+2) << 16) | (EEPROM_ReadDataByte(p+3) << 24); |
| 173 | } | 168 | } |
| 174 | 169 | ||
| @@ -184,10 +179,14 @@ void eeprom_write_dword (uint32_t *Address, uint32_t Value) | |||
| 184 | void eeprom_update_dword (uint32_t *Address, uint32_t Value) | 179 | void eeprom_update_dword (uint32_t *Address, uint32_t Value) |
| 185 | { | 180 | { |
| 186 | uint16_t p = (const uint32_t) Address; | 181 | uint16_t p = (const uint32_t) Address; |
| 187 | EEPROM_WriteDataByte(p, (uint8_t) Value); | 182 | uint32_t existingValue = EEPROM_ReadDataByte(p) | (EEPROM_ReadDataByte(p+1) << 8) |
| 188 | EEPROM_WriteDataByte(p+1, (uint8_t) (Value >> 8)); | 183 | | (EEPROM_ReadDataByte(p+2) << 16) | (EEPROM_ReadDataByte(p+3) << 24); |
| 189 | EEPROM_WriteDataByte(p+2, (uint8_t) (Value >> 16)); | 184 | if(Value != existingValue){ |
| 190 | EEPROM_WriteDataByte(p+3, (uint8_t) (Value >> 24)); | 185 | EEPROM_WriteDataByte(p, (uint8_t) Value); |
| 186 | EEPROM_WriteDataByte(p+1, (uint8_t) (Value >> 8)); | ||
| 187 | EEPROM_WriteDataByte(p+2, (uint8_t) (Value >> 16)); | ||
| 188 | EEPROM_WriteDataByte(p+3, (uint8_t) (Value >> 24)); | ||
| 189 | } | ||
| 191 | } | 190 | } |
| 192 | 191 | ||
| 193 | void eeprom_read_block(void *buf, const void *addr, uint32_t len) { | 192 | void eeprom_read_block(void *buf, const void *addr, uint32_t len) { |
diff --git a/tmk_core/common/chibios/eeprom_stm32.h b/tmk_core/common/chibios/eeprom_stm32.h index 892e417b7..083eb16ee 100755 --- a/tmk_core/common/chibios/eeprom_stm32.h +++ b/tmk_core/common/chibios/eeprom_stm32.h | |||
| @@ -34,6 +34,8 @@ | |||
| 34 | #define MCU_STM32F303CC | 34 | #define MCU_STM32F303CC |
| 35 | #elif defined(EEPROM_EMU_STM32F103xB) | 35 | #elif defined(EEPROM_EMU_STM32F103xB) |
| 36 | #define MCU_STM32F103RB | 36 | #define MCU_STM32F103RB |
| 37 | #elif defined(EEPROM_EMU_STM32F072xB) | ||
| 38 | #define MCU_STM32F072CB | ||
| 37 | #else | 39 | #else |
| 38 | #error "not implemented." | 40 | #error "not implemented." |
| 39 | #endif | 41 | #endif |
| @@ -42,7 +44,7 @@ | |||
| 42 | #if defined (MCU_STM32F103RB) | 44 | #if defined (MCU_STM32F103RB) |
| 43 | #define FEE_PAGE_SIZE (uint16_t)0x400 // Page size = 1KByte | 45 | #define FEE_PAGE_SIZE (uint16_t)0x400 // Page size = 1KByte |
| 44 | #define FEE_DENSITY_PAGES 2 // How many pages are used | 46 | #define FEE_DENSITY_PAGES 2 // How many pages are used |
| 45 | #elif defined (MCU_STM32F103ZE) || defined (MCU_STM32F103RE) || defined (MCU_STM32F103RD) || defined (MCU_STM32F303CC) | 47 | #elif defined (MCU_STM32F103ZE) || defined (MCU_STM32F103RE) || defined (MCU_STM32F103RD) || defined (MCU_STM32F303CC) || defined(MCU_STM32F072CB) |
| 46 | #define FEE_PAGE_SIZE (uint16_t)0x800 // Page size = 2KByte | 48 | #define FEE_PAGE_SIZE (uint16_t)0x800 // Page size = 2KByte |
| 47 | #define FEE_DENSITY_PAGES 4 // How many pages are used | 49 | #define FEE_DENSITY_PAGES 4 // How many pages are used |
| 48 | #else | 50 | #else |
| @@ -51,7 +53,7 @@ | |||
| 51 | #endif | 53 | #endif |
| 52 | 54 | ||
| 53 | #ifndef EEPROM_START_ADDRESS | 55 | #ifndef EEPROM_START_ADDRESS |
| 54 | #if defined (MCU_STM32F103RB) | 56 | #if defined (MCU_STM32F103RB) || defined(MCU_STM32F072CB) |
| 55 | #define FEE_MCU_FLASH_SIZE 128 // Size in Kb | 57 | #define FEE_MCU_FLASH_SIZE 128 // Size in Kb |
| 56 | #elif defined (MCU_STM32F103ZE) || defined (MCU_STM32F103RE) | 58 | #elif defined (MCU_STM32F103ZE) || defined (MCU_STM32F103RE) |
| 57 | #define FEE_MCU_FLASH_SIZE 512 // Size in Kb | 59 | #define FEE_MCU_FLASH_SIZE 512 // Size in Kb |
diff --git a/tmk_core/common/chibios/flash_stm32.c b/tmk_core/common/chibios/flash_stm32.c index 164654a15..832bf3908 100755 --- a/tmk_core/common/chibios/flash_stm32.c +++ b/tmk_core/common/chibios/flash_stm32.c | |||
| @@ -22,6 +22,9 @@ | |||
| 22 | #elif defined(EEPROM_EMU_STM32F103xB) | 22 | #elif defined(EEPROM_EMU_STM32F103xB) |
| 23 | #define STM32F103xB | 23 | #define STM32F103xB |
| 24 | #include "stm32f1xx.h" | 24 | #include "stm32f1xx.h" |
| 25 | #elif defined(EEPROM_EMU_STM32F072xB) | ||
| 26 | #define STM32F072xB | ||
| 27 | #include "stm32f0xx.h" | ||
| 25 | #else | 28 | #else |
| 26 | #error "not implemented." | 29 | #error "not implemented." |
| 27 | #endif | 30 | #endif |
| @@ -193,7 +196,7 @@ void FLASH_Lock(void) | |||
| 193 | * This parameter can be any combination of the following values: | 196 | * This parameter can be any combination of the following values: |
| 194 | * @arg FLASH_FLAG_PGERR: FLASH Programming error flag flag | 197 | * @arg FLASH_FLAG_PGERR: FLASH Programming error flag flag |
| 195 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag | 198 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag |
| 196 | * @arg FLASH_FLAG_EOP: FLASH End of Programming flag | 199 | * @arg FLASH_FLAG_EOP: FLASH End of Programming flag |
| 197 | * @retval None | 200 | * @retval None |
| 198 | */ | 201 | */ |
| 199 | void FLASH_ClearFlag(uint32_t FLASH_FLAG) | 202 | void FLASH_ClearFlag(uint32_t FLASH_FLAG) |
diff --git a/tmk_core/common/command.h b/tmk_core/common/command.h index c38f2b9e8..052e25184 100644 --- a/tmk_core/common/command.h +++ b/tmk_core/common/command.h | |||
| @@ -34,6 +34,9 @@ bool command_proc(uint8_t code); | |||
| 34 | #define command_proc(code) false | 34 | #define command_proc(code) false |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #ifndef IS_COMMAND | ||
| 38 | #define IS_COMMAND() (get_mods() == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) | ||
| 39 | #endif | ||
| 37 | 40 | ||
| 38 | #ifndef MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS | 41 | #ifndef MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS |
| 39 | #define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true | 42 | #define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 25be28d02..849d74aa1 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -139,6 +139,40 @@ __attribute__ ((weak)) | |||
| 139 | void matrix_setup(void) { | 139 | void matrix_setup(void) { |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /** \brief keyboard_pre_init_user | ||
| 143 | * | ||
| 144 | * FIXME: needs doc | ||
| 145 | */ | ||
| 146 | __attribute__ ((weak)) | ||
| 147 | void keyboard_pre_init_user(void) { } | ||
| 148 | |||
| 149 | /** \brief keyboard_pre_init_kb | ||
| 150 | * | ||
| 151 | * FIXME: needs doc | ||
| 152 | */ | ||
| 153 | __attribute__ ((weak)) | ||
| 154 | void keyboard_pre_init_kb(void) { | ||
| 155 | keyboard_pre_init_user(); | ||
| 156 | } | ||
| 157 | |||
| 158 | /** \brief keyboard_post_init_user | ||
| 159 | * | ||
| 160 | * FIXME: needs doc | ||
| 161 | */ | ||
| 162 | |||
| 163 | __attribute__ ((weak)) | ||
| 164 | void keyboard_post_init_user() {} | ||
| 165 | |||
| 166 | /** \brief keyboard_post_init_kb | ||
| 167 | * | ||
| 168 | * FIXME: needs doc | ||
| 169 | */ | ||
| 170 | |||
| 171 | __attribute__ ((weak)) | ||
| 172 | void keyboard_post_init_kb(void) { | ||
| 173 | keyboard_post_init_user(); | ||
| 174 | } | ||
| 175 | |||
| 142 | /** \brief keyboard_setup | 176 | /** \brief keyboard_setup |
| 143 | * | 177 | * |
| 144 | * FIXME: needs doc | 178 | * FIXME: needs doc |
| @@ -146,6 +180,7 @@ void matrix_setup(void) { | |||
| 146 | void keyboard_setup(void) { | 180 | void keyboard_setup(void) { |
| 147 | disable_jtag(); | 181 | disable_jtag(); |
| 148 | matrix_setup(); | 182 | matrix_setup(); |
| 183 | keyboard_pre_init_kb(); | ||
| 149 | } | 184 | } |
| 150 | 185 | ||
| 151 | /** \brief is_keyboard_master | 186 | /** \brief is_keyboard_master |
| @@ -199,6 +234,7 @@ void keyboard_init(void) { | |||
| 199 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) | 234 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) |
| 200 | keymap_config.nkro = 1; | 235 | keymap_config.nkro = 1; |
| 201 | #endif | 236 | #endif |
| 237 | keyboard_post_init_kb(); /* Always keep this last */ | ||
| 202 | } | 238 | } |
| 203 | 239 | ||
| 204 | /** \brief Keyboard task: Do keyboard routine jobs | 240 | /** \brief Keyboard task: Do keyboard routine jobs |
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h index ea2f336e9..bf8b71fb7 100644 --- a/tmk_core/common/keyboard.h +++ b/tmk_core/common/keyboard.h | |||
| @@ -70,6 +70,11 @@ void keyboard_set_leds(uint8_t leds); | |||
| 70 | /* it runs whenever code has to behave differently on a slave */ | 70 | /* it runs whenever code has to behave differently on a slave */ |
| 71 | bool is_keyboard_master(void); | 71 | bool is_keyboard_master(void); |
| 72 | 72 | ||
| 73 | void keyboard_pre_init_kb(void); | ||
| 74 | void keyboard_pre_init_user(void); | ||
| 75 | void keyboard_post_init_kb(void); | ||
| 76 | void keyboard_post_init_user(void); | ||
| 77 | |||
| 73 | #ifdef __cplusplus | 78 | #ifdef __cplusplus |
| 74 | } | 79 | } |
| 75 | #endif | 80 | #endif |
diff --git a/tmk_core/protocol/arm_atsam/adc.c b/tmk_core/protocol/arm_atsam/adc.c index ab77f9240..cb5c349b7 100644 --- a/tmk_core/protocol/arm_atsam/adc.c +++ b/tmk_core/protocol/arm_atsam/adc.c | |||
| @@ -74,9 +74,9 @@ void ADC0_init(void) | |||
| 74 | while (ADC0->SYNCBUSY.bit.SAMPCTRL) { DBGC(DC_ADC0_SAMPCTRL_SYNCING_1); } | 74 | while (ADC0->SYNCBUSY.bit.SAMPCTRL) { DBGC(DC_ADC0_SAMPCTRL_SYNCING_1); } |
| 75 | 75 | ||
| 76 | //Load factory calibration data | 76 | //Load factory calibration data |
| 77 | ADC0->CALIB.bit.BIASCOMP = (ADC0_FUSES_BIASCOMP_ADDR >> ADC0_FUSES_BIASCOMP_Pos) & ADC0_FUSES_BIASCOMP_Msk; | 77 | ADC0->CALIB.bit.BIASCOMP = ((*(uint32_t *)ADC0_FUSES_BIASCOMP_ADDR) & ADC0_FUSES_BIASCOMP_Msk) >> ADC0_FUSES_BIASCOMP_Pos; |
| 78 | ADC0->CALIB.bit.BIASR2R = (ADC0_FUSES_BIASR2R_ADDR >> ADC0_FUSES_BIASR2R_Pos) & ADC0_FUSES_BIASR2R_Msk; | 78 | ADC0->CALIB.bit.BIASR2R = ((*(uint32_t *)ADC0_FUSES_BIASR2R_ADDR) & ADC0_FUSES_BIASR2R_Msk) >> ADC0_FUSES_BIASR2R_Pos; |
| 79 | ADC0->CALIB.bit.BIASREFBUF = (ADC0_FUSES_BIASREFBUF_ADDR >> ADC0_FUSES_BIASREFBUF_Pos) & ADC0_FUSES_BIASREFBUF_Msk; | 79 | ADC0->CALIB.bit.BIASREFBUF = ((*(uint32_t *)ADC0_FUSES_BIASREFBUF_ADDR) & ADC0_FUSES_BIASREFBUF_Msk) >> ADC0_FUSES_BIASREFBUF_Pos; |
| 80 | 80 | ||
| 81 | //Enable | 81 | //Enable |
| 82 | ADC0->CTRLA.bit.ENABLE = 1; | 82 | ADC0->CTRLA.bit.ENABLE = 1; |
diff --git a/tmk_core/protocol/bluefruit/main.c b/tmk_core/protocol/bluefruit/main.c index 0dbb637e2..8a6386b4e 100644 --- a/tmk_core/protocol/bluefruit/main.c +++ b/tmk_core/protocol/bluefruit/main.c | |||
| @@ -42,13 +42,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | int main(void) | 44 | int main(void) |
| 45 | { | 45 | { |
| 46 | 46 | ||
| 47 | CPU_PRESCALE(0); | 47 | CPU_PRESCALE(0); |
| 48 | 48 | ||
| 49 | // DDRD = _BV(PD5); | 49 | // DDRD = _BV(PD5); |
| 50 | // DDRB = _BV(PB0); | 50 | // DDRB = _BV(PB0); |
| 51 | 51 | ||
| 52 | // PORTD = _BV(PD5); | 52 | // PORTD = _BV(PD5); |
| 53 | // PORTB = _BV(PB0); | 53 | // PORTB = _BV(PB0); |
| 54 | 54 | ||
| @@ -59,22 +59,23 @@ int main(void) | |||
| 59 | // while (!usb_configured()) /* wait */ | 59 | // while (!usb_configured()) /* wait */ |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | keyboard_setup(); | ||
| 62 | 63 | ||
| 63 | dprintf("Initializing keyboard...\n"); | 64 | dprintf("Initializing keyboard...\n"); |
| 64 | keyboard_init(); | 65 | keyboard_init(); |
| 65 | 66 | ||
| 66 | // This implementation is pretty simplistic... if the USB connection | 67 | // This implementation is pretty simplistic... if the USB connection |
| 67 | // is not configured, choose the Bluefruit, otherwise use USB | 68 | // is not configured, choose the Bluefruit, otherwise use USB |
| 68 | // Definitely would prefer to have this driven by an input pin and make | 69 | // Definitely would prefer to have this driven by an input pin and make |
| 69 | // it switch dynamically - BCG | 70 | // it switch dynamically - BCG |
| 70 | // if (!usb_configured()) { | 71 | // if (!usb_configured()) { |
| 71 | 72 | ||
| 72 | // // Send power to Bluefruit... Adafruit says it takes 27 mA, I think | 73 | // // Send power to Bluefruit... Adafruit says it takes 27 mA, I think |
| 73 | // // the pins should provide 40 mA, but just in case I switch the | 74 | // // the pins should provide 40 mA, but just in case I switch the |
| 74 | // // Bluefruit using a transistor - BCG | 75 | // // Bluefruit using a transistor - BCG |
| 75 | // DDRB = _BV(PB6); | 76 | // DDRB = _BV(PB6); |
| 76 | // PORTB |= _BV(PB6); | 77 | // PORTB |= _BV(PB6); |
| 77 | 78 | ||
| 78 | dprintf("Setting host driver to bluefruit...\n"); | 79 | dprintf("Setting host driver to bluefruit...\n"); |
| 79 | host_set_driver(bluefruit_driver()); | 80 | host_set_driver(bluefruit_driver()); |
| 80 | 81 | ||
| @@ -131,7 +132,7 @@ int main(void) | |||
| 131 | // usb_remote_wakeup(); | 132 | // usb_remote_wakeup(); |
| 132 | // } | 133 | // } |
| 133 | // } | 134 | // } |
| 134 | // keyboard_task(); | 135 | // keyboard_task(); |
| 135 | // } | 136 | // } |
| 136 | // } | 137 | // } |
| 137 | 138 | ||
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index 5436d4909..8de55bfe3 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/main.c | |||
| @@ -119,6 +119,8 @@ int main(void) { | |||
| 119 | // TESTING | 119 | // TESTING |
| 120 | // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); | 120 | // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); |
| 121 | 121 | ||
| 122 | keyboard_setup(); | ||
| 123 | |||
| 122 | /* Init USB */ | 124 | /* Init USB */ |
| 123 | init_usb_driver(&USB_DRIVER); | 125 | init_usb_driver(&USB_DRIVER); |
| 124 | 126 | ||
diff --git a/tmk_core/protocol/usb_hid/test/config.h b/tmk_core/protocol/usb_hid/test/config.h index c2230fb57..71a6814fd 100644 --- a/tmk_core/protocol/usb_hid/test/config.h +++ b/tmk_core/protocol/usb_hid/test/config.h | |||
| @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License | |||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #ifndef CONFIG_H | 18 | #pragma once |
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | 19 | ||
| 22 | #define VENDOR_ID 0xFEED | 20 | #define VENDOR_ID 0xFEED |
| 23 | #define PRODUCT_ID 0xCAFE | 21 | #define PRODUCT_ID 0xCAFE |
| @@ -25,16 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #define MANUFACTURER t.m.k. | 23 | #define MANUFACTURER t.m.k. |
| 26 | #define PRODUCT USB to USB keyboard converter | 24 | #define PRODUCT USB to USB keyboard converter |
| 27 | 25 | ||
| 28 | |||
| 29 | #define DESCRIPTION Product from t.m.k. keyboard firmware project | 26 | #define DESCRIPTION Product from t.m.k. keyboard firmware project |
| 30 | 27 | ||
| 31 | |||
| 32 | /* matrix size */ | 28 | /* matrix size */ |
| 33 | #define MATRIX_ROWS 32 | 29 | #define MATRIX_ROWS 32 |
| 34 | #define MATRIX_COLS 8 | 30 | #define MATRIX_COLS 8 |
| 35 | |||
| 36 | |||
| 37 | /* key combination for command */ | ||
| 38 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT))) | ||
| 39 | |||
| 40 | #endif | ||
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c index f6a0c7e9a..86c2188c8 100644 --- a/tmk_core/protocol/vusb/main.c +++ b/tmk_core/protocol/vusb/main.c | |||
| @@ -56,6 +56,7 @@ int main(void) | |||
| 56 | #ifndef NO_UART | 56 | #ifndef NO_UART |
| 57 | uart_init(UART_BAUD_RATE); | 57 | uart_init(UART_BAUD_RATE); |
| 58 | #endif | 58 | #endif |
| 59 | keyboard_setup(); | ||
| 59 | 60 | ||
| 60 | keyboard_init(); | 61 | keyboard_init(); |
| 61 | host_set_driver(vusb_driver()); | 62 | host_set_driver(vusb_driver()); |
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index 2e419dd66..c43f14292 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk | |||
| @@ -48,9 +48,6 @@ FORMAT = ihex | |||
| 48 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) | 48 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
| 49 | OPT = s | 49 | OPT = s |
| 50 | 50 | ||
| 51 | AUTOGEN ?= false | ||
| 52 | |||
| 53 | |||
| 54 | # Compiler flag to set the C Standard level. | 51 | # Compiler flag to set the C Standard level. |
| 55 | # c89 = "ANSI" C | 52 | # c89 = "ANSI" C |
| 56 | # gnu89 = c89 plus GCC extensions | 53 | # gnu89 = c89 plus GCC extensions |
| @@ -142,7 +139,7 @@ CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) | |||
| 142 | # files -- see avr-libc docs [FIXME: not yet described there] | 139 | # files -- see avr-libc docs [FIXME: not yet described there] |
| 143 | # -listing-cont-lines: Sets the maximum number of continuation lines of hex | 140 | # -listing-cont-lines: Sets the maximum number of continuation lines of hex |
| 144 | # dump that will be displayed for a given single line of source input. | 141 | # dump that will be displayed for a given single line of source input. |
| 145 | ASFLAGS += $(ADEFS) | 142 | ASFLAGS += $(ADEFS) |
| 146 | ifndef SKIP_DEBUG_INFO | 143 | ifndef SKIP_DEBUG_INFO |
| 147 | ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 | 144 | ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 |
| 148 | else | 145 | else |
| @@ -260,10 +257,6 @@ gccversion : | |||
| 260 | @$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD) | 257 | @$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD) |
| 261 | $(eval CMD=$(HEX) $< $@) | 258 | $(eval CMD=$(HEX) $< $@) |
| 262 | @$(BUILD_CMD) | 259 | @$(BUILD_CMD) |
| 263 | @if $(AUTOGEN); then \ | ||
| 264 | $(SILENT) || printf "Copying $(TARGET).hex to keymaps/$(KEYMAP)/$(TARGET).hex\n"; \ | ||
| 265 | $(COPY) $@ $(KEYMAP_PATH)/$(TARGET).hex; \ | ||
| 266 | fi | ||
| 267 | 260 | ||
| 268 | %.eep: %.elf | 261 | %.eep: %.elf |
| 269 | @$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD) | 262 | @$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD) |
| @@ -297,7 +290,7 @@ BEGIN = gccversion sizebefore | |||
| 297 | @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) | 290 | @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) |
| 298 | $(eval CMD=$(CC) $(ALL_CFLAGS) $(filter-out %.txt,$^) --output $@ $(LDFLAGS)) | 291 | $(eval CMD=$(CC) $(ALL_CFLAGS) $(filter-out %.txt,$^) --output $@ $(LDFLAGS)) |
| 299 | @$(BUILD_CMD) | 292 | @$(BUILD_CMD) |
| 300 | 293 | ||
| 301 | 294 | ||
| 302 | define GEN_OBJRULE | 295 | define GEN_OBJRULE |
| 303 | $1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC)) | 296 | $1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC)) |
| @@ -371,7 +364,7 @@ DEPS = $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ))) | |||
| 371 | .PRECIOUS: $(DEPS) | 364 | .PRECIOUS: $(DEPS) |
| 372 | # Empty rule to force recompilation if the .d file is missing | 365 | # Empty rule to force recompilation if the .d file is missing |
| 373 | $(DEPS): | 366 | $(DEPS): |
| 374 | 367 | ||
| 375 | 368 | ||
| 376 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(call GEN_OBJRULE,$(OUTPUT)))) | 369 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(call GEN_OBJRULE,$(OUTPUT)))) |
| 377 | 370 | ||
