ruuvi.drivers.c
${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
|
Interface for I2C operations. More...
#include "ruuvi_driver_enabled_modules.h"
#include "ruuvi_driver_error.h"
#include "ruuvi_interface_gpio.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | ri_i2c_init_config_t |
Enumerations | |
enum | ri_i2c_frequency_t { RI_I2C_FREQUENCY_100k , RI_I2C_FREQUENCY_250k , RI_I2C_FREQUENCY_400k } |
Functions | |
rd_status_t | ri_i2c_init (const ri_i2c_init_config_t *const config) |
Initialize I2C driver with given settings. More... | |
rd_status_t | ri_i2c_uninit (void) |
Uninitialize I2C. More... | |
bool | ri_i2c_is_init () |
Check if i2c driver is initialized. More... | |
rd_status_t | ri_i2c_read_blocking (const uint8_t address, uint8_t *const p_rx, const size_t rx_len) |
I2C read function. More... | |
rd_status_t | ri_i2c_write_blocking (const uint8_t address, uint8_t *const p_tx, const size_t tx_len, const bool stop) |
I2C read function. More... | |
Interface for I2C operations.
Definition in file ruuvi_interface_i2c.h.
enum ri_i2c_frequency_t |
Clock speed
Enumerator | |
---|---|
RI_I2C_FREQUENCY_100k | 100 kbps. |
RI_I2C_FREQUENCY_250k | 250 kbps. |
RI_I2C_FREQUENCY_400k | 400 kbps. |
Definition at line 32 of file ruuvi_interface_i2c.h.
rd_status_t ri_i2c_init | ( | const ri_i2c_init_config_t *const | config | ) |
Initialize I2C driver with given settings.
[in] | config | Configuration of the I2C peripheral. |
bool ri_i2c_is_init | ( | ) |
Check if i2c driver is initialized.
rd_status_t ri_i2c_read_blocking | ( | const uint8_t | address, |
uint8_t *const | p_rx, | ||
const size_t | rx_len | ||
) |
I2C read function.
Function is blocking and will not sleep while transaction is ongoing.
[in] | address | 7-bit I2C address of the device, without R/W bit. |
[out] | p_rx | pointer to data to be received |
[in] | rx_len | length of data to be received |
rd_status_t ri_i2c_uninit | ( | void | ) |
Uninitialize I2C.
rd_status_t ri_i2c_write_blocking | ( | const uint8_t | address, |
uint8_t *const | p_tx, | ||
const size_t | tx_len, | ||
const bool | stop | ||
) |
I2C read function.
Function is blocking and will not sleep while transaction is ongoing.
[in] | address | 7-bit I2C address of the device, without R/W bit. |
[out] | p_tx | pointer to data to be transmitted |
[in] | tx_len | length of data to be transmitted |
[in] | stop | true to transmit stop condition after read, false to hold bus active. |