Driver for managing the serial port
More...
|
file | scif.h |
| Serial port functionality.
|
|
Driver for managing the serial port
◆ scif_detected()
int scif_detected |
( |
void | | ) |
|
Is the SCIF port detected? Of course it is!
- Returns
- 1
◆ scif_flush()
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
-
0 | On success. |
-1 | If the SCIF port is disabled (errno set to EIO). |
◆ scif_init()
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
-
0 | On success (no error conditions defined). |
◆ scif_read()
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
-
data | The buffer to read into. |
len | The 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
-
on | 1 to enable IRQ usage, 0 for polled I/O. |
- Return values
-
0 | On success (no error conditions defined). |
◆ scif_set_parameters()
void scif_set_parameters |
( |
int | baud, |
|
|
int | fifo ) |
Set serial parameters.
- Parameters
-
baud | The bitrate to set. |
fifo | 1 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
-
0 | On 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
-
0 | On success. |
-1 | On 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
-
buffer | Buffer to store read data into. |
len | Number of bytes to read from the device. |
◆ scif_spi_rw_byte()
Read and write one byte from the SPI port.
This function writes one byte and reads one back from the SPI device simultaneously.
- Parameters
-
b | The 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
-
v | Non-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
-
0 | On success (no errors defined). |
◆ scif_spi_slow_rw_byte()
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
-
b | The 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
-
b | The byte to write out to the port. |
◆ scif_write()
Write a single character to the SCIF port.
- Parameters
-
c | The character to write (only the low 8-bits are written). |
- Return values
-
1 | On success. |
-1 | If 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
-
data | The buffer to write. |
len | The length of the buffer, in bytes. |
xlat | If set to 1, all newlines will be written as CRLF. |
- Returns
- The number of bytes written on success, -1 on error.
◆ dbgio_scif
SCIF debug I/O handler.
Do not modify!