This commit is contained in:
Alexander Heldt
2024-08-12 21:54:29 +02:00
parent 2fc8ee4f92
commit 6caccce751
11 changed files with 780 additions and 529 deletions

View File

@@ -2201,6 +2201,15 @@ struct usart {
#define USART_SR_TXE_BIT 7
#define USART_SR_TXE_TRANSMITTED (1 << USART_SR_TXE_BIT)
#define USART_SR_RXNE_BIT 5
#define USART_SR_RXNE_READY (1 <<USART_SR_RXNE_BIT)
#define USART_CR1_OVER8_BIT 15
#define USART_CR1_OVER8_8 (1 << USART_CR1_OVER8_BIT)
@@ -2225,6 +2234,8 @@ struct usart {
void usart2_init(void);
void usart2_start(void);
void usart2_write_byte(char byte);
# 4 "src/usart.c" 2
void usart2_init(void) {
@@ -2254,9 +2265,9 @@ void usart2_init(void) {
((struct usart *) (0x40004400U))->CR1 |= (1 << 15);
((struct usart *) (0x40004400U))->BRR &= ~((0b111111111111) << 4);
((struct usart *) (0x40004400U))->BRR |= (52 << 4);
((struct usart *) (0x40004400U))->BRR |= (0x34 << 4);
((struct usart *) (0x40004400U))->BRR &= ~((0b111) << 0);
((struct usart *) (0x40004400U))->BRR |= (0 << 0);
((struct usart *) (0x40004400U))->BRR |= (0x0 << 0);
((struct usart *) (0x40004400U))->CR1 |= (1 << 3);
@@ -2266,3 +2277,11 @@ void usart2_init(void) {
void usart2_start(void) {
((struct usart *) (0x40004400U))->CR1 |= (1 << 13);
}
void usart2_write_byte(char c) {
((struct usart *) (0x40004400U))->DR = c;
while ((((struct usart *) (0x40004400U))->SR & (1 << 7)) == 0);
}