libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
serial.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
27#ifndef __WF_LIBWS_SERIAL_H__
28#define __WF_LIBWS_SERIAL_H__
29
30#include <stdbool.h>
31#include <stdint.h>
32#include "hardware.h"
33#include "util.h"
34
40static inline void ws_serial_open(uint8_t baud_rate) {
42}
43
44static inline void ws_serial_close(void) {
45 outportb(IO_SERIAL_STATUS, 0x00);
46}
47
48static inline bool ws_serial_is_overrun(void) {
49 return inportb(IO_SERIAL_STATUS) & SERIAL_OVERRUN;
50}
51
52static inline void ws_serial_ack_overrun(void) {
54}
55
56static inline bool ws_serial_is_readable(void) {
57 return inportb(IO_SERIAL_STATUS) & SERIAL_RX_READY;
58}
59
60static inline bool ws_serial_is_writable(void) {
61 return inportb(IO_SERIAL_STATUS) & SERIAL_TX_READY;
62}
63
64uint8_t ws_serial_getc(void);
66void ws_serial_putc(uint8_t value);
67
70#endif /* __WF_LIBWS_SERIAL_H__ */
#define SERIAL_RX_READY
Definition hardware.h:375
#define SERIAL_OVERRUN
Definition hardware.h:374
#define IO_SERIAL_STATUS
Definition hardware.h:368
#define SERIAL_ENABLE
Definition hardware.h:369
#define SERIAL_TX_READY
Definition hardware.h:373
#define SERIAL_OVERRUN_RESET
Definition hardware.h:372
void ws_serial_putc(uint8_t value)
static bool ws_serial_is_readable(void)
Definition serial.h:56
uint8_t ws_serial_getc(void)
static bool ws_serial_is_overrun(void)
Definition serial.h:48
static bool ws_serial_is_writable(void)
Definition serial.h:60
static void ws_serial_close(void)
Definition serial.h:44
static void ws_serial_ack_overrun(void)
Definition serial.h:52
static void ws_serial_open(uint8_t baud_rate)
Definition serial.h:40
int16_t ws_serial_getc_nonblock(void)