blob: 6c145c61787a0703e7c7b9d52ec16d657cbae669 (
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
|
#ifndef USART_H
#define USART_H
template<>
void interrupt<Interrupt::USART1>() {
USART1.DR;
GPIOA.ODR ^= 1 << 5;
}
void usart_enable() {
RCC.enable(RCC.USART1);
USART1.BRR = 7500; // 9600 baud
USART1.CR1 = 0x202c;
Interrupt::enable(Interrupt::USART1);
}
void usart_send(uint8_t data) {
while(!(USART1.SR & 0x80)); // Wait for TXE.
USART1.DR = data;
}
#endif
|