-
Notifications
You must be signed in to change notification settings - Fork 0
i2c.h
Go to the source code for i2c.h
#include "common.h"
#include "gpio.h"
InitializeI2C
I2CSuccess
I2CBackgroundSend
I2CSend
I2CBackgroundReceive
I2CReceive
I2CBackgroundRequest
I2CRequest
Initializes an I2C module on a pair of pins
tI2C *InitializeI2C(tPin sda, tPin scl);
Parameters:
-
sda
[TODO: describe sda] -
scl
[TODO: describe scl]
Returns:
- Pointer to a I2C module used by other i2c functions
Checks if the previous i2c transaction was successful
tBoolean I2CSuccess(tI2C *i2c);
Parameters:
-
i2c
An initialized I2C module, which is returned by InitializeI2C
Returns:
- true if the previous i2c transaction was successful
Sends data to an I2C address
void I2CBackgroundSend(tI2C *i2c, unsigned char addr, const unsigned char *data, unsigned int len, tCallback callback, void *cbdata);
Parameters:
-
i2c
An initialized I2C module, which is returned by InitializeI2C -
addr
I2C address where data is being sent -
data
Pointer to array of byes being sent -
len
Number of bytes in data array -
callback
Function that will be called when the data has been sent -
cbdata
Argument sent to the callback whenever it is called
Sends data to an I2C address
tBoolean I2CSend(tI2C *i2c, unsigned char addr, const unsigned char *data, unsigned int len);
Parameters:
-
i2c
An initialized I2C module, which is returned by InitializeI2C -
addr
I2C address where data is being sent -
data
Pointer to array of byes being sent -
len
Number of bytes in data array
Returns:
- true if successful
Receives data from an I2C address
void I2CBackgroundReceive(tI2C *i2c, unsigned char addr, unsigned char *data, unsigned int len, tCallback callback, void *cbdata);
Parameters:
-
i2c
An initialized I2C module, which is returned by InitializeI2C -
addr
I2C address where data is being received -
data
Pointer to array of byes to store the data received -
len
Number of bytes allocated in the data array -
callback
Function that will be called when all of the data is received -
cbdata
Argument sent to the callback whenever it is called
Receives data from an I2C address
tBoolean I2CReceive(tI2C *i2c, unsigned char addr, unsigned char* data, unsigned int len);
Parameters:
-
i2c
An initialized I2C module, which is returned by InitializeI2C -
addr
I2C address where data is being received -
data
Pointer to array of byes to store the data received -
len
Number of bytes allocated in the data array
Returns:
- true if successful
Requests data from an I2C address (nonblocking). This is the same as two sequential send and recieve calls but takes place in the internal state machine.
void I2CBackgroundRequest(tI2C *i2c, unsigned char addr, const unsigned char *sendData, unsigned int sendLen, unsigned char *recData, unsigned int recLen, tCallback callback, void *cbdata);
Parameters:
-
i2c
An initialized I2C module, which is returned by InitializeI2C -
addr
I2C address where data is being requested -
sendData
Pointer to array of byes being sent -
sendLen
Number of bytes allocated in the send data array -
recData
Pointer to array of byes to store the data received -
recLen
Number of bytes allocated in the receive data array -
callback
Function that will be called when all of the data is received -
cbdata
Argument sent to the callback whenever it is called
Requests data from an I2C address (blocking). This is the same as two sequential send and recieve calls but takes place in the internal state machine.
tBoolean I2CRequest(tI2C *i2c, unsigned char addr, const unsigned char *sendData, unsigned int sendLen, unsigned char *recData, unsigned int recLen);
Parameters:
-
i2c
An initialized I2C module, which is returned by InitializeI2C -
addr
I2C address where data is being requested -
sendData
Pointer to array of byes being sent -
sendLen
Number of bytes allocated in the send data array -
recData
Pointer to array of byes to store the data received -
recLen
Number of bytes allocated in the receive data array
Returns:
- true if successful