|
| 1 | +#if F0 |
| 2 | +#include "stm32f0xx_hal.h" |
| 3 | +#elif F1 |
| 4 | +#include "stm32f1xx_hal.h" |
| 5 | +#elif F2 |
| 6 | +#include "stm32f2xx_hal.h" |
| 7 | +#elif F3 |
| 8 | +#include "stm32f3xx_hal.h" |
| 9 | +#elif F4 |
| 10 | +#include "stm32f4xx_hal.h" |
| 11 | +#elif F7 |
| 12 | +#include "stm32f7xx_hal.h" |
| 13 | +#elif L0 |
| 14 | +#include "stm32l0xx_hal.h" |
| 15 | +#elif L1 |
| 16 | +#include "stm32l1xx_hal.h" |
| 17 | +#elif L4 |
| 18 | +#include "stm32l4xx_hal.h" |
| 19 | +#else |
| 20 | +#error "Unsupported STM32 Family" |
| 21 | +#endif |
| 22 | + |
| 23 | +#define LED_PIN GPIO_PIN_5 |
| 24 | +#define LED_GPIO_PORT GPIOA |
| 25 | +#define LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
| 26 | + |
| 27 | +int main(void) |
| 28 | +{ |
| 29 | + HAL_Init(); |
| 30 | + |
| 31 | + LED_GPIO_CLK_ENABLE(); |
| 32 | + |
| 33 | + GPIO_InitTypeDef GPIO_InitStruct; |
| 34 | + |
| 35 | + GPIO_InitStruct.Pin = LED_PIN; |
| 36 | + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| 37 | + GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 38 | + GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; |
| 39 | + HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct); |
| 40 | + |
| 41 | + while (1) |
| 42 | + { |
| 43 | + HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN); |
| 44 | + |
| 45 | + HAL_Delay(1000); |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +void SysTick_Handler(void) |
| 50 | +{ |
| 51 | + HAL_IncTick(); |
| 52 | +} |
| 53 | + |
| 54 | +void NMI_Handler(void) |
| 55 | +{ |
| 56 | +} |
| 57 | + |
| 58 | +void HardFault_Handler(void) |
| 59 | +{ |
| 60 | + while (1) {} |
| 61 | +} |
| 62 | + |
| 63 | + |
| 64 | +void MemManage_Handler(void) |
| 65 | +{ |
| 66 | + while (1) {} |
| 67 | +} |
| 68 | + |
| 69 | +void BusFault_Handler(void) |
| 70 | +{ |
| 71 | + while (1) {} |
| 72 | +} |
| 73 | + |
| 74 | +void UsageFault_Handler(void) |
| 75 | +{ |
| 76 | + while (1) {} |
| 77 | +} |
| 78 | + |
| 79 | +void SVC_Handler(void) |
| 80 | +{ |
| 81 | +} |
| 82 | + |
| 83 | + |
| 84 | +void DebugMon_Handler(void) |
| 85 | +{ |
| 86 | +} |
| 87 | + |
| 88 | +void PendSV_Handler(void) |
| 89 | +{ |
| 90 | +} |
0 commit comments