Go to the source code of this file.
Data Structures | |
struct | _NUTSPIBUS |
SPI bus structure. More... | |
struct | _NUTSPINODE |
SPI node structure. More... | |
Defines | |
#define | SPI_CURRENT_MODE ((uint16_t)-1) |
#define | SPI_MODE_CPHA 0x0001 |
#define | SPI_MODE_CPOL 0x0002 |
#define | SPI_MODE_FAULT 0x0004 |
#define | SPI_MODE_LOOPBACK 0x0400 |
#define | SPI_MODE_SLAVE 0x0800 |
#define | SPI_MODE_CSKEEP 0x1000 |
#define | SPI_MODE_CSDEC 0x2000 |
#define | SPI_MODE_CSHIGH 0x4000 |
#define | SPI_MODE_UPDATE 0x8000 |
#define | SPI_MODE_0 0x0000 |
#define | SPI_MODE_1 SPI_MODE_CPHA |
#define | SPI_MODE_2 SPI_MODE_CPOL |
#define | SPI_MODE_3 (SPI_MODE_CPOL | SPI_MODE_CPHA) |
#define | SPI_CURRENT_RATE ((uint32_t)-1) |
#define | SPI_CURRENT_BITS ((uint8_t)-1) |
Typedefs | |
typedef struct _NUTSPIBUS | NUTSPIBUS |
typedef struct _NUTSPINODE | NUTSPINODE |
Functions | |
int | NutRegisterSpiDevice (NUTDEVICE *dev, NUTSPIBUS *bus, int cs) |
Register and initialize an SPI device attached to a specified bus. | |
uint_fast16_t | NutSpiBusSetMode (NUTSPINODE *node, uint_fast16_t mode) |
Set SPI mode of a specified bus device. | |
uint_fast32_t | NutSpiBusSetRate (NUTSPINODE *node, uint_fast32_t rate) |
Set clock rate of a specified SPI device. | |
uint_fast8_t | NutSpiBusSetBits (NUTSPINODE *node, uint_fast8_t bits) |
Set clock rate of a specified SPI device. | |
int | NutSpiBusWait (NUTSPINODE *node, uint32_t tmo) |
Wait until all SPI bus transfers are done. |
* $Id: spibus.h 2375 2009-01-09 17:54:38Z haraldkipp $ *
Definition in file spibus.h.
#define SPI_CURRENT_MODE ((uint16_t)-1) |
#define SPI_MODE_CPHA 0x0001 |
#define SPI_MODE_CPOL 0x0002 |
#define SPI_MODE_FAULT 0x0004 |
#define SPI_MODE_LOOPBACK 0x0400 |
#define SPI_MODE_CSKEEP 0x1000 |
#define SPI_MODE_CSHIGH 0x4000 |
Definition at line 59 of file spibus.h.
Referenced by At91SpiBus0Deselect(), At91SpiBus0Select(), At91SpiBusNodeInit(), AvrSpiBus0Deselect(), AvrSpiBus0NodeInit(), AvrSpiBus0Select(), GpioSpiBus0Deselect(), GpioSpiBus0NodeInit(), and GpioSpiBus0Select().
#define SPI_MODE_UPDATE 0x8000 |
Definition at line 60 of file spibus.h.
Referenced by At91SpiBus0Select(), At91SpiSetup(), AvrSpiBus0Select(), AvrSpiSetup(), GpioSpiBus0Select(), GpioSpiSetup(), NutSpiBusSetBits(), NutSpiBusSetMode(), and NutSpiBusSetRate().
#define SPI_MODE_0 0x0000 |
#define SPI_MODE_1 SPI_MODE_CPHA |
#define SPI_MODE_2 SPI_MODE_CPOL |
#define SPI_MODE_3 (SPI_MODE_CPOL | SPI_MODE_CPHA) |
#define SPI_CURRENT_RATE ((uint32_t)-1) |
#define SPI_CURRENT_BITS ((uint8_t)-1) |
typedef struct _NUTSPIBUS NUTSPIBUS |
typedef struct _NUTSPINODE NUTSPINODE |
Register and initialize an SPI device attached to a specified bus.
Calls the bus controller initialization and, if successful, initializes the SPI device and adds it to the system device list.
Applications should call this function during initialization for each SPI device they intend to use.
dev | Pointer to the NUTDEVICE structure, which is provided by the device driver. | |
bus | Pointer to the NUTSPIBUS structure, which is provided by the bus controller driver. | |
cs | Zero based chip select number for this device. Must be set to 0, if only one device is attached to the bus and no chip select line is provided. |
uint_fast16_t NutSpiBusSetMode | ( | NUTSPINODE * | node, | |
uint_fast16_t | mode | |||
) |
Set SPI mode of a specified bus device.
The new mode will be used during the next transfer. If its value is SPI_CURRENT_MODE, then the mode is not updated. This can be used to query the current mode.
Otherwise this parameter may be the or'ed combination of the following bits:
Be aware, that SPI drivers may have implemented a subset only.
Instead of SPI_MODE_CPHA and SPI_MODE_CPOL one of the following mode numbers may be used:
The return value may additionally contain the bit SPI_MODE_UPDATE, which indicates that here had been no transfer since the last mode update.
node | Specifies the SPI bus node. | |
mode | New mode. |
uint_fast32_t NutSpiBusSetRate | ( | NUTSPINODE * | node, | |
uint_fast32_t | rate | |||
) |
Set clock rate of a specified SPI device.
The new clock rate will be used for the next transfer. If the given rate is beyond the capabilities of the bus controller, it will automatically adjusted before the transfer starts.
node | Specifies the SPI bus node. | |
rate | New clock rate, given in bits per second. If the value is SPI_CURRENT_RATE, then the current rate is kept. |
uint_fast8_t NutSpiBusSetBits | ( | NUTSPINODE * | node, | |
uint_fast8_t | bits | |||
) |
Set clock rate of a specified SPI device.
The new clock rate will be used for the next transfer. If the given rate is beyond the capabilities of the bus controller, it will automatically adjusted before the transfer starts.
node | Specifies the SPI bus node. | |
rate | New clock rate, given in bits per second. If the value is SPI_CURRENT_RATE, then the current rate is kept. |
int NutSpiBusWait | ( | NUTSPINODE * | node, | |
uint32_t | tmo | |||
) |
Wait until all SPI bus transfers are done.
This dummy function is used by SPI device drivers, which do not provide asynchronous transfers.
node | Specifies the SPI bus node. | |
tmo | Timeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE. |