summaryrefslogtreecommitdiff
path: root/main.cpp
blob: 807c0b0ec5e30d9ebb40685cc82b3bea57d68002 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "stm32.h"
#include "rcc.h"
#include "interrupt.h"
#include "thread.h"
#include "time.h"

#include "pin.h"

#include "usb.h"

static Pin& led_green = PD12;
static Pin& led_yellow = PD13;
static Pin& led_red = PD14;
static Pin& led_blue = PD15;

int main() {
	// Initialize system timer.
	STK.LOAD = 168000000 / 8 / 1000; // 1000 Hz.
	STK.CTRL = 0x03;
	
	RCC.enable(RCC.GPIOA);
	RCC.enable(RCC.GPIOB);
	RCC.enable(RCC.GPIOD);
	
	led_green.set_mode(Pin::Output);
	led_yellow.set_mode(Pin::Output);
	led_red.set_mode(Pin::Output);
	led_blue.set_mode(Pin::Output);
	
	RCC.enable(RCC.OTGFS);
	
	while(1) {
		led_green.on();
		Time::sleep(100);
		led_green.off();
		
		led_yellow.on();
		Time::sleep(100);
		led_yellow.off();
		
		led_red.on();
		Time::sleep(100);
		led_red.off();
		
		led_blue.on();
		Time::sleep(100);
		led_blue.off();
	}
}