#include "main.h" // Replace with your specific STM32 series header file
// Function prototypes
void SystemClock_Config(void);
void GPIO_Init(void);
void delay(uint32_t ms);
int main(void) {
// Initialize the HAL Library
HAL_Init();
// Configure the system clock
SystemClock_Config();
// Initialize GPIO for LED
GPIO_Init();
while (1) {
// Toggle the LED
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_13); // Replace GPIOA and GPIO_PIN_5 with your specific port/pin
delay(500); // 500ms delay
}
}
void SystemClock_Config(void) {
// Use STM32CubeMX to generate system clock configuration
// Or configure the clock manually based on your board and requirements
}
void GPIO_Init(void) {
// Enable GPIO clock
__HAL_RCC_GPIOA_CLK_ENABLE(); // Replace GPIOA with the specific port
GPIO_InitTypeDef GPIO_InitStruct = {0};
// Configure GPIO pin for the LED
GPIO_InitStruct.Pin = GPIO_PIN_13; // Replace GPIO_PIN_5 with your LED pin
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); // Replace GPIOA with your specific port
}
void delay(uint32_t ms) {
HAL_Delay(ms); // HAL_Delay provides millisecond delays
}