summaryrefslogtreecommitdiff
path: root/include/uart.h
blob: 7b414ca111a57935e27c2106dccd7b830a1144a7 (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
#pragma once

#include <stdbool.h>
#include <stdint.h>

#define UART_BASE 0x10000
#define UART_REG(offset) *(volatile uint32_t *)(UART_BASE + offset)
#define UART_TXDATA UART_REG(0x00)
#define UART_RXDATA UART_REG(0x04)
#define UART_TXCTRL UART_REG(0x08)
#define UART_RXCTRL UART_REG(0x0c)
#define UART_IE UART_REG(0x10)
#define UART_IP UART_REG(0x14)
#define UART_DIV UART_REG(0x18)

#define UART_TXDATA_FULL 0x80000000
#define UART_RXDATA_EMPTY 0x80000000

#define UART_TXCTRL_TXEN 1
#define UART_RXCTRL_RXEN 1

void uart_init(void);

bool uart_tx_ready(void);

void uart_putc(char c);
void uart_puts(const char *s);

char uart_getc(void);