#include <cfg/spi.h>
#include <cfg/arch/gpio.h>
#include <dev/spibus_at91.h>
#include <dev/irqreg.h>
#include <sys/event.h>
#include <sys/nutdebug.h>
#include <stdlib.h>
#include <errno.h>
Go to the source code of this file.
Functions | |
int | At91Spi0ChipSelect (uint_fast8_t cs, uint_fast8_t hi) |
Set the specified chip select to a given level. | |
int | At91SpiBus0Select (NUTSPINODE *node, uint32_t tmo) |
Select a device on the first SPI bus. | |
int | At91SpiBus0Deselect (NUTSPINODE *node) |
Deselect a device on the first SPI bus. | |
void | At91SpiBus0Interrupt (void *arg) |
int | At91SpiBus0Transfer (NUTSPINODE *node, CONST void *txbuf, void *rxbuf, int xlen) |
Transfer data on the SPI bus using single buffered interrupt mode. | |
Variables | |
NUTSPIBUS | spiBus0At91 |
AT91 SPI bus driver implementation structure. |
int At91Spi0ChipSelect | ( | uint_fast8_t | cs, |
uint_fast8_t | hi | ||
) |
Set the specified chip select to a given level.
Definition at line 169 of file spibus0at91.c.
Referenced by At91SpiBus0Deselect(), At91SpiBus0Select(), and At91SpiBusNodeInit().
int At91SpiBus0Select | ( | NUTSPINODE * | node, |
uint32_t | tmo | ||
) |
Select a device on the first SPI bus.
Locks and activates the bus for the specified node.
node | Specifies the SPI bus node. |
tmo | Timeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE. |
Definition at line 233 of file spibus0at91.c.
References _BV, At91Spi0ChipSelect(), _AT91SPIREG::at91spi_csr, _AT91SPIREG::at91spi_mr, At91SpiSetup(), _NUTSPIBUS::bus_mutex, EIO, errno, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NUTASSERT, NutEventPost(), NutEventWait(), outr, PIO_PDR_OFF, PMC_PCER, SPI0_ID, SPI0_PINS, SPI0_PIO_BASE, SPI0_PSR_OFF, SPI_MODE_CSHIGH, SPI_MODE_UPDATE, and SPI_SPIEN.
int At91SpiBus0Deselect | ( | NUTSPINODE * | node | ) |
Deselect a device on the first SPI bus.
Deactivates the chip select and unlocks the bus.
node | Specifies the SPI bus node. |
Definition at line 284 of file spibus0at91.c.
References At91Spi0ChipSelect(), At91SpiBusWait(), _NUTSPIBUS::bus_mutex, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, NUT_WAIT_INFINITE, NUTASSERT, NutEventPost(), outr, PIO_ODR_OFF, PIO_PER_OFF, SPI0_PINS, SPI0_PIO_BASE, and SPI_MODE_CSHIGH.
void At91SpiBus0Interrupt | ( | void * | arg | ) |
Definition at line 314 of file spibus0at91.c.
References inb, NutEventPostFromIrq, and outb.
Referenced by At91SpiBusNodeInit().
int At91SpiBus0Transfer | ( | NUTSPINODE * | node, |
CONST void * | txbuf, | ||
void * | rxbuf, | ||
int | xlen | ||
) |
Transfer data on the SPI bus using single buffered interrupt mode.
A device must have been selected by calling At91SpiSelect().
node | Specifies the SPI bus node. |
txbuf | Pointer to the transmit buffer. If NULL, undetermined byte values are transmitted. |
rxbuf | Pointer to the receive buffer. If NULL, then incoming data is discarded. |
xlen | Number of bytes to transfer. |
Definition at line 350 of file spibus0at91.c.
References _NUTSPIBUS::bus_base, _NUTSPIBUS::bus_ready, _NUTSPINODE::node_bus, NUT_WAIT_INFINITE, NUTASSERT, NutEventWait(), outr, SPI_IDR_OFF, SPI_IER_OFF, SPI_RDRF, and SPI_TDR_OFF.
{ NULL, NULL, SPI0_BASE, &sig_SPI0, At91SpiBusNodeInit, At91SpiBus0Select, At91SpiBus0Deselect, At91SpiBus0Transfer, NutSpiBusWait, NutSpiBusSetMode, NutSpiBusSetRate, NutSpiBusSetBits }
AT91 SPI bus driver implementation structure.
Definition at line 382 of file spibus0at91.c.