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

Go to the source code of this file.

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 Documentation

#define NPL_MMC_CLOCK   12500000

Definition at line 58 of file spibus_npl.c.


Function Documentation

int NplSpiBusSelect ( 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 150 of file spibus_npl.c.

References _NUTSPIBUS::bus_mutex, EIO, errno, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, NUTASSERT, NutEventPost(), NutEventWait(), and SPI_MODE_UPDATE.

Here is the call graph for this function:

int NplSpiBusDeselect ( 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 186 of file spibus_npl.c.

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

Here is the call graph for this function:

int NplSpiBusNodeInit ( 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 211 of file spibus_npl.c.

References _NUTSPINODE::node_cs, and NUTASSERT.

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

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 241 of file spibus_npl.c.

References inb, NPL_MMCDR, NPL_MMCREADY, NPL_SLR, NUTASSERT, and outb.


Variable Documentation

Initial value:

SPI bus driver implementation structure.

Definition at line 271 of file spibus_npl.c.