28 #include <libopencm3/stm32/rcc.h> 29 #include <libopencm3/stm32/gpio.h> 30 #include <libopencm3/stm32/i2c.h> 31 #include <libopencm3/stm32/timer.h> 40 #define I2C_GENERAL_I2C 2 46 #define I2C_GENERAL_TIMER 3 47 #define I2C_GENERAL_TIMEOUT 4 50 void i2c_general_setup_master(bool fast) 59 rcc_periph_clock_enable(RCC_AFIO);
160 if (data==NULL || data_size==0) {
171 for (
size_t i=0; i<data_size; i++) {
172 if (i==data_size-1) {
196 if (data==NULL || data_size==0) {
207 for (
size_t i=0; i<data_size; i++) {
#define I2C_SCL_PORT(x)
get I2C port for SCL pin based on I2C identifier
#define I2C(x)
get I2C based on I2C identifier
bool i2c_general_select_slave(uint8_t slave, bool write)
select slave device
#define I2C_SDA_PIN(x)
get I2C port for SDA pin based on I2C identifier
global definitions and methods (API)
#define I2C_SDA_PORT(x)
get I2C port for SDA pin based on I2C identifier
#define RCC_TIM(x)
get RCC for timer based on TIM identifier
bool i2c_general_read(uint8_t *data, size_t data_size)
read data
bool i2c_general_check(void)
check if SDA and SCL signals are high
#define I2C_GENERAL_TIMEOUT
timeout factor (compared to expected time)
#define I2C_GENERAL_I2C
I2C peripheral.
library to communicate using I2C as master or slave (API)
void i2c_general_stop(void)
sent stop condition
#define I2C_SCL_PIN(x)
get I2C pin for SCL pin based on I2C identifier
bool i2c_general_start(void)
send start condition
#define RCC_I2C_SCL_PORT(x)
get RCC for GPIO port for SCL based on I2C identifier
bool i2c_general_write(const uint8_t *data, size_t data_size)
write data
#define TIM(x)
get TIM based on TIM identifier
#define I2C_GENERAL_TIMER
timer peripheral
#define RCC_I2C(x)
get RCC for I2C based on I2C identifier