PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
sio.h File Reference
#include <tamtypes.h>
#include <stddef.h>
+ Include dependency graph for sio.h:
+ This graph shows which files directly or indirectly include this file:

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_LCR

#define SIO_LCR   0x1000f100

Line Control Register.

Definition at line 29 of file sio.h.

◆ SIO_LCR_UMODE_8BIT

#define SIO_LCR_UMODE_8BIT   0x00

UART Mode.

Definition at line 31 of file sio.h.

◆ SIO_LCR_UMODE_7BIT

#define SIO_LCR_UMODE_7BIT   0x01

Definition at line 32 of file sio.h.

◆ SIO_LCR_USBL_1BIT

#define SIO_LCR_USBL_1BIT   0x00

UART Stop Bit Length.

Definition at line 34 of file sio.h.

◆ SIO_LCR_USBL_2BITS

#define SIO_LCR_USBL_2BITS   0x01

Definition at line 35 of file sio.h.

◆ SIO_LCR_UPEN_OFF

#define SIO_LCR_UPEN_OFF   0x00

UART Parity Enable.

Definition at line 37 of file sio.h.

◆ SIO_LCR_UPEN_ON

#define SIO_LCR_UPEN_ON   0x01

Definition at line 38 of file sio.h.

◆ SIO_LCR_UEPS_ODD

#define SIO_LCR_UEPS_ODD   0x00

UART Even Parity Select.

Definition at line 40 of file sio.h.

◆ SIO_LCR_UEPS_EVEN

#define SIO_LCR_UEPS_EVEN   0x01

Definition at line 41 of file sio.h.

◆ SIO_LSR

#define SIO_LSR   0x1000f110

Line Status Register.

Definition at line 44 of file sio.h.

◆ SIO_LSR_DR

#define SIO_LSR_DR   0x01

Data Ready. (Not tested)

Definition at line 46 of file sio.h.

◆ SIO_LSR_OE

#define SIO_LSR_OE   0x02

Overrun Error.

Definition at line 48 of file sio.h.

◆ SIO_LSR_PE

#define SIO_LSR_PE   0x04

Parity Error.

Definition at line 50 of file sio.h.

◆ SIO_LSR_FE

#define SIO_LSR_FE   0x08

Framing Error.

Definition at line 52 of file sio.h.

◆ SIO_IER

#define SIO_IER   0x1000f120

Interrupt Enable Register.

Definition at line 55 of file sio.h.

◆ SIO_IER_ERDAI

#define SIO_IER_ERDAI   0x01

Enable Received Data Available Interrupt

Definition at line 57 of file sio.h.

◆ SIO_IER_ELSI

#define SIO_IER_ELSI   0x04

Enable Line Status Interrupt.

Definition at line 59 of file sio.h.

◆ SIO_ISR

#define SIO_ISR   0x1000f130

Interrupt Status Register (?).

Definition at line 62 of file sio.h.

◆ SIO_ISR_RX_DATA

#define SIO_ISR_RX_DATA   0x01

Definition at line 63 of file sio.h.

◆ SIO_ISR_TX_EMPTY

#define SIO_ISR_TX_EMPTY   0x02

Definition at line 64 of file sio.h.

◆ SIO_ISR_RX_ERROR

#define SIO_ISR_RX_ERROR   0x04

Definition at line 65 of file sio.h.

◆ SIO_FCR

#define SIO_FCR   0x1000f140

FIFO Control Register.

Definition at line 68 of file sio.h.

◆ SIO_FCR_FRSTE

#define SIO_FCR_FRSTE   0x01

FIFO Reset Enable.

Definition at line 70 of file sio.h.

◆ SIO_FCR_RFRST

#define SIO_FCR_RFRST   0x02

RX FIFO Reset.

Definition at line 72 of file sio.h.

◆ SIO_FCR_TFRST

#define SIO_FCR_TFRST   0x04

TX FIFO Reset.

Definition at line 74 of file sio.h.

◆ SIO_BGR

#define SIO_BGR   0x1000f150

Baud Rate Control Register.

Definition at line 77 of file sio.h.

◆ SIO_TXFIFO

#define SIO_TXFIFO   0x1000f180

Transmit FIFO.

Definition at line 80 of file sio.h.

◆ SIO_RXFIFO

#define SIO_RXFIFO   0x1000f1c0

Receive FIFO.

Definition at line 82 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 85 of file sio.h.

Function Documentation

◆ sio_init()

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

Definition at line 31 of file sior.c.

◆ sio_putc()

int sio_putc ( int  c)

Definition at line 41 of file sior.c.

◆ sio_getc()

int sio_getc ( void  )

Definition at line 47 of file sior.c.

◆ sio_getc_block()

int sio_getc_block ( void  )

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

Definition at line 52 of file sior.c.

◆ sio_write()

size_t sio_write ( void *  buf,
size_t  size 
)

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.

◆ sio_read()

size_t sio_read ( void *  buf,
size_t  size 
)

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

◆ sio_puts()

int sio_puts ( const char *  str)

Definition at line 71 of file sior.c.

◆ sio_putsn()

int sio_putsn ( const char *  str)

Definition at line 77 of file sior.c.

◆ sio_gets()

char * sio_gets ( char *  str)

Will block until it recieves
or \r.

Definition at line 83 of file sior.c.

◆ sio_flush()

void sio_flush ( void  )

Flushes the input buffer.

Definition at line 89 of file sior.c.