Go to the source code of this file.
Defines | |
#define | TWI_SETSPEED 0x0401 |
Set transfer speed. | |
#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 |
No error occured. | |
#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 | TWSLA_MIN 17 |
Lowest slave address. Addresses below are reserved for special purposes. | |
#define | TWSLA_MAX 79 |
Lowest 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. | |
Functions | |
int | TwInit (uint8_t sla) |
Initialize TWI interface. | |
int | TwIOCtl (int req, void *conf) |
Perform TWI control functions. | |
int | TwMasterTransact (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 | TwMasterError (void) |
Get last master mode error. | |
int | TwSlaveListen (uint8_t *sla, void *rxdata, uint16_t rxsiz, uint32_t tmo) |
Listen for incoming data from a master. | |
int | TwSlaveRespond (void *txdata, uint16_t txlen, uint32_t tmo) |
Send response to a master. | |
int | TwSlaveError (void) |
Get last slave mode error. |
#define TWI_SETSPEED 0x0401 |
#define TWI_GETSPEED 0x0402 |
#define TWI_SETSLAVEADDRESS 0x0403 |
#define TWI_GETSLAVEADDRESS 0x0404 |
#define TWI_SETSTATUS 0x0409 |
#define TWI_GETSTATUS 0x040a |
#define TWERR_TIMEOUT 1 |
Interface timeout.
Definition at line 64 of file twif.h.
Referenced by TwMasterTransact(), TwSlaveListen(), and TwSlaveRespond().
#define TWERR_BUS 2 |
#define TWERR_IF_LOCKED 3 |
#define TWERR_SLA_NACK 4 |
#define TWSLA_MIN 17 |
#define TWSLA_MAX 79 |
Listen for incoming data from a master.
If this function returns without error, the bus is blocked. The caller must immediately process the request and return a response by calling TwSlaveRespond().
sla | Points to a byte variable, which receives the slave address sent by the master. This can be used by the caller to determine whether the the interface has been addressed by a general call or its individual address. | |
rxdata | Points to a data buffer where the received data bytes are stored. | |
rxsiz | Specifies the maximum number of data bytes to receive. | |
tmo | Timeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE. |
sla | Points to a byte variable, which receives the slave address sent by the master. This can be used by the caller to determine whether the the interface has been addressed by a general call or its individual address. | |
rxdata | Points to a data buffer where the received data bytes are stored. | |
rxsiz | Specifies the maximum number of data bytes to receive. | |
tmo | Timeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE. |
Send response to a master.
This function must be called as soon as possible after TwSlaveListen() returned successfully, even if no data needs to be returned. Not doing so will completely block the bus.
txdata | Points to the data to transmit. Ignored, if the number of bytes to transmit is zero. | |
txlen | Number of data bytes to transmit. | |
tmo | Timeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE. |
txdata | Points to the data to transmit. Ignored, if the number of bytes to transmit is zero. | |
txlen | Number of data bytes to transmit. | |
tmo | Timeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE. |
int TwSlaveError | ( | void | ) |
Get last slave mode error.
You may call this function to determine the specific cause of an error after TwSlaveListen() or TwSlaveRespond() failed.