I2C: up_i2creset should not be a global function; Now it is an I2C interface method
This commit is contained in:
parent
52ef3b2d23
commit
9ce58ad5b7
|
@ -11437,4 +11437,6 @@
|
|||
Any bug reports of bug fixes will be much appreciated (2016-02-01).
|
||||
* drivers/i2c/i2c_driver.c: Add an I2C character drivers to support
|
||||
raw I2C data transfers for test applications (2016-02-02).
|
||||
* I2C_RESET: Eliminate up_i2creset(). It should not be a global function;
|
||||
Now it is an I2C interface method (2016-02-02).
|
||||
|
||||
|
|
2
arch
2
arch
|
@ -1 +1 @@
|
|||
Subproject commit f80912e0ceb3ff4c83eb86a3d128df81b2bc9a85
|
||||
Subproject commit 263fa48aae03da290b64ee43a31e321722e32ee1
|
|
@ -292,10 +292,10 @@ uint16_t wm8904_readreg(FAR struct wm8904_dev_s *priv, uint8_t regaddr)
|
|||
|
||||
auddbg("WARNING: I2C_TRANSFER failed: %d ... Resetting\n", ret);
|
||||
|
||||
ret = up_i2creset(priv->i2c);
|
||||
ret = I2C_RESET(priv->i2c);
|
||||
if (ret < 0)
|
||||
{
|
||||
auddbg("ERROR: up_i2creset failed: %d\n", ret);
|
||||
auddbg("ERROR: I2C_RESET failed: %d\n", ret);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
|
@ -368,10 +368,10 @@ static void wm8904_writereg(FAR struct wm8904_dev_s *priv, uint8_t regaddr,
|
|||
|
||||
auddbg("WARNING: i2c_write failed: %d ... Resetting\n", ret);
|
||||
|
||||
ret = up_i2creset(priv->i2c);
|
||||
ret = I2C_RESET(priv->i2c);
|
||||
if (ret < 0)
|
||||
{
|
||||
auddbg("ERROR: up_i2creset failed: %d\n", ret);
|
||||
auddbg("ERROR: I2C_RESET failed: %d\n", ret);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -14,7 +14,7 @@ config I2C_POLLED
|
|||
default n
|
||||
|
||||
config I2C_RESET
|
||||
bool "Support up_i2creset"
|
||||
bool "Support I2C reset interface method"
|
||||
default n
|
||||
depends on ARCH_HAVE_I2CRESET
|
||||
|
||||
|
|
|
@ -344,10 +344,10 @@ static int mxt_getreg(FAR struct mxt_dev_s *priv, uint16_t regaddr,
|
|||
|
||||
idbg("WARNING: I2C_TRANSFER failed: %d ... Resetting\n", ret);
|
||||
|
||||
ret = up_i2creset(priv->i2c);
|
||||
ret = I2C_RESET(priv->i2c);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("ERROR: up_i2creset failed: %d\n", ret);
|
||||
idbg("ERROR: I2C_RESET failed: %d\n", ret);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
|
@ -418,10 +418,10 @@ static int mxt_putreg(FAR struct mxt_dev_s *priv, uint16_t regaddr,
|
|||
|
||||
idbg("WARNING: I2C_TRANSFER failed: %d ... Resetting\n", ret);
|
||||
|
||||
ret = up_i2creset(priv->i2c);
|
||||
ret = I2C_RESET(priv->i2c);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("ERROR: up_i2creset failed: %d\n", ret);
|
||||
idbg("ERROR: I2C_RESET failed: %d\n", ret);
|
||||
}
|
||||
#else
|
||||
idbg("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
||||
|
|
|
@ -113,6 +113,24 @@
|
|||
|
||||
#define I2C_TRANSFER(d,m,c) ((d)->ops->transfer(d,m,c))
|
||||
|
||||
/************************************************************************************
|
||||
* Name: I2C_RESET
|
||||
*
|
||||
* Description:
|
||||
* Perform an I2C bus reset in an attempt to break loose stuck I2C devices.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - Device-specific state data
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
# define I2C_RESET(d) ((d)->ops->reset(d))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -125,6 +143,9 @@ struct i2c_ops_s
|
|||
{
|
||||
int (*transfer)(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs,
|
||||
int count);
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
int (*reset)(FAR struct i2c_master_s *dev);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* This structure contains the full state of I2C as needed for a specific
|
||||
|
@ -186,54 +207,6 @@ extern "C"
|
|||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_i2cinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected I2C port. And return a unique instance of struct
|
||||
* struct i2c_master_s. This function may be called to obtain multiple
|
||||
* instances of the interface, each of which may be set up with a
|
||||
* different frequency and slave address.
|
||||
*
|
||||
* Input Parameter:
|
||||
* Port number (for hardware that has multiple I2C interfaces)
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid I2C device structure reference on succcess; a NULL on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct i2c_master_s *up_i2cinitialize(int port);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_i2cuninitialize
|
||||
*
|
||||
* Description:
|
||||
* De-initialize the selected I2C port, and power down the device.
|
||||
*
|
||||
* Input Parameter:
|
||||
* Device structure as returned by the up_i2cinitialize()
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success, ERROR when internal reference count mismatch or dev
|
||||
* points to invalid hardware device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int up_i2cuninitialize(FAR struct i2c_master_s *dev);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: up_i2creset
|
||||
*
|
||||
* Description:
|
||||
* Reset an I2C bus
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
int up_i2creset(FAR struct i2c_master_s *dev);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: i2c_register
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue