#include <stdint.h>
#include <nds.h>
#include <stdio.h>
#include "card_spi_driver.h"
#include "fifo.h"
#include "spi_uart_bridge.h"
#include "spi_uart_bridge_commands.h"
#include "spi_uart_bridge_internals.h"
#include "spi_comms.h"
Defines | |
| #define | MAX_TRANSFER_SIZE 16 |
| #define | IDLE_BRIDGE_STATE 0 |
| #define | BUSY_BRIDGE_STATE 1 |
| #define | STALLED_BRIDGE_STATE 2 |
| #define | INVERTED_BYTE_BRIDGE_STATE 3 |
Functions | |
| void | init_spiUART (uint8_t *rx_buffer, uint32_t rx_buffer_size, uint8_t *tx_buffer, uint32_t tx_buffer_size) |
| Initialise the bridge driver. | |
| void | prepareIRQs_spiUART (void) |
| Prepares the bridge to use interrupts. | |
| uint32_t | poll_spiUART (void) |
| Poll the bridge. | |
| uint32_t | write_spiUART (const uint8_t *buffer, uint32_t size) |
| Write bytes to the SPI UART bridge. | |
| uint32_t | read_spiUART (uint8_t *buffer, uint32_t max_size) |
| read bytes from the SPI UART bridge. | |
| uint32_t | getTxBufferCount_spiUART (void) |
| Get the number of bytes waiting to be sent across the bridge. | |
| uint32_t | getRxBufferCount_spiUART (void) |
| Get the number of bytes available for reading. | |
Variables | |
| spi_uart_bridge | bridge |
| The instance of the SPI UART bridge driver. | |
This driver can configure and send/receive data across the SPI UART bridge. The SPI side of the bridge is connected to the SPI bus of the DS card slot.
| #define BUSY_BRIDGE_STATE 1 |
The side of the bridge is transferring data.
| #define IDLE_BRIDGE_STATE 0 |
The side of the bridge is idle.
| #define INVERTED_BYTE_BRIDGE_STATE 3 |
The side of the bridge is half way through a inverted byte transfer
| #define MAX_TRANSFER_SIZE 16 |
The maximum number of bytes sent as a single block
| #define STALLED_BRIDGE_STATE 2 |
The side of the bridge is stalled due to the other side ask it to stop transmitting.
| uint32_t getRxBufferCount_spiUART | ( | void | ) |
Get the number of bytes available for reading.
| uint32_t getTxBufferCount_spiUART | ( | void | ) |
Get the number of bytes waiting to be sent across the bridge.
| void init_spiUART | ( | uint8_t * | rx_buffer, | |
| uint32_t | rx_buffer_size, | |||
| uint8_t * | tx_buffer, | |||
| uint32_t | tx_buffer_size | |||
| ) |
Initialise the bridge driver.
Initialise the SPI UART bridge driver, setting up the Tx and Rx fifos to use the supplied buffers. Initialises the Card SPI driver.
| rx_buffer | The buffer for use by the receive fifo. | |
| rx_buffer_size | The size (in bytes) of the receive buffer. | |
| tx_buffer | The buffer for use by the transmit fifo. | |
| tx_buffer_size | The size (in bytes) of the transmit buffer. |
| uint32_t poll_spiUART | ( | void | ) |
Poll the bridge.
Transfers any outstanding data across the SPI bus. NOTE: do not call if the bridge is interrupt driven.
| void prepareIRQs_spiUART | ( | void | ) |
Prepares the bridge to use interrupts.
Installs an interrupt handler for the DS card SPI interrupt. Installs an interrupt handler for the DS card interrupt. NOTE: irqInit() must have been called before calling this function.
| uint32_t read_spiUART | ( | uint8_t * | buffer, | |
| uint32_t | max_size | |||
| ) |
read bytes from the SPI UART bridge.
| buffer | The buffer in which the read data will be placed. | |
| max_size | The maximum number of bytes to be read. |
| uint32_t write_spiUART | ( | const uint8_t * | buffer, | |
| uint32_t | size | |||
| ) |
Write bytes to the SPI UART bridge.
| buffer | The buffer containing the data to be written. | |
| size | The number of bytes to be written out. |
1.4.7