Nut/OS  4.10.3
API Reference
spibus0at91.c File Reference
#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>
Include dependency graph for spibus0at91.c:

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.

Function Documentation

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.

References EIO, and errno.

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.

Parameters:
nodeSpecifies the SPI bus node.
tmoTimeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE.
Returns:
0 on success. In case of an error, -1 is returned and the bus is not locked.

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.

Here is the call graph for this function:

int At91SpiBus0Deselect ( NUTSPINODE node)

Deselect a device on the first SPI bus.

Deactivates the chip select and unlocks the bus.

Parameters:
nodeSpecifies the SPI bus node.
Returns:
Always 0.

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.

Here is the call graph for this function:

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().

Parameters:
nodeSpecifies the SPI bus node.
txbufPointer to the transmit buffer. If NULL, undetermined byte values are transmitted.
rxbufPointer to the receive buffer. If NULL, then incoming data is discarded.
xlenNumber of bytes to transfer.
Returns:
Always 0.

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.

Here is the call graph for this function:


Variable Documentation

Initial value:

AT91 SPI bus driver implementation structure.

Definition at line 382 of file spibus0at91.c.