Nut/OS  4.10.3
API Reference
spibus0gpio.c File Reference
#include <cfg/spi.h>
#include <cfg/arch/gpio.h>
#include <dev/gpio.h>
#include <dev/spibus_gpio.h>
#include <sys/event.h>
#include <sys/timer.h>
#include <sys/nutdebug.h>
#include <errno.h>
#include <stdlib.h>
Include dependency graph for spibus0gpio.c:

Go to the source code of this file.

Functions

int GpioSpiBus0Transfer (NUTSPINODE *node, CONST void *txbuf, void *rxbuf, int xlen)
 Transfer data on the SPI bus.
int GpioSpiBus0NodeInit (NUTSPINODE *node)
 Initialize an SPI bus node.
int GpioSpiBus0Select (NUTSPINODE *node, uint32_t tmo)
 Select a device on the SPI bus.
int GpioSpiBus0Deselect (NUTSPINODE *node)
 Deselect a device on the SPI bus.

Variables

NUTSPIBUS spiBus0Gpio
 AVR SPI bus driver implementation structure.

Function Documentation

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

Transfer data on the SPI bus.

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

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 301 of file spibus0gpio.c.

References _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NUTASSERT, SPI_MODE_0, SPI_MODE_1, SPI_MODE_2, and SPI_MODE_3.

int GpioSpiBus0NodeInit ( NUTSPINODE node)

Initialize an SPI bus node.

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

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

Definition at line 339 of file spibus0gpio.c.

References GpioSpiSetup(), _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NUTASSERT, and SPI_MODE_CSHIGH.

Here is the call graph for this function:

int GpioSpiBus0Select ( NUTSPINODE node,
uint32_t  tmo 
)

Select a device on the 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 364 of file spibus0gpio.c.

References _NUTSPIBUS::bus_mutex, EIO, errno, GPIO_CFG_OUTPUT, GpioPinConfigSet(), GpioPinSetLow(), GpioSpiSetup(), _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NUTASSERT, NutEventPost(), NutEventWait(), SPI_MODE_CPOL, SPI_MODE_CSHIGH, and SPI_MODE_UPDATE.

Here is the call graph for this function:

int GpioSpiBus0Deselect ( NUTSPINODE node)

Deselect a device on the SPI bus.

Deactivates the chip select and unlocks the bus.

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

Definition at line 411 of file spibus0gpio.c.

References _NUTSPIBUS::bus_mutex, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, NUTASSERT, NutEventPost(), and SPI_MODE_CSHIGH.

Here is the call graph for this function:


Variable Documentation

Initial value:

AVR SPI bus driver implementation structure.

Definition at line 429 of file spibus0gpio.c.