|
Lamp-Da 0.1
A compact lantern project
|
Interface for the platform specific i2c protocols. More...
Go to the source code of this file.
Namespaces | |
| namespace | lampda |
| Program scope. | |
| namespace | lampda::platform |
| Handle the platform specific interactions. | |
Functions | |
| void | lampda::platform::i2c::i2c_setup (uint8_t i2cIndex, uint32_t baudrate, uint32_t timeout) |
| Setup the i2c interface, needs to be called at program start. | |
| void | lampda::platform::i2c::i2c_turn_off (uint8_t i2cIndex) |
| Turn of the i2c interface, all i2c functions will return an error after that, until i2c_setup is called again. | |
| int | lampda::platform::i2c::i2c_check_existence (uint8_t i2cIndex, uint8_t deviceAddr) |
| Return 0 if the address exists on the I2C line. | |
| int | lampda::platform::i2c::lock_i2c () |
| int | lampda::platform::i2c::unlock_i2c () |
| int | lampda::platform::i2c::i2c_writeData (uint8_t i2cIndex, uint8_t deviceAddr, uint8_t registerAdd, uint8_t size, const uint8_t *buf, int stopBit) |
| Write data to the two wire interface. | |
| int | lampda::platform::i2c::i2c_readData (uint8_t i2cIndex, uint8_t deviceAddr, uint8_t registerAdd, uint8_t size, uint8_t *buf, int stopBit) |
| Read data from the two wire interface. | |
| int | lampda::platform::i2c::i2c_xfer_unlocked (uint8_t i2cIndex, uint8_t deviceAddr, int out_size, const uint8_t *out, int in_size, uint8_t *in, uint8_t flags) |
| Does a range read/write. | |
| int | lampda::platform::i2c::i2c_xfer (uint8_t i2cIndex, uint8_t deviceAddr, int out_size, const uint8_t *out, int in_size, uint8_t *in, uint8_t flags) |
| Does a range read/write. | |
| int | lampda::platform::i2c::i2c_read8 (uint8_t i2cIndex, uint8_t deviceAddr, uint8_t registerAdd, uint8_t *val, int stopBit) |
| Read 8bits from the two wire interface. | |
| int | lampda::platform::i2c::i2c_write8 (uint8_t i2cIndex, uint8_t deviceAddr, uint8_t registerAdd, uint8_t val, int stopBit) |
| Write 8bits from the two wire interface. | |
| int | lampda::platform::i2c::i2c_read16 (uint8_t i2cIndex, uint8_t deviceAddr, uint8_t registerAdd, uint16_t *val, int stopBit) |
| Read 16bits from the two wire interface. | |
| int | lampda::platform::i2c::i2c_write16 (uint8_t i2cIndex, uint8_t deviceAddr, uint8_t registerAdd, uint16_t val, int stopBit) |
| Write 16bits from the two wire interface. | |
Interface for the platform specific i2c protocols.
|
inline |
Read 16bits from the two wire interface.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | deviceAddr | the address of the target device |
| [in] | registerAdd | The address of the register to read |
| [in] | val | The value read from register |
| [in] | stopBit | if > 0, will add a stopBit after message |
|
inline |
Read 8bits from the two wire interface.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | deviceAddr | the address of the target device |
| [in] | registerAdd | The address of the register to read |
| [in] | val | The value read from register |
| [in] | stopBit | if > 0, will add a stopBit after message |
| int lampda::platform::i2c::i2c_readData | ( | uint8_t | i2cIndex, |
| uint8_t | deviceAddr, | ||
| uint8_t | registerAdd, | ||
| uint8_t | size, | ||
| uint8_t * | buf, | ||
| int | stopBit | ||
| ) |
Read data from the two wire interface.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | deviceAddr | the address of the target device |
| [in] | registerAdd | The address of the register to read |
| [in] | size | the size of the data to read (in bytes) |
| [in,out] | buf | the data to read, in an array of size size |
| [in] | stopBit | if > 0, will add a stopBit after message |
| void lampda::platform::i2c::i2c_setup | ( | uint8_t | i2cIndex, |
| uint32_t | baudrate, | ||
| uint32_t | timeout | ||
| ) |
Setup the i2c interface, needs to be called at program start.
Define the general i2c interface (in c style for compatibility) ALL FUNCTION RETURN 0 IN CASE OF SUCCESS !! THEY RETURN 1 IN FAILURE This is C style, not C++
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | baudrate | The baud rate of this interface (100000, 250000, 400000) in hertz |
| [in] | timeout | The tiemout in milliseconds after which a read or write fails |
| void lampda::platform::i2c::i2c_turn_off | ( | uint8_t | i2cIndex | ) |
Turn of the i2c interface, all i2c functions will return an error after that, until i2c_setup is called again.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
|
inline |
Write 16bits from the two wire interface.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | deviceAddr | the address of the target device |
| [in] | registerAdd | The address of the register to write |
| [in] | val | The value written to register |
| [in] | stopBit | if > 0, will add a stopBit after message |
|
inline |
Write 8bits from the two wire interface.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | deviceAddr | the address of the target device |
| [in] | registerAdd | The address of the register to write |
| [in] | val | The value written to register |
| [in] | stopBit | if > 0, will add a stopBit after message |
| int lampda::platform::i2c::i2c_writeData | ( | uint8_t | i2cIndex, |
| uint8_t | deviceAddr, | ||
| uint8_t | registerAdd, | ||
| uint8_t | size, | ||
| const uint8_t * | buf, | ||
| int | stopBit | ||
| ) |
Write data to the two wire interface.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | deviceAddr | the address of the target device |
| [in] | registerAdd | The address of the register to write |
| [in] | size | the size of the data to write (in bytes) |
| [in,out] | buf | the data to write, in an array of size size |
| [in] | stopBit | if > 0, will add a stopBit after message |
|
inline |
Does a range read/write.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | deviceAddr | the address of the target device |
| [in] | out_size | Size of the out buffer to read |
| [out] | out | The buffer that will contain the read data |
| [in] | in_size | Size of the in buffer to write |
| [in] | in | The buffer that contains the write data |
| [in] | flags | Flags to set the stop bit, start/stop info, etc |
| int lampda::platform::i2c::i2c_xfer_unlocked | ( | uint8_t | i2cIndex, |
| uint8_t | deviceAddr, | ||
| int | out_size, | ||
| const uint8_t * | out, | ||
| int | in_size, | ||
| uint8_t * | in, | ||
| uint8_t | flags | ||
| ) |
Does a range read/write.
| [in] | i2cIndex | The index of the i2c interface (from 0 to WIRE_INTERFACES_COUNT - 1) |
| [in] | deviceAddr | the address of the target device |
| [in] | out_size | Size of the out buffer to read |
| [out] | out | The buffer that will contain the read data |
| [in] | in_size | Size of the in buffer to write |
| [in] | in | The buffer that contains the write data |
| [in] | flags | Flags to set the stop bit, start/stop info, etc |