summaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/chibios/init_hooks.h5
-rw-r--r--tmk_core/protocol/chibios/main.c38
2 files changed, 43 insertions, 0 deletions
diff --git a/tmk_core/protocol/chibios/init_hooks.h b/tmk_core/protocol/chibios/init_hooks.h
new file mode 100644
index 0000000000..fffced913a
--- /dev/null
+++ b/tmk_core/protocol/chibios/init_hooks.h
@@ -0,0 +1,5 @@
+#pragma once
+
+// Override the initialisation functions inside the ChibiOS board.c files
+#define __early_init __chibios_override___early_init
+#define boardInit __chibios_override_boardInit
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c
index f9a6aa45eb..f109efb798 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/main.c
@@ -33,6 +33,11 @@
#include "debug.h"
#include "printf.h"
+#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
+// Change this to be TRUE once we've migrated keyboards to the new init system
+# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP FALSE
+#endif
+
#ifdef SLEEP_LED_ENABLE
# include "sleep_led.h"
#endif
@@ -105,6 +110,39 @@ void webusb_task(void);
// }
// }
+/* Early initialisation
+ */
+__attribute__((weak)) void early_hardware_init_pre(void) {
+#if EARLY_INIT_PERFORM_BOOTLOADER_JUMP
+ void enter_bootloader_mode_if_requested(void);
+ enter_bootloader_mode_if_requested();
+#endif // EARLY_INIT_PERFORM_BOOTLOADER_JUMP
+}
+
+__attribute__((weak)) void early_hardware_init_post(void) {}
+
+__attribute__((weak)) void board_init(void) {}
+
+// This overrides what's normally in ChibiOS board definitions
+void __early_init(void) {
+ early_hardware_init_pre();
+
+ // This is the renamed equivalent of __early_init in the board.c file
+ void __chibios_override___early_init(void);
+ __chibios_override___early_init();
+
+ early_hardware_init_post();
+}
+
+// This overrides what's normally in ChibiOS board definitions
+void boardInit(void) {
+ // This is the renamed equivalent of boardInit in the board.c file
+ void __chibios_override_boardInit(void);
+ __chibios_override_boardInit();
+
+ board_init();
+}
+
/* Main thread
*/
int main(void) {