Add support for hardware and board initialisation overrides. (#8330)
* Add support for hardware and board initialisation overrides. * qmk cformat. * Add some documentation. * Docs clarity. * Make early_hardware_init_pre a no-op for now, until migrations occur. * Doco update * Make distinction between keyboard and ChibiOS board in docs * Doc anchors. * Update tmk_core/protocol/chibios/main.c Co-Authored-By: Joel Challis <git@zvecr.com> * Rework bootloader entry to be off by default, allow opting-in. Co-authored-by: Joel Challis <git@zvecr.com>
This commit is contained in:
parent
17bda000f3
commit
05e9ff6554
5 changed files with 111 additions and 5 deletions
|
@ -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
|
||||
|
@ -101,6 +106,39 @@ void midi_ep_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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue