diff --git a/drivers/sensors/Kconfig b/drivers/sensors/Kconfig index 03911022b5..43c82293f1 100644 --- a/drivers/sensors/Kconfig +++ b/drivers/sensors/Kconfig @@ -41,6 +41,11 @@ config HTS221 if HTS221 +config HTS221_I2C_FREQUENCY + int "HTS221 I2C frequency" + default 400000 + range 1 400000 + config DEBUG_HTS221 bool "Debug support for the HTS221" default n @@ -84,6 +89,11 @@ config LIS2DH if LIS2DH +config LIS2DH_I2C_FREQUENCY + int "LIS2DH I2C frequency" + default 400000 + range 1 400000 + config DEBUG_LIS2DH bool "Debug support for the LIS2DH" default n @@ -144,6 +154,11 @@ config LPS25H if LPS25H +config LPS25H_I2C_FREQUENCY + int "LPS25H I2C frequency" + default 400000 + range 1 400000 + config DEBUG_LPS25H bool "Debug support for the LPS25H" default n diff --git a/drivers/sensors/hts221.c b/drivers/sensors/hts221.c index 9f3138bddf..9b85cf7e93 100644 --- a/drivers/sensors/hts221.c +++ b/drivers/sensors/hts221.c @@ -61,6 +61,10 @@ # define hts221_dbg(x, ...) sninfo(x, ##__VA_ARGS__) #endif +#ifndef CONFIG_HTS221_I2C_FREQUENCY +# define CONFIG_HTS221_I2C_FREQUENCY 400000 +#endif + #define HTS221_WHO_AM_I 0x0f #define HTS221_AV_CONF 0x10 #define HTS221_CTRL_REG1 0x20 @@ -221,16 +225,18 @@ static int32_t hts221_write_reg8(FAR struct hts221_dev_s *priv, struct i2c_msg_s msgv[2] = { { - .addr = priv->addr, - .flags = 0, - .buffer = (FAR void *)&command[0], - .length = 1 + .frequency = CONFIG_HTS221_I2C_FREQUENCY, + .addr = priv->addr, + .flags = 0, + .buffer = (FAR void *)&command[0], + .length = 1 }, { - .addr = priv->addr, - .flags = I2C_M_NORESTART, - .buffer = (FAR void *)&command[1], - .length = 1 + .frequency = CONFIG_HTS221_I2C_FREQUENCY, + .addr = priv->addr, + .flags = I2C_M_NORESTART, + .buffer = (FAR void *)&command[1], + .length = 1 } }; @@ -243,16 +249,18 @@ static int hts221_read_reg(FAR struct hts221_dev_s *priv, struct i2c_msg_s msgv[2] = { { - .addr = priv->addr, - .flags = 0, - .buffer = (FAR void *)command, - .length = 1 + .frequency = CONFIG_HTS221_I2C_FREQUENCY, + .addr = priv->addr, + .flags = 0, + .buffer = (FAR void *)command, + .length = 1 }, { - .addr = priv->addr, - .flags = I2C_M_READ, - .buffer = value, - .length = 1 + .frequency = CONFIG_HTS221_I2C_FREQUENCY, + .addr = priv->addr, + .flags = I2C_M_READ, + .buffer = value, + .length = 1 } }; diff --git a/drivers/sensors/lis2dh.c b/drivers/sensors/lis2dh.c index f7a982f151..67e0bf1185 100644 --- a/drivers/sensors/lis2dh.c +++ b/drivers/sensors/lis2dh.c @@ -65,6 +65,10 @@ # define lis2dh_dbg(x, ...) sninfo(x, ##__VA_ARGS__) #endif +#ifndef CONFIG_LIS2DH_I2C_FREQUENCY +# define CONFIG_LIS2DH_I2C_FREQUENCY 400000 +#endif + #ifdef CONFIG_LIS2DH_DRIVER_SELFTEST # define LSB_AT_10BIT_RESOLUTION 4 # define LSB_AT_12BIT_RESOLUTION 1 @@ -1594,16 +1598,18 @@ static int lis2dh_access(FAR struct lis2dh_dev_s *dev, uint8_t subaddr, struct i2c_msg_s msgv[2] = { { - .addr = dev->addr, - .flags = 0, - .buffer = &subaddr, - .length = 1 + .frequency = CONFIG_LIS2DH_I2C_FREQUENCY, + .addr = dev->addr, + .flags = 0, + .buffer = &subaddr, + .length = 1 }, { - .addr = dev->addr, - .flags = flags, - .buffer = buf, - .length = length + .frequency = CONFIG_LIS2DH_I2C_FREQUENCY, + .addr = dev->addr, + .flags = flags, + .buffer = buf, + .length = length } }; diff --git a/drivers/sensors/lps25h.c b/drivers/sensors/lps25h.c index bd35f38043..1eb762af0a 100644 --- a/drivers/sensors/lps25h.c +++ b/drivers/sensors/lps25h.c @@ -58,6 +58,10 @@ # define lps25h_dbg(x, ...) sninfo(x, ##__VA_ARGS__) #endif +#ifndef CONFIG_LPS25H_I2C_FREQUENCY +# define CONFIG_LPS25H_I2C_FREQUENCY 400000 +#endif + #define LPS25H_PRESSURE_INTERNAL_DIVIDER 4096 /* 'AN4450 - Hardware and software guidelines for use of LPS25H pressure @@ -277,16 +281,18 @@ static int lps25h_write_reg8(struct lps25h_dev_s *dev, uint8_t reg_addr, struct i2c_msg_s msgv[2] = { { - .addr = dev->addr, - .flags = 0, - .buffer = ®_addr, - .length = 1 + .frequency = CONFIG_LPS25H_I2C_FREQUENCY, + .addr = dev->addr, + .flags = 0, + .buffer = ®_addr, + .length = 1 }, { - .addr = dev->addr, - .flags = I2C_M_NORESTART, - .buffer = (void *)&value, - .length = 1 + .frequency = CONFIG_LPS25H_I2C_FREQUENCY, + .addr = dev->addr, + .flags = I2C_M_NORESTART, + .buffer = (void *)&value, + .length = 1 } }; @@ -300,16 +306,18 @@ static int lps25h_read_reg8(FAR struct lps25h_dev_s *dev, struct i2c_msg_s msgv[2] = { { - .addr = dev->addr, - .flags = 0, - .buffer = reg_addr, - .length = 1 + .frequency = CONFIG_LPS25H_I2C_FREQUENCY, + .addr = dev->addr, + .flags = 0, + .buffer = reg_addr, + .length = 1 }, { - .addr = dev->addr, - .flags = I2C_M_READ, - .buffer = value, - .length = 1 + .frequency = CONFIG_LPS25H_I2C_FREQUENCY, + .addr = dev->addr, + .flags = I2C_M_READ, + .buffer = value, + .length = 1 } }; diff --git a/drivers/usbmisc/Kconfig b/drivers/usbmisc/Kconfig index 68bd619ee3..6669061283 100644 --- a/drivers/usbmisc/Kconfig +++ b/drivers/usbmisc/Kconfig @@ -14,6 +14,11 @@ config FUSB301 if FUSB301 +config FUSB301_I2C_FREQUENCY + int "FUSB301 I2C frequency" + default 400000 + range 1 400000 + config DEBUG_FUSB301 bool "Enable debug support for the FUSB301" default n diff --git a/drivers/usbmisc/fusb301.c b/drivers/usbmisc/fusb301.c index f24ae78558..d57d8a95ec 100644 --- a/drivers/usbmisc/fusb301.c +++ b/drivers/usbmisc/fusb301.c @@ -63,6 +63,10 @@ # define fusb301_info(x, ...) uinfo(x, ##__VA_ARGS__) #endif +#ifndef CONFIG_FUSB301_I2C_FREQUENCY +# define CONFIG_FUSB301_I2C_FREQUENCY 400000 +#endif + /* Other macros */ #define FUSB301_I2C_RETRIES 10 @@ -146,15 +150,17 @@ static int fusb301_getreg(FAR struct fusb301_dev_s *priv, uint8_t reg) DEBUGASSERT(priv); - msg[0].addr = priv->addr; - msg[0].flags = 0; - msg[0].buffer = ® - msg[0].length = 1; + msg[0].frequency = CONFIG_FUSB301_I2C_FREQUENCY; + msg[0].addr = priv->addr; + msg[0].flags = 0; + msg[0].buffer = ® + msg[0].length = 1; - msg[1].addr = priv->addr; - msg[1].flags = I2C_M_READ; - msg[1].buffer = ®val; - msg[1].length = 1; + msg[1].frequency = CONFIG_FUSB301_I2C_FREQUENCY; + msg[1].addr = priv->addr; + msg[1].flags = I2C_M_READ; + msg[1].buffer = ®val; + msg[1].length = 1; /* Perform the transfer */ @@ -220,10 +226,11 @@ static int fusb301_putreg(FAR struct fusb301_dev_s *priv, uint8_t regaddr, /* Setup 8-bit FUSB301 address write message */ - msg.addr = priv->addr; - msg.flags = 0; - msg.buffer = txbuffer; - msg.length = 2; + msg.frequency = CONFIG_FUSB301_I2C_FREQUENCY; + msg.addr = priv->addr; + msg.flags = 0; + msg.buffer = txbuffer; + msg.length = 2; /* Perform the transfer */