13#include "hardware/i2c.h"
14#include "pico/i2c_slave.h"
15#include "pico/stdlib.h"
20#define I2C_STANDARD_MODE 100 * 1000
22#define I2C_FAST_MODE 400 * 1000
24#define I2C_FAST_MODE_PLUS 1000 * 1000
26#define I2C_SLAVE_DEFAULT_MAX_MEMORY_SIZE 256
65 i2c_inst_t *
i2c = i2c0;
91 i2c_inst_t *
i2c = i2c1;
134 uint time_out_us_per_byte;
struct_I2CXferResult burst_byte_write(uint8_t slave_address, uint8_t mem_addr, uint8_t *src, size_t len)
a convenient C++ member wrapper to write a block of data starting at a slave memory address....
Definition hw_i2c.cpp:28
struct_I2CXferResult single_byte_write(uint8_t slave_address, uint8_t mem_addr, uint8_t mem_value)
a convenient C++ member wrapper to write a single byte at a slave memory address. The operation is bo...
Definition hw_i2c.cpp:48
std::set< uint8_t > bus_scan()
A utility that scan the I2C bus and return the set of answering devices.
Definition hw_i2c.cpp:127
struct_I2CXferResult burst_byte_read(uint8_t slave_address, uint8_t mem_addr, uint8_t *dest, size_t len)
a convenient C++ member wrapper to read a block of data starting at a slave memory address....
Definition hw_i2c.cpp:97
bool device_is_connected(uint8_t slave_address)
utility to know if a device is connected
Definition hw_i2c.cpp:135
HW_I2C_Master(struct_ConfigMasterI2C master_config)
Construct a new hw i2c master object.
Definition hw_i2c.cpp:7
struct_I2CXferResult single_byte_read(uint8_t slave_address, uint8_t mem_addr, uint8_t *dest)
a convenient C++ member wrapper to read a single byte at a slave memory address. The operation is bou...
Definition hw_i2c.cpp:67
struct_SlaveMemory context
a data structure used to configure the slave device
Definition hw_i2c.h:228
void slave_isr(i2c_slave_event_t event)
this is the actual Interrupt Service Routine executed by the slave after each received data
Definition hw_i2c.cpp:143
HW_I2C_Slave(struct_ConfigSlaveI2C slave_config)
Construct a new hw i2c slave object.
Definition hw_i2c.cpp:174
#define I2C_SLAVE_DEFAULT_MAX_MEMORY_SIZE
I2C max buffer memory size, default to 256 words.
Definition hw_i2c.h:26
#define I2C_STANDARD_MODE
I2C standard mode speed 100kb/s.
Definition hw_i2c.h:20
The configuration data of I2C interface used as Master.
Definition hw_i2c.h:61
uint scl_pin
the associated gpio pin for clock
Definition hw_i2c.h:73
uint baud_rate
the I2C baudrate:
Definition hw_i2c.h:80
i2c_inst_t * i2c
the I2C interface used in the rp2040: i2c0 or i2c1
Definition hw_i2c.h:65
uint sda_pin
the associated gpio pin for data
Definition hw_i2c.h:69
The configuration data of I2C interface used as Slave.
Definition hw_i2c.h:87
size_t slave_memory_size
the size of the memory buffer reserved by the slave interface (default to 256)
Definition hw_i2c.h:114
uint scl_pin
the associated gpio pin for clock
Definition hw_i2c.h:99
i2c_inst_t * i2c
the I2C interface used in the rp2040: i2c0 or i2c1
Definition hw_i2c.h:91
uint sda_pin
the associated gpio pin for data
Definition hw_i2c.h:95
i2c_slave_handler_t handler
a function pointer to the IRQ handler, required by pico SDK, to the program that manage the reception...
Definition hw_i2c.h:121
uint baud_rate
the I2C baudrate:
Definition hw_i2c.h:106
uint8_t slave_address
the i2c slave address at which the interface responds
Definition hw_i2c.h:110
this data structure collects result when an I2C transfer is done. It gives a more verbose error descr...
Definition hw_i2c.h:33
bool error
flag that indicates if an error occurred.
Definition hw_i2c.h:38
int xfer_size
the number of byte transfered.
Definition hw_i2c.h:54
std::string context
a clear indication of where the error occurred:
Definition hw_i2c.h:49
this is the structure of the memory used by the slave i2c interface
Definition hw_i2c.h:203
uint8_t mem[256]
the size of the slave memory buffer
Definition hw_i2c.h:205
uint8_t mem_address
the addresse where the slave read/write. this chages for each exchange sequence, the slave points to ...
Definition hw_i2c.h:207
bool mem_address_written
falg that determine if the slave read or write to its memory buffer
Definition hw_i2c.h:209