From 9d9f9dc034765aa4b1c5bd2d0aa4cd24e4110055 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 25 Sep 2022 15:21:12 +0200 Subject: c++ to c for stm32 firmware --- stm32f091/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 stm32f091/main.c (limited to 'stm32f091/main.c') diff --git a/stm32f091/main.c b/stm32f091/main.c new file mode 100644 index 0000000..180240e --- /dev/null +++ b/stm32f091/main.c @@ -0,0 +1,21 @@ +#include +#include + +#define PORT GPIOA +#define PIN 5 + +int main() { + RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN; + + PORT->MODER &= ~(0b11 << (PIN * 2)); + PORT->MODER |= (0b01 << (PIN * 2)); + + uint8_t led = 1; + + while (1) { + PORT->ODR &= ~(1 << PIN); + PORT->ODR |= (led << PIN); + led ^= 1; + for (unsigned long i = 0; i < 50000; i++) asm("nop"); + } +} -- cgit v1.2.3