From 7f00bcccfaff32a40349b4782f48a5b2a5bdddf9 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Sun, 3 May 2015 23:19:14 +0200 Subject: [PATCH] Fixes --- boot/crt0.c | 46 ++++++++++++++++++++++++++++++++++----- external/FreeRTOSConfig.h | 12 +++++----- external/NEWLIB.txt | 2 ++ src/freertos_blinky.c | 42 +++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 external/NEWLIB.txt create mode 100644 src/freertos_blinky.c diff --git a/boot/crt0.c b/boot/crt0.c index 7dfbd0250..797cee228 100644 --- a/boot/crt0.c +++ b/boot/crt0.c @@ -10,7 +10,14 @@ extern const void * _bss_section_end_ram; extern const void * _stack_start; extern const void * _stack_end; -void _start(void); +void _ResetServiceRoutine(void); +void _NMIServiceRoutine(void); +void _HardFaultServiceRoutine(void); +void _MemManageServiceRoutine(void); +void _BusFaultServiceRoutine(void); +void _SVCallServiceRoutine(void); +void _PendSVServiceRoutine(void); +void _SystickServiceRoutine(void); /* Interrupt Service Routines are void->void functions */ typedef void(*ISR)(void); @@ -27,15 +34,24 @@ ISR InitialisationVector[INITIALISATION_VECTOR_SIZE] __attribute__((section(".isr_vector_table"))) = { (ISR)&_stack_start, - _start, - 0, - 0, + _ResetServiceRoutine, + _NMIServiceRoutine, + _HardFaultServiceRoutine, + _MemManageServiceRoutine, + _BusFaultServiceRoutine, + 0, // UsageFault + 0, // Reserved + _SVCallServiceRoutine, + 0, // Debug Monitor + _PendSVServiceRoutine, // PendSV + _SystickServiceRoutine, // Systick 0 }; + int main(int argc, char * argv[]); -void _start(void) { +void _ResetServiceRoutine(void) { // This is where execution starts after reset. // Many things are not initialized yet so the code here has to pay attention. @@ -54,3 +70,23 @@ void _start(void) { main(0, 0x0); } + +void _NMIServiceRoutine(void) { + while (1) { + } +} + +void _HardFaultServiceRoutine(void) { + while (1) { + } +} + +void _MemManageServiceRoutine(void) { + while (1) { + } +} + +void _BusFaultServiceRoutine(void) { + while (1) { + } +} diff --git a/external/FreeRTOSConfig.h b/external/FreeRTOSConfig.h index e15ab575a..e856c2bda 100755 --- a/external/FreeRTOSConfig.h +++ b/external/FreeRTOSConfig.h @@ -158,13 +158,15 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ /* Normal assert() semantics without relying on the provision of an assert.h header file. */ -#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); } - +//#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ ) +#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); } + + /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS standard names. */ -//#define vPortSVCHandler SVC_Handler -//#define xPortPendSVHandler PendSV_Handler -//#define xPortSysTickHandler SysTick_Handler +#define vPortSVCHandler _SVCallServiceRoutine +#define xPortPendSVHandler _PendSVServiceRoutine +#define xPortSysTickHandler _SystickServiceRoutine #endif /* FREERTOS_CONFIG_H */ diff --git a/external/NEWLIB.txt b/external/NEWLIB.txt new file mode 100644 index 000000000..f61308d58 --- /dev/null +++ b/external/NEWLIB.txt @@ -0,0 +1,2 @@ +- Using memcpy and memset +- using , , and diff --git a/src/freertos_blinky.c b/src/freertos_blinky.c new file mode 100644 index 000000000..4f62af1d9 --- /dev/null +++ b/src/freertos_blinky.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include + +int main(int argc, char * argv[]) { + + vTaskStartScheduler(); + + // We want to blink LEDs connected to GPIO pin G13 and G14 + // (this is documented in our board's PDF) + // + // GPIO are grouped by letter, and GPIO "G" live on the "AHB1" bus + // (this is documented in the STM32F4 reference mnual, page 65) + + // Step 1 : Enable clock in RCC_AHBxENR + RCC_AHB1ENR->GPIOGEN = 1; + + + // Step 2 : Configure the GPIO pin to "general purpose output + GPIO_MODER(GPIOG)->MODER13 = GPIO_MODE_OUTPUT; + GPIO_MODER(GPIOG)->MODER14 = GPIO_MODE_OUTPUT; + + // Per doc, the output is push-pull by default (yay) + // And we should also set the output speed, but really + // we don't care (we're doing something super slow) + + long delay = 50000; + + while (1) { + GPIO_ODR(GPIOG)->ODR13 = 0; + GPIO_ODR(GPIOG)->ODR14 = 1; + +// sleep(delay); + + GPIO_ODR(GPIOG)->ODR13 = 1; + GPIO_ODR(GPIOG)->ODR14 = 0; + +// sleep(delay); + } +}