From cfb02cebff0e9c85de18cd29d75525ece82586dd Mon Sep 17 00:00:00 2001 From: Andreas Ortner Date: Tue, 16 Jun 2020 06:59:45 +0200 Subject: [PATCH] make and main.c changes to support STM32F446RE Nucelo board * Just added STM32F446RE to the make file as DEVICE. Note that this change should not really be pulled into master, I just wanted to commit a working and consistent version into the branches. * the main simply checks the define for the Nucleo board and adapts the LED port and pin accordingly * Note that the compiled binary was tested with the Nucleo STM32F446RE board --- Makefile | 2 +- src/main.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 343e0fe..568f136 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -DEVICE = STM32F407xE +DEVICE = STM32F446RE FLASH = 0x08000000 USE_ST_CMSIS = true diff --git a/src/main.c b/src/main.c index 1e1228f..92ebd1a 100644 --- a/src/main.c +++ b/src/main.c @@ -7,8 +7,12 @@ static void delay (unsigned int time) { } int main (void) { - // Turn on the GPIOC peripheral + // Turn on the GPIOx peripheral +#if defined(STM32F446xx) + RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; +#else RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; +#endif // Put pin 13 in general purpose output mode // Note: The only difference here is the name of the register in the @@ -16,6 +20,8 @@ int main (void) { #if defined(STM32F413xx) || \ defined(STM32F423xx) GPIOC->MODER |= GPIO_MODER_MODE13_0; +#elif defined(STM32F446xx) + GPIOA->MODER |= GPIO_MODER_MODE5_0; #else GPIOC->MODER |= GPIO_MODER_MODER13_0; #endif @@ -25,6 +31,8 @@ int main (void) { #if defined(STM32F413xx) || \ defined(STM32F423xx) GPIOC->BSRR = GPIO_BSRR_BR_13; +#elif defined(STM32F446xx) + GPIOA->BSRR = GPIO_BSRR_BR_5; #else GPIOC->BSRR = GPIO_BSRR_BR13; #endif @@ -35,6 +43,8 @@ int main (void) { #if defined(STM32F413xx) || \ defined(STM32F423xx) GPIOC->BSRR = GPIO_BSRR_BS_13; +#elif defined(STM32F446xx) + GPIOA->BSRR = GPIO_BSRR_BS_5; #else GPIOC->BSRR = GPIO_BSRR_BS13; #endif @@ -45,3 +55,4 @@ int main (void) { // Return 0 to satisfy compiler return 0; } +