Functions | |
int | TwMasterTransact (u_char sla, CONST void *txdata, u_short txlen, void *rxdata, u_short rxsiz, u_long tmo) |
Transmit and/or receive data as a master. | |
int | TwMasterError (void) |
Get last master mode error. | |
int | TwIOCtl (int req, void *conf) |
Perform TWI control functions. | |
int | TwInit (u_char sla) |
Initialize TWI interface. | |
Variables | |
HANDLE | tw_mm_mutex |
HANDLE | tw_mm_que |
int TwMasterTransact | ( | u_char | sla, | |
CONST void * | txdata, | |||
u_short | txlen, | |||
void * | rxdata, | |||
u_short | rxsiz, | |||
u_long | tmo | |||
) |
Transmit and/or receive data as a master.
The two-wire serial interface must have been initialized by calling TwInit() before this function can be used.
sla | Slave address of the destination. This slave address must be specified as a 7-bit address. For example, the PCF8574A may be configured to slave addresses from 0x38 to 0x3F. | |
txdata | Points to the data to transmit. Ignored, if the number of data bytes to transmit is zero. | |
txlen | Number of data bytes to transmit. If zero, then the interface will not send any data to the slave device and will directly enter the master receive mode. | |
rxdata | Points to a buffer, where the received data will be stored. Ignored, if the maximum number of bytes to receive is zero. | |
rxsiz | Maximum number of bytes to receive. Set to zero, if no bytes are expected from the slave device. | |
tmo | Timeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE. |
Definition at line 186 of file at91_twi.c.
References NutEnterCritical, NutEventPost(), NutEventWait(), NutExitCritical, NutIrqDisable(), NutIrqEnable(), outb, outr, tw_mm_mutex, tw_mm_que, TWERR_IF_LOCKED, TWERR_TIMEOUT, TWI_CR, TWI_IDR, TWI_IER, TWI_MMR, TWI_MREAD, TWI_NACK, TWI_RXRDY, TWI_START, TWI_STOP, TWI_THR, TWI_TXCOMP, and TWI_TXRDY.
int TwMasterError | ( | void | ) |
Get last master mode error.
You may call this function to determine the specific cause of an error after TwMasterTransact() failed.
Definition at line 273 of file at91_twi.c.
int TwIOCtl | ( | int | req, | |
void * | conf | |||
) |
Perform TWI control functions.
req | Requested control function. May be set to one of the following constants:
| |
conf | Points to a buffer that contains any data required for the given control function or receives data from that function. |
Definition at line 295 of file at91_twi.c.
References inr, NutGetCpuClock(), outr, TWI_CWGR, TWI_GETSPEED, TWI_GETSTATUS, TWI_SETSPEED, and TWI_SETSTATUS.
int TwInit | ( | u_char | sla | ) |
Initialize TWI interface.
The specified slave address is not used here as we don't support twi-slave on AT91SAM7X
sla | Slave address, must be specified as a 7-bit address, always lower than 128. |
Definition at line 359 of file at91_twi.c.
References _BV, NutEventPost(), NutRegisterIrqHandler(), outr, PMC_PCER, tw_mm_mutex, TWI_CR, TWI_ID, TWI_IDR, TWI_MSEN, TWI_SETSPEED, TWI_SVDIS, TWI_SWRST, and TwIOCtl().
Definition at line 67 of file at91_twi.c.
Definition at line 68 of file at91_twi.c.