blob: 484d89e8de7a5069463d417d4696c55075c0b0a2 (
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
#include "stm32.h"
#include "interrupt.h"
#include "thread.h"
inline void usart_enable() {
RCC.enable(RCC.USART1);
USART1.BRR = 625; // 115200 baud
USART1.CR1 = 0x202c;
Interrupt::enable(Interrupt::USART1);
}
inline void usart_send(uint8_t data) {
while(!(USART1.SR & 0x80)) {
Thread::yield();
} // Wait for TXE.
USART1.DR = data;
}
#endif
|