CuVoodoo STM32F1 firmware template
Macros | Functions
i2c_master.c File Reference

library to communicate using I2C as master (code) More...

Go to the source code of this file.

Macros

#define I2C_MASTER_I2C   2
 I2C peripheral.
 
#define I2C_MASTER_TIMER   4
 timer peripheral
 
#define I2C_MASTER_TIMEOUT   4
 timeout factor (compared to expected time)
 

Functions

void i2c_master_setup (bool fast)
 setup I2C peripheral More...
 
bool i2c_master_read (uint8_t slave, const uint8_t *address, size_t address_size, uint8_t *data, size_t data_size)
 read from I2C slave More...
 
bool i2c_master_write (uint8_t slave, const uint8_t *address, size_t address_size, const uint8_t *data, size_t data_size)
 write to I2C slave More...
 

Detailed Description

library to communicate using I2C as master (code)

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2017
Note
peripherals used: I2C I2C peripheral used to communicate, timer timer peripheral used for timeouts

Definition in file i2c_master.c.

Function Documentation

◆ i2c_master_read()

bool i2c_master_read ( uint8_t  slave,
const uint8_t *  address,
size_t  address_size,
uint8_t *  data,
size_t  data_size 
)

read from I2C slave

Parameters
[in]slave7-bit I2C salve device address to read from
[in]addressmemory address of slave to read from
[in]address_sizeaddress size in bytes
[out]dataarray to store bytes read
[in]data_sizenumber of bytes to read
Returns
if read succeeded

Definition at line 97 of file i2c_master.c.

◆ i2c_master_setup()

void i2c_master_setup ( bool  fast)

setup I2C peripheral

Parameters
[in]fastuse standard (100 kHz) or fast (400 kHz) mode

Definition at line 50 of file i2c_master.c.

◆ i2c_master_write()

bool i2c_master_write ( uint8_t  slave,
const uint8_t *  address,
size_t  address_size,
const uint8_t *  data,
size_t  data_size 
)

write to I2C slave

Parameters
[in]slave7-bit I2C salve device address to write to
[in]addressmemory address of slave to write to
[in]address_sizeaddress size in bytes
[in]dataarray of byte to write to slave
[in]data_sizenumber of bytes to write
Returns
if write succeeded

Definition at line 216 of file i2c_master.c.