#include <cfg/spi.h>
#include <sys/timer.h>
#include <sys/nutdebug.h>
#include <stdlib.h>
#include <memdebug.h>
#include <errno.h>
#include <dev/cy2239x.h>
#include <dev/npl.h>
#include <dev/spibus_npl.h>
Defines | |
#define | NPL_MMC_CLOCK 12500000 |
Functions | |
int | NplSpiBusSelect (NUTSPINODE *node, uint32_t tmo) |
Select a device on the first SPI bus. | |
int | NplSpiBusDeselect (NUTSPINODE *node) |
Deselect a device on the first SPI bus. | |
int | NplSpiBusNodeInit (NUTSPINODE *node) |
Initialize an SPI bus node. | |
int | NplSpiBusPollTransfer (NUTSPINODE *node, const void *txbuf, void *rxbuf, int xlen) |
Transfer data on the SPI bus in polling mode. | |
Variables | |
NUTSPIBUS | spiBusNpl |
SPI bus driver implementation structure. |
#define NPL_MMC_CLOCK 12500000 |
int NplSpiBusSelect | ( | 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. |
References _NUTSPIBUS::bus_mutex, EIO, errno, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, NULL, NUTASSERT, NutEventPost(), NutEventWait(), rc, and SPI_MODE_UPDATE.
int NplSpiBusDeselect | ( | NUTSPINODE * | node | ) |
Deselect a device on the first 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, NULL, NUTASSERT, and NutEventPost().
int NplSpiBusNodeInit | ( | 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 _NUTSPINODE::node_cs, NULL, NUTASSERT, and rc.
int NplSpiBusPollTransfer | ( | NUTSPINODE * | node, |
const void * | txbuf, | ||
void * | rxbuf, | ||
int | xlen | ||
) |
Transfer data on the SPI bus in polling mode.
A device must have been selected by calling NplSpiSelect().
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 inb, NPL_MMCDR, NPL_MMCREADY, NPL_SLR, NULL, NUTASSERT, and outb.
{ NULL, NULL, 0, NULL, NplSpiBusNodeInit, NplSpiBusSelect, NplSpiBusDeselect, NplSpiBusPollTransfer, NutSpiBusWait, NutSpiBusSetMode, NutSpiBusSetRate, NutSpiBusSetBits }
SPI bus driver implementation structure.