i2c: Update API terminology
Updates the API and types to match updated I2C terminology. Replaces master with controller and slave with target. Updates all drivers to match the changed macros, types, and API signatures. Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This commit is contained in:
parent
19f8ba6a04
commit
88ca215eed
|
@ -291,7 +291,7 @@
|
|||
/drivers/i2c/i2c_shell.c @nashif
|
||||
/drivers/i2c/Kconfig.i2c_emul @sjg20
|
||||
/drivers/i2c/Kconfig.it8xxx2 @GTLin08
|
||||
/drivers/i2c/slave/*eeprom* @henrikbrixandersen
|
||||
/drivers/i2c/target/*eeprom* @henrikbrixandersen
|
||||
/drivers/i2c/Kconfig.test @mbolivar-nordic
|
||||
/drivers/i2c/i2c_test.c @mbolivar-nordic
|
||||
/drivers/i2c/*rcar* @aaillet
|
||||
|
|
|
@ -152,7 +152,7 @@ current :ref:`stability level <api_lifecycle>`.
|
|||
- 1.14
|
||||
- 3.1
|
||||
|
||||
* - :ref:`i2c_eeprom_slave_api`
|
||||
* - :ref:`i2c_eeprom_target_api`
|
||||
- Stable
|
||||
- 1.13
|
||||
- 1.13
|
||||
|
@ -162,7 +162,7 @@ current :ref:`stability level <api_lifecycle>`.
|
|||
- 1.0
|
||||
- 3.1
|
||||
|
||||
* - :ref:`i2c-slave-api`
|
||||
* - :ref:`i2c-target-api`
|
||||
- Experimental
|
||||
- 1.12
|
||||
- 1.12
|
||||
|
|
|
@ -6,6 +6,12 @@ I2C
|
|||
Overview
|
||||
********
|
||||
|
||||
.. note::
|
||||
|
||||
The terminology used in Zephyr I2C APIs follows that of the
|
||||
`NXP I2C Bus Specification Rev 7.0 <i2c-specification>`_. These changed
|
||||
from previous revisions as of its release October 1, 2021.
|
||||
|
||||
`I2C <i2c-specification>`_ (Inter-Integrated Circuit, pronounced "eye
|
||||
squared see") is a commonly-used two-signal shared peripheral interface
|
||||
bus. Many system-on-chip solutions provide controllers that communicate
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
.. _i2c_eeprom_slave_api:
|
||||
|
||||
I2C EEPROM Slave
|
||||
################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
API Reference
|
||||
**************
|
||||
|
||||
.. doxygengroup:: i2c_eeprom_slave_api
|
12
doc/hardware/peripherals/i2c_eeprom_target.rst
Normal file
12
doc/hardware/peripherals/i2c_eeprom_target.rst
Normal file
|
@ -0,0 +1,12 @@
|
|||
.. _i2c_eeprom_target_api:
|
||||
|
||||
I2C EEPROM Target
|
||||
#################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
API Reference
|
||||
**************
|
||||
|
||||
.. doxygengroup:: i2c_eeprom_target_api
|
|
@ -23,7 +23,7 @@ Peripherals
|
|||
gna.rst
|
||||
gpio.rst
|
||||
hwinfo.rst
|
||||
i2c_eeprom_slave.rst
|
||||
i2c_eeprom_target.rst
|
||||
i2c.rst
|
||||
ipm.rst
|
||||
kscan.rst
|
||||
|
|
|
@ -178,7 +178,7 @@ int ataes132a_init(const struct device *dev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
i2c_cfg = I2C_MODE_MASTER | I2C_SPEED_SET(ATAES132A_BUS_SPEED);
|
||||
i2c_cfg = I2C_MODE_CONTROLLER | I2C_SPEED_SET(ATAES132A_BUS_SPEED);
|
||||
|
||||
i2c_configure(ataes132a->i2c, i2c_cfg);
|
||||
|
||||
|
|
|
@ -52,4 +52,4 @@ zephyr_library_sources_ifdef(CONFIG_I2C_TEST i2c_test.c)
|
|||
|
||||
zephyr_library_sources_ifdef(CONFIG_USERSPACE i2c_handlers.c)
|
||||
|
||||
add_subdirectory_ifdef(CONFIG_I2C_SLAVE slave)
|
||||
add_subdirectory_ifdef(CONFIG_I2C_TARGET target)
|
||||
|
|
|
@ -34,7 +34,7 @@ source "drivers/i2c/Kconfig.b91"
|
|||
source "drivers/i2c/Kconfig.cc13xx_cc26xx"
|
||||
source "drivers/i2c/Kconfig.dw"
|
||||
source "drivers/i2c/Kconfig.esp32"
|
||||
source "drivers/i2c/slave/Kconfig"
|
||||
source "drivers/i2c/target/Kconfig"
|
||||
source "drivers/i2c/Kconfig.gpio"
|
||||
source "drivers/i2c/Kconfig.xec"
|
||||
source "drivers/i2c/Kconfig.nrfx"
|
||||
|
|
|
@ -17,7 +17,7 @@ config I2C_STM32_V1
|
|||
bool
|
||||
default $(dt_compat_enabled,$(DT_COMPAT_ST_STM32_I2C_V1))
|
||||
select USE_STM32_LL_I2C
|
||||
select I2C_STM32_INTERRUPT if I2C_SLAVE
|
||||
select I2C_STM32_INTERRUPT if I2C_TARGET
|
||||
help
|
||||
Driver variant matching `st,stm32-i2c-v1` compatible.
|
||||
|
||||
|
@ -26,10 +26,10 @@ config I2C_STM32_V2
|
|||
default $(dt_compat_enabled,$(DT_COMPAT_ST_STM32_I2C_V2))
|
||||
select USE_STM32_LL_I2C
|
||||
select USE_STM32_LL_RCC if SOC_SERIES_STM32F0X || SOC_SERIES_STM32F3X
|
||||
select I2C_STM32_INTERRUPT if I2C_SLAVE
|
||||
select I2C_STM32_INTERRUPT if I2C_TARGET
|
||||
help
|
||||
Driver variant matching `st,stm32-i2c-v2` compatible.
|
||||
If I2C_SLAVE is enabled it selects I2C_STM32_INTERRUPT, since slave mode
|
||||
If I2C_TARGET is enabled it selects I2C_STM32_INTERRUPT, since target mode
|
||||
is only supported by this driver with interrupts enabled.
|
||||
|
||||
config I2C_STM32_INTERRUPT
|
||||
|
|
|
@ -41,7 +41,7 @@ static int i2c_b91_configure(const struct device *dev, uint32_t dev_config)
|
|||
}
|
||||
|
||||
/* check I2C Master/Slave configuration */
|
||||
if (!(dev_config & I2C_MODE_MASTER)) {
|
||||
if (!(dev_config & I2C_MODE_CONTROLLER)) {
|
||||
LOG_ERR("I2C slave is not implemented");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ static int i2c_b91_init(const struct device *dev)
|
|||
int status = 0;
|
||||
const struct i2c_b91_cfg *cfg = dev->config;
|
||||
struct i2c_b91_data *data = dev->data;
|
||||
uint32_t dev_config = (I2C_MODE_MASTER | i2c_map_dt_bitrate(cfg->bitrate));
|
||||
uint32_t dev_config = (I2C_MODE_CONTROLLER | i2c_map_dt_bitrate(cfg->bitrate));
|
||||
|
||||
/* init mutex */
|
||||
k_sem_init(&data->mutex, 1, 1);
|
||||
|
|
|
@ -245,7 +245,7 @@ static int i2c_cc13xx_cc26xx_configure(const struct device *dev,
|
|||
}
|
||||
|
||||
/* Support for slave mode has not been implemented */
|
||||
if (!(dev_config & I2C_MODE_MASTER)) {
|
||||
if (!(dev_config & I2C_MODE_CONTROLLER)) {
|
||||
LOG_ERR("Slave mode is not supported");
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ static int i2c_cc13xx_cc26xx_init(const struct device *dev)
|
|||
}
|
||||
|
||||
cfg = i2c_map_dt_bitrate(DT_INST_PROP(0, clock_frequency));
|
||||
err = i2c_cc13xx_cc26xx_configure(dev, cfg | I2C_MODE_MASTER);
|
||||
err = i2c_cc13xx_cc26xx_configure(dev, cfg | I2C_MODE_CONTROLLER);
|
||||
if (err) {
|
||||
LOG_ERR("Failed to configure");
|
||||
return err;
|
||||
|
|
|
@ -84,7 +84,7 @@ static int i2c_cc32xx_configure(const struct device *dev,
|
|||
uint32_t base = DEV_BASE(dev);
|
||||
uint32_t bitrate_id;
|
||||
|
||||
if (!(dev_config_raw & I2C_MODE_MASTER)) {
|
||||
if (!(dev_config_raw & I2C_MODE_CONTROLLER)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ static int i2c_cc32xx_init(const struct device *dev)
|
|||
|
||||
/* Set to default configuration: */
|
||||
bitrate_cfg = i2c_map_dt_bitrate(config->bitrate);
|
||||
error = i2c_cc32xx_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
error = i2c_cc32xx_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ static inline void i2c_dw_transfer_complete(const struct device *dev)
|
|||
k_sem_give(&dw->device_sync_sem);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
static inline uint8_t i2c_dw_read_byte_non_blocking(const struct device *dev);
|
||||
static inline void i2c_dw_write_byte_non_blocking(const struct device *dev, uint8_t data);
|
||||
static void i2c_dw_slave_read_clear_intr_bits(const struct device *dev);
|
||||
|
@ -275,8 +275,8 @@ static void i2c_dw_isr(const struct device *port)
|
|||
}
|
||||
|
||||
} else {
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
const struct i2c_slave_callbacks *slave_cb = dw->slave_cfg->callbacks;
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
const struct i2c_target_callbacks *slave_cb = dw->slave_cfg->callbacks;
|
||||
uint32_t slave_activity = test_bit_status_activity(reg_base);
|
||||
uint8_t data;
|
||||
|
||||
|
@ -338,7 +338,7 @@ static int i2c_dw_setup(const struct device *dev, uint16_t slave_address)
|
|||
value = read_clr_intr(reg_base);
|
||||
|
||||
/* Set master or slave mode - (initialization = slave) */
|
||||
if (I2C_MODE_MASTER & dw->app_config) {
|
||||
if (I2C_MODE_CONTROLLER & dw->app_config) {
|
||||
/*
|
||||
* Make sure to set both the master_mode and slave_disable_bit
|
||||
* to both 0 or both 1
|
||||
|
@ -432,7 +432,7 @@ static int i2c_dw_setup(const struct device *dev, uint16_t slave_address)
|
|||
* bit in ic_tar register would control whether the DW_apb_i2c starts
|
||||
* its transfers in 7-bit or 10-bit addressing mode.
|
||||
*/
|
||||
if (I2C_MODE_MASTER & dw->app_config) {
|
||||
if (I2C_MODE_CONTROLLER & dw->app_config) {
|
||||
if (I2C_ADDR_10_BITS & dw->app_config) {
|
||||
ic_tar.bits.ic_10bitaddr_master = 1U;
|
||||
} else {
|
||||
|
@ -654,12 +654,12 @@ static int i2c_dw_runtime_configure(const struct device *dev, uint32_t config)
|
|||
* currently. This "hack" forces us to always be configured for master
|
||||
* mode, until we can verify that Slave mode works correctly.
|
||||
*/
|
||||
dw->app_config |= I2C_MODE_MASTER;
|
||||
dw->app_config |= I2C_MODE_CONTROLLER;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
static inline uint8_t i2c_dw_read_byte_non_blocking(const struct device *dev)
|
||||
{
|
||||
uint32_t reg_base = get_regs(dev);
|
||||
|
@ -735,7 +735,7 @@ static int i2c_dw_set_slave_mode(const struct device *dev, uint8_t addr)
|
|||
}
|
||||
|
||||
static int i2c_dw_slave_register(const struct device *dev,
|
||||
struct i2c_slave_config *cfg)
|
||||
struct i2c_target_config *cfg)
|
||||
{
|
||||
struct i2c_dw_dev_config * const dw = dev->data;
|
||||
uint32_t reg_base = get_regs(dev);
|
||||
|
@ -753,7 +753,7 @@ static int i2c_dw_slave_register(const struct device *dev,
|
|||
}
|
||||
|
||||
static int i2c_dw_slave_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *cfg)
|
||||
struct i2c_target_config *cfg)
|
||||
{
|
||||
struct i2c_dw_dev_config * const dw = dev->data;
|
||||
int ret;
|
||||
|
@ -770,7 +770,7 @@ static void i2c_dw_slave_read_clear_intr_bits(const struct device *dev)
|
|||
union ic_interrupt_register intr_stat;
|
||||
uint32_t reg_base = get_regs(dev);
|
||||
|
||||
const struct i2c_slave_callbacks *slave_cb = dw->slave_cfg->callbacks;
|
||||
const struct i2c_target_callbacks *slave_cb = dw->slave_cfg->callbacks;
|
||||
|
||||
intr_stat.raw = read_intr_stat(reg_base);
|
||||
|
||||
|
@ -822,15 +822,15 @@ static void i2c_dw_slave_read_clear_intr_bits(const struct device *dev)
|
|||
dw->state = I2C_DW_STATE_READY;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_I2C_SLAVE */
|
||||
#endif /* CONFIG_I2C_TARGET */
|
||||
|
||||
static const struct i2c_driver_api funcs = {
|
||||
.configure = i2c_dw_runtime_configure,
|
||||
.transfer = i2c_dw_transfer,
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
.slave_register = i2c_dw_slave_register,
|
||||
.slave_unregister = i2c_dw_slave_unregister,
|
||||
#endif /* CONFIG_I2C_SLAVE */
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
.target_register = i2c_dw_slave_register,
|
||||
.target_unregister = i2c_dw_slave_unregister,
|
||||
#endif /* CONFIG_I2C_TARGET */
|
||||
};
|
||||
|
||||
static int i2c_dw_initialize(const struct device *dev)
|
||||
|
@ -892,7 +892,7 @@ static int i2c_dw_initialize(const struct device *dev)
|
|||
|
||||
rom->config_func(dev);
|
||||
|
||||
dw->app_config = I2C_MODE_MASTER | i2c_map_dt_bitrate(rom->bitrate);
|
||||
dw->app_config = I2C_MODE_CONTROLLER | i2c_map_dt_bitrate(rom->bitrate);
|
||||
|
||||
if (i2c_dw_runtime_configure(dev, dw->app_config) != 0) {
|
||||
LOG_DBG("I2C: Cannot set default configuration");
|
||||
|
|
|
@ -119,7 +119,7 @@ struct i2c_dw_dev_config {
|
|||
uint8_t xfr_flags;
|
||||
bool support_hs_mode;
|
||||
|
||||
struct i2c_slave_config *slave_cfg;
|
||||
struct i2c_target_config *slave_cfg;
|
||||
};
|
||||
|
||||
#define Z_REG_READ(__sz) sys_read##__sz
|
||||
|
|
|
@ -114,7 +114,7 @@ static int i2c_emul_init(const struct device *dev)
|
|||
rc = emul_init_for_bus_from_list(dev, list);
|
||||
|
||||
/* Set config to an uninitialized state */
|
||||
data->config = (I2C_MODE_MASTER | i2c_map_dt_bitrate(data->bitrate));
|
||||
data->config = (I2C_MODE_CONTROLLER | i2c_map_dt_bitrate(data->bitrate));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ static int i2c_esp32_configure(const struct device *dev, uint32_t dev_config)
|
|||
const struct i2c_esp32_config *config = dev->config;
|
||||
struct i2c_esp32_data *data = (struct i2c_esp32_data *const)(dev)->data;
|
||||
|
||||
if (!(dev_config & I2C_MODE_MASTER)) {
|
||||
if (!(dev_config & I2C_MODE_CONTROLLER)) {
|
||||
LOG_ERR("Only I2C Master mode supported.");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ static int IRAM_ATTR i2c_esp32_init(const struct device *dev)
|
|||
}, \
|
||||
.irq_source = ETS_I2C_EXT##idx##_INTR_SOURCE, \
|
||||
.bitrate = I2C_FREQUENCY(idx), \
|
||||
.default_config = I2C_MODE_MASTER, \
|
||||
.default_config = I2C_MODE_CONTROLLER, \
|
||||
}; \
|
||||
I2C_DEVICE_DT_DEFINE(DT_NODELABEL(i2c##idx), \
|
||||
i2c_esp32_init, \
|
||||
|
|
|
@ -686,7 +686,7 @@ static int i2c_gd32_init(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(cfg->bitrate);
|
||||
|
||||
i2c_gd32_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
i2c_gd32_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ static int i2c_gecko_configure(const struct device *dev,
|
|||
I2C_Init_TypeDef i2cInit = I2C_INIT_DEFAULT;
|
||||
uint32_t baudrate;
|
||||
|
||||
if (!(I2C_MODE_MASTER & dev_config_raw)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config_raw)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ static int i2c_gecko_init(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(config->bitrate);
|
||||
|
||||
error = i2c_gecko_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
error = i2c_gecko_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ static int i2c_gpio_init(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(config->bitrate);
|
||||
err = i2c_bitbang_configure(&context->bitbang,
|
||||
I2C_MODE_MASTER | bitrate_cfg);
|
||||
I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (err) {
|
||||
LOG_ERR("failed to configure I2C bitbang (err %d)", err);
|
||||
return err;
|
||||
|
|
|
@ -71,19 +71,19 @@ static inline int z_vrfy_i2c_transfer(const struct device *dev,
|
|||
}
|
||||
#include <syscalls/i2c_transfer_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_i2c_slave_driver_register(const struct device *dev)
|
||||
static inline int z_vrfy_i2c_target_driver_register(const struct device *dev)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C));
|
||||
return z_impl_i2c_slave_driver_register(dev);
|
||||
return z_impl_i2c_target_driver_register(dev);
|
||||
}
|
||||
#include <syscalls/i2c_slave_driver_register_mrsh.c>
|
||||
#include <syscalls/i2c_target_driver_register_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_i2c_slave_driver_unregister(const struct device *dev)
|
||||
static inline int z_vrfy_i2c_target_driver_unregister(const struct device *dev)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C));
|
||||
return z_impl_i2c_slave_driver_unregister(dev);
|
||||
return z_impl_i2c_target_driver_unregister(dev);
|
||||
}
|
||||
#include <syscalls/i2c_slave_driver_unregister_mrsh.c>
|
||||
#include <syscalls/i2c_target_driver_unregister_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_i2c_recover_bus(const struct device *dev)
|
||||
{
|
||||
|
|
|
@ -128,7 +128,7 @@ static int i2c_imx_configure(const struct device *dev,
|
|||
struct i2c_master_transfer *transfer = &data->transfer;
|
||||
uint32_t baudrate;
|
||||
|
||||
if (!(I2C_MODE_MASTER & dev_config_raw)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config_raw)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ static int i2c_imx_init(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(config->bitrate);
|
||||
|
||||
error = i2c_imx_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
error = i2c_imx_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ static int i2c_enhance_configure(const struct device *dev,
|
|||
const struct i2c_enhance_config *config = dev->config;
|
||||
struct i2c_enhance_data *const data = dev->data;
|
||||
|
||||
if (!(I2C_MODE_MASTER & dev_config_raw)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config_raw)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ static int i2c_enhance_get_config(const struct device *dev, uint32_t *dev_config
|
|||
return -ERANGE;
|
||||
}
|
||||
|
||||
*dev_config = (I2C_MODE_MASTER | speed);
|
||||
*dev_config = (I2C_MODE_CONTROLLER | speed);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -624,7 +624,7 @@ static int i2c_enhance_init(const struct device *dev)
|
|||
bitrate_cfg = I2C_SPEED_DT << I2C_SPEED_SHIFT;
|
||||
}
|
||||
|
||||
error = i2c_enhance_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
error = i2c_enhance_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
data->i2ccs = I2C_CH_NORMAL;
|
||||
|
||||
if (error) {
|
||||
|
|
|
@ -212,7 +212,7 @@ static int i2c_it8xxx2_configure(const struct device *dev,
|
|||
struct i2c_it8xxx2_data *const data = dev->data;
|
||||
uint32_t freq_set;
|
||||
|
||||
if (!(I2C_MODE_MASTER & dev_config_raw)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config_raw)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ static int i2c_it8xxx2_get_config(const struct device *dev,
|
|||
return -ERANGE;
|
||||
}
|
||||
|
||||
*dev_config = (I2C_MODE_MASTER | speed);
|
||||
*dev_config = (I2C_MODE_CONTROLLER | speed);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -656,7 +656,7 @@ static int i2c_it8xxx2_init(const struct device *dev)
|
|||
bitrate_cfg = I2C_SPEED_DT << I2C_SPEED_SHIFT;
|
||||
}
|
||||
|
||||
error = i2c_it8xxx2_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
error = i2c_it8xxx2_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
data->i2ccs = I2C_CH_NORMAL;
|
||||
|
||||
if (error) {
|
||||
|
|
|
@ -190,9 +190,9 @@ static int i2c_stm32_transfer(const struct device *dev, struct i2c_msg *msg,
|
|||
static const struct i2c_driver_api api_funcs = {
|
||||
.configure = i2c_stm32_runtime_configure,
|
||||
.transfer = i2c_stm32_transfer,
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
.slave_register = i2c_stm32_slave_register,
|
||||
.slave_unregister = i2c_stm32_slave_unregister,
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
.target_register = i2c_stm32_target_register,
|
||||
.target_unregister = i2c_stm32_target_unregister,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -271,7 +271,7 @@ static int i2c_stm32_init(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(cfg->bitrate);
|
||||
|
||||
ret = i2c_stm32_runtime_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
ret = i2c_stm32_runtime_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("i2c: failure initializing");
|
||||
return ret;
|
||||
|
|
|
@ -61,9 +61,9 @@ struct i2c_stm32_data {
|
|||
unsigned int len;
|
||||
uint8_t *buf;
|
||||
} current;
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
bool master_active;
|
||||
struct i2c_slave_config *slave_cfg;
|
||||
struct i2c_target_config *slave_cfg;
|
||||
bool slave_attached;
|
||||
#endif
|
||||
};
|
||||
|
@ -83,11 +83,9 @@ void stm32_i2c_error_isr(void *arg);
|
|||
void stm32_i2c_combined_isr(void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
int i2c_stm32_slave_register(const struct device *dev,
|
||||
struct i2c_slave_config *config);
|
||||
int i2c_stm32_slave_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *config);
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
int i2c_stm32_target_register(const struct device *dev, struct i2c_target_config *config);
|
||||
int i2c_stm32_target_unregister(const struct device *dev, struct i2c_target_config *config);
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_I2C_I2C_LL_STM32_H_ */
|
||||
|
|
|
@ -124,7 +124,7 @@ static void stm32_i2c_master_finish(const struct device *dev)
|
|||
stm32_i2c_disable_transfer_interrupts(dev);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
struct i2c_stm32_data *data = dev->data;
|
||||
data->master_active = false;
|
||||
if (!data->slave_attached) {
|
||||
|
@ -161,7 +161,7 @@ static inline void msg_init(const struct device *dev, struct i2c_msg *msg,
|
|||
data->current.is_err = 0U;
|
||||
data->current.is_nack = 0U;
|
||||
data->current.msg = msg;
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
data->master_active = true;
|
||||
#endif
|
||||
data->slave_address = slave;
|
||||
|
@ -420,13 +420,13 @@ static inline void handle_btf(const struct device *dev)
|
|||
}
|
||||
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
static void stm32_i2c_slave_event(const struct device *dev)
|
||||
{
|
||||
const struct i2c_stm32_config *cfg = dev->config;
|
||||
struct i2c_stm32_data *data = dev->data;
|
||||
I2C_TypeDef *i2c = cfg->i2c;
|
||||
const struct i2c_slave_callbacks *slave_cb =
|
||||
const struct i2c_target_callbacks *slave_cb =
|
||||
data->slave_cfg->callbacks;
|
||||
|
||||
if (LL_I2C_IsActiveFlag_TXE(i2c) && LL_I2C_IsActiveFlag_BTF(i2c)) {
|
||||
|
@ -472,8 +472,7 @@ static void stm32_i2c_slave_event(const struct device *dev)
|
|||
}
|
||||
|
||||
/* Attach and start I2C as slave */
|
||||
int i2c_stm32_slave_register(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
int i2c_stm32_target_register(const struct device *dev, struct i2c_target_config *config)
|
||||
{
|
||||
const struct i2c_stm32_config *cfg = dev->config;
|
||||
struct i2c_stm32_data *data = dev->data;
|
||||
|
@ -518,8 +517,7 @@ int i2c_stm32_slave_register(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int i2c_stm32_slave_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
int i2c_stm32_target_unregister(const struct device *dev, struct i2c_target_config *config)
|
||||
{
|
||||
const struct i2c_stm32_config *cfg = dev->config;
|
||||
struct i2c_stm32_data *data = dev->data;
|
||||
|
@ -547,7 +545,7 @@ int i2c_stm32_slave_unregister(const struct device *dev,
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* defined(CONFIG_I2C_SLAVE) */
|
||||
#endif /* defined(CONFIG_I2C_TARGET) */
|
||||
|
||||
void stm32_i2c_event_isr(void *arg)
|
||||
{
|
||||
|
@ -556,7 +554,7 @@ void stm32_i2c_event_isr(void *arg)
|
|||
struct i2c_stm32_data *data = dev->data;
|
||||
I2C_TypeDef *i2c = cfg->i2c;
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
if (data->slave_attached && !data->master_active) {
|
||||
stm32_i2c_slave_event(dev);
|
||||
return;
|
||||
|
@ -585,7 +583,7 @@ void stm32_i2c_error_isr(void *arg)
|
|||
struct i2c_stm32_data *data = dev->data;
|
||||
I2C_TypeDef *i2c = cfg->i2c;
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
if (data->slave_attached && !data->master_active) {
|
||||
/* No need for a slave error function right now. */
|
||||
return;
|
||||
|
|
|
@ -58,7 +58,7 @@ static inline void msg_init(const struct device *dev, struct i2c_msg *msg,
|
|||
LL_I2C_SetTransferRequest(i2c, transfer);
|
||||
LL_I2C_SetTransferSize(i2c, msg->len);
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
data->master_active = true;
|
||||
#endif
|
||||
LL_I2C_Enable(i2c);
|
||||
|
@ -101,7 +101,7 @@ static void stm32_i2c_master_mode_end(const struct device *dev)
|
|||
|
||||
stm32_i2c_disable_transfer_interrupts(dev);
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
data->master_active = false;
|
||||
if (!data->slave_attached) {
|
||||
LL_I2C_Disable(i2c);
|
||||
|
@ -112,13 +112,13 @@ static void stm32_i2c_master_mode_end(const struct device *dev)
|
|||
k_sem_give(&data->device_sync_sem);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
static void stm32_i2c_slave_event(const struct device *dev)
|
||||
{
|
||||
const struct i2c_stm32_config *cfg = dev->config;
|
||||
struct i2c_stm32_data *data = dev->data;
|
||||
I2C_TypeDef *i2c = cfg->i2c;
|
||||
const struct i2c_slave_callbacks *slave_cb =
|
||||
const struct i2c_target_callbacks *slave_cb =
|
||||
data->slave_cfg->callbacks;
|
||||
|
||||
if (LL_I2C_IsActiveFlag_TXIS(i2c)) {
|
||||
|
@ -177,9 +177,9 @@ static void stm32_i2c_slave_event(const struct device *dev)
|
|||
}
|
||||
}
|
||||
|
||||
/* Attach and start I2C as slave */
|
||||
int i2c_stm32_slave_register(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
/* Attach and start I2C as target */
|
||||
int i2c_stm32_target_register(const struct device *dev,
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
const struct i2c_stm32_config *cfg = dev->config;
|
||||
struct i2c_stm32_data *data = dev->data;
|
||||
|
@ -224,8 +224,8 @@ int i2c_stm32_slave_register(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int i2c_stm32_slave_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
int i2c_stm32_target_unregister(const struct device *dev,
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
const struct i2c_stm32_config *cfg = dev->config;
|
||||
struct i2c_stm32_data *data = dev->data;
|
||||
|
@ -257,7 +257,7 @@ int i2c_stm32_slave_unregister(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_I2C_SLAVE) */
|
||||
#endif /* defined(CONFIG_I2C_TARGET) */
|
||||
|
||||
static void stm32_i2c_event(const struct device *dev)
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ static void stm32_i2c_event(const struct device *dev)
|
|||
struct i2c_stm32_data *data = dev->data;
|
||||
I2C_TypeDef *i2c = cfg->i2c;
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
if (data->slave_attached && !data->master_active) {
|
||||
stm32_i2c_slave_event(dev);
|
||||
return;
|
||||
|
@ -328,7 +328,7 @@ static int stm32_i2c_error(const struct device *dev)
|
|||
struct i2c_stm32_data *data = dev->data;
|
||||
I2C_TypeDef *i2c = cfg->i2c;
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
if (data->slave_attached && !data->master_active) {
|
||||
/* No need for a slave error function right now. */
|
||||
return 0;
|
||||
|
|
|
@ -121,7 +121,7 @@ static int lpc11u6x_i2c_transfer(const struct device *dev,
|
|||
}
|
||||
|
||||
static int lpc11u6x_i2c_slave_register(const struct device *dev,
|
||||
struct i2c_slave_config *cfg)
|
||||
struct i2c_target_config *cfg)
|
||||
{
|
||||
const struct lpc11u6x_i2c_config *dev_cfg = dev->config;
|
||||
struct lpc11u6x_i2c_data *data = dev->data;
|
||||
|
@ -131,7 +131,7 @@ static int lpc11u6x_i2c_slave_register(const struct device *dev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (cfg->flags & I2C_SLAVE_FLAGS_ADDR_10_BITS) {
|
||||
if (cfg->flags & I2C_TARGET_FLAGS_ADDR_10_BITS) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ exit:
|
|||
|
||||
|
||||
static int lpc11u6x_i2c_slave_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *cfg)
|
||||
struct i2c_target_config *cfg)
|
||||
{
|
||||
const struct lpc11u6x_i2c_config *dev_cfg = dev->config;
|
||||
struct lpc11u6x_i2c_data *data = dev->data;
|
||||
|
@ -349,8 +349,8 @@ static int lpc11u6x_i2c_init(const struct device *dev)
|
|||
static const struct i2c_driver_api i2c_api = {
|
||||
.configure = lpc11u6x_i2c_configure,
|
||||
.transfer = lpc11u6x_i2c_transfer,
|
||||
.slave_register = lpc11u6x_i2c_slave_register,
|
||||
.slave_unregister = lpc11u6x_i2c_slave_unregister,
|
||||
.target_register = lpc11u6x_i2c_slave_register,
|
||||
.target_unregister = lpc11u6x_i2c_slave_unregister,
|
||||
};
|
||||
|
||||
#define LPC11U6X_I2C_INIT(idx) \
|
||||
|
|
|
@ -86,7 +86,7 @@ struct lpc11u6x_i2c_current_transfer {
|
|||
|
||||
struct lpc11u6x_i2c_data {
|
||||
struct lpc11u6x_i2c_current_transfer transfer;
|
||||
struct i2c_slave_config *slave;
|
||||
struct i2c_target_config *slave;
|
||||
struct k_sem completion;
|
||||
struct k_mutex mutex;
|
||||
};
|
||||
|
|
|
@ -62,7 +62,7 @@ struct i2c_xec_data {
|
|||
uint32_t speed_id;
|
||||
const struct device *sda_gpio;
|
||||
const struct device *scl_gpio;
|
||||
struct i2c_slave_config *slave_cfg;
|
||||
struct i2c_target_config *slave_cfg;
|
||||
bool slave_attached;
|
||||
bool slave_read;
|
||||
};
|
||||
|
@ -177,7 +177,7 @@ static void cleanup_registers(uint32_t ba)
|
|||
cfg &= ~MCHP_I2C_SMB_CFG_FLUSH_SRBUF_WO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
static void restart_slave(uint32_t ba)
|
||||
{
|
||||
MCHP_I2C_SMB_CTRL_WO(ba) = MCHP_I2C_SMB_CTRL_PIN |
|
||||
|
@ -328,7 +328,7 @@ static int i2c_xec_configure(const struct device *dev,
|
|||
struct i2c_xec_data *data =
|
||||
(struct i2c_xec_data *const) (dev->data);
|
||||
|
||||
if (!(dev_config_raw & I2C_MODE_MASTER)) {
|
||||
if (!(dev_config_raw & I2C_MODE_CONTROLLER)) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ static int i2c_xec_transfer(const struct device *dev, struct i2c_msg *msgs,
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
struct i2c_xec_data *data = dev->data;
|
||||
|
||||
if (data->slave_attached) {
|
||||
|
@ -689,11 +689,11 @@ static int i2c_xec_transfer(const struct device *dev, struct i2c_msg *msgs,
|
|||
|
||||
static void i2c_xec_bus_isr(const struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
const struct i2c_xec_config *config =
|
||||
(const struct i2c_xec_config *const) (dev->config);
|
||||
struct i2c_xec_data *data = dev->data;
|
||||
const struct i2c_slave_callbacks *slave_cb = data->slave_cfg->callbacks;
|
||||
const struct i2c_target_callbacks *slave_cb = data->slave_cfg->callbacks;
|
||||
uint32_t ba = config->base_addr;
|
||||
|
||||
uint32_t status;
|
||||
|
@ -773,9 +773,9 @@ clear_iag:
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
static int i2c_xec_slave_register(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
const struct i2c_xec_config *cfg = dev->config;
|
||||
struct i2c_xec_data *data = dev->data;
|
||||
|
@ -818,7 +818,7 @@ static int i2c_xec_slave_register(const struct device *dev,
|
|||
}
|
||||
|
||||
static int i2c_xec_slave_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
const struct i2c_xec_config *cfg = dev->config;
|
||||
struct i2c_xec_data *data = dev->data;
|
||||
|
@ -838,7 +838,7 @@ static int i2c_xec_slave_unregister(const struct device *dev,
|
|||
static const struct i2c_driver_api i2c_xec_driver_api = {
|
||||
.configure = i2c_xec_configure,
|
||||
.transfer = i2c_xec_transfer,
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
.slave_register = i2c_xec_slave_register,
|
||||
.slave_unregister = i2c_xec_slave_unregister,
|
||||
#endif
|
||||
|
@ -868,14 +868,14 @@ static int i2c_xec_init(const struct device *dev)
|
|||
|
||||
/* Default configuration */
|
||||
ret = i2c_xec_configure(dev,
|
||||
I2C_MODE_MASTER |
|
||||
I2C_MODE_CONTROLLER |
|
||||
I2C_SPEED_SET(I2C_SPEED_STANDARD));
|
||||
if (ret) {
|
||||
LOG_ERR("%s configure failed %d", dev->name, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
const struct i2c_xec_config *config =
|
||||
(const struct i2c_xec_config *const) (dev->config);
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ struct i2c_xec_data {
|
|||
uint8_t state;
|
||||
uint8_t read_discard;
|
||||
uint8_t speed_id;
|
||||
struct i2c_slave_config *target_cfg;
|
||||
struct i2c_target_config *target_cfg;
|
||||
bool target_attached;
|
||||
bool target_read;
|
||||
uint32_t i2c_compl;
|
||||
|
@ -247,7 +247,7 @@ static int i2c_xec_reset_config(const struct device *dev)
|
|||
* enable in the configuration register.
|
||||
*/
|
||||
regs->OWN_ADDR = EC_OWN_I2C_ADDR | (EC_OWN_I2C_ADDR << 8);
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
if (data->target_cfg) {
|
||||
regs->OWN_ADDR = data->target_cfg->address;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ recov_exit:
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
/*
|
||||
* Restart I2C controller as target for ACK of address match.
|
||||
* Setting PIN clears all status in I2C.Status register except NBB.
|
||||
|
@ -571,7 +571,7 @@ static int i2c_xec_configure(const struct device *dev,
|
|||
struct i2c_xec_data *data =
|
||||
(struct i2c_xec_data *const) (dev->data);
|
||||
|
||||
if (!(dev_config_raw & I2C_MODE_MASTER)) {
|
||||
if (!(dev_config_raw & I2C_MODE_CONTROLLER)) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -776,7 +776,7 @@ static int i2c_xec_transfer(const struct device *dev, struct i2c_msg *msgs,
|
|||
struct i2c_xec_data *data = dev->data;
|
||||
int ret = 0;
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
if (data->target_attached) {
|
||||
LOG_ERR("Device is registered as target");
|
||||
return -EBUSY;
|
||||
|
@ -804,11 +804,11 @@ static int i2c_xec_transfer(const struct device *dev, struct i2c_msg *msgs,
|
|||
|
||||
static void i2c_xec_bus_isr(const struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
const struct i2c_xec_config *cfg =
|
||||
(const struct i2c_xec_config *const) (dev->config);
|
||||
struct i2c_xec_data *data = dev->data;
|
||||
const struct i2c_slave_callbacks *target_cb =
|
||||
const struct i2c_target_callbacks *target_cb =
|
||||
data->target_cfg->callbacks;
|
||||
struct i2c_smb_regs *regs = (struct i2c_smb_regs *)cfg->base_addr;
|
||||
int ret;
|
||||
|
@ -972,9 +972,9 @@ clear_iag:
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
static int i2c_xec_target_register(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
const struct i2c_xec_config *cfg = dev->config;
|
||||
struct i2c_xec_data *data = dev->data;
|
||||
|
@ -1015,7 +1015,7 @@ static int i2c_xec_target_register(const struct device *dev,
|
|||
}
|
||||
|
||||
static int i2c_xec_target_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
const struct i2c_xec_config *cfg = dev->config;
|
||||
struct i2c_xec_data *data = dev->data;
|
||||
|
@ -1036,9 +1036,9 @@ static int i2c_xec_target_unregister(const struct device *dev,
|
|||
static const struct i2c_driver_api i2c_xec_driver_api = {
|
||||
.configure = i2c_xec_configure,
|
||||
.transfer = i2c_xec_transfer,
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
.slave_register = i2c_xec_target_register,
|
||||
.slave_unregister = i2c_xec_target_unregister,
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
.target_register = i2c_xec_target_register,
|
||||
.target_unregister = i2c_xec_target_unregister,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1066,12 +1066,12 @@ static int i2c_xec_init(const struct device *dev)
|
|||
}
|
||||
|
||||
/* Default configuration */
|
||||
ret = i2c_xec_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
ret = i2c_xec_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
const struct i2c_xec_config *config =
|
||||
(const struct i2c_xec_config *const) (dev->config);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ static int i2c_mcux_configure(const struct device *dev,
|
|||
uint32_t clock_freq;
|
||||
uint32_t baudrate;
|
||||
|
||||
if (!(I2C_MODE_MASTER & dev_config_raw)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config_raw)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ static int i2c_mcux_init(const struct device *dev)
|
|||
return error;
|
||||
}
|
||||
|
||||
error = i2c_mcux_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
error = i2c_mcux_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ struct mcux_flexcomm_data {
|
|||
i2c_master_handle_t handle;
|
||||
struct k_sem device_sync_sem;
|
||||
status_t callback_status;
|
||||
#ifdef CONFIG_I2C_SLAVE
|
||||
#ifdef CONFIG_I2C_TARGET
|
||||
i2c_slave_handle_t target_handle;
|
||||
struct i2c_slave_config *target_cfg;
|
||||
struct i2c_target_config *target_cfg;
|
||||
bool target_attached;
|
||||
bool first_read;
|
||||
bool first_write;
|
||||
|
@ -53,7 +53,7 @@ static int mcux_flexcomm_configure(const struct device *dev,
|
|||
uint32_t clock_freq;
|
||||
uint32_t baudrate;
|
||||
|
||||
if (!(I2C_MODE_MASTER & dev_config_raw)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config_raw)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -179,12 +179,12 @@ static int mcux_flexcomm_transfer(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
static void i2c_target_transfer_callback(I2C_Type *base,
|
||||
volatile i2c_slave_transfer_t *transfer, void *userData)
|
||||
{
|
||||
struct mcux_flexcomm_data *data = userData;
|
||||
const struct i2c_slave_callbacks *target_cb = data->target_cfg->callbacks;
|
||||
const struct i2c_target_callbacks *target_cb = data->target_cfg->callbacks;
|
||||
static uint8_t rxVal, txVal;
|
||||
|
||||
ARG_UNUSED(base);
|
||||
|
@ -239,7 +239,7 @@ static void i2c_target_transfer_callback(I2C_Type *base,
|
|||
}
|
||||
|
||||
int mcux_flexcomm_target_register(const struct device *dev,
|
||||
struct i2c_slave_config *target_config)
|
||||
struct i2c_target_config *target_config)
|
||||
{
|
||||
const struct mcux_flexcomm_config *config = dev->config;
|
||||
struct mcux_flexcomm_data *data = dev->data;
|
||||
|
@ -282,7 +282,7 @@ int mcux_flexcomm_target_register(const struct device *dev,
|
|||
}
|
||||
|
||||
int mcux_flexcomm_target_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *target_config)
|
||||
struct i2c_target_config *target_config)
|
||||
{
|
||||
const struct mcux_flexcomm_config *config = dev->config;
|
||||
struct mcux_flexcomm_data *data = dev->data;
|
||||
|
@ -307,7 +307,7 @@ static void mcux_flexcomm_isr(const struct device *dev)
|
|||
struct mcux_flexcomm_data *data = dev->data;
|
||||
I2C_Type *base = config->base;
|
||||
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
if (data->target_attached) {
|
||||
I2C_SlaveTransferHandleIRQ(base, &data->target_handle);
|
||||
return;
|
||||
|
@ -349,7 +349,7 @@ static int mcux_flexcomm_init(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(config->bitrate);
|
||||
|
||||
error = mcux_flexcomm_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
error = mcux_flexcomm_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
@ -362,9 +362,9 @@ static int mcux_flexcomm_init(const struct device *dev)
|
|||
static const struct i2c_driver_api mcux_flexcomm_driver_api = {
|
||||
.configure = mcux_flexcomm_configure,
|
||||
.transfer = mcux_flexcomm_transfer,
|
||||
#if defined(CONFIG_I2C_SLAVE)
|
||||
.slave_register = mcux_flexcomm_target_register,
|
||||
.slave_unregister = mcux_flexcomm_target_unregister,
|
||||
#if defined(CONFIG_I2C_TARGET)
|
||||
.target_register = mcux_flexcomm_target_register,
|
||||
.target_unregister = mcux_flexcomm_target_unregister,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ static int mcux_lpi2c_configure(const struct device *dev,
|
|||
uint32_t baudrate;
|
||||
int ret;
|
||||
|
||||
if (!(I2C_MODE_MASTER & dev_config_raw)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config_raw)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ static int mcux_lpi2c_init(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(config->bitrate);
|
||||
|
||||
error = mcux_lpi2c_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
error = mcux_lpi2c_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ i2c_nios2_configure(const struct device *dev, uint32_t dev_config)
|
|||
int32_t rc = 0;
|
||||
|
||||
k_sem_take(&data->sem_lock, K_FOREVER);
|
||||
if (!(I2C_MODE_MASTER & dev_config)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config)) {
|
||||
LOG_ERR("i2c config mode error\n");
|
||||
rc = -EINVAL;
|
||||
goto i2c_cfg_err;
|
||||
|
@ -173,7 +173,7 @@ static int i2c_nios2_init(const struct device *dev)
|
|||
k_sem_init(&data->sem_lock, 1, 1);
|
||||
|
||||
rc = i2c_nios2_configure(dev,
|
||||
I2C_MODE_MASTER |
|
||||
I2C_MODE_CONTROLLER |
|
||||
I2C_SPEED_SET(I2C_SPEED_STANDARD));
|
||||
if (rc) {
|
||||
LOG_ERR("i2c configure failed %d\n", rc);
|
||||
|
|
|
@ -62,7 +62,7 @@ static int i2c_npcx_port_configure(const struct device *dev,
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
if (!(dev_config & I2C_MODE_MASTER)) {
|
||||
if (!(dev_config & I2C_MODE_CONTROLLER)) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ static int i2c_npcx_port_get_config(const struct device *dev, uint32_t *dev_conf
|
|||
|
||||
ret = npcx_i2c_ctrl_get_speed(config->i2c_ctrl, &speed);
|
||||
if (!ret) {
|
||||
*dev_config = (I2C_MODE_MASTER | speed);
|
||||
*dev_config = (I2C_MODE_CONTROLLER | speed);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -139,7 +139,7 @@ static int i2c_npcx_port_init(const struct device *dev)
|
|||
|
||||
|
||||
/* Setup initial i2c configuration */
|
||||
i2c_config = (I2C_MODE_MASTER | i2c_map_dt_bitrate(config->bitrate));
|
||||
i2c_config = (I2C_MODE_CONTROLLER | i2c_map_dt_bitrate(config->bitrate));
|
||||
ret = i2c_npcx_port_configure(dev, i2c_config);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
|
|
|
@ -270,7 +270,7 @@ static int i2c_rcar_configure(const struct device *dev, uint32_t dev_config)
|
|||
uint8_t cdf, scgd;
|
||||
|
||||
/* We only support Master mode */
|
||||
if ((dev_config & I2C_MODE_MASTER) != I2C_MODE_MASTER) {
|
||||
if ((dev_config & I2C_MODE_CONTROLLER) != I2C_MODE_CONTROLLER) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ static int i2c_rcar_init(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(config->bitrate);
|
||||
|
||||
ret = i2c_rcar_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
ret = i2c_rcar_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ static int rv32m1_lpi2c_configure(const struct device *dev,
|
|||
uint32_t clk_freq;
|
||||
int err;
|
||||
|
||||
if (!(I2C_MODE_MASTER & dev_config)) {
|
||||
if (!(I2C_MODE_CONTROLLER & dev_config)) {
|
||||
/* Slave mode not supported - yet */
|
||||
LOG_ERR("Slave mode not supported");
|
||||
return -ENOTSUP;
|
||||
|
@ -236,7 +236,7 @@ static int rv32m1_lpi2c_init(const struct device *dev)
|
|||
data);
|
||||
|
||||
dev_cfg = i2c_map_dt_bitrate(config->bitrate);
|
||||
err = rv32m1_lpi2c_configure(dev, dev_cfg | I2C_MODE_MASTER);
|
||||
err = rv32m1_lpi2c_configure(dev, dev_cfg | I2C_MODE_CONTROLLER);
|
||||
if (err) {
|
||||
LOG_ERR("Could not configure controller (err %d)", err);
|
||||
return err;
|
||||
|
|
|
@ -668,7 +668,7 @@ static int i2c_sam0_configure(const struct device *dev, uint32_t config)
|
|||
SercomI2cm *i2c = cfg->regs;
|
||||
int retval;
|
||||
|
||||
if (!(config & I2C_MODE_MASTER)) {
|
||||
if (!(config & I2C_MODE_CONTROLLER)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ static int i2c_sam_twim_configure(const struct device *dev, uint32_t config)
|
|||
uint32_t bitrate;
|
||||
int ret;
|
||||
|
||||
if (!(config & I2C_MODE_MASTER)) {
|
||||
if (!(config & I2C_MODE_CONTROLLER)) {
|
||||
LOG_ERR("Master Mode is not enabled");
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ static int i2c_sam_twim_initialize(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(cfg->bitrate);
|
||||
|
||||
ret = i2c_sam_twim_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
ret = i2c_sam_twim_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Failed to initialize %s device", dev->name);
|
||||
return ret;
|
||||
|
|
|
@ -107,7 +107,7 @@ static int i2c_sam_twi_configure(const struct device *dev, uint32_t config)
|
|||
uint32_t bitrate;
|
||||
int ret;
|
||||
|
||||
if (!(config & I2C_MODE_MASTER)) {
|
||||
if (!(config & I2C_MODE_CONTROLLER)) {
|
||||
LOG_ERR("Master Mode is not enabled");
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ static int i2c_sam_twi_initialize(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(dev_cfg->bitrate);
|
||||
|
||||
ret = i2c_sam_twi_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
ret = i2c_sam_twi_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Failed to initialize %s device", dev->name);
|
||||
return ret;
|
||||
|
|
|
@ -105,7 +105,7 @@ static int i2c_sam_twihs_configure(const struct device *dev, uint32_t config)
|
|||
uint32_t bitrate;
|
||||
int ret;
|
||||
|
||||
if (!(config & I2C_MODE_MASTER)) {
|
||||
if (!(config & I2C_MODE_CONTROLLER)) {
|
||||
LOG_ERR("Master Mode is not enabled");
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ static int i2c_sam_twihs_initialize(const struct device *dev)
|
|||
|
||||
bitrate_cfg = i2c_map_dt_bitrate(dev_cfg->bitrate);
|
||||
|
||||
ret = i2c_sam_twihs_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
|
||||
ret = i2c_sam_twihs_configure(dev, I2C_MODE_CONTROLLER | bitrate_cfg);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Failed to initialize %s device", dev->name);
|
||||
return ret;
|
||||
|
|
|
@ -243,7 +243,7 @@ static int i2c_sifive_configure(const struct device *dev, uint32_t dev_config)
|
|||
I2C_REG(config, REG_PRESCALE_HIGH));
|
||||
|
||||
/* Support I2C Master mode only */
|
||||
if (!(dev_config & I2C_MODE_MASTER)) {
|
||||
if (!(dev_config & I2C_MODE_CONTROLLER)) {
|
||||
LOG_ERR("I2C only supports operation as master");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ static int i2c_sifive_init(const struct device *dev)
|
|||
uint32_t dev_config = 0U;
|
||||
int rc = 0;
|
||||
|
||||
dev_config = (I2C_MODE_MASTER | i2c_map_dt_bitrate(config->f_bus));
|
||||
dev_config = (I2C_MODE_CONTROLLER | i2c_map_dt_bitrate(config->f_bus));
|
||||
|
||||
rc = i2c_sifive_configure(dev, dev_config);
|
||||
if (rc != 0) {
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_I2C_EEPROM_SLAVE eeprom_slave.c)
|
|
@ -1,24 +0,0 @@
|
|||
# I2C Slave configuration options
|
||||
|
||||
# Copyright (c) 2017 BayLibre, SAS
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#
|
||||
# I2C options
|
||||
#
|
||||
menuconfig I2C_SLAVE
|
||||
bool "I2C Slave Drivers"
|
||||
help
|
||||
Enable I2C Slave Driver Configuration
|
||||
|
||||
if I2C_SLAVE
|
||||
|
||||
config I2C_SLAVE_INIT_PRIORITY
|
||||
int "Init priority"
|
||||
default 60
|
||||
help
|
||||
I2C Slave device driver initialization priority.
|
||||
|
||||
source "drivers/i2c/slave/Kconfig.eeprom"
|
||||
|
||||
endif # I2C_SLAVE
|
|
@ -1,9 +0,0 @@
|
|||
# I2C EEPROM Slave configuration options
|
||||
|
||||
# Copyright (c) 2017 BayLibre, SAS
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config I2C_EEPROM_SLAVE
|
||||
bool "I2C Slave EEPROM driver"
|
||||
help
|
||||
Enable virtual I2C Slave EEPROM driver
|
|
@ -1,221 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 BayLibre, SAS
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT atmel_at24
|
||||
|
||||
#include <zephyr/sys/util.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <errno.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <string.h>
|
||||
#include <zephyr/drivers/i2c/slave/eeprom.h>
|
||||
|
||||
#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(i2c_slave);
|
||||
|
||||
struct i2c_eeprom_slave_data {
|
||||
struct i2c_slave_config config;
|
||||
uint32_t buffer_size;
|
||||
uint8_t *buffer;
|
||||
uint32_t buffer_idx;
|
||||
bool first_write;
|
||||
};
|
||||
|
||||
struct i2c_eeprom_slave_config {
|
||||
struct i2c_dt_spec bus;
|
||||
uint32_t buffer_size;
|
||||
uint8_t *buffer;
|
||||
};
|
||||
|
||||
int eeprom_slave_program(const struct device *dev, const uint8_t *eeprom_data,
|
||||
unsigned int length)
|
||||
{
|
||||
struct i2c_eeprom_slave_data *data = dev->data;
|
||||
|
||||
if (length > data->buffer_size) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memcpy(data->buffer, eeprom_data, length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int eeprom_slave_read(const struct device *dev, uint8_t *eeprom_data,
|
||||
unsigned int offset)
|
||||
{
|
||||
struct i2c_eeprom_slave_data *data = dev->data;
|
||||
|
||||
if (!data || offset >= data->buffer_size) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*eeprom_data = data->buffer[offset];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_slave_write_requested(struct i2c_slave_config *config)
|
||||
{
|
||||
struct i2c_eeprom_slave_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_slave_data,
|
||||
config);
|
||||
|
||||
LOG_DBG("eeprom: write req");
|
||||
|
||||
data->first_write = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_slave_read_requested(struct i2c_slave_config *config,
|
||||
uint8_t *val)
|
||||
{
|
||||
struct i2c_eeprom_slave_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_slave_data,
|
||||
config);
|
||||
|
||||
*val = data->buffer[data->buffer_idx];
|
||||
|
||||
LOG_DBG("eeprom: read req, val=0x%x", *val);
|
||||
|
||||
/* Increment will be done in the read_processed callback */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_slave_write_received(struct i2c_slave_config *config,
|
||||
uint8_t val)
|
||||
{
|
||||
struct i2c_eeprom_slave_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_slave_data,
|
||||
config);
|
||||
|
||||
LOG_DBG("eeprom: write done, val=0x%x", val);
|
||||
|
||||
/* In case EEPROM wants to be R/O, return !0 here could trigger
|
||||
* a NACK to the I2C controller, support depends on the
|
||||
* I2C controller support
|
||||
*/
|
||||
|
||||
if (data->first_write) {
|
||||
data->buffer_idx = val;
|
||||
data->first_write = false;
|
||||
} else {
|
||||
data->buffer[data->buffer_idx++] = val;
|
||||
}
|
||||
|
||||
data->buffer_idx = data->buffer_idx % data->buffer_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_slave_read_processed(struct i2c_slave_config *config,
|
||||
uint8_t *val)
|
||||
{
|
||||
struct i2c_eeprom_slave_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_slave_data,
|
||||
config);
|
||||
|
||||
/* Increment here */
|
||||
data->buffer_idx = (data->buffer_idx + 1) % data->buffer_size;
|
||||
|
||||
*val = data->buffer[data->buffer_idx];
|
||||
|
||||
LOG_DBG("eeprom: read done, val=0x%x", *val);
|
||||
|
||||
/* Increment will be done in the next read_processed callback
|
||||
* In case of STOP, the byte won't be taken in account
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_slave_stop(struct i2c_slave_config *config)
|
||||
{
|
||||
struct i2c_eeprom_slave_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_slave_data,
|
||||
config);
|
||||
|
||||
LOG_DBG("eeprom: stop");
|
||||
|
||||
data->first_write = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_slave_register(const struct device *dev)
|
||||
{
|
||||
const struct i2c_eeprom_slave_config *cfg = dev->config;
|
||||
struct i2c_eeprom_slave_data *data = dev->data;
|
||||
|
||||
return i2c_slave_register(cfg->bus.bus, &data->config);
|
||||
}
|
||||
|
||||
static int eeprom_slave_unregister(const struct device *dev)
|
||||
{
|
||||
const struct i2c_eeprom_slave_config *cfg = dev->config;
|
||||
struct i2c_eeprom_slave_data *data = dev->data;
|
||||
|
||||
return i2c_slave_unregister(cfg->bus.bus, &data->config);
|
||||
}
|
||||
|
||||
static const struct i2c_slave_driver_api api_funcs = {
|
||||
.driver_register = eeprom_slave_register,
|
||||
.driver_unregister = eeprom_slave_unregister,
|
||||
};
|
||||
|
||||
static const struct i2c_slave_callbacks eeprom_callbacks = {
|
||||
.write_requested = eeprom_slave_write_requested,
|
||||
.read_requested = eeprom_slave_read_requested,
|
||||
.write_received = eeprom_slave_write_received,
|
||||
.read_processed = eeprom_slave_read_processed,
|
||||
.stop = eeprom_slave_stop,
|
||||
};
|
||||
|
||||
static int i2c_eeprom_slave_init(const struct device *dev)
|
||||
{
|
||||
struct i2c_eeprom_slave_data *data = dev->data;
|
||||
const struct i2c_eeprom_slave_config *cfg = dev->config;
|
||||
|
||||
if (!device_is_ready(cfg->bus.bus)) {
|
||||
LOG_ERR("I2C controller device not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
data->buffer_size = cfg->buffer_size;
|
||||
data->buffer = cfg->buffer;
|
||||
data->config.address = cfg->bus.addr;
|
||||
data->config.callbacks = &eeprom_callbacks;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define I2C_EEPROM_INIT(inst) \
|
||||
static struct i2c_eeprom_slave_data \
|
||||
i2c_eeprom_slave_##inst##_dev_data; \
|
||||
\
|
||||
static uint8_t \
|
||||
i2c_eeprom_slave_##inst##_buffer[(DT_INST_PROP(inst, size))]; \
|
||||
\
|
||||
static const struct i2c_eeprom_slave_config \
|
||||
i2c_eeprom_slave_##inst##_cfg = { \
|
||||
.bus = I2C_DT_SPEC_INST_GET(inst), \
|
||||
.buffer_size = DT_INST_PROP(inst, size), \
|
||||
.buffer = i2c_eeprom_slave_##inst##_buffer \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(inst, \
|
||||
&i2c_eeprom_slave_init, \
|
||||
NULL, \
|
||||
&i2c_eeprom_slave_##inst##_dev_data, \
|
||||
&i2c_eeprom_slave_##inst##_cfg, \
|
||||
POST_KERNEL, \
|
||||
CONFIG_I2C_SLAVE_INIT_PRIORITY, \
|
||||
&api_funcs);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(I2C_EEPROM_INIT)
|
3
drivers/i2c/target/CMakeLists.txt
Normal file
3
drivers/i2c/target/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_I2C_EEPROM_TARGET eeprom_target.c)
|
24
drivers/i2c/target/Kconfig
Normal file
24
drivers/i2c/target/Kconfig
Normal file
|
@ -0,0 +1,24 @@
|
|||
# I2C Target configuration options
|
||||
|
||||
# Copyright (c) 2017 BayLibre, SAS
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#
|
||||
# I2C options
|
||||
#
|
||||
menuconfig I2C_TARGET
|
||||
bool "I2C Target Drivers"
|
||||
help
|
||||
Enable I2C Target Driver Configuration
|
||||
|
||||
if I2C_TARGET
|
||||
|
||||
config I2C_TARGET_INIT_PRIORITY
|
||||
int "Init priority"
|
||||
default 60
|
||||
help
|
||||
I2C Target device driver initialization priority.
|
||||
|
||||
source "drivers/i2c/target/Kconfig.eeprom"
|
||||
|
||||
endif # I2C_TARGET
|
9
drivers/i2c/target/Kconfig.eeprom
Normal file
9
drivers/i2c/target/Kconfig.eeprom
Normal file
|
@ -0,0 +1,9 @@
|
|||
# I2C EEPROM Target configuration options
|
||||
|
||||
# Copyright (c) 2017 BayLibre, SAS
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config I2C_EEPROM_TARGET
|
||||
bool "I2C Target EEPROM driver"
|
||||
help
|
||||
Enable virtual I2C Target EEPROM driver
|
221
drivers/i2c/target/eeprom_target.c
Normal file
221
drivers/i2c/target/eeprom_target.c
Normal file
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
* Copyright (c) 2017 BayLibre, SAS
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT atmel_at24
|
||||
|
||||
#include <zephyr/sys/util.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <errno.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <string.h>
|
||||
#include <zephyr/drivers/i2c/target/eeprom.h>
|
||||
|
||||
#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(i2c_target);
|
||||
|
||||
struct i2c_eeprom_target_data {
|
||||
struct i2c_target_config config;
|
||||
uint32_t buffer_size;
|
||||
uint8_t *buffer;
|
||||
uint32_t buffer_idx;
|
||||
bool first_write;
|
||||
};
|
||||
|
||||
struct i2c_eeprom_target_config {
|
||||
struct i2c_dt_spec bus;
|
||||
uint32_t buffer_size;
|
||||
uint8_t *buffer;
|
||||
};
|
||||
|
||||
int eeprom_target_program(const struct device *dev, const uint8_t *eeprom_data,
|
||||
unsigned int length)
|
||||
{
|
||||
struct i2c_eeprom_target_data *data = dev->data;
|
||||
|
||||
if (length > data->buffer_size) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memcpy(data->buffer, eeprom_data, length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int eeprom_target_read(const struct device *dev, uint8_t *eeprom_data,
|
||||
unsigned int offset)
|
||||
{
|
||||
struct i2c_eeprom_target_data *data = dev->data;
|
||||
|
||||
if (!data || offset >= data->buffer_size) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*eeprom_data = data->buffer[offset];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_target_write_requested(struct i2c_target_config *config)
|
||||
{
|
||||
struct i2c_eeprom_target_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_target_data,
|
||||
config);
|
||||
|
||||
LOG_DBG("eeprom: write req");
|
||||
|
||||
data->first_write = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_target_read_requested(struct i2c_target_config *config,
|
||||
uint8_t *val)
|
||||
{
|
||||
struct i2c_eeprom_target_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_target_data,
|
||||
config);
|
||||
|
||||
*val = data->buffer[data->buffer_idx];
|
||||
|
||||
LOG_DBG("eeprom: read req, val=0x%x", *val);
|
||||
|
||||
/* Increment will be done in the read_processed callback */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_target_write_received(struct i2c_target_config *config,
|
||||
uint8_t val)
|
||||
{
|
||||
struct i2c_eeprom_target_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_target_data,
|
||||
config);
|
||||
|
||||
LOG_DBG("eeprom: write done, val=0x%x", val);
|
||||
|
||||
/* In case EEPROM wants to be R/O, return !0 here could trigger
|
||||
* a NACK to the I2C controller, support depends on the
|
||||
* I2C controller support
|
||||
*/
|
||||
|
||||
if (data->first_write) {
|
||||
data->buffer_idx = val;
|
||||
data->first_write = false;
|
||||
} else {
|
||||
data->buffer[data->buffer_idx++] = val;
|
||||
}
|
||||
|
||||
data->buffer_idx = data->buffer_idx % data->buffer_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_target_read_processed(struct i2c_target_config *config,
|
||||
uint8_t *val)
|
||||
{
|
||||
struct i2c_eeprom_target_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_target_data,
|
||||
config);
|
||||
|
||||
/* Increment here */
|
||||
data->buffer_idx = (data->buffer_idx + 1) % data->buffer_size;
|
||||
|
||||
*val = data->buffer[data->buffer_idx];
|
||||
|
||||
LOG_DBG("eeprom: read done, val=0x%x", *val);
|
||||
|
||||
/* Increment will be done in the next read_processed callback
|
||||
* In case of STOP, the byte won't be taken in account
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_target_stop(struct i2c_target_config *config)
|
||||
{
|
||||
struct i2c_eeprom_target_data *data = CONTAINER_OF(config,
|
||||
struct i2c_eeprom_target_data,
|
||||
config);
|
||||
|
||||
LOG_DBG("eeprom: stop");
|
||||
|
||||
data->first_write = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eeprom_target_register(const struct device *dev)
|
||||
{
|
||||
const struct i2c_eeprom_target_config *cfg = dev->config;
|
||||
struct i2c_eeprom_target_data *data = dev->data;
|
||||
|
||||
return i2c_target_register(cfg->bus.bus, &data->config);
|
||||
}
|
||||
|
||||
static int eeprom_target_unregister(const struct device *dev)
|
||||
{
|
||||
const struct i2c_eeprom_target_config *cfg = dev->config;
|
||||
struct i2c_eeprom_target_data *data = dev->data;
|
||||
|
||||
return i2c_target_unregister(cfg->bus.bus, &data->config);
|
||||
}
|
||||
|
||||
static const struct i2c_target_driver_api api_funcs = {
|
||||
.driver_register = eeprom_target_register,
|
||||
.driver_unregister = eeprom_target_unregister,
|
||||
};
|
||||
|
||||
static const struct i2c_target_callbacks eeprom_callbacks = {
|
||||
.write_requested = eeprom_target_write_requested,
|
||||
.read_requested = eeprom_target_read_requested,
|
||||
.write_received = eeprom_target_write_received,
|
||||
.read_processed = eeprom_target_read_processed,
|
||||
.stop = eeprom_target_stop,
|
||||
};
|
||||
|
||||
static int i2c_eeprom_target_init(const struct device *dev)
|
||||
{
|
||||
struct i2c_eeprom_target_data *data = dev->data;
|
||||
const struct i2c_eeprom_target_config *cfg = dev->config;
|
||||
|
||||
if (!device_is_ready(cfg->bus.bus)) {
|
||||
LOG_ERR("I2C controller device not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
data->buffer_size = cfg->buffer_size;
|
||||
data->buffer = cfg->buffer;
|
||||
data->config.address = cfg->bus.addr;
|
||||
data->config.callbacks = &eeprom_callbacks;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define I2C_EEPROM_INIT(inst) \
|
||||
static struct i2c_eeprom_target_data \
|
||||
i2c_eeprom_target_##inst##_dev_data; \
|
||||
\
|
||||
static uint8_t \
|
||||
i2c_eeprom_target_##inst##_buffer[(DT_INST_PROP(inst, size))]; \
|
||||
\
|
||||
static const struct i2c_eeprom_target_config \
|
||||
i2c_eeprom_target_##inst##_cfg = { \
|
||||
.bus = I2C_DT_SPEC_INST_GET(inst), \
|
||||
.buffer_size = DT_INST_PROP(inst, size), \
|
||||
.buffer = i2c_eeprom_target_##inst##_buffer \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(inst, \
|
||||
&i2c_eeprom_target_init, \
|
||||
NULL, \
|
||||
&i2c_eeprom_target_##inst##_dev_data, \
|
||||
&i2c_eeprom_target_##inst##_cfg, \
|
||||
POST_KERNEL, \
|
||||
CONFIG_I2C_TARGET_INIT_PRIORITY, \
|
||||
&api_funcs);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(I2C_EEPROM_INIT)
|
|
@ -27,7 +27,7 @@ static inline int bmg160_bus_config(const struct device *dev)
|
|||
const struct bmg160_device_config *dev_cfg = dev->config;
|
||||
uint32_t i2c_cfg;
|
||||
|
||||
i2c_cfg = I2C_MODE_MASTER | I2C_SPEED_SET(BMG160_BUS_SPEED);
|
||||
i2c_cfg = I2C_MODE_CONTROLLER | I2C_SPEED_SET(BMG160_BUS_SPEED);
|
||||
|
||||
return i2c_configure(dev_cfg->i2c.bus, i2c_cfg);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ static inline int hp206c_bus_config(const struct device *dev)
|
|||
const struct hp206c_device_config *cfg = dev->config;
|
||||
uint32_t i2c_cfg;
|
||||
|
||||
i2c_cfg = I2C_MODE_MASTER | I2C_SPEED_SET(I2C_SPEED_STANDARD);
|
||||
i2c_cfg = I2C_MODE_CONTROLLER | I2C_SPEED_SET(I2C_SPEED_STANDARD);
|
||||
|
||||
return i2c_configure(cfg->i2c.bus, i2c_cfg);
|
||||
}
|
||||
|
|
|
@ -1048,7 +1048,7 @@ static int ov2640_init_0(const struct device *dev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
uint32_t i2c_cfg = I2C_MODE_MASTER |
|
||||
uint32_t i2c_cfg = I2C_MODE_CONTROLLER |
|
||||
I2C_SPEED_SET(I2C_SPEED_STANDARD);
|
||||
|
||||
if (i2c_configure(drv_data->i2c, i2c_cfg)) {
|
||||
|
|
|
@ -58,8 +58,11 @@ extern "C" {
|
|||
/** Use 10-bit addressing. DEPRECATED - Use I2C_MSG_ADDR_10_BITS instead. */
|
||||
#define I2C_ADDR_10_BITS BIT(0)
|
||||
|
||||
/** Controller to act as Controller. */
|
||||
#define I2C_MODE_MASTER BIT(4)
|
||||
/** Peripheral to act as Controller. */
|
||||
#define I2C_MODE_CONTROLLER BIT(4)
|
||||
|
||||
/** @deprecated Use I2C_MODE_CONTROLLER instead. */
|
||||
#define I2C_MODE_MASTER __DEPRECATED_MACRO BIT(4)
|
||||
|
||||
/**
|
||||
* @brief Complete I2C DT information
|
||||
|
@ -162,7 +165,7 @@ struct i2c_msg {
|
|||
* These are for internal use only, so skip these in
|
||||
* public documentation.
|
||||
*/
|
||||
struct i2c_slave_config;
|
||||
struct i2c_target_config;
|
||||
|
||||
typedef int (*i2c_api_configure_t)(const struct device *dev,
|
||||
uint32_t dev_config);
|
||||
|
@ -172,27 +175,27 @@ typedef int (*i2c_api_full_io_t)(const struct device *dev,
|
|||
struct i2c_msg *msgs,
|
||||
uint8_t num_msgs,
|
||||
uint16_t addr);
|
||||
typedef int (*i2c_api_slave_register_t)(const struct device *dev,
|
||||
struct i2c_slave_config *cfg);
|
||||
typedef int (*i2c_api_slave_unregister_t)(const struct device *dev,
|
||||
struct i2c_slave_config *cfg);
|
||||
typedef int (*i2c_api_target_register_t)(const struct device *dev,
|
||||
struct i2c_target_config *cfg);
|
||||
typedef int (*i2c_api_target_unregister_t)(const struct device *dev,
|
||||
struct i2c_target_config *cfg);
|
||||
typedef int (*i2c_api_recover_bus_t)(const struct device *dev);
|
||||
|
||||
__subsystem struct i2c_driver_api {
|
||||
i2c_api_configure_t configure;
|
||||
i2c_api_get_config_t get_config;
|
||||
i2c_api_full_io_t transfer;
|
||||
i2c_api_slave_register_t slave_register;
|
||||
i2c_api_slave_unregister_t slave_unregister;
|
||||
i2c_api_target_register_t target_register;
|
||||
i2c_api_target_unregister_t target_unregister;
|
||||
i2c_api_recover_bus_t recover_bus;
|
||||
};
|
||||
|
||||
typedef int (*i2c_slave_api_register_t)(const struct device *dev);
|
||||
typedef int (*i2c_slave_api_unregister_t)(const struct device *dev);
|
||||
typedef int (*i2c_target_api_register_t)(const struct device *dev);
|
||||
typedef int (*i2c_target_api_unregister_t)(const struct device *dev);
|
||||
|
||||
struct i2c_slave_driver_api {
|
||||
i2c_slave_api_register_t driver_register;
|
||||
i2c_slave_api_unregister_t driver_unregister;
|
||||
struct i2c_target_driver_api {
|
||||
i2c_target_api_register_t driver_register;
|
||||
i2c_target_api_unregister_t driver_unregister;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -200,7 +203,7 @@ struct i2c_slave_driver_api {
|
|||
*/
|
||||
|
||||
/** Target device responds to 10-bit addressing. */
|
||||
#define I2C_SLAVE_FLAGS_ADDR_10_BITS BIT(0)
|
||||
#define I2C_TARGET_FLAGS_ADDR_10_BITS BIT(0)
|
||||
|
||||
/** @brief Function called when a write to the device is initiated.
|
||||
*
|
||||
|
@ -217,8 +220,8 @@ struct i2c_slave_driver_api {
|
|||
*
|
||||
* @return 0 if the write is accepted, or a negative error code.
|
||||
*/
|
||||
typedef int (*i2c_slave_write_requested_cb_t)(
|
||||
struct i2c_slave_config *config);
|
||||
typedef int (*i2c_target_write_requested_cb_t)(
|
||||
struct i2c_target_config *config);
|
||||
|
||||
/** @brief Function called when a write to the device is continued.
|
||||
*
|
||||
|
@ -238,8 +241,8 @@ typedef int (*i2c_slave_write_requested_cb_t)(
|
|||
* @return 0 if more data can be accepted, or a negative error
|
||||
* code.
|
||||
*/
|
||||
typedef int (*i2c_slave_write_received_cb_t)(
|
||||
struct i2c_slave_config *config, uint8_t val);
|
||||
typedef int (*i2c_target_write_received_cb_t)(
|
||||
struct i2c_target_config *config, uint8_t val);
|
||||
|
||||
/** @brief Function called when a read from the device is initiated.
|
||||
*
|
||||
|
@ -260,8 +263,8 @@ typedef int (*i2c_slave_write_received_cb_t)(
|
|||
*
|
||||
* @return 0 if more data can be requested, or a negative error code.
|
||||
*/
|
||||
typedef int (*i2c_slave_read_requested_cb_t)(
|
||||
struct i2c_slave_config *config, uint8_t *val);
|
||||
typedef int (*i2c_target_read_requested_cb_t)(
|
||||
struct i2c_target_config *config, uint8_t *val);
|
||||
|
||||
/** @brief Function called when a read from the device is continued.
|
||||
*
|
||||
|
@ -282,8 +285,8 @@ typedef int (*i2c_slave_read_requested_cb_t)(
|
|||
*
|
||||
* @return 0 if data has been provided, or a negative error code.
|
||||
*/
|
||||
typedef int (*i2c_slave_read_processed_cb_t)(
|
||||
struct i2c_slave_config *config, uint8_t *val);
|
||||
typedef int (*i2c_target_read_processed_cb_t)(
|
||||
struct i2c_target_config *config, uint8_t *val);
|
||||
|
||||
/** @brief Function called when a stop condition is observed after a
|
||||
* start condition addressed to a particular device.
|
||||
|
@ -299,7 +302,7 @@ typedef int (*i2c_slave_read_processed_cb_t)(
|
|||
*
|
||||
* @return Ignored.
|
||||
*/
|
||||
typedef int (*i2c_slave_stop_cb_t)(struct i2c_slave_config *config);
|
||||
typedef int (*i2c_target_stop_cb_t)(struct i2c_target_config *config);
|
||||
|
||||
/** @brief Structure providing callbacks to be implemented for devices
|
||||
* that supports the I2C target API.
|
||||
|
@ -307,37 +310,37 @@ typedef int (*i2c_slave_stop_cb_t)(struct i2c_slave_config *config);
|
|||
* This structure may be shared by multiple devices that implement the
|
||||
* same API at different addresses on the bus.
|
||||
*/
|
||||
struct i2c_slave_callbacks {
|
||||
i2c_slave_write_requested_cb_t write_requested;
|
||||
i2c_slave_read_requested_cb_t read_requested;
|
||||
i2c_slave_write_received_cb_t write_received;
|
||||
i2c_slave_read_processed_cb_t read_processed;
|
||||
i2c_slave_stop_cb_t stop;
|
||||
struct i2c_target_callbacks {
|
||||
i2c_target_write_requested_cb_t write_requested;
|
||||
i2c_target_read_requested_cb_t read_requested;
|
||||
i2c_target_write_received_cb_t write_received;
|
||||
i2c_target_read_processed_cb_t read_processed;
|
||||
i2c_target_stop_cb_t stop;
|
||||
};
|
||||
|
||||
/** @brief Structure describing a device that supports the I2C
|
||||
* target API.
|
||||
*
|
||||
* Instances of this are passed to the i2c_slave_register() and
|
||||
* i2c_slave_unregister() functions to indicate addition and removal
|
||||
* Instances of this are passed to the i2c_target_register() and
|
||||
* i2c_target_unregister() functions to indicate addition and removal
|
||||
* of a target device, respective.
|
||||
*
|
||||
* Fields other than @c node must be initialized by the module that
|
||||
* implements the device behavior prior to passing the object
|
||||
* reference to i2c_slave_register().
|
||||
* reference to i2c_target_register().
|
||||
*/
|
||||
struct i2c_slave_config {
|
||||
struct i2c_target_config {
|
||||
/** Private, do not modify */
|
||||
sys_snode_t node;
|
||||
|
||||
/** Flags for the target device defined by I2C_SLAVE_FLAGS_* constants */
|
||||
/** Flags for the target device defined by I2C_TARGET_FLAGS_* constants */
|
||||
uint8_t flags;
|
||||
|
||||
/** Address for this target device */
|
||||
uint16_t address;
|
||||
|
||||
/** Callback functions */
|
||||
const struct i2c_slave_callbacks *callbacks;
|
||||
const struct i2c_target_callbacks *callbacks;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_I2C_STATS) || defined(__DOXYGEN__)
|
||||
|
@ -668,17 +671,17 @@ static inline int z_impl_i2c_recover_bus(const struct device *dev)
|
|||
* @retval -EIO General input / output error.
|
||||
* @retval -ENOSYS If target mode is not implemented
|
||||
*/
|
||||
static inline int i2c_slave_register(const struct device *dev,
|
||||
struct i2c_slave_config *cfg)
|
||||
static inline int i2c_target_register(const struct device *dev,
|
||||
struct i2c_target_config *cfg)
|
||||
{
|
||||
const struct i2c_driver_api *api =
|
||||
(const struct i2c_driver_api *)dev->api;
|
||||
|
||||
if (api->slave_register == NULL) {
|
||||
if (api->target_register == NULL) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return api->slave_register(dev, cfg);
|
||||
return api->target_register(dev, cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -697,24 +700,24 @@ static inline int i2c_slave_register(const struct device *dev,
|
|||
* @retval -EINVAL If parameters are invalid
|
||||
* @retval -ENOSYS If target mode is not implemented
|
||||
*/
|
||||
static inline int i2c_slave_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *cfg)
|
||||
static inline int i2c_target_unregister(const struct device *dev,
|
||||
struct i2c_target_config *cfg)
|
||||
{
|
||||
const struct i2c_driver_api *api =
|
||||
(const struct i2c_driver_api *)dev->api;
|
||||
|
||||
if (api->slave_unregister == NULL) {
|
||||
if (api->target_unregister == NULL) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return api->slave_unregister(dev, cfg);
|
||||
return api->target_unregister(dev, cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Instructs the I2C Target device to register itself to the I2C Controller
|
||||
*
|
||||
* This routine instructs the I2C Target device to register itself to the I2C
|
||||
* Controller via its parent controller's i2c_slave_register() API.
|
||||
* Controller via its parent controller's i2c_target_register() API.
|
||||
*
|
||||
* @param dev Pointer to the device structure for the I2C target
|
||||
* device (not itself an I2C controller).
|
||||
|
@ -723,12 +726,12 @@ static inline int i2c_slave_unregister(const struct device *dev,
|
|||
* @retval -EINVAL If parameters are invalid
|
||||
* @retval -EIO General input / output error.
|
||||
*/
|
||||
__syscall int i2c_slave_driver_register(const struct device *dev);
|
||||
__syscall int i2c_target_driver_register(const struct device *dev);
|
||||
|
||||
static inline int z_impl_i2c_slave_driver_register(const struct device *dev)
|
||||
static inline int z_impl_i2c_target_driver_register(const struct device *dev)
|
||||
{
|
||||
const struct i2c_slave_driver_api *api =
|
||||
(const struct i2c_slave_driver_api *)dev->api;
|
||||
const struct i2c_target_driver_api *api =
|
||||
(const struct i2c_target_driver_api *)dev->api;
|
||||
|
||||
return api->driver_register(dev);
|
||||
}
|
||||
|
@ -738,7 +741,7 @@ static inline int z_impl_i2c_slave_driver_register(const struct device *dev)
|
|||
* Controller
|
||||
*
|
||||
* This routine instructs the I2C Target device to unregister itself from the I2C
|
||||
* Controller via its parent controller's i2c_slave_register() API.
|
||||
* Controller via its parent controller's i2c_target_register() API.
|
||||
*
|
||||
* @param dev Pointer to the device structure for the I2C target
|
||||
* device (not itself an I2C controller).
|
||||
|
@ -746,12 +749,12 @@ static inline int z_impl_i2c_slave_driver_register(const struct device *dev)
|
|||
* @retval 0 Is successful
|
||||
* @retval -EINVAL If parameters are invalid
|
||||
*/
|
||||
__syscall int i2c_slave_driver_unregister(const struct device *dev);
|
||||
__syscall int i2c_target_driver_unregister(const struct device *dev);
|
||||
|
||||
static inline int z_impl_i2c_slave_driver_unregister(const struct device *dev)
|
||||
static inline int z_impl_i2c_target_driver_unregister(const struct device *dev)
|
||||
{
|
||||
const struct i2c_slave_driver_api *api =
|
||||
(const struct i2c_slave_driver_api *)dev->api;
|
||||
const struct i2c_target_driver_api *api =
|
||||
(const struct i2c_target_driver_api *)dev->api;
|
||||
|
||||
return api->driver_unregister(dev);
|
||||
}
|
||||
|
@ -1203,19 +1206,19 @@ void i2c_dump_msgs(const char *name, const struct i2c_msg *msgs,
|
|||
uint8_t num_msgs, uint16_t addr);
|
||||
|
||||
struct i2c_client_config {
|
||||
char *i2c_master;
|
||||
char *i2c_controller;
|
||||
uint16_t i2c_addr;
|
||||
};
|
||||
|
||||
#define I2C_DECLARE_CLIENT_CONFIG struct i2c_client_config i2c_client
|
||||
|
||||
#define I2C_CLIENT(_master, _addr) \
|
||||
#define I2C_CLIENT(_controller, _addr) \
|
||||
.i2c_client = { \
|
||||
.i2c_master = (_master), \
|
||||
.i2c_controller = (_controller), \
|
||||
.i2c_addr = (_addr), \
|
||||
}
|
||||
|
||||
#define I2C_GET_MASTER(_conf) ((_conf)->i2c_client.i2c_master)
|
||||
#define I2C_GET_CONTROLLER(_conf) ((_conf)->i2c_client.i2c_controller)
|
||||
#define I2C_GET_ADDR(_conf) ((_conf)->i2c_client.i2c_addr)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Public APIs for the I2C EEPROM Slave driver.
|
||||
* @brief Public APIs for the I2C EEPROM Target driver.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -9,12 +9,12 @@
|
|||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef ZEPHYR_INCLUDE_DRIVERS_I2C_SLAVE_EEPROM_H_
|
||||
#define ZEPHYR_INCLUDE_DRIVERS_I2C_SLAVE_EEPROM_H_
|
||||
#ifndef ZEPHYR_INCLUDE_DRIVERS_I2C_TARGET_EEPROM_H_
|
||||
#define ZEPHYR_INCLUDE_DRIVERS_I2C_TARGET_EEPROM_H_
|
||||
|
||||
/**
|
||||
* @brief I2C EEPROM Slave Driver API
|
||||
* @defgroup i2c_eeprom_slave_api I2C EEPROM Slave Driver API
|
||||
* @brief I2C EEPROM Target Driver API
|
||||
* @defgroup i2c_eeprom_target_api I2C EEPROM Target Driver API
|
||||
* @ingroup io_interfaces
|
||||
* @{
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@
|
|||
* @retval 0 If successful.
|
||||
* @retval -EINVAL Invalid data size
|
||||
*/
|
||||
int eeprom_slave_program(const struct device *dev, const uint8_t *eeprom_data,
|
||||
int eeprom_target_program(const struct device *dev, const uint8_t *eeprom_data,
|
||||
unsigned int length);
|
||||
|
||||
/**
|
||||
|
@ -42,11 +42,11 @@ int eeprom_slave_program(const struct device *dev, const uint8_t *eeprom_data,
|
|||
* @retval 0 If successful.
|
||||
* @retval -EINVAL Invalid data pointer or offset
|
||||
*/
|
||||
int eeprom_slave_read(const struct device *dev, uint8_t *eeprom_data,
|
||||
int eeprom_target_read(const struct device *dev, uint8_t *eeprom_data,
|
||||
unsigned int offset);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_DRIVERS_I2C_SLAVE_EEPROM_H_ */
|
||||
#endif /* ZEPHYR_INCLUDE_DRIVERS_I2C_TARGET_EEPROM_H_ */
|
|
@ -67,7 +67,7 @@ static int test_i2c_adv7513(void)
|
|||
{
|
||||
const struct device *i2c_dev =
|
||||
device_get_binding(DT_LABEL(DT_INST(0, altr_nios2_i2c)));
|
||||
uint32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_MASTER;
|
||||
uint32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_CONTROLLER;
|
||||
uint8_t data;
|
||||
|
||||
if (!i2c_dev) {
|
||||
|
|
|
@ -28,7 +28,7 @@ void test_i2c_pca95xx(void)
|
|||
{
|
||||
int32_t ret;
|
||||
uint8_t datas[3];
|
||||
uint32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_MASTER;
|
||||
uint32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_CONTROLLER;
|
||||
|
||||
/* get i2c device */
|
||||
const struct device *i2c_dev = device_get_binding(I2C_DEV_NAME);
|
||||
|
|
|
@ -196,7 +196,7 @@ static void run_tests_on_eeprom(const char *label_eeprom, const char *label_i2c)
|
|||
if (i2c != NULL) {
|
||||
/* If the test is using I2C, configure it */
|
||||
k_object_access_grant(i2c, k_current_get());
|
||||
i2c_configure(i2c, I2C_MODE_MASTER |
|
||||
i2c_configure(i2c, I2C_MODE_CONTROLLER |
|
||||
I2C_SPEED_SET(I2C_SPEED_STANDARD));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#error "Please set the correct I2C device"
|
||||
#endif
|
||||
|
||||
uint32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_MASTER;
|
||||
uint32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_CONTROLLER;
|
||||
|
||||
static int test_gy271(void)
|
||||
{
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
mainmenu "I2C Slave API Test"
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
||||
source "tests/drivers/i2c/i2c_slave_api/common/Kconfig"
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_I2C=y
|
||||
CONFIG_I2C_SLAVE=y
|
7
tests/drivers/i2c/i2c_target_api/Kconfig
Normal file
7
tests/drivers/i2c/i2c_target_api/Kconfig
Normal file
|
@ -0,0 +1,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
mainmenu "I2C Target API Test"
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
||||
source "tests/drivers/i2c/i2c_target_api/common/Kconfig"
|
|
@ -1,19 +1,19 @@
|
|||
I2C Slave API test
|
||||
I2C Target API test
|
||||
##################
|
||||
|
||||
.. note:
|
||||
See :ref:`coding_guideline_inclusive_language` for information about
|
||||
plans to change the terminology used in this API.
|
||||
|
||||
This test verifies I2C slave driver implementations using two I2C
|
||||
This test verifies I2C target driver implementations using two I2C
|
||||
controllers on a common bus. The test is supported by a test-specific
|
||||
driver that simulates an EEPROM with an I2C bus slave interface. Data
|
||||
driver that simulates an EEPROM with an I2C bus target interface. Data
|
||||
is pre-loaded into the simulated devices outside the I2C API, and the
|
||||
Zephyr application issues commands to one controller that are responded
|
||||
to by the simulated EEPROM connected through the other controller.
|
||||
|
||||
This test was originally designed for I2C controllers that support both
|
||||
master and slave behavior simultaneously. This is not true of all
|
||||
controller and target behavior simultaneously. This is not true of all
|
||||
I2C controllers, so this behavior is now opt-in using
|
||||
CONFIG_APP_DUAL_ROLE_I2C. However, the devicetree still must provide a
|
||||
second EEPROM just to identify the bus.
|
||||
|
@ -22,11 +22,11 @@ In slightly more detail the test has these phases:
|
|||
|
||||
* Use API specific to the simulated EEPROM to pre-populate the simulated
|
||||
devices with device-specific content.
|
||||
* Register a simulated EEPROM as a I2C slave device on a bus. If
|
||||
* Register a simulated EEPROM as a I2C target device on a bus. If
|
||||
CONFIG_APP_DUAL_ROLE_I2C is selected, register both.
|
||||
|
||||
* Issue commands on one bus controller (operating as the bus master) and
|
||||
verify that the data supplied by the other controller (slave) match
|
||||
* Issue commands on one bus controller (operating as the bus controller) and
|
||||
verify that the data supplied by the other controller (target) match
|
||||
the expected values given the content known to be present on the
|
||||
simulated device. If CONFIG_APP_DUAL_ROLE_I2C is selected, do this
|
||||
with the roles reversed.
|
2
tests/drivers/i2c/i2c_target_api/boards/rpi_pico.conf
Normal file
2
tests/drivers/i2c/i2c_target_api/boards/rpi_pico.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
CONFIG_I2C=y
|
||||
CONFIG_I2C_TARGET=y
|
|
@ -1,14 +1,14 @@
|
|||
# I2C slave tests common configuration options
|
||||
# I2C target tests common configuration options
|
||||
|
||||
# Copyright (c) 2017 BayLibre, SAS
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config I2C_VIRTUAL
|
||||
bool "Virtual I2C Driver for Slave development"
|
||||
bool "Virtual I2C Driver for Target development"
|
||||
depends on I2C
|
||||
help
|
||||
This driver exposes a virtual I2C driver used to debug virtual
|
||||
I2C slave drivers.
|
||||
I2C target drivers.
|
||||
|
||||
config I2C_VIRTUAL_NAME
|
||||
string "Virtual Port device name"
|
||||
|
@ -16,4 +16,4 @@ config I2C_VIRTUAL_NAME
|
|||
depends on I2C_VIRTUAL
|
||||
|
||||
config APP_DUAL_ROLE_I2C
|
||||
bool "Test with combined master/slave behavior"
|
||||
bool "Test with combined controller/target behavior"
|
|
@ -16,7 +16,7 @@
|
|||
LOG_MODULE_DECLARE(main);
|
||||
|
||||
struct i2c_virtual_data {
|
||||
sys_slist_t slaves;
|
||||
sys_slist_t targets;
|
||||
};
|
||||
|
||||
int i2c_virtual_runtime_configure(const struct device *dev, uint32_t config)
|
||||
|
@ -24,17 +24,17 @@ int i2c_virtual_runtime_configure(const struct device *dev, uint32_t config)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_slave_config *find_address(struct i2c_virtual_data *data,
|
||||
static struct i2c_target_config *find_address(struct i2c_virtual_data *data,
|
||||
uint16_t address, bool is_10bit)
|
||||
{
|
||||
struct i2c_slave_config *cfg = NULL;
|
||||
struct i2c_target_config *cfg = NULL;
|
||||
sys_snode_t *node;
|
||||
bool search_10bit;
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&data->slaves, node) {
|
||||
cfg = CONTAINER_OF(node, struct i2c_slave_config, node);
|
||||
SYS_SLIST_FOR_EACH_NODE(&data->targets, node) {
|
||||
cfg = CONTAINER_OF(node, struct i2c_target_config, node);
|
||||
|
||||
search_10bit = (cfg->flags & I2C_SLAVE_FLAGS_ADDR_10_BITS);
|
||||
search_10bit = (cfg->flags & I2C_TARGET_FLAGS_ADDR_10_BITS);
|
||||
|
||||
if (cfg->address == address && search_10bit == is_10bit) {
|
||||
return cfg;
|
||||
|
@ -44,9 +44,9 @@ static struct i2c_slave_config *find_address(struct i2c_virtual_data *data,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Attach I2C slaves */
|
||||
int i2c_virtual_slave_register(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
/* Attach I2C targets */
|
||||
int i2c_virtual_target_register(const struct device *dev,
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
struct i2c_virtual_data *data = dev->data;
|
||||
|
||||
|
@ -56,18 +56,18 @@ int i2c_virtual_slave_register(const struct device *dev,
|
|||
|
||||
/* Check the address is unique */
|
||||
if (find_address(data, config->address,
|
||||
(config->flags & I2C_SLAVE_FLAGS_ADDR_10_BITS))) {
|
||||
(config->flags & I2C_TARGET_FLAGS_ADDR_10_BITS))) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sys_slist_append(&data->slaves, &config->node);
|
||||
sys_slist_append(&data->targets, &config->node);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int i2c_virtual_slave_unregister(const struct device *dev,
|
||||
struct i2c_slave_config *config)
|
||||
int i2c_virtual_target_unregister(const struct device *dev,
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
struct i2c_virtual_data *data = dev->data;
|
||||
|
||||
|
@ -75,7 +75,7 @@ int i2c_virtual_slave_unregister(const struct device *dev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!sys_slist_find_and_remove(&data->slaves, &config->node)) {
|
||||
if (!sys_slist_find_and_remove(&data->targets, &config->node)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ int i2c_virtual_slave_unregister(const struct device *dev,
|
|||
|
||||
static int i2c_virtual_msg_write(const struct device *dev,
|
||||
struct i2c_msg *msg,
|
||||
struct i2c_slave_config *config,
|
||||
struct i2c_target_config *config,
|
||||
bool prev_write)
|
||||
{
|
||||
unsigned int len = 0U;
|
||||
|
@ -118,7 +118,7 @@ error:
|
|||
}
|
||||
|
||||
static int i2c_virtual_msg_read(const struct device *dev, struct i2c_msg *msg,
|
||||
struct i2c_slave_config *config)
|
||||
struct i2c_target_config *config)
|
||||
{
|
||||
unsigned int len = msg->len;
|
||||
uint8_t *buf = msg->buf;
|
||||
|
@ -147,15 +147,15 @@ static int i2c_virtual_msg_read(const struct device *dev, struct i2c_msg *msg,
|
|||
#define OPERATION(msg) (((struct i2c_msg *) msg)->flags & I2C_MSG_RW_MASK)
|
||||
|
||||
static int i2c_virtual_transfer(const struct device *dev, struct i2c_msg *msg,
|
||||
uint8_t num_msgs, uint16_t slave)
|
||||
uint8_t num_msgs, uint16_t target)
|
||||
{
|
||||
struct i2c_virtual_data *data = dev->data;
|
||||
struct i2c_msg *current, *next;
|
||||
struct i2c_slave_config *cfg;
|
||||
struct i2c_target_config *cfg;
|
||||
bool is_write = false;
|
||||
int ret = 0;
|
||||
|
||||
cfg = find_address(data, slave, (msg->flags & I2C_SLAVE_FLAGS_ADDR_10_BITS));
|
||||
cfg = find_address(data, target, (msg->flags & I2C_TARGET_FLAGS_ADDR_10_BITS));
|
||||
if (!cfg) {
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -207,15 +207,15 @@ static int i2c_virtual_transfer(const struct device *dev, struct i2c_msg *msg,
|
|||
static const struct i2c_driver_api api_funcs = {
|
||||
.configure = i2c_virtual_runtime_configure,
|
||||
.transfer = i2c_virtual_transfer,
|
||||
.slave_register = i2c_virtual_slave_register,
|
||||
.slave_unregister = i2c_virtual_slave_unregister,
|
||||
.target_register = i2c_virtual_target_register,
|
||||
.target_unregister = i2c_virtual_target_unregister,
|
||||
};
|
||||
|
||||
static int i2c_virtual_init(const struct device *dev)
|
||||
{
|
||||
struct i2c_virtual_data *data = dev->data;
|
||||
|
||||
sys_slist_init(&data->slaves);
|
||||
sys_slist_init(&data->targets);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -3,6 +3,6 @@ CONFIG_I2C_LOG_LEVEL_INF=y
|
|||
CONFIG_BOOT_BANNER=y
|
||||
CONFIG_ZTEST=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_SLAVE=y
|
||||
CONFIG_I2C_EEPROM_SLAVE=y
|
||||
CONFIG_I2C_TARGET=y
|
||||
CONFIG_I2C_EEPROM_TARGET=y
|
||||
CONFIG_I2C_VIRTUAL=y
|
|
@ -14,7 +14,7 @@
|
|||
#include <zephyr/sys/util.h>
|
||||
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <zephyr/drivers/i2c/slave/eeprom.h>
|
||||
#include <zephyr/drivers/i2c/target/eeprom.h>
|
||||
|
||||
#include <ztest.h>
|
||||
|
||||
|
@ -132,7 +132,7 @@ static int run_program_read(const struct device *i2c, uint8_t addr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void test_eeprom_slave(void)
|
||||
void test_eeprom_target(void)
|
||||
{
|
||||
const char *label_0 = DT_LABEL(NODE_EP0);
|
||||
const struct device *eeprom_0 = device_get_binding(label_0);
|
||||
|
@ -167,29 +167,29 @@ void test_eeprom_slave(void)
|
|||
/* Program differentiable data into the two devices through a back door
|
||||
* that doesn't use I2C.
|
||||
*/
|
||||
ret = eeprom_slave_program(eeprom_0, eeprom_0_data, TEST_DATA_SIZE);
|
||||
ret = eeprom_target_program(eeprom_0, eeprom_0_data, TEST_DATA_SIZE);
|
||||
zassert_equal(ret, 0, "Failed to program EEPROM %s", label_0);
|
||||
if (IS_ENABLED(CONFIG_APP_DUAL_ROLE_I2C)) {
|
||||
ret = eeprom_slave_program(eeprom_1, eeprom_1_data,
|
||||
ret = eeprom_target_program(eeprom_1, eeprom_1_data,
|
||||
TEST_DATA_SIZE);
|
||||
zassert_equal(ret, 0, "Failed to program EEPROM %s", label_1);
|
||||
}
|
||||
|
||||
/* Attach each EEPROM to its owning bus as a slave device. */
|
||||
ret = i2c_slave_driver_register(eeprom_0);
|
||||
/* Attach each EEPROM to its owning bus as a target device. */
|
||||
ret = i2c_target_driver_register(eeprom_0);
|
||||
zassert_equal(ret, 0, "Failed to register EEPROM %s", label_0);
|
||||
|
||||
if (IS_ENABLED(CONFIG_APP_DUAL_ROLE_I2C)) {
|
||||
ret = i2c_slave_driver_register(eeprom_1);
|
||||
ret = i2c_target_driver_register(eeprom_1);
|
||||
zassert_equal(ret, 0, "Failed to register EEPROM %s", label_1);
|
||||
}
|
||||
|
||||
/* The simulated EP0 is configured to be accessed as a slave device
|
||||
/* The simulated EP0 is configured to be accessed as a target device
|
||||
* at addr_0 on i2c_0 and should expose eeprom_0_data. The validation
|
||||
* uses i2c_1 as a bus master to access this device, which works because
|
||||
* i2c_0 and i2_c have their SDA (SCL) pins shorted (they are on the
|
||||
* same physical bus). Thus in these calls i2c_1 is a master device
|
||||
* operating on the slave address addr_0.
|
||||
* operating on the target address addr_0.
|
||||
*
|
||||
* Similarly validation of EP1 uses i2c_0 as a master with addr_1 and
|
||||
* eeprom_1_data for validation.
|
||||
|
@ -226,11 +226,11 @@ void test_eeprom_slave(void)
|
|||
}
|
||||
|
||||
/* Detach EEPROM */
|
||||
ret = i2c_slave_driver_unregister(eeprom_0);
|
||||
ret = i2c_target_driver_unregister(eeprom_0);
|
||||
zassert_equal(ret, 0, "Failed to unregister EEPROM %s", label_0);
|
||||
|
||||
if (IS_ENABLED(CONFIG_APP_DUAL_ROLE_I2C)) {
|
||||
ret = i2c_slave_driver_unregister(eeprom_1);
|
||||
ret = i2c_target_driver_unregister(eeprom_1);
|
||||
zassert_equal(ret, 0, "Failed to unregister EEPROM %s",
|
||||
label_1);
|
||||
}
|
||||
|
@ -238,6 +238,6 @@ void test_eeprom_slave(void)
|
|||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(test_eeprom_slave, ztest_unit_test(test_eeprom_slave));
|
||||
ztest_run_test_suite(test_eeprom_slave);
|
||||
ztest_test_suite(test_eeprom_target, ztest_unit_test(test_eeprom_target));
|
||||
ztest_run_test_suite(test_eeprom_target);
|
||||
}
|
|
@ -6,7 +6,7 @@ common:
|
|||
fixture: i2c_bus_short
|
||||
|
||||
tests:
|
||||
drivers.i2c.slave_api.dual_role:
|
||||
drivers.i2c.target_api.dual_role:
|
||||
platform_allow: nucleo_f091rc stm32f072b_disco nucleo_g071rb rpi_pico
|
||||
extra_configs:
|
||||
- CONFIG_APP_DUAL_ROLE_I2C=y
|
Loading…
Reference in a new issue