From 1a467fcad1336db77688f01799499353deb663f4 Mon Sep 17 00:00:00 2001 From: Michael Schloh von Bennewitz Date: Thu, 3 Sep 2020 23:43:38 +0200 Subject: [PATCH] Include GPIO blink source file for boilerplate and correct project. --- firmware/platformio.ini | 1 + firmware/src/main.c | 88 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 firmware/src/main.c diff --git a/firmware/platformio.ini b/firmware/platformio.ini index deba21b..f2ad9f4 100644 --- a/firmware/platformio.ini +++ b/firmware/platformio.ini @@ -12,3 +12,4 @@ platform = ststm32 board = genericSTM32F405RG framework = stm32cube +build_flags = -DF4 \ No newline at end of file diff --git a/firmware/src/main.c b/firmware/src/main.c new file mode 100644 index 0000000..120318b --- /dev/null +++ b/firmware/src/main.c @@ -0,0 +1,88 @@ +#if F0 +#include "stm32f0xx_hal.h" +#elif F1 +#include "stm32f1xx_hal.h" +#elif F2 +#include "stm32f2xx_hal.h" +#elif F3 +#include "stm32f3xx_hal.h" +#elif F4 +#include "stm32f4xx_hal.h" +#elif F7 +#include "stm32f7xx_hal.h" +#elif L0 +#include "stm32l0xx_hal.h" +#elif L1 +#include "stm32l1xx_hal.h" +#elif L4 +#include "stm32l4xx_hal.h" +#else +#error "Unsupported STM32 Family" +#endif + +#define LED_PIN GPIO_PIN_5 +#define LED_GPIO_PORT GPIOA +#define LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() + +int main(void) +{ + HAL_Init(); + + LED_GPIO_CLK_ENABLE(); + + GPIO_InitTypeDef GPIO_InitStruct; + + GPIO_InitStruct.Pin = LED_PIN; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct); + + while (1) + { + HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN); + + HAL_Delay(1000); + } +} + +void SysTick_Handler(void) +{ + HAL_IncTick(); +} + +void NMI_Handler(void) +{ +} + +void HardFault_Handler(void) +{ + while (1) {} +} + +void MemManage_Handler(void) +{ + while (1) {} +} + +void BusFault_Handler(void) +{ + while (1) {} +} + +void UsageFault_Handler(void) +{ + while (1) {} +} + +void SVC_Handler(void) +{ +} + +void DebugMon_Handler(void) +{ +} + +void PendSV_Handler(void) +{ +} \ No newline at end of file