drivers/{sensors,usbmisc}: Fix uninitialized I2C frequency

This commit is contained in:
Juha Niskanen 2017-06-01 06:19:54 -06:00 committed by Gregory Nutt
parent ad6515563b
commit 32610b53f4
6 changed files with 101 additions and 52 deletions

View File

@ -41,6 +41,11 @@ config HTS221
if HTS221 if HTS221
config HTS221_I2C_FREQUENCY
int "HTS221 I2C frequency"
default 400000
range 1 400000
config DEBUG_HTS221 config DEBUG_HTS221
bool "Debug support for the HTS221" bool "Debug support for the HTS221"
default n default n
@ -84,6 +89,11 @@ config LIS2DH
if LIS2DH if LIS2DH
config LIS2DH_I2C_FREQUENCY
int "LIS2DH I2C frequency"
default 400000
range 1 400000
config DEBUG_LIS2DH config DEBUG_LIS2DH
bool "Debug support for the LIS2DH" bool "Debug support for the LIS2DH"
default n default n
@ -144,6 +154,11 @@ config LPS25H
if LPS25H if LPS25H
config LPS25H_I2C_FREQUENCY
int "LPS25H I2C frequency"
default 400000
range 1 400000
config DEBUG_LPS25H config DEBUG_LPS25H
bool "Debug support for the LPS25H" bool "Debug support for the LPS25H"
default n default n

View File

@ -61,6 +61,10 @@
# define hts221_dbg(x, ...) sninfo(x, ##__VA_ARGS__) # define hts221_dbg(x, ...) sninfo(x, ##__VA_ARGS__)
#endif #endif
#ifndef CONFIG_HTS221_I2C_FREQUENCY
# define CONFIG_HTS221_I2C_FREQUENCY 400000
#endif
#define HTS221_WHO_AM_I 0x0f #define HTS221_WHO_AM_I 0x0f
#define HTS221_AV_CONF 0x10 #define HTS221_AV_CONF 0x10
#define HTS221_CTRL_REG1 0x20 #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] = struct i2c_msg_s msgv[2] =
{ {
{ {
.addr = priv->addr, .frequency = CONFIG_HTS221_I2C_FREQUENCY,
.flags = 0, .addr = priv->addr,
.buffer = (FAR void *)&command[0], .flags = 0,
.length = 1 .buffer = (FAR void *)&command[0],
.length = 1
}, },
{ {
.addr = priv->addr, .frequency = CONFIG_HTS221_I2C_FREQUENCY,
.flags = I2C_M_NORESTART, .addr = priv->addr,
.buffer = (FAR void *)&command[1], .flags = I2C_M_NORESTART,
.length = 1 .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] = struct i2c_msg_s msgv[2] =
{ {
{ {
.addr = priv->addr, .frequency = CONFIG_HTS221_I2C_FREQUENCY,
.flags = 0, .addr = priv->addr,
.buffer = (FAR void *)command, .flags = 0,
.length = 1 .buffer = (FAR void *)command,
.length = 1
}, },
{ {
.addr = priv->addr, .frequency = CONFIG_HTS221_I2C_FREQUENCY,
.flags = I2C_M_READ, .addr = priv->addr,
.buffer = value, .flags = I2C_M_READ,
.length = 1 .buffer = value,
.length = 1
} }
}; };

View File

@ -65,6 +65,10 @@
# define lis2dh_dbg(x, ...) sninfo(x, ##__VA_ARGS__) # define lis2dh_dbg(x, ...) sninfo(x, ##__VA_ARGS__)
#endif #endif
#ifndef CONFIG_LIS2DH_I2C_FREQUENCY
# define CONFIG_LIS2DH_I2C_FREQUENCY 400000
#endif
#ifdef CONFIG_LIS2DH_DRIVER_SELFTEST #ifdef CONFIG_LIS2DH_DRIVER_SELFTEST
# define LSB_AT_10BIT_RESOLUTION 4 # define LSB_AT_10BIT_RESOLUTION 4
# define LSB_AT_12BIT_RESOLUTION 1 # 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] = struct i2c_msg_s msgv[2] =
{ {
{ {
.addr = dev->addr, .frequency = CONFIG_LIS2DH_I2C_FREQUENCY,
.flags = 0, .addr = dev->addr,
.buffer = &subaddr, .flags = 0,
.length = 1 .buffer = &subaddr,
.length = 1
}, },
{ {
.addr = dev->addr, .frequency = CONFIG_LIS2DH_I2C_FREQUENCY,
.flags = flags, .addr = dev->addr,
.buffer = buf, .flags = flags,
.length = length .buffer = buf,
.length = length
} }
}; };

View File

@ -58,6 +58,10 @@
# define lps25h_dbg(x, ...) sninfo(x, ##__VA_ARGS__) # define lps25h_dbg(x, ...) sninfo(x, ##__VA_ARGS__)
#endif #endif
#ifndef CONFIG_LPS25H_I2C_FREQUENCY
# define CONFIG_LPS25H_I2C_FREQUENCY 400000
#endif
#define LPS25H_PRESSURE_INTERNAL_DIVIDER 4096 #define LPS25H_PRESSURE_INTERNAL_DIVIDER 4096
/* 'AN4450 - Hardware and software guidelines for use of LPS25H pressure /* '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] = struct i2c_msg_s msgv[2] =
{ {
{ {
.addr = dev->addr, .frequency = CONFIG_LPS25H_I2C_FREQUENCY,
.flags = 0, .addr = dev->addr,
.buffer = &reg_addr, .flags = 0,
.length = 1 .buffer = &reg_addr,
.length = 1
}, },
{ {
.addr = dev->addr, .frequency = CONFIG_LPS25H_I2C_FREQUENCY,
.flags = I2C_M_NORESTART, .addr = dev->addr,
.buffer = (void *)&value, .flags = I2C_M_NORESTART,
.length = 1 .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] = struct i2c_msg_s msgv[2] =
{ {
{ {
.addr = dev->addr, .frequency = CONFIG_LPS25H_I2C_FREQUENCY,
.flags = 0, .addr = dev->addr,
.buffer = reg_addr, .flags = 0,
.length = 1 .buffer = reg_addr,
.length = 1
}, },
{ {
.addr = dev->addr, .frequency = CONFIG_LPS25H_I2C_FREQUENCY,
.flags = I2C_M_READ, .addr = dev->addr,
.buffer = value, .flags = I2C_M_READ,
.length = 1 .buffer = value,
.length = 1
} }
}; };

View File

@ -14,6 +14,11 @@ config FUSB301
if FUSB301 if FUSB301
config FUSB301_I2C_FREQUENCY
int "FUSB301 I2C frequency"
default 400000
range 1 400000
config DEBUG_FUSB301 config DEBUG_FUSB301
bool "Enable debug support for the FUSB301" bool "Enable debug support for the FUSB301"
default n default n

View File

@ -63,6 +63,10 @@
# define fusb301_info(x, ...) uinfo(x, ##__VA_ARGS__) # define fusb301_info(x, ...) uinfo(x, ##__VA_ARGS__)
#endif #endif
#ifndef CONFIG_FUSB301_I2C_FREQUENCY
# define CONFIG_FUSB301_I2C_FREQUENCY 400000
#endif
/* Other macros */ /* Other macros */
#define FUSB301_I2C_RETRIES 10 #define FUSB301_I2C_RETRIES 10
@ -146,15 +150,17 @@ static int fusb301_getreg(FAR struct fusb301_dev_s *priv, uint8_t reg)
DEBUGASSERT(priv); DEBUGASSERT(priv);
msg[0].addr = priv->addr; msg[0].frequency = CONFIG_FUSB301_I2C_FREQUENCY;
msg[0].flags = 0; msg[0].addr = priv->addr;
msg[0].buffer = ® msg[0].flags = 0;
msg[0].length = 1; msg[0].buffer = ®
msg[0].length = 1;
msg[1].addr = priv->addr; msg[1].frequency = CONFIG_FUSB301_I2C_FREQUENCY;
msg[1].flags = I2C_M_READ; msg[1].addr = priv->addr;
msg[1].buffer = &regval; msg[1].flags = I2C_M_READ;
msg[1].length = 1; msg[1].buffer = &regval;
msg[1].length = 1;
/* Perform the transfer */ /* 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 */ /* Setup 8-bit FUSB301 address write message */
msg.addr = priv->addr; msg.frequency = CONFIG_FUSB301_I2C_FREQUENCY;
msg.flags = 0; msg.addr = priv->addr;
msg.buffer = txbuffer; msg.flags = 0;
msg.length = 2; msg.buffer = txbuffer;
msg.length = 2;
/* Perform the transfer */ /* Perform the transfer */