37 lines
761 B
C
37 lines
761 B
C
#pragma once
|
|
|
|
#include "stdint.h"
|
|
#include "stddef.h"
|
|
|
|
#define UART_COM1_PORT 0x3F8
|
|
#define UART_COM2_PORT 0x2F8
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Initialize 16550 UART port with target baud rate */
|
|
int uart_init(uint16_t port, uint32_t baud);
|
|
|
|
/* Check if transmit buffer is empty */
|
|
int uart_is_tx_empty(uint16_t port);
|
|
|
|
/* Transmit a single character */
|
|
void uart_putc(uint16_t port, char c);
|
|
|
|
/* Transmit a null-terminated string */
|
|
void uart_puts(uint16_t port, const char *s);
|
|
|
|
/* Transmit a buffer of given length */
|
|
void uart_write(uint16_t port, const char *buf, size_t len);
|
|
|
|
/* Check if data received */
|
|
int uart_has_data(uint16_t port);
|
|
|
|
/* Read a single character (blocking) */
|
|
char uart_getc(uint16_t port);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|