Functions which handle the TWI. More...
Modules | |
Advanced informations | |
Lock Functions | |
uint8_t | twi_lock (void) |
Locks the TWI for the user. More... | |
uint8_t | twi_lockGet (void) |
Gets if the TWI is only locked for the user. More... | |
void | twi_unlock (void) |
Unlocks the TWI by the user. More... | |
void | twi_lockForce (void) |
Locks the TWI for the user. More... | |
Setup Functions | |
void | twi_reset (void) |
Resets the TWI software. More... | |
uint8_t | twi_errorGet (void) |
Returns the error value of the TWI. More... | |
void | twi_read (uint8_t count) |
Starts the reception of data over the TWI. More... | |
void | twi_write (void) |
Starts the transmission of data over the TWI. More... | |
void | twi_wait (void) |
Waits until the TWI is not busy anymore. More... | |
void | twi_sendTo (uint8_t address) |
Sets the slave address for the next transfer. More... | |
Transfer Functions | |
uint8_t | twiinp (void) |
Gets one byte from the receive buffer of the twi. More... | |
uint8_t | twiinp_ir (void) |
Gets one byte from the receive buffer of the twi. More... | |
uint8_t | twistat (void) |
Gets the number of bytes in the receive buffer of the twi. More... | |
void | twiout (uint8_t send_data) |
Puts one byte in the transmit buffer of the twi. More... | |
void | twistr (const char *send_data) |
Puts a string located in the RAM in the transmit buffer of the twi. More... | |
void | twistr_p (const char *send_data) |
Puts a string located in the flash in the transmit buffer of the twi. More... | |
Functions which handle the TWI.
example
uint8_t twi_errorGet | ( | void | ) |
Returns the error value of the TWI.
The return value corresponds to the last error.
If no error occured 0x00 will be returned.
uint8_t twi_lock | ( | void | ) |
Locks the TWI for the user.
This function waits for the last internal transfer to be done.
If the internal transfer is not done within 100 milliseconds, this function will fail and return 0x00. Otherwise it returns 0xFF;
The locking and unlocking is done incrementally. The TWI must be unlocked as often as it was locked. Otherwise the library will not access the TWI again.
void twi_lockForce | ( | void | ) |
Locks the TWI for the user.
This function does not wait for the current internal transfer to be done.
The locking and unlocking is done incrementally. The TWI must be unlocked as often as it was locked. Otherwise the library will not access the TWI again.
uint8_t twi_lockGet | ( | void | ) |
Gets if the TWI is only locked for the user.
This function returns, if and how often the twi is locked for the user.
void twi_read | ( | uint8_t | count | ) |
Starts the reception of data over the TWI.
This function initiates the reception of the data.
The count parameter sets the number of bytes to be read. Since the receive buffer is 16 bytes count must be between 0 and 15.
The corresponding slave is selected with the function twi_sendTo().
count | 8-bit unsigned integer |
void twi_reset | ( | void | ) |
Resets the TWI software.
This function flushes the TWI buffers and clears the TWI error value.
void twi_sendTo | ( | uint8_t | address | ) |
Sets the slave address for the next transfer.
The lowest significant bit is masked out and automatically set by the twi hardware for each read operation.
address | 8-bit unsigned integer |
void twi_unlock | ( | void | ) |
Unlocks the TWI by the user.
The locking and unlocking is done incrementally. The TWI must be unlocked as often as it was locked. Otherwise the library will not access the TWI again.
void twi_wait | ( | void | ) |
Waits until the TWI is not busy anymore.
This function returns if no more data is going to be read or written and the last TWI commands have been executed. It also returns if an error occured.
void twi_write | ( | void | ) |
Starts the transmission of data over the TWI.
This function initiates the transmission of the data.
Since the transmit buffer is 16 bytes, no more than 16 bytes will be transmitted.
The corresponding slave is selected with the function twi_sendTo().
uint8_t twiinp | ( | void | ) |
Gets one byte from the receive buffer of the twi.
This function will return the first received byte in the receive buffer.
If the reveive buffer is empty and a read operation is still going on this function will wait until the next data byte is received. Otherwise 0x00 will be returned.
uint8_t twiinp_ir | ( | void | ) |
Gets one byte from the receive buffer of the twi.
This function will return the first received byte in the receive buffer.
If the reveive buffer is empty this function will return 0x00.
void twiout | ( | uint8_t | send_data | ) |
Puts one byte in the transmit buffer of the twi.
send_data | 8-bit unsigned integer |
uint8_t twistat | ( | void | ) |
Gets the number of bytes in the receive buffer of the twi.
void twistr | ( | const char * | send_data | ) |
Puts a string located in the RAM in the transmit buffer of the twi.
This function loads the referenced string character by character and passes those to the twiout() function until a terminating \ 0-character is found.
*send_data | 16-bit pointer to a character located in the RAM |
void twistr_p | ( | const char * | send_data | ) |
Puts a string located in the flash in the transmit buffer of the twi.
This function loads the referenced string character by character and passes those to the twiout() function until a terminating \ 0-character is found.
*send_data | 16-bit pointer to a character located in the flash |