libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
uart.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Adrian "asie" Siekierka
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 *
17 * 2. Altered source versions must be plainly marked as such, and must not be
18 * misrepresented as being the original software.
19 *
20 * 3. This notice may not be removed or altered from any source distribution.
21 */
22
26
27#ifndef LIBWS_UART_H_
28#define LIBWS_UART_H_
29
30#include <stdbool.h>
31#include <stdint.h>
32#include "ports.h"
33#include "util.h"
34
39
47
55static inline void ws_uart_open(uint8_t baud_rate) {
57}
58
62static inline void ws_uart_close(void) {
63 outportb(WS_UART_CTRL_PORT, 0x00);
64}
65
69static inline bool ws_uart_is_rx_overrun(void) {
71}
72
79static inline void ws_uart_ack_rx_overrun(void) {
81}
82
88static inline bool ws_uart_is_rx_ready(void) {
90}
91
97static inline bool ws_uart_is_tx_ready(void) {
99}
100
108uint8_t ws_uart_getc(void);
109
117
125void ws_uart_putc(uint8_t value);
126
128
129#endif /* LIBWS_UART_H_ */
#define WS_UART_CTRL_ENABLE
Definition ports.h:1129
#define WS_UART_CTRL_RX_OVERRUN
Definition ports.h:1151
#define WS_UART_CTRL_BAUD_9600
Definition ports.h:1133
#define WS_UART_CTRL_RX_READY
Definition ports.h:1155
#define WS_UART_CTRL_BAUD_38400
Definition ports.h:1137
#define WS_UART_CTRL_TX_READY
Definition ports.h:1147
#define WS_UART_CTRL_RX_OVERRUN_RESET
Definition ports.h:1143
#define WS_UART_CTRL_PORT
Definition ports.h:1125
uint8_t ws_uart_getc(void)
Read a character from the UART.
ws_uart_baud_rate_t
UART baud rate.
Definition uart.h:43
void ws_uart_putc(uint8_t value)
Write a character to the UART.
static void ws_uart_close(void)
Close the UART (EXT port) connection.
Definition uart.h:62
static void ws_uart_open(uint8_t baud_rate)
Open the UART (EXT port) connection.
Definition uart.h:55
static bool ws_uart_is_tx_ready(void)
Is the UART transmit buffer ready to accept a byte?
Definition uart.h:97
static void ws_uart_ack_rx_overrun(void)
Acknowledge that the UART receive buffer has overflowed.
Definition uart.h:79
static bool ws_uart_is_rx_overrun(void)
Check if the UART receive buffer has overflowed.
Definition uart.h:69
int16_t ws_uart_getc_nonblock(void)
Try to read a character from the UART.
static bool ws_uart_is_rx_ready(void)
Does the UART receive buffer contain a byte?
Definition uart.h:88
@ WS_UART_BAUD_RATE_38400
UART baud rate: 38400 baud (3840 bytes/second).
Definition uart.h:45
@ WS_UART_BAUD_RATE_9600
UART baud rate: 9600 baud (960 bytes/second).
Definition uart.h:44