lib/card_spi_driver.c File Reference

A driver for the DS Card SPI bus. More...

#include <stdint.h>
#include <nds.h>
#include "card_spi_driver.h"
#include "card_spi_internals.h"
#include "spi_comms.h"

Data Structures

struct  spi_driver
 A SPI driver descriptor. More...

Functions

void init_cardSPI (void)
 Initialise the SPI driver.
enum card_spi_return_code read_cardSPI (uint8_t *read_byte)
 Read from the card SPI.
enum card_spi_return_code readBlocking_cardSPI (uint8_t *read_byte)
 Read from the card SPI blocking if it is busy.
enum card_spi_return_code write_cardSPI (uint8_t byte)
 Write a byte out on the SPI bus (initiates a transfer).
enum card_spi_return_code writeBlocking_cardSPI (uint8_t byte)
 Write a byte out on the SPI bus (initiates a transfer) blocking until the write can be performed.
void setupConsecutive_cardSPI (uint32_t num_bytes)
 Set up a transfer of a number of consecutive bytes.
void config_cardSPI (enum card_spi_clock_freq freq, int use_interrupts)
 Set the configuration of the Card SPI bus.
void disable_cardSPI (void)
 Disable the Card SPI bus.


Detailed Description

A driver for the DS Card SPI bus.


Function Documentation

void disable_cardSPI ( void   ) 

Disable the Card SPI bus.

Disables the Card SPI bus. A write call will enable the bus again.

void init_cardSPI ( void   ) 

Initialise the SPI driver.

Initialise the Card SPI driver.

enum card_spi_return_code read_cardSPI ( uint8_t *  read_byte  ) 

Read from the card SPI.

If the SPI bus is busy then the read will fail. Otherwise the last received byte is returned.

Parameters:
read_byte Pointer to the location to store the received byte.
Returns:
CARD_SPI_OK if the read was successful or CARD_SPI_BUSY if a transfer is in progress.

enum card_spi_return_code readBlocking_cardSPI ( uint8_t *  read_byte  ) 

Read from the card SPI blocking if it is busy.

Block until any outstanding transfer has completed and then return the byte receive over the SPI bus. The call is always successful, the function parameters and return type is kept in the same format as the non blocking function.

Parameters:
read_byte Pointer to the location to store the received byte.
Returns:
CARD_SPI_OK if the read was successful.

void setupConsecutive_cardSPI ( uint32_t  num_bytes  ) 

Set up a transfer of a number of consecutive bytes.

The chip select will remain low (active) until the supplied number of bytes have been sent out.

enum card_spi_return_code write_cardSPI ( uint8_t  byte  ) 

Write a byte out on the SPI bus (initiates a transfer).

Writes the supplied byte out on the SPI bus. The write initiates a transfer which once completed will mean the next received byte is available.

Parameters:
byte The byte value to be sent out.
Returns:
CARD_SPI_OK if the write was successful or CARD_SPI_BUSY if the SPI bus is busy.

enum card_spi_return_code writeBlocking_cardSPI ( uint8_t  byte  ) 

Write a byte out on the SPI bus (initiates a transfer) blocking until the write can be performed.

Block until any outstanding transfer has completed and then send the byte over the SPI bus. The call is always successful, the function parameters and return type is kept in the same format as the non blocking function.

Parameters:
byte The byte value to be sent
Returns:
CARD_SPI_OK if the read was successful.


Generated on Sat Aug 12 18:40:55 2006 for Nintendo DS SPI UART Bridge Driver by  doxygen 1.4.7