Skip to content

Commit 0ab4091

Browse files
xiaolusucfriedt
authored andcommitted
drivers: i2c_sedi: add API to retrieve current configuration
Introduced a API to get the current I2C configuration. Facilitates runtime inspection of I2C settings. Useful for debugging and dynamic configuration changes. Signed-off-by: Xiaolu Sun <[email protected]>
1 parent 0a9c763 commit 0ab4091

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/i2c/i2c_sedi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct i2c_sedi_context {
2525
int err;
2626
uint16_t addr_10bit;
2727
uint32_t bitrate;
28+
uint32_t cfg;
2829
};
2930

3031
struct i2c_sedi_config {
@@ -33,13 +34,23 @@ struct i2c_sedi_config {
3334
void (*irq_config)(const struct device *dev);
3435
};
3536

37+
static int i2c_sedi_api_get_config(const struct device *dev, uint32_t *dev_config)
38+
{
39+
struct i2c_sedi_context *const context = dev->data;
40+
41+
*dev_config = context->cfg;
42+
return 0;
43+
}
44+
3645
static int i2c_sedi_api_configure(const struct device *dev, uint32_t dev_config)
3746
{
3847
int ret;
3948
int speed = I2C_SPEED_GET(dev_config);
4049
int sedi_speed;
4150
struct i2c_sedi_context *const context = dev->data;
4251

52+
context->cfg = dev_config;
53+
4354
context->addr_10bit = (dev_config & I2C_ADDR_10_BITS) ? SEDI_I2C_ADDRESS_10BIT : 0;
4455

4556
if (speed == I2C_SPEED_STANDARD) {
@@ -119,6 +130,7 @@ static int i2c_sedi_api_full_io(const struct device *dev, struct i2c_msg *msgs,
119130
static DEVICE_API(i2c, i2c_sedi_apis) = {
120131
.configure = i2c_sedi_api_configure,
121132
.transfer = i2c_sedi_api_full_io,
133+
.get_config = i2c_sedi_api_get_config,
122134
#ifdef CONFIG_I2C_RTIO
123135
.iodev_submit = i2c_iodev_submit_fallback,
124136
#endif

0 commit comments

Comments
 (0)