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.pull/1/head
parent
d9e69681f5
commit
7856a416bd
|
@ -413,7 +413,7 @@ STATIC uint update_reset_mode(uint reset_mode) {
|
||||||
return reset_mode;
|
return reset_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
void stm32_main(uint32_t reset_mode) {
|
||||||
// TODO disable JTAG
|
// TODO disable JTAG
|
||||||
|
|
||||||
/* STM32F4xx HAL library initialization:
|
/* STM32F4xx HAL library initialization:
|
||||||
|
@ -488,7 +488,7 @@ soft_reset:
|
||||||
#endif
|
#endif
|
||||||
led_state(3, 0);
|
led_state(3, 0);
|
||||||
led_state(4, 0);
|
led_state(4, 0);
|
||||||
uint reset_mode = update_reset_mode(1);
|
reset_mode = update_reset_mode(1);
|
||||||
|
|
||||||
// Python threading init
|
// Python threading init
|
||||||
#if MICROPY_PY_THREAD
|
#if MICROPY_PY_THREAD
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
.type Reset_Handler, %function
|
.type Reset_Handler, %function
|
||||||
|
|
||||||
Reset_Handler:
|
Reset_Handler:
|
||||||
|
/* Save the first argument to pass through to stm32_main */
|
||||||
|
mov r4, r0
|
||||||
|
|
||||||
/* Load the stack pointer */
|
/* Load the stack pointer */
|
||||||
ldr sp, =_estack
|
ldr sp, =_estack
|
||||||
|
|
||||||
|
@ -61,6 +64,7 @@ Reset_Handler:
|
||||||
|
|
||||||
/* Initialise the system and jump to the main code */
|
/* Initialise the system and jump to the main code */
|
||||||
bl SystemInit
|
bl SystemInit
|
||||||
b main
|
mov r0, r4
|
||||||
|
b stm32_main
|
||||||
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
.size Reset_Handler, .-Reset_Handler
|
||||||
|
|
Loading…
Reference in New Issue