pw_i2c#
Cross-platform I2C API with interactive debugging
Stable C++17
#include "pw_i2c_rp2040/initiator.h"
#include "hardware/i2c.h"
constexpr pw::i2c::Rp2040Initiator::Config ki2cConfig{
.clock_frequency_hz = 400'000,
.sda_pin = 8,
.scl_pin = 9,
};
pw::i2c::Rp2040Initiator i2c_bus(ki2cConfig, i2c0);
// Calls these Pico SDK functions:
// * gpio_set_function(8, GPIO_FUNC_I2C)
// * gpio_set_function(9, GPIO_FUNC_I2C)
i2c_bus.Enable();
cc_library(
# ...
deps = [
# ...
"@pigweed//pw_i2c:address",
"@pigweed//pw_i2c:device",
# ...
] + select({
"@platforms//os:freertos": [
"@pigweed//pw_i2c_rp2040:initiator",
],
"//conditions:default": [
# Fake example of a custom implementation.
"//lib/pw_i2c_my_device:initiator",
],
}),
)
pw_i2c
provides C++ libraries and helpers for interacting with I2C
devices.