stm32_i2c: make private symbols static
This commit is contained in:
parent
3f22fd07d6
commit
819a6e049e
@ -318,7 +318,7 @@ static int stm32_i2c_reset(FAR struct i2c_master_s *dev);
|
||||
|
||||
/* Device Structures, Instantiation */
|
||||
|
||||
const struct i2c_ops_s stm32_i2c_ops =
|
||||
static const struct i2c_ops_s stm32_i2c_ops =
|
||||
{
|
||||
.transfer = stm32_i2c_transfer
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
@ -340,7 +340,7 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32_i2c_priv_s stm32_i2c1_priv =
|
||||
static struct stm32_i2c_priv_s stm32_i2c1_priv =
|
||||
{
|
||||
.ops = &stm32_i2c_ops,
|
||||
.config = &stm32_i2c1_config,
|
||||
@ -369,7 +369,7 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32_i2c_priv_s stm32_i2c2_priv =
|
||||
static struct stm32_i2c_priv_s stm32_i2c2_priv =
|
||||
{
|
||||
.ops = &stm32_i2c_ops,
|
||||
.config = &stm32_i2c2_config,
|
||||
@ -398,7 +398,7 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32_i2c_priv_s stm32_i2c3_priv =
|
||||
static struct stm32_i2c_priv_s stm32_i2c3_priv =
|
||||
{
|
||||
.ops = &stm32_i2c_ops,
|
||||
.config = &stm32_i2c3_config,
|
||||
|
@ -307,7 +307,7 @@ static int stm32f0_i2c_reset(FAR struct i2c_master_s *dev);
|
||||
|
||||
/* Device Structures, Instantiation */
|
||||
|
||||
const struct i2c_ops_s stm32f0_i2c_ops =
|
||||
static const struct i2c_ops_s stm32f0_i2c_ops =
|
||||
{
|
||||
.transfer = stm32f0_i2c_transfer
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
@ -328,7 +328,7 @@ static const struct stm32f0_i2c_config_s stm32f0_i2c1_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32f0_i2c_priv_s stm32f0_i2c1_priv =
|
||||
static struct stm32f0_i2c_priv_s stm32f0_i2c1_priv =
|
||||
{
|
||||
.ops = &stm32f0_i2c_ops,
|
||||
.config = &stm32f0_i2c1_config,
|
||||
@ -356,7 +356,7 @@ static const struct stm32f0_i2c_config_s stm32f0_i2c2_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32f0_i2c_priv_s stm32f0_i2c2_priv =
|
||||
static struct stm32f0_i2c_priv_s stm32f0_i2c2_priv =
|
||||
{
|
||||
.ops = &stm32f0_i2c_ops,
|
||||
.config = &stm32f0_i2c2_config,
|
||||
@ -384,7 +384,7 @@ static const struct stm32f0_i2c_config_s stm32f0_i2c3_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32f0_i2c_priv_s stm32f0_i2c3_priv =
|
||||
static struct stm32f0_i2c_priv_s stm32f0_i2c3_priv =
|
||||
{
|
||||
.ops = &stm32f0_i2c_ops,
|
||||
.config = &stm32f0_i2c3_config,
|
||||
|
@ -290,7 +290,7 @@
|
||||
#if !defined(CONFIG_STM32F7_I2CTIMEOSEC) && !defined(CONFIG_STM32F7_I2CTIMEOMS)
|
||||
# define CONFIG_STM32F7_I2CTIMEOSEC 0
|
||||
# define CONFIG_STM32F7_I2CTIMEOMS 500 /* Default is 500 milliseconds */
|
||||
# warning "Using Defualt 500 Ms Timeout"
|
||||
# warning "Using Default 500 Ms Timeout"
|
||||
#elif !defined(CONFIG_STM32F7_I2CTIMEOSEC)
|
||||
# define CONFIG_STM32F7_I2CTIMEOSEC 0 /* User provided milliseconds */
|
||||
#elif !defined(CONFIG_STM32F7_I2CTIMEOMS)
|
||||
@ -445,7 +445,7 @@ struct stm32_i2c_priv_s
|
||||
|
||||
struct stm32_i2c_inst_s
|
||||
{
|
||||
struct i2c_ops_s *ops; /* Standard I2C operations */
|
||||
const struct i2c_ops_s *ops; /* Standard I2C operations */
|
||||
struct stm32_i2c_priv_s *priv; /* Common driver private data structure */
|
||||
};
|
||||
|
||||
@ -495,7 +495,7 @@ static int stm32_i2c_process(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s
|
||||
static int stm32_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs,
|
||||
int count);
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
int stm32_i2c_reset(FAR struct i2c_master_s * dev);
|
||||
static int stm32_i2c_reset(FAR struct i2c_master_s * dev);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
@ -516,7 +516,7 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32_i2c_priv_s stm32_i2c1_priv =
|
||||
static struct stm32_i2c_priv_s stm32_i2c1_priv =
|
||||
{
|
||||
.config = &stm32_i2c1_config,
|
||||
.refs = 0,
|
||||
@ -545,7 +545,7 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32_i2c_priv_s stm32_i2c2_priv =
|
||||
static struct stm32_i2c_priv_s stm32_i2c2_priv =
|
||||
{
|
||||
.config = &stm32_i2c2_config,
|
||||
.refs = 0,
|
||||
@ -574,7 +574,7 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32_i2c_priv_s stm32_i2c3_priv =
|
||||
static struct stm32_i2c_priv_s stm32_i2c3_priv =
|
||||
{
|
||||
.config = &stm32_i2c3_config,
|
||||
.refs = 0,
|
||||
@ -603,7 +603,7 @@ static const struct stm32_i2c_config_s stm32_i2c4_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32_i2c_priv_s stm32_i2c4_priv =
|
||||
static struct stm32_i2c_priv_s stm32_i2c4_priv =
|
||||
{
|
||||
.config = &stm32_i2c4_config,
|
||||
.refs = 0,
|
||||
@ -620,7 +620,7 @@ struct stm32_i2c_priv_s stm32_i2c4_priv =
|
||||
|
||||
/* Device Structures, Instantiation */
|
||||
|
||||
struct i2c_ops_s stm32_i2c_ops =
|
||||
static const struct i2c_ops_s stm32_i2c_ops =
|
||||
{
|
||||
.transfer = stm32_i2c_transfer
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
@ -2485,6 +2485,124 @@ static int stm32_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s
|
||||
return stm32_i2c_process(dev, msgs, count);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_i2c_reset
|
||||
*
|
||||
* Description:
|
||||
* Reset an I2C bus
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
static int stm32_i2c_reset(FAR struct i2c_master_s * dev)
|
||||
{
|
||||
struct stm32_i2c_priv_s * priv;
|
||||
unsigned int clock_count;
|
||||
unsigned int stretch_count;
|
||||
uint32_t scl_gpio;
|
||||
uint32_t sda_gpio;
|
||||
int ret = ERROR;
|
||||
|
||||
ASSERT(dev);
|
||||
|
||||
/* Get I2C private structure */
|
||||
|
||||
priv = ((struct stm32_i2c_inst_s *)dev)->priv;
|
||||
|
||||
/* Our caller must own a ref */
|
||||
|
||||
ASSERT(priv->refs > 0);
|
||||
|
||||
/* Lock out other clients */
|
||||
|
||||
stm32_i2c_sem_wait(dev);
|
||||
|
||||
/* De-init the port */
|
||||
|
||||
stm32_i2c_deinit(priv);
|
||||
|
||||
/* Use GPIO configuration to un-wedge the bus */
|
||||
|
||||
scl_gpio = MKI2C_OUTPUT(priv->config->scl_pin);
|
||||
sda_gpio = MKI2C_OUTPUT(priv->config->sda_pin);
|
||||
|
||||
/* Let SDA go high */
|
||||
|
||||
stm32_gpiowrite(sda_gpio, 1);
|
||||
|
||||
/* Clock the bus until any slaves currently driving it let it go. */
|
||||
|
||||
clock_count = 0;
|
||||
while (!stm32_gpioread(sda_gpio))
|
||||
{
|
||||
/* Give up if we have tried too hard */
|
||||
|
||||
if (clock_count++ > 10)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Sniff to make sure that clock stretching has finished.
|
||||
*
|
||||
* If the bus never relaxes, the reset has failed.
|
||||
*/
|
||||
|
||||
stretch_count = 0;
|
||||
while (!stm32_gpioread(scl_gpio))
|
||||
{
|
||||
/* Give up if we have tried too hard */
|
||||
|
||||
if (stretch_count++ > 10)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
up_udelay(10);
|
||||
}
|
||||
|
||||
/* Drive SCL low */
|
||||
|
||||
stm32_gpiowrite(scl_gpio, 0);
|
||||
up_udelay(10);
|
||||
|
||||
/* Drive SCL high again */
|
||||
|
||||
stm32_gpiowrite(scl_gpio, 1);
|
||||
up_udelay(10);
|
||||
}
|
||||
|
||||
/* Generate a start followed by a stop to reset slave
|
||||
* state machines.
|
||||
*/
|
||||
|
||||
stm32_gpiowrite(sda_gpio, 0);
|
||||
up_udelay(10);
|
||||
stm32_gpiowrite(scl_gpio, 0);
|
||||
up_udelay(10);
|
||||
stm32_gpiowrite(scl_gpio, 1);
|
||||
up_udelay(10);
|
||||
stm32_gpiowrite(sda_gpio, 1);
|
||||
up_udelay(10);
|
||||
|
||||
/* Revert the GPIO configuration. */
|
||||
|
||||
stm32_unconfiggpio(sda_gpio);
|
||||
stm32_unconfiggpio(scl_gpio);
|
||||
|
||||
/* Re-init the port */
|
||||
|
||||
stm32_i2c_init(priv);
|
||||
ret = OK;
|
||||
|
||||
out:
|
||||
|
||||
/* Release the port for re-use by other clients */
|
||||
|
||||
stm32_i2c_sem_post(dev);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_I2C_RESET */
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
@ -2608,122 +2726,4 @@ int stm32_i2cbus_uninitialize(FAR struct i2c_master_s * dev)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_i2c_reset
|
||||
*
|
||||
* Description:
|
||||
* Reset an I2C bus
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
int stm32_i2c_reset(FAR struct i2c_master_s * dev)
|
||||
{
|
||||
struct stm32_i2c_priv_s * priv;
|
||||
unsigned int clock_count;
|
||||
unsigned int stretch_count;
|
||||
uint32_t scl_gpio;
|
||||
uint32_t sda_gpio;
|
||||
int ret = ERROR;
|
||||
|
||||
ASSERT(dev);
|
||||
|
||||
/* Get I2C private structure */
|
||||
|
||||
priv = ((struct stm32_i2c_inst_s *)dev)->priv;
|
||||
|
||||
/* Our caller must own a ref */
|
||||
|
||||
ASSERT(priv->refs > 0);
|
||||
|
||||
/* Lock out other clients */
|
||||
|
||||
stm32_i2c_sem_wait(dev);
|
||||
|
||||
/* De-init the port */
|
||||
|
||||
stm32_i2c_deinit(priv);
|
||||
|
||||
/* Use GPIO configuration to un-wedge the bus */
|
||||
|
||||
scl_gpio = MKI2C_OUTPUT(priv->config->scl_pin);
|
||||
sda_gpio = MKI2C_OUTPUT(priv->config->sda_pin);
|
||||
|
||||
/* Let SDA go high */
|
||||
|
||||
stm32_gpiowrite(sda_gpio, 1);
|
||||
|
||||
/* Clock the bus until any slaves currently driving it let it go. */
|
||||
|
||||
clock_count = 0;
|
||||
while (!stm32_gpioread(sda_gpio))
|
||||
{
|
||||
/* Give up if we have tried too hard */
|
||||
|
||||
if (clock_count++ > 10)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Sniff to make sure that clock stretching has finished.
|
||||
*
|
||||
* If the bus never relaxes, the reset has failed.
|
||||
*/
|
||||
|
||||
stretch_count = 0;
|
||||
while (!stm32_gpioread(scl_gpio))
|
||||
{
|
||||
/* Give up if we have tried too hard */
|
||||
|
||||
if (stretch_count++ > 10)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
up_udelay(10);
|
||||
}
|
||||
|
||||
/* Drive SCL low */
|
||||
|
||||
stm32_gpiowrite(scl_gpio, 0);
|
||||
up_udelay(10);
|
||||
|
||||
/* Drive SCL high again */
|
||||
|
||||
stm32_gpiowrite(scl_gpio, 1);
|
||||
up_udelay(10);
|
||||
}
|
||||
|
||||
/* Generate a start followed by a stop to reset slave
|
||||
* state machines.
|
||||
*/
|
||||
|
||||
stm32_gpiowrite(sda_gpio, 0);
|
||||
up_udelay(10);
|
||||
stm32_gpiowrite(scl_gpio, 0);
|
||||
up_udelay(10);
|
||||
stm32_gpiowrite(scl_gpio, 1);
|
||||
up_udelay(10);
|
||||
stm32_gpiowrite(sda_gpio, 1);
|
||||
up_udelay(10);
|
||||
|
||||
/* Revert the GPIO configuration. */
|
||||
|
||||
stm32_unconfiggpio(sda_gpio);
|
||||
stm32_unconfiggpio(scl_gpio);
|
||||
|
||||
/* Re-init the port */
|
||||
|
||||
stm32_i2c_init(priv);
|
||||
ret = OK;
|
||||
|
||||
out:
|
||||
|
||||
/* Release the port for re-use by other clients */
|
||||
|
||||
stm32_i2c_sem_post(dev);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_I2C_RESET */
|
||||
|
||||
#endif /* CONFIG_STM32F7_I2C1 || CONFIG_STM32F7_I2C2 || CONFIG_STM32F7_I2C3 */
|
||||
|
@ -307,7 +307,7 @@ static int stm32l4_i2c_reset(FAR struct i2c_master_s *dev);
|
||||
|
||||
/* Device Structures, Instantiation */
|
||||
|
||||
const struct i2c_ops_s stm32l4_i2c_ops =
|
||||
static const struct i2c_ops_s stm32l4_i2c_ops =
|
||||
{
|
||||
.transfer = stm32l4_i2c_transfer
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
@ -329,7 +329,7 @@ static const struct stm32l4_i2c_config_s stm32l4_i2c1_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32l4_i2c_priv_s stm32l4_i2c1_priv =
|
||||
static struct stm32l4_i2c_priv_s stm32l4_i2c1_priv =
|
||||
{
|
||||
.ops = &stm32l4_i2c_ops,
|
||||
.config = &stm32l4_i2c1_config,
|
||||
@ -358,7 +358,7 @@ static const struct stm32l4_i2c_config_s stm32l4_i2c2_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32l4_i2c_priv_s stm32l4_i2c2_priv =
|
||||
static struct stm32l4_i2c_priv_s stm32l4_i2c2_priv =
|
||||
{
|
||||
.ops = &stm32l4_i2c_ops,
|
||||
.config = &stm32l4_i2c2_config,
|
||||
@ -387,7 +387,7 @@ static const struct stm32l4_i2c_config_s stm32l4_i2c3_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32l4_i2c_priv_s stm32l4_i2c3_priv =
|
||||
static struct stm32l4_i2c_priv_s stm32l4_i2c3_priv =
|
||||
{
|
||||
.ops = &stm32l4_i2c_ops,
|
||||
.config = &stm32l4_i2c3_config,
|
||||
@ -416,7 +416,7 @@ static const struct stm32l4_i2c_config_s stm32l4_i2c4_config =
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32l4_i2c_priv_s stm32l4_i2c4_priv =
|
||||
static struct stm32l4_i2c_priv_s stm32l4_i2c4_priv =
|
||||
{
|
||||
.ops = &stm32l4_i2c_ops,
|
||||
.config = &stm32l4_i2c4_config,
|
||||
@ -1831,7 +1831,7 @@ static int stm32l4_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg
|
||||
* dev - Device-specific state data
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
* Zero (OK) on success; negative value on failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user