rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
|
Provides functions for I2C bus manipulation. More...
Enumerations | |
enum | rflpc_i2c_port_t { RFLPC_I2C_PORT0, RFLPC_I2C_PORT1, RFLPC_I2C_PORT2 } |
These constants selects which port the driver functions manipulate. More... | |
enum | rflpc_i2c_mode_t { RFLPC_I2C_MODE_MASTER, RFLPC_I2C_MODE_SLAVE } |
Defines the operating mode of the I2C bus. More... | |
enum | rflpc_i2c_status_t { RFLPC_I2C_SUCCESSFUL_TRANSMISSION = 0, RFLPC_I2C_SIZE_EQUAL_TO_ZERO, RFLPC_I2C_SLAVE_IS_BUSY, RFLPC_I2C_SLAVE_DID_NOT_ACKNOWLEDGED_DATA, RFLPC_I2C_MASTER_DID_NOT_ACKNOWLEDGED_DATA, RFLPC_I2C_STOP_CONDITION_RECEIVED, RFLPC_I2C_SLAVE_TRANSMITTED_DATA, RFLPC_I2C_UNKNOWN_ERROR, RFLPC_I2C_NOT_YET_IMPLEMENTED } |
Defines the return status of the I2C driver. More... | |
Functions | |
int | rflpc_i2c_init (rflpc_i2c_port_t port, rflpc_i2c_mode_t mode, uint8_t addr) |
Inits a given I2C port on a given mode. More... | |
uint16_t | rflpc_i2c_write (rflpc_i2c_port_t port, uint8_t addr, uint8_t *data, uint8_t nbytes, uint8_t stop) |
Send bytes on the I2C bus. More... | |
uint16_t | rflpc_i2c_read (rflpc_i2c_port_t port, uint8_t addr, uint8_t *data, uint8_t nbytes, uint8_t stop) |
Reads data from the I2C bus. More... | |
void | rflpc_i2c_set_slave_transmitter_config (uint8_t *data, uint8_t size) |
Set data's location and size to be transmitted as slave. More... | |
Provides functions for I2C bus manipulation.
enum rflpc_i2c_mode_t |
enum rflpc_i2c_port_t |
enum rflpc_i2c_status_t |
int rflpc_i2c_init | ( | rflpc_i2c_port_t | port, |
rflpc_i2c_mode_t | mode, | ||
uint8_t | addr | ||
) |
Inits a given I2C port on a given mode.
port | The I2C port to initialize (cf. rflpc_i2c_port_t) |
mode | The I2C mode to use (cf. rflpc_i2c_mode_t) |
addr | If Slave mode is requested, this parameter is the I2C address of |
uint16_t rflpc_i2c_read | ( | rflpc_i2c_port_t | port, |
uint8_t | addr, | ||
uint8_t * | data, | ||
uint8_t | nbytes, | ||
uint8_t | stop | ||
) |
Reads data from the I2C bus.
[in] | port | The I2C port to read on. |
[in] | addr | The I2C address of the slave from which a message will be read. |
[in] | data | A pointer to a data buffer where the message will be stored. |
[in] | nbytes | The expected number of bytes to be received. |
[in] | stop | If equal to zero, the driver will send a RESTART condition instead of a STOP condition at the end of transmission. |
void rflpc_i2c_set_slave_transmitter_config | ( | uint8_t * | data, |
uint8_t | size | ||
) |
Set data's location and size to be transmitted as slave.
[in] | data | A pointer to the data to be transmitted. |
[in] | size | Size in bytes of the data to be transmitted. |
uint16_t rflpc_i2c_write | ( | rflpc_i2c_port_t | port, |
uint8_t | addr, | ||
uint8_t * | data, | ||
uint8_t | nbytes, | ||
uint8_t | stop | ||
) |
Send bytes on the I2C bus.
[in] | port | The I2C port to write on. |
[in] | addr | The I2C address of the slave to which the message will be sent. This parameter has no effect if Slave mode is set. |
[in] | data | A pointer to the data buffer to be transmitted. |
[in] | nbytes | The number of bytes to be transmitted. |
[in] | stop | If equal to zero, the driver will send a RESTART condition instead of a STOP condition at the end of transmission. |