sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
sio.h File Reference
#include <tamtypes.h>
#include <stddef.h>

Go to the source code of this file.

Macros

#define SIO_LCR   0x1000f100
#define SIO_LCR_UMODE_8BIT   0x00
#define SIO_LCR_UMODE_7BIT   0x01
#define SIO_LCR_USBL_1BIT   0x00
#define SIO_LCR_USBL_2BITS   0x01
#define SIO_LCR_UPEN_OFF   0x00
#define SIO_LCR_UPEN_ON   0x01
#define SIO_LCR_UEPS_ODD   0x00
#define SIO_LCR_UEPS_EVEN   0x01
#define SIO_LSR   0x1000f110
#define SIO_LSR_DR   0x01
#define SIO_LSR_OE   0x02
#define SIO_LSR_PE   0x04
#define SIO_LSR_FE   0x08
#define SIO_IER   0x1000f120
#define SIO_IER_ERDAI   0x01
#define SIO_IER_ELSI   0x04
#define SIO_ISR   0x1000f130
#define SIO_ISR_RX_DATA   0x01
#define SIO_ISR_TX_EMPTY   0x02
#define SIO_ISR_RX_ERROR   0x04
#define SIO_FCR   0x1000f140
#define SIO_FCR_FRSTE   0x01
#define SIO_FCR_RFRST   0x02
#define SIO_FCR_TFRST   0x04
#define SIO_BGR   0x1000f150
#define SIO_TXFIFO   0x1000f180
#define SIO_RXFIFO   0x1000f1c0
#define SIO_CAUSE_BIT   (1 << 12)

Functions

void sio_init (u32 baudrate, u8 lcr_ueps, u8 lcr_upen, u8 lcr_usbl, u8 lcr_umode)
int sio_putc (int c)
int sio_getc (void)
int sio_getc_block (void)
size_t sio_write (void *buf, size_t size)
size_t sio_read (void *buf, size_t size)
int sio_puts (const char *str)
int sio_putsn (const char *str)
char * sio_gets (char *str)
void sio_flush (void)

Detailed Description

EE Serial I/O

Definition in file sio.h.

Macro Definition Documentation

◆ SIO_BGR

#define SIO_BGR   0x1000f150

Baud Rate Control Register.

Definition at line 78 of file sio.h.

◆ SIO_CAUSE_BIT

#define SIO_CAUSE_BIT   (1 << 12)

The bit in the EE cause register which indicates an SIO exception

Definition at line 86 of file sio.h.

◆ SIO_FCR

#define SIO_FCR   0x1000f140

FIFO Control Register.

Definition at line 69 of file sio.h.

◆ SIO_FCR_FRSTE

#define SIO_FCR_FRSTE   0x01

FIFO Reset Enable.

Definition at line 71 of file sio.h.

◆ SIO_FCR_RFRST

#define SIO_FCR_RFRST   0x02

RX FIFO Reset.

Definition at line 73 of file sio.h.

◆ SIO_FCR_TFRST

#define SIO_FCR_TFRST   0x04

TX FIFO Reset.

Definition at line 75 of file sio.h.

◆ SIO_IER

#define SIO_IER   0x1000f120

Interrupt Enable Register.

Definition at line 56 of file sio.h.

◆ SIO_IER_ELSI

#define SIO_IER_ELSI   0x04

Enable Line Status Interrupt.

Definition at line 60 of file sio.h.

◆ SIO_IER_ERDAI

#define SIO_IER_ERDAI   0x01

Enable Received Data Available Interrupt

Definition at line 58 of file sio.h.

◆ SIO_ISR

#define SIO_ISR   0x1000f130

Interrupt Status Register (?).

Definition at line 63 of file sio.h.

◆ SIO_ISR_RX_DATA

#define SIO_ISR_RX_DATA   0x01

Definition at line 64 of file sio.h.

◆ SIO_ISR_RX_ERROR

#define SIO_ISR_RX_ERROR   0x04

Definition at line 66 of file sio.h.

◆ SIO_ISR_TX_EMPTY

#define SIO_ISR_TX_EMPTY   0x02

Definition at line 65 of file sio.h.

◆ SIO_LCR

#define SIO_LCR   0x1000f100

Line Control Register.

Definition at line 30 of file sio.h.

◆ SIO_LCR_UEPS_EVEN

#define SIO_LCR_UEPS_EVEN   0x01

Definition at line 42 of file sio.h.

◆ SIO_LCR_UEPS_ODD

#define SIO_LCR_UEPS_ODD   0x00

UART Even Parity Select.

Definition at line 41 of file sio.h.

◆ SIO_LCR_UMODE_7BIT

#define SIO_LCR_UMODE_7BIT   0x01

Definition at line 33 of file sio.h.

◆ SIO_LCR_UMODE_8BIT

#define SIO_LCR_UMODE_8BIT   0x00

UART Mode.

Definition at line 32 of file sio.h.

◆ SIO_LCR_UPEN_OFF

#define SIO_LCR_UPEN_OFF   0x00

UART Parity Enable.

Definition at line 38 of file sio.h.

◆ SIO_LCR_UPEN_ON

#define SIO_LCR_UPEN_ON   0x01

Definition at line 39 of file sio.h.

◆ SIO_LCR_USBL_1BIT

#define SIO_LCR_USBL_1BIT   0x00

UART Stop Bit Length.

Definition at line 35 of file sio.h.

◆ SIO_LCR_USBL_2BITS

#define SIO_LCR_USBL_2BITS   0x01

Definition at line 36 of file sio.h.

◆ SIO_LSR

#define SIO_LSR   0x1000f110

Line Status Register.

Definition at line 45 of file sio.h.

◆ SIO_LSR_DR

#define SIO_LSR_DR   0x01

Data Ready. (Not tested)

Definition at line 47 of file sio.h.

◆ SIO_LSR_FE

#define SIO_LSR_FE   0x08

Framing Error.

Definition at line 53 of file sio.h.

◆ SIO_LSR_OE

#define SIO_LSR_OE   0x02

Overrun Error.

Definition at line 49 of file sio.h.

◆ SIO_LSR_PE

#define SIO_LSR_PE   0x04

Parity Error.

Definition at line 51 of file sio.h.

◆ SIO_RXFIFO

#define SIO_RXFIFO   0x1000f1c0

Receive FIFO.

Definition at line 83 of file sio.h.

◆ SIO_TXFIFO

#define SIO_TXFIFO   0x1000f180

Transmit FIFO.

Definition at line 81 of file sio.h.

Function Documentation

◆ sio_flush()

void sio_flush ( void )
extern

Flushes the input buffer.

Definition at line 167 of file sio.c.

◆ sio_getc()

int sio_getc ( void )
extern

Definition at line 78 of file sio.c.

◆ sio_getc_block()

int sio_getc_block ( void )
extern

Same as sio_getc, but blocking. Note that getc should be blocking by default. Ho well.

Definition at line 91 of file sio.c.

◆ sio_gets()

char * sio_gets ( char * str)
extern

Will block until it recieves
or \r.

Definition at line 148 of file sio.c.

◆ sio_init()

void sio_init ( u32 baudrate,
u8 lcr_ueps,
u8 lcr_upen,
u8 lcr_usbl,
u8 lcr_umode )
extern

Definition at line 34 of file sio.c.

◆ sio_putc()

int sio_putc ( int c)
extern

Definition at line 60 of file sio.c.

◆ sio_puts()

int sio_puts ( const char * str)
extern

Definition at line 127 of file sio.c.

◆ sio_putsn()

int sio_putsn ( const char * str)
extern

Definition at line 138 of file sio.c.

◆ sio_read()

size_t sio_read ( void * buf,
size_t size )
extern

This will read from the serial port until size characters have been read or EOF (RX FIFO is empty).

Definition at line 110 of file sio.c.

◆ sio_write()

size_t sio_write ( void * buf,
size_t size )
extern

Not really much to do in the way of error-handling. sio_putc() already checks to see if there's room in the TX FIFO, and my cable doesn't support hardware flow control.

Definition at line 99 of file sio.c.