From b7affa79a14cc90a38b3e48c9393cd87710512b9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 4 Oct 2008 09:59:39 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@455 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-AT91SAM7X-GCC/board.c | 22 ++++++++++++++++++---- demos/ARM7-AT91SAM7X-GCC/main.c | 14 ++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/demos/ARM7-AT91SAM7X-GCC/board.c b/demos/ARM7-AT91SAM7X-GCC/board.c index 4bc78f086..8a4b7c4ea 100644 --- a/demos/ARM7-AT91SAM7X-GCC/board.c +++ b/demos/ARM7-AT91SAM7X-GCC/board.c @@ -54,11 +54,11 @@ static void SYSIrqHandler(void) { } /* - * Board initialization code. + * Early initialization code. + * This initialization is performed just after reset before BSS and DATA + * segments initialization. */ -void hwinit(void) { - int i; - +void hwinit0(void) { /* * Flash Memory: 1 wait state, about 50 cycles in a microsecond. */ @@ -99,6 +99,15 @@ void hwinit(void) { AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_PIOA) | (1 << AT91C_ID_PIOB); AT91C_BASE_PIOA->PIO_PER = 0xFFFFFFFF; AT91C_BASE_PIOB->PIO_PER = 0xFFFFFFFF; +} + +/* + * Late initialization code. + * This initialization is performed after BSS and DATA segments initialization + * and before invoking the main() function. + */ +void hwinit1(void) { + int i; /* * Default AIC setup, the device drivers will modify it as needed. @@ -150,4 +159,9 @@ void hwinit(void) { AT91C_BASE_PIOA->PIO_PDR = AT91C_PA3_RTS0 | AT91C_PA4_CTS0; AT91C_BASE_PIOA->PIO_ASR = AT91C_PIO_PA3 | AT91C_PIO_PA4; AT91C_BASE_PIOA->PIO_PPUDR = AT91C_PIO_PA3 | AT91C_PIO_PA4; + + /* + * ChibiOS/RT initialization. + */ + chSysInit(); } diff --git a/demos/ARM7-AT91SAM7X-GCC/main.c b/demos/ARM7-AT91SAM7X-GCC/main.c index abd84bd87..c280e5489 100644 --- a/demos/ARM7-AT91SAM7X-GCC/main.c +++ b/demos/ARM7-AT91SAM7X-GCC/main.c @@ -36,18 +36,20 @@ 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); + /* + * Normal main() thread activity. + */ while (TRUE) { chThdSleep(500); if (!(AT91C_BASE_PIOB->PIO_PDSR & PIOB_SW1))