Advertisement
Guest User

Untitled

a guest
Mar 20th, 2024
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. mkdir STM32_example_blink
  2. cd STM32_example_blink
  3.  
  4. git -c http.sslVerify=false clone --recurse-submodules https://github.com/STMicroelectronics/STM32CubeF1
  5.  
  6. cat <<EOF >> blink.c #include "stm32f1xx.h"
  7. #include "stm32f1xx_ll_bus.h"
  8. #include "stm32f1xx_ll_gpio.h"
  9.  
  10. void GPIO_config(void) {
  11. LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
  12.  
  13. LL_GPIO_SetPinMode(GPIOC, LL_GPIO_PIN_13, LL_GPIO_MODE_OUTPUT);
  14. LL_GPIO_SetPinOutputType(GPIOC, LL_GPIO_PIN_13, LL_GPIO_OUTPUT_PUSHPULL);
  15. LL_GPIO_SetPinSpeed(GPIOC, LL_GPIO_PIN_13, LL_GPIO_SPEED_FREQ_LOW);
  16. }
  17.  
  18. int main(void) {
  19. GPIO_config();
  20.  
  21. for (;;) {
  22. LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_13);
  23. for (volatile int i = 0; i < 100000; i++);
  24. LL_GPIO_SetOutputPin(GPIOC, LL_GPIO_PIN_13);
  25. for (volatile int i = 0; i < 100000; i++);
  26. }
  27.  
  28. }
  29. EOF
  30.  
  31.  
  32. arm-none-eabi-gcc -DSTM32F103xB -I./STM32CubeF1/Drivers/CMSIS/Device/ST/STM32F1xx/Include -I./STM32CubeF1/Drivers/CMSIS/Include -I./STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Inc -mcpu=cortex-m3 -mthumb -std=c99 -ffunction-sections -fdata-sections -c blink.c
  33.  
  34. arm-none-eabi-gcc -DSTM32F103xB -I./STM32CubeF1/Drivers/CMSIS/Device/ST/STM32F1xx/Include -I./STM32CubeF1/Drivers/CMSIS/Include -I./STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Inc -mcpu=cortex-m3 -mthumb -std=c99 -ffunction-sections -fdata-sections -c ./STM32CubeF1/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c
  35.  
  36. arm-none-eabi-gcc -x assembler-with-cpp -mthumb -c ./STM32CubeF1/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s
  37.  
  38. arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -std=c99 -ffunction-sections -fdata-sections -pipe --specs=nosys.specs -Wl,--gc-sections -ffreestanding "-T./STM32CubeF1/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XB_FLASH.ld" blink.o startup_stm32f103xb.o system_stm32f1xx.o -o blink.elf
  39.  
  40. arm-none-eabi-objcopy -Oihex blink.elf blink.hex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement