#include <sys/types.h>
#include <cfg/arch.h>
#include <cfg/twi.h>
#include <dev/irqreg.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | _NUTTWIBUS |
TWI/I2C bus structure. More... | |
Defines | |
#define | TWI_SETSPEED 0x0401 |
TWI ioctl() control codes. | |
#define | TWI_GETSPEED 0x0402 |
Query transfer speed. | |
#define | TWI_SETSLAVEADDRESS 0x0403 |
Set local slave address. | |
#define | TWI_GETSLAVEADDRESS 0x0404 |
Query local slave address. | |
#define | TWI_SETSTATUS 0x0409 |
Set status. | |
#define | TWI_GETSTATUS 0x040a |
Query status. | |
#define | TWERR_OK 0 |
TWI error codes. | |
#define | TWERR_TIMEOUT -1 |
Interface timeout. | |
#define | TWERR_BUS -2 |
Bus error. | |
#define | TWERR_IF_LOCKED -3 |
Interface locked. | |
#define | TWERR_SLA_NACK -4 |
No slave response. | |
#define | TWERR_DATA_NACK -5 |
Data not acknowledged. | |
#define | TWERR_OVRE -6 |
Overrun Error. | |
#define | TWERR_ARBLOST -7 |
Arbitration lost. | |
#define | TWERR_SPCTOUT -8 |
Start/Stop Condition timeout. | |
#define | TWSLA_MIN 17 |
Lowest slave address. Addresses below are reserved for special purposes. | |
#define | TWSLA_MAX 79 |
Highest slave address. Addresses above are reserved for special purposes. | |
#define | TWSLA_BCAST 0 |
Broadcast slave address. | |
#define | TWSLA_HOST 16 |
Host slave address. | |
#define | TWSLA_DEFAULT 193 |
Default slave address. | |
#define | TwInit(slv) NutRegisterTwiBus(&DEF_TWIBUS, slv) |
#define | TwIOCtl(req, conf) NutTwiIOCtl(&DEF_TWIBUS, req, conf) |
#define | TwMasterTransact(sla, txd, txl, rxd, rxs, tmo) NutTwiMasterTranceive(&DEF_TWIBUS, sla, txd, txl, rxd, rxs, tmo) |
#define | TwMasterRegRead(sla, iadr, ial, rxd, rxs, tmo) NutTwiMasterRegRead(&DEF_TWIBUS, sla, iadr, ial, rxd, rxs, tmo) |
#define | TwMasterRegWrite(sla, iadr, ial, txd, txs, tmo) NutTwiMasterRegWrite(&DEF_TWIBUS, sla, iadr, ial, txd, txs, tmo) |
#define | TwMasterError(void) NutTwiMasterError(&DEF_TWIBUS) |
#define | TwMasterIndexes(idx) NutTwiIndexes(&DEF_TWIBUS, idx) |
#define | TwSlaveListen(sla, rxdata, rxsiz, tmo) NutTwiSlaveListen(&DEF_TWIBUS, rxdata, rxsiz, tmo) |
#define | TwSlaveRespond(txdata, txlen, tmo) NutTwiSlaveRespond(&DEF_TWIBUS, txlen, tmo) |
#define | TwSlaveError(void) NutTwiSlaveError(&DEF_TWIBUS) |
Typedefs | |
typedef struct _NUTTWIBUS | NUTTWIBUS |
Functions | |
int | NutTwiMasterTranceive (NUTTWIBUS *bus, uint8_t sla, const void *txdata, uint16_t txlen, void *rxdata, uint16_t rxsiz, uint32_t tmo) |
Transmit and/or receive data as a master. | |
int | NutTwiMasterRegRead (NUTTWIBUS *bus, uint8_t sla, uint32_t iadr, uint8_t iadrlen, void *rxdata, uint16_t rxsiz, uint32_t tmo) |
Receive data as a master from a device having internal addressable registers. | |
int | NutTwiMasterRegWrite (NUTTWIBUS *bus, uint8_t sla, uint32_t iadr, uint8_t iadrlen, const void *txdata, uint16_t txsiz, uint32_t tmo) |
Transmit data as a master to a device having internal addressable registers. | |
int | NutTwiMasterError (NUTTWIBUS *bus) |
Get last master mode error. | |
int | NutTwiSlaveListen (NUTTWIBUS *bus, uint8_t *sla, void *rxdata, uint16_t rxsiz, uint32_t tmo) |
Listen for incoming data from a master. | |
int | NutTwiSlaveRespond (NUTTWIBUS *bus, void *txdata, uint16_t txlen, uint32_t tmo) |
Send response to a master. | |
int | NutTwiSlaveError (NUTTWIBUS *bus) |
Get last slave mode error. | |
uint16_t | NutTwiIndexes (NUTTWIBUS *bus, uint8_t idx) |
Get last transfer results. | |
int | NutTwiIOCtl (NUTTWIBUS *bus, int req, void *conf) |
Perform TWI control functions. | |
int | NutRegisterTwiBus (NUTTWIBUS *bus, uint8_t sla) |
Initialize TWI interface bus. | |
int | NutDestroyTwiBus (NUTTWIBUS *bus) |
#define TWI_SETSPEED 0x0401 |
#define TWI_GETSPEED 0x0402 |
Query transfer speed.
Referenced by NutTwiIOCtl().
#define TWI_SETSLAVEADDRESS 0x0403 |
Set local slave address.
Referenced by NutTwiIOCtl().
#define TWI_GETSLAVEADDRESS 0x0404 |
Query local slave address.
Referenced by NutTwiIOCtl().
#define TWI_SETSTATUS 0x0409 |
Set status.
Referenced by NutTwiIOCtl().
#define TWI_GETSTATUS 0x040a |
Query status.
Referenced by NutTwiIOCtl().
#define TWERR_OK 0 |
TWI error codes.
No error occured.
#define TWERR_TIMEOUT -1 |
Interface timeout.
Referenced by NutTwiMasterRegRead(), NutTwiMasterRegWrite(), NutTwiMasterTranceive(), NutTwiSlaveListen(), NutTwiSlaveRespond(), NutTwiStartRolling(), and TwErrorIrq().
#define TWERR_BUS -2 |
Bus error.
Referenced by NutTwiSlaveError(), and TwErrorIrq().
#define TWERR_IF_LOCKED -3 |
Interface locked.
Referenced by NutTwiMasterRegRead(), NutTwiMasterRegWrite(), and NutTwiMasterTranceive().
#define TWERR_SLA_NACK -4 |
No slave response.
Referenced by NutTwiMasterTranceive(), and TwErrorIrq().
#define TWERR_DATA_NACK -5 |
Data not acknowledged.
#define TWERR_OVRE -6 |
Overrun Error.
Referenced by TwErrorIrq().
#define TWERR_ARBLOST -7 |
Arbitration lost.
Referenced by TwErrorIrq().
#define TWERR_SPCTOUT -8 |
Start/Stop Condition timeout.
Referenced by TwWaitForFlag().
#define TWSLA_MIN 17 |
Lowest slave address. Addresses below are reserved for special purposes.
#define TWSLA_MAX 79 |
Highest slave address. Addresses above are reserved for special purposes.
#define TWSLA_BCAST 0 |
Broadcast slave address.
#define TWSLA_HOST 16 |
Host slave address.
#define TWSLA_DEFAULT 193 |
Default slave address.
#define TwInit | ( | slv | ) | NutRegisterTwiBus(&DEF_TWIBUS, slv) |
Referenced by DS1307Init(), EEInit(), NutTwiMasterTranceive(), PcfRtcInit(), and X12Init().
#define TwIOCtl | ( | req, | |
conf | |||
) | NutTwiIOCtl(&DEF_TWIBUS, req, conf) |
#define TwMasterTransact | ( | sla, | |
txd, | |||
txl, | |||
rxd, | |||
rxs, | |||
tmo | |||
) | NutTwiMasterTranceive(&DEF_TWIBUS, sla, txd, txl, rxd, rxs, tmo) |
Referenced by Cy2239xGetDivider(), Cy2239xGetFreq(), Cy2239xGetPll(), Cy2239xPllEnable(), Cy2239xPllGetFreq(), Cy2239xPllSetFreq(), Cy2239xSetDivider(), Cy2239xSetPll(), DS1307RamWrite(), DS1307RtcReadRegs(), DS1307RtcWrite(), PcfRtcReadRegs(), PcfRtcWrite(), ShtCommand(), X12EepromRead(), X12EepromWrite(), X12RtcReadRegs(), and X12RtcWrite().
#define TwMasterRegRead | ( | sla, | |
iadr, | |||
ial, | |||
rxd, | |||
rxs, | |||
tmo | |||
) | NutTwiMasterRegRead(&DEF_TWIBUS, sla, iadr, ial, rxd, rxs, tmo) |
Referenced by IOExpGetBit(), IOExpRawRead(), Mma745xRead(), and ShtCommand().
#define TwMasterRegWrite | ( | sla, | |
iadr, | |||
ial, | |||
txd, | |||
txs, | |||
tmo | |||
) | NutTwiMasterRegWrite(&DEF_TWIBUS, sla, iadr, ial, txd, txs, tmo) |
Referenced by IOExpInit(), IOExpPinConfigSet(), IOExpRawWrite(), IOExpSetBitHigh(), IOExpSetBitLow(), and Mma745xWrite().
#define TwMasterError | ( | void | ) | NutTwiMasterError(&DEF_TWIBUS) |
#define TwMasterIndexes | ( | idx | ) | NutTwiIndexes(&DEF_TWIBUS, idx) |
#define TwSlaveListen | ( | sla, | |
rxdata, | |||
rxsiz, | |||
tmo | |||
) | NutTwiSlaveListen(&DEF_TWIBUS, rxdata, rxsiz, tmo) |
#define TwSlaveRespond | ( | txdata, | |
txlen, | |||
tmo | |||
) | NutTwiSlaveRespond(&DEF_TWIBUS, txlen, tmo) |
#define TwSlaveError | ( | void | ) | NutTwiSlaveError(&DEF_TWIBUS) |
typedef struct _NUTTWIBUS NUTTWIBUS |