GPIO_InitTypeDef GPIO_InitStruct = 0; GPIO_InitStruct.Pin = GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
CC = arm-none-eabi-gcc CFLAGS = -mcpu=cortex-m3 -mthumb -Os -ffunction-sections -fdata-sections LDFLAGS = -Wl,--gc-sections -T STM32F103C8Tx_FLASH.ld SRCS = main.c system_stm32f1xx.c OBJS = $(SRCS:.c=.o) all: firmware.elf firmware.elf: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ flash: firmware.elf openocd -f interface/stlink.cfg -f target/stm32f1x.cfg -c "program $< verify reset exit" Paper completed – suitable for undergraduate embedded systems coursework or professional reference. program stm32
HAL_Init(); SystemClock_Config(); // generated by CubeMX __HAL_RCC_GPIOC_CLK_ENABLE(); GPIO_InitTypeDef GPIO_InitStruct = 0; GPIO_InitStruct
if(GPIO_Pin == GPIO_PIN_0) // button pressed GPIO_InitTypeDef GPIO_InitStruct = 0
| Method | Cycles per toggle | Code size (bytes) | |----------------------|------------------|--------------------| | HAL_TogglePin | 36 | 52 | | LL_GPIO_TogglePin | 8 | 12 | | Direct register (BSRR)| 4 | 8 |
while (1)