ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_i2c.h
Go to the documentation of this file.
1 #ifndef RUUVI_INTERFACE_I2C_H
2 #define RUUVI_INTERFACE_I2C_H
4 #include "ruuvi_driver_error.h"
5 #include "ruuvi_interface_gpio.h"
6 #include <stdbool.h>
7 #include <stddef.h>
8 #include <stdint.h>
9 
25 #if RI_I2C_ENABLED
26 # define RUUVI_NRF5_SDK15_I2C_ENABLED RUUVI_NRF5_SDK15_ENABLED
27 #endif
28 
32 typedef enum
33 {
38 
42 typedef struct
43 {
50 
58  const config);
59 
66 
73 
83 rd_status_t ri_i2c_read_blocking (const uint8_t address,
84  uint8_t * const p_rx, const size_t rx_len);
85 
96 rd_status_t ri_i2c_write_blocking (const uint8_t address,
97  uint8_t * const p_tx, const size_t tx_len, const bool stop);
98 /* @} */
99 #endif
uint32_t rd_status_t
bitfield for representing errors
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
uint16_t ri_gpio_id_t
port<<8 + pin
rd_status_t ri_i2c_init(const ri_i2c_init_config_t *const config)
Initialize I2C driver with given settings.
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.
bool ri_i2c_is_init()
Check if i2c driver is initialized.
rd_status_t ri_i2c_uninit(void)
Uninitialize I2C.
ri_i2c_frequency_t
@ RI_I2C_FREQUENCY_250k
250 kbps.
@ RI_I2C_FREQUENCY_400k
400 kbps.
@ RI_I2C_FREQUENCY_100k
100 kbps.
rd_status_t ri_i2c_read_blocking(const uint8_t address, uint8_t *const p_rx, const size_t rx_len)
I2C read function.
ri_gpio_id_t bus_pwr
Power to pull-ups, UNUSED if fixed.
ri_gpio_id_t sda
pin number of SDA
ri_i2c_frequency_t frequency
Frequency of I2C Bus, see ri_i2c_frequency_t.
ri_gpio_id_t scl
pin number of SCL