This module provides the hardware-specific implementation of the EmbeddedComm protocol for the Raspberry Pi Pico (RP2040/RP2350) using the I2C interface. It bridges the abstract GenericMaster and GenericSlave logic with the Raspberry Pi Pico C/C++ SDK.
Parent: GenericMaster<uint8_t>
Implements the master-side driver. It wraps the standard hardware_i2c blocking API.
picoMasterI2C(
uint8_t scl,
uint8_t sda,
i2c_inst_t *i2c,
uint32_t i2cFreqKHz
);- scl: GPIO pin number for Serial Clock.
- sda: GPIO pin number for Serial Data.
- i2c: Pointer to the I2C instance (
i2c0ori2c1). - i2cFreqKHz: Bus frequency in kHz (e.g., 100, 400).
Header: picoSlaveI2C.hpp
Parent: GenericSlave
Implements the slave-side driver using interrupt-driven I2C.
void initialize(
uint8_t scl,
uint8_t sda,
i2c_inst_t *i2c,
uint32_t i2cFreqKHz,
uint8_t i2c_address,
uint8_t *memory,
uint32_t memorySize
);- scl/sda: GPIO pins for I2C.
- i2c: I2C instance (
i2c0ori2c1). - i2cFreqKHz: Bus frequency.
- i2c_address: The 7-bit I2C address for this slave.
- memory: Pointer to the buffer serving as the slave's memory map.
- memorySize: Size of the memory buffer.
The class uses a static context mapping system to route C-style hardware interrupts to the correct C++ object instance.
- Limitation: You can create only one
picoSlaveI2Cobject per hardware I2C block (i2c0andi2c1). Creating a second object for the same hardware block will overwrite the interrupt context of the first.
- Hardware: Raspberry Pi Pico (RP2040) or Pico 2 (RP2350).
- SDK:
pico-sdk(Requireshardware_i2candhardware_gpiolibraries). - Library:
pico_i2c_slave(Ensure yourCMakeLists.txtlinks against the I2C slave library implementation).