#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 <dev/board.h>#include <errno.h>#include <stdlib.h>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. | |
| 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().
| 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. |
References _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NULL, 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().
| node | Specifies the SPI bus node. |
References GpioSpiSetup(), _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NULL, NUTASSERT, and SPI_MODE_CSHIGH.
| int GpioSpiBus0Select | ( | NUTSPINODE * | node, |
| uint32_t | tmo | ||
| ) |
Select a device on the 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. |
References _NUTSPIBUS::bus_mutex, EIO, errno, GPIO_CFG_OUTPUT, GpioPinConfigSet(), GpioPinSetLow, GpioSpiSetup(), _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NULL, NUTASSERT, NutEventPost(), NutEventWait(), rc, SBBI0_MISO_BIT, SBBI0_MISO_PORT, SBBI0_MOSI_BIT, SBBI0_MOSI_PORT, SBBI0_SCK_BIT, SBBI0_SCK_PORT, SPI_MODE_CPOL, SPI_MODE_CSHIGH, and SPI_MODE_UPDATE.
| int GpioSpiBus0Deselect | ( | NUTSPINODE * | node | ) |
Deselect a device on the SPI bus.
Deactivates the chip select and unlocks the bus.
| node | Specifies the SPI bus node. |
References _NUTSPIBUS::bus_mutex, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, NULL, NUTASSERT, NutEventPost(), and SPI_MODE_CSHIGH.
{
NULL,
NULL,
0,
NULL,
GpioSpiBus0NodeInit,
GpioSpiBus0Select,
GpioSpiBus0Deselect,
GpioSpiBus0Transfer,
NutSpiBusWait,
NutSpiBusSetMode,
GpioSpiBusSetRate,
NutSpiBusSetBits
}
AVR SPI bus driver implementation structure.