aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
Diffstat (limited to 'demos')
-rw-r--r--demos/ARMCM3-STM32F103-GCC/board.c20
-rw-r--r--demos/ARMCM3-STM32F103-GCC/main.c9
2 files changed, 19 insertions, 10 deletions
diff --git a/demos/ARMCM3-STM32F103-GCC/board.c b/demos/ARMCM3-STM32F103-GCC/board.c
index f10269aa6..7bfa42133 100644
--- a/demos/ARMCM3-STM32F103-GCC/board.c
+++ b/demos/ARMCM3-STM32F103-GCC/board.c
@@ -24,10 +24,11 @@
#include "stm32_serial.h"
/*
- * Hardware initialization goes here.
- * NOTE: Interrupts are still disabled.
+ * Early initialization code.
+ * This initialization is performed just after reset before BSS and DATA
+ * segments initialization.
*/
-void hwinit(void) {
+void hwinit0(void) {
/*
* Clocks and PLL initialization.
@@ -76,6 +77,14 @@ void hwinit(void) {
GPIOD->CRL = VAL_GPIODCRL;
GPIOD->CRH = VAL_GPIODCRH;
GPIOD->ODR = VAL_GPIODODR;
+}
+
+/*
+ * Late initialization code.
+ * This initialization is performed after BSS and DATA segments initialization
+ * and before invoking the main() function.
+ */
+void hwinit1(void) {
/*
* NVIC/SCB initialization.
@@ -95,4 +104,9 @@ void hwinit(void) {
* Other subsystems initialization.
*/
InitSerial(0x80, 0x80, 0x80);
+
+ /*
+ * ChibiOS/RT initialization.
+ */
+ chSysInit();
}
diff --git a/demos/ARMCM3-STM32F103-GCC/main.c b/demos/ARMCM3-STM32F103-GCC/main.c
index 59e7b792a..0df4bc03d 100644
--- a/demos/ARMCM3-STM32F103-GCC/main.c
+++ b/demos/ARMCM3-STM32F103-GCC/main.c
@@ -39,17 +39,12 @@ static msg_t Thread1(void *arg) {
}
/*
- * Entry point, the interrupts are disabled on entry.
+ * Entry point, note, the main() function is already a thread in the system
+ * on entry.
*/
int main(int argc, char **argv) {
/*
- * The main() function becomes a thread here then the interrupts are
- * enabled and ChibiOS/RT goes live.
- */
- chSysInit();
-
- /*
* Creates the blinker thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);