KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
SCIF

Driver for managing the serial port More...

Files

file  scif.h
 Serial port functionality.
 

Functions

void scif_set_parameters (int baud, int fifo)
 Set serial parameters.
 
int scif_set_irq_usage (int on)
 Enable or disable SCIF IRQ usage.
 
int scif_detected (void)
 Is the SCIF port detected? Of course it is!
 
int scif_init (void)
 Initialize the SCIF port.
 
int scif_shutdown (void)
 Shutdown the SCIF port.
 
int scif_read (void)
 Read a single character from the SCIF port.
 
int scif_write (int c)
 Write a single character to the SCIF port.
 
int scif_flush (void)
 Flush any FIFO'd bytes out of the buffer.
 
int scif_write_buffer (const uint8 *data, int len, int xlat)
 Write a whole buffer of data to the SCIF port.
 
int scif_read_buffer (uint8 *data, int len)
 Read a buffer of data from the SCIF port.
 
int scif_spi_init (void)
 Initialize the SCIF port for use of an SPI peripheral.
 
int scif_spi_shutdown (void)
 Shut down SPI card support over the SCIF port.
 
void scif_spi_set_cs (int v)
 Set or clear the SPI /CS line.
 
uint8 scif_spi_rw_byte (uint8 b)
 Read and write one byte from the SPI port.
 
uint8 scif_spi_slow_rw_byte (uint8 b)
 Read and write one byte from the SPI device, slowly.
 
void scif_spi_write_byte (uint8 b)
 Write a byte to the SPI device.
 
uint8 scif_spi_read_byte (void)
 Read a byte from the SPI device.
 
void scif_spi_read_data (uint8 *buffer, size_t len)
 Read a data from the SPI device.
 

Variables

dbgio_handler_t dbgio_scif
 SCIF debug I/O handler.
 

Detailed Description

Driver for managing the serial port

Function Documentation

◆ scif_detected()

int scif_detected ( void )

Is the SCIF port detected? Of course it is!

Returns
1

◆ scif_flush()

int scif_flush ( void )

Flush any FIFO'd bytes out of the buffer.

This function sends any bytes that have been queued up for transmission but have not left yet in FIFO mode.

Return values
0On success.
-1If the SCIF port is disabled (errno set to EIO).

◆ scif_init()

int scif_init ( void )

Initialize the SCIF port.

This function initializes the SCIF port to a sane state. If dcload-serial is in use, this is effectively a no-op.

Return values
0On success (no error conditions defined).

◆ scif_read()

int scif_read ( void )

Read a single character from the SCIF port.

Returns
The character read if one is available, otherwise -1 and errno is set to EAGAIN.

◆ scif_read_buffer()

int scif_read_buffer ( uint8 * data,
int len )

Read a buffer of data from the SCIF port.

This function reads a whole buffer of data from the SCIF port, blocking until it has been filled.

Parameters
dataThe buffer to read into.
lenThe number of bytes to read.
Returns
The number of bytes read on success, -1 on error.

◆ scif_set_irq_usage()

int scif_set_irq_usage ( int on)

Enable or disable SCIF IRQ usage.

Parameters
on1 to enable IRQ usage, 0 for polled I/O.
Return values
0On success (no error conditions defined).

◆ scif_set_parameters()

void scif_set_parameters ( int baud,
int fifo )

Set serial parameters.

Parameters
baudThe bitrate to set.
fifo1 to enable FIFO mode.

◆ scif_shutdown()

int scif_shutdown ( void )

Shutdown the SCIF port.

This function disables SCIF IRQs, if they were enabled and cleans up.

Return values
0On success (no error conditions defined).

◆ scif_spi_init()

int scif_spi_init ( void )

Initialize the SCIF port for use of an SPI peripheral.

This function initializes the SCIF port for accessing the an SPI peripheral that has been connected to the serial port. The design of the SCIF->SPI wiring follows the wiring of the SD card adapter which is (at least now) somewhat commonly available online and is the same as the one designed by jj1odm.

Return values
0On success.
-1On error (if dcload-serial is detected).

◆ scif_spi_read_byte()

uint8 scif_spi_read_byte ( void )

Read a byte from the SPI device.

This function reads a byte from the SPI device, one bit at a time. Timing is similar to (but slightly faster than) the scif_spi_rw_byte() function.

Returns
The byte returned from the device.

◆ scif_spi_read_data()

void scif_spi_read_data ( uint8 * buffer,
size_t len )

Read a data from the SPI device.

This function reads data from the SPI device. If the buffer is aligned and len is divisible by 4, optimizations are applied.

Parameters
bufferBuffer to store read data into.
lenNumber of bytes to read from the device.

◆ scif_spi_rw_byte()

uint8 scif_spi_rw_byte ( uint8 b)

Read and write one byte from the SPI port.

This function writes one byte and reads one back from the SPI device simultaneously.

Parameters
bThe byte to write out to the port.
Returns
The byte returned from the card.

◆ scif_spi_set_cs()

void scif_spi_set_cs ( int v)

Set or clear the SPI /CS line.

This function sets or clears the /CS line (connected to the RTS line of the SCIF port).

Parameters
vNon-zero to output 1 on the line, zero to output 0.

◆ scif_spi_shutdown()

int scif_spi_shutdown ( void )

Shut down SPI card support over the SCIF port.

This function shuts down SPI support on the SCIF port. If you want to get regular usage of the port back, you must call scif_init() after shutting down SPI support.

Return values
0On success (no errors defined).

◆ scif_spi_slow_rw_byte()

uint8 scif_spi_slow_rw_byte ( uint8 b)

Read and write one byte from the SPI device, slowly.

This function does the same thing as the scif_sd_rw_byte() function, but with a 1.5usec delay between asserting the CLK line and reading back the bit and a 1.5usec delay between clearing the CLK line and writing the next bit out.

This ends up working out to a clock of about 333khz, or so.

Parameters
bThe byte to write out to the port.
Returns
The byte returned from the card.

◆ scif_spi_write_byte()

void scif_spi_write_byte ( uint8 b)

Write a byte to the SPI device.

This function writes out the specified byte to the SPI device, one bit at a time. The timing follows that of the scif_spi_rw_byte() function.

Parameters
bThe byte to write out to the port.

◆ scif_write()

int scif_write ( int c)

Write a single character to the SCIF port.

Parameters
cThe character to write (only the low 8-bits are written).
Return values
1On success.
-1If the SCIF port is disabled (errno set to EIO).

◆ scif_write_buffer()

int scif_write_buffer ( const uint8 * data,
int len,
int xlat )

Write a whole buffer of data to the SCIF port.

This function writes a whole buffer of data to the SCIF port, optionally making all newlines into carriage return + newline pairs.

Parameters
dataThe buffer to write.
lenThe length of the buffer, in bytes.
xlatIf set to 1, all newlines will be written as CRLF.
Returns
The number of bytes written on success, -1 on error.

Variable Documentation

◆ dbgio_scif

dbgio_handler_t dbgio_scif
extern

SCIF debug I/O handler.

Do not modify!