aboutsummaryrefslogtreecommitdiffstats
path: root/example/main.cpp
blob: 9fc545e3f79770a89bb9cf6c30f587468172222f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "stm32u083.hpp"

int main()
{
    using namespace STM32U083;
    using LD3 = GPIOC::ODR::OD13;
    using LD4 = GPIOA::ODR::OD5;
    using LD5 = GPIOB::ODR::OD2;

    RCC::ALL::set<
        RCC::IOPENR::GPIOAEN,
        RCC::IOPENR::GPIOBEN,
        RCC::IOPENR::GPIOCEN,
        RCC::APBENR1::USART2EN>();

    GPIOC::MODER::MODE13::write<1>();
    GPIOA::MODER::MODE5::write<1>();
    GPIOB::MODER::MODE2::write<1>();

    unsigned i = 0;
    while (1) {
        if (i & 1) LD3::set(); else LD3::clear();
        if (i & 2) LD4::set(); else LD4::clear();
        if (i & 4) LD5::set(); else LD5::clear();

        for (int j = 0; j < 100000; j++)
            asm("nop");

        i++;
    }
}