/* serial.h * Serial Interface * * Send/receive data via serial ports. */ #ifndef SERIAL_H #define SERIAL_H #include "asm.h" #include "io.h" #include typedef struct SerialState_s { uint16_t port; } SerialState_t; extern char_writer_t* default_COM; /** * @brief Initialize a serial port for communication * @param port The serial port number to initialize * @return Status code indicating success or failure */ int serial_init(uint16_t port); /** * @brief Check if there is pending data to receive on the serial port * @return Non-zero if data is pending, 0 otherwise */ int serial_recv_pending(); /** * @brief Receive a single byte from the serial port * @return The received byte as an 8-bit unsigned integer */ uint8_t serial_recv8(uint16_t port); /** * @brief Check if the serial port is ready to send data * @return Non-zero if ready to send, 0 otherwise */ int serial_send_pending(uint16_t port); /** * @brief Send a single byte through the serial port * @param data The 8-bit data byte to send */ int serial_send8(uint16_t port, char data); #endif