stm32/main: Rename main to stm32_main and pass through first argument.

The main() function has a predefined type in C which is not so useful for
embedded contexts.  This patch renames main() to stm32_main() so we can
define our own type signature for this function.  The type signature is
defined to have a single argument which is the "reset_mode" and is passed
through as r0 from Reset_Handler.  This allows, for example, a bootloader
to pass through information into the main application.
This commit is contained in:
Damien George 2018-03-29 16:15:57 +11:00
parent d9e69681f5
commit 7856a416bd
2 changed files with 7 additions and 3 deletions

View File

@ -413,7 +413,7 @@ STATIC uint update_reset_mode(uint reset_mode) {
return reset_mode;
}
int main(void) {
void stm32_main(uint32_t reset_mode) {
// TODO disable JTAG
/* STM32F4xx HAL library initialization:
@ -488,7 +488,7 @@ soft_reset:
#endif
led_state(3, 0);
led_state(4, 0);
uint reset_mode = update_reset_mode(1);
reset_mode = update_reset_mode(1);
// Python threading init
#if MICROPY_PY_THREAD

View File

@ -33,6 +33,9 @@
.type Reset_Handler, %function
Reset_Handler:
/* Save the first argument to pass through to stm32_main */
mov r4, r0
/* Load the stack pointer */
ldr sp, =_estack
@ -61,6 +64,7 @@ Reset_Handler:
/* Initialise the system and jump to the main code */
bl SystemInit
b main
mov r0, r4
b stm32_main
.size Reset_Handler, .-Reset_Handler