#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
Macros | |
#define | I2C_NO 1 |
I²C hardware module number. | |
#define | I2C_TRX_BUFFER_SIZE 32 |
Enumerations | |
enum | i2c_states { I2C_STATE_idle, I2C_STATE_sendingStart, I2C_STATE_dataTX, I2C_STATE_sendingRestart, I2C_STATE_sendingStop, I2C_STATE_dataRX, I2C_STATE_ack, I2C_STATE_error, I2C_STATE_disabled } |
I²C driver states. More... | |
enum | i2c_errors { I2C_ERR_noError = 0, I2C_ERR_internal = 1, I2C_ERR_inErrorState = 2, I2C_ERR_busy = 3, I2C_ERR_TXBufferOverflow = 4, I2C_ERR_RXBufferOverflow = 5, I2C_ERR_slaveNACK = 6, I2C_ERR_nothingReceived = 7, I2C_ERR_collisionDetected = 8, I2C_ERR_disabled = 9 } |
I²C driver errors. More... |
Functions | |
void | i2c_reset () |
Enter idle state and reset error variable. | |
bool | i2c_busy () |
Check if I²C driver is busy. | |
void | i2c_init (int brg, bool enableSlewRateControl, int priority) |
Initialise the I²C driver. | |
void | i2c_disable () |
Temporarily disable the I²C driver. | |
void | i2c_enable () |
Re-enable the I²C driver. | |
int | i2c_putc (unsigned char address, unsigned char reg, unsigned char data) |
Sends a byte to a device on the I²C bus. | |
int | i2c_puts (unsigned char address, unsigned char reg, unsigned char *data, size_t len) |
Sends a series of bytes to a device on the I²C bus. | |
int | i2c_getc (unsigned char address, unsigned char reg) |
Query a byte from a device on the I²C bus. If the reception succeeded, the I²C driver will be in the idle state when the operation is done. | |
int | i2c_gets (unsigned char address, unsigned char reg, size_t len) |
Query a series of bytes from a device on the I²C bus. If the reception succeeded, the I²C driver will be in the idle state when the operation is done. | |
int | i2c_getData (unsigned char *data, size_t len) |
Retrieve data captured from a previous i2c_getc()/i2c_gets() call. |
Variables | |
enum i2c_states | i2c_state |
The current I²C driver state. | |
volatile bool | i2c_stayInErrorState |
Decides whether the I²C driver should remain in the error state once it has entered it. | |
enum i2c_errors | i2c_error |
Contains the type of error that occured since last reset. |