aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: 8a393128c4c1b1cd3c97ad2f4ecb37f22621d425 (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
#include "STM32F0xx.h"

// Quick and dirty delay
static void delay (unsigned int time) {
    for (unsigned int i = 0; i < time; i++)
        for (volatile unsigned int j = 0; j < 2000; j++);
}

int main (void) {
    // Turn on the GPIOC peripheral
    RCC->AHBENR |= RCC_AHBENR_GPIOCEN;

    // Put pin 13 in general purpose output mode
    GPIOC->MODER |= GPIO_MODER_MODER13_0;

    while (1) {
        // Reset the state of pin 13 to output low
        GPIOC->BSRR = GPIO_BSRR_BR_13;

        delay(500);

        // Set the state of pin 13 to output high
        GPIOC->BSRR = GPIO_BSRR_BS_13;

        delay(500);
    }
}