blob: 8fde39a3299e1e4b588e91c772d782367ee8f9ca (
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
|
#ifndef USART_H
#define USART_H
template<>
void interrupt<Interrupt::USART1>() {
USART1.DR;
//GPIOB.ODR ^= 1 << 1;
}
void usart_enable() {
RCC.enable(RCC.USART1);
USART1.BRR = 625; // 115200 baud
USART1.CR1 = 0x202c;
Interrupt::enable(Interrupt::USART1);
}
void usart_send(uint8_t data) {
while(!(USART1.SR & 0x80)) {
Thread::yield();
} // Wait for TXE.
USART1.DR = data;
}
#endif
|