spibus0avr.c File Reference

AVR SPI bus 0 driver. More...

Go to the source code of this file.

Functions

int AvrSpiBus0Transfer (NUTSPINODE *node, CONST void *txbuf, void *rxbuf, int xlen)
 Transfer data on the SPI bus.
int AvrSpiBus0NodeInit (NUTSPINODE *node)
 Initialize an SPI bus node.
int AvrSpiBus0Select (NUTSPINODE *node, uint32_t tmo)
 Select a device on the SPI bus.
int AvrSpiBus0Deselect (NUTSPINODE *node)
 Deselect a device on the SPI bus.

Variables

NUTSPIBUS spiBus0Avr
 AVR SPI bus driver implementation structure.

Detailed Description

AVR SPI bus 0 driver.

May be configured as an interrupt driven or polling driver. The interrupt driven version may use single or double buffering.

Single buffer interrupt mode is the default.

Polling mode requires about 300 bytes less code and is roughly 10% faster. However, it blocks the CPU during the whole transfer.

Double buffering additionally requires about 200 bytes of code space and is only slightly faster (less than 1%).

 * $Id: spibus0avr.c 2467 2009-02-17 09:30:02Z haraldkipp $
 * 

Definition in file spibus0avr.c.


Function Documentation

int AvrSpiBus0Transfer ( NUTSPINODE *  node,
CONST void *  txbuf,
void *  rxbuf,
int  xlen 
)

Transfer data on the SPI bus.

A device must have been selected by calling AvrSpi0Select().

Depending on the configuration, this routine implemets polling or interrupt mode. For the latter either single or double buffering may have been selected.

When using double buffered interrupt mode, then the transfer may be still in progress when returning from this function.

Parameters:
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.
Returns:
Always 0.

Definition at line 255 of file spibus0avr.c.

References cbi, inb, NUT_WAIT_INFINITE, NUTASSERT, NutEventWait(), outb, and sbi.

int AvrSpiBus0NodeInit ( NUTSPINODE *  node  ) 

Initialize an SPI bus node.

This routine is called for each SPI node, which is registered via NutRegisterSpiDevice().

Parameters:
node Specifies the SPI bus node.
Returns:
0 on success or -1 if there is no valid chip select.

Definition at line 366 of file spibus0avr.c.

References AvrSpiSetup(), malloc, NUTASSERT, NutRegisterIrqHandler(), and SPI_MODE_CSHIGH.

int AvrSpiBus0Select ( NUTSPINODE *  node,
uint32_t  tmo 
)

Select a device on the SPI bus.

Locks and activates the bus for the specified node.

Parameters:
node Specifies the SPI bus node.
tmo Timeout 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 405 of file spibus0avr.c.

References _BV, AvrSpiSetup(), bit_is_clear, cbi, EIO, errno, inb, NUTASSERT, NutEventPost(), NutEventWait(), outb, sbi, SPI_MODE_CSHIGH, and SPI_MODE_UPDATE.

int AvrSpiBus0Deselect ( NUTSPINODE *  node  ) 

Deselect a device on the SPI bus.

Deactivates the chip select and unlocks the bus.

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

Definition at line 477 of file spibus0avr.c.

References NUT_WAIT_INFINITE, NUTASSERT, NutEventPost(), and SPI_MODE_CSHIGH.


Variable Documentation

NUTSPIBUS spiBus0Avr
Initial value:

AVR SPI bus driver implementation structure.

Definition at line 498 of file spibus0avr.c.


© 2000-2010 by contributors - visit http://www.ethernut.de/