mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
esp32: port support for I2C_M_NOSTART and I2C_M_NOSTOP
Signed-off-by: Robert-Ionut Alexa <robertalexa2000@gmail.com>
This commit is contained in:
committed by
Xiang Xiao
parent
d48114a4b7
commit
f2530c53a5
@@ -895,16 +895,39 @@ static int esp32_i2c_transfer(struct i2c_master_s *dev,
|
|||||||
|
|
||||||
esp32_i2c_init_clock(priv, msgs[i].frequency);
|
esp32_i2c_init_clock(priv, msgs[i].frequency);
|
||||||
|
|
||||||
/* Reset I2C trace logic */
|
if ((msgs[i].flags & I2C_M_NOSTART) != 0)
|
||||||
|
{
|
||||||
|
esp32_i2c_traceevent(priv, I2CEVENT_SENDBYTE, priv->bytes,
|
||||||
|
esp32_i2c_get_reg(priv, I2C_SR_OFFSET));
|
||||||
|
esp32_i2c_senddata(priv);
|
||||||
|
|
||||||
esp32_i2c_tracereset(priv);
|
if (priv->bytes == msgs[i].length)
|
||||||
|
{
|
||||||
|
if ((msgs[i].flags & I2C_M_NOSTOP) == 0)
|
||||||
|
{
|
||||||
|
priv->i2cstate = I2CSTATE_STOP;
|
||||||
|
}
|
||||||
|
#ifndef CONFIG_I2C_POLLED
|
||||||
|
else
|
||||||
|
{
|
||||||
|
priv->i2cstate = I2CSTATE_FINISH;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Reset I2C trace logic */
|
||||||
|
|
||||||
esp32_i2c_traceevent(priv, I2CEVENT_SENDADDR, msgs[i].addr,
|
esp32_i2c_tracereset(priv);
|
||||||
esp32_i2c_get_reg(priv, I2C_SR_OFFSET));
|
|
||||||
|
|
||||||
/* Send the start cmd */
|
esp32_i2c_traceevent(priv, I2CEVENT_SENDADDR, msgs[i].addr,
|
||||||
|
esp32_i2c_get_reg(priv, I2C_SR_OFFSET));
|
||||||
|
|
||||||
esp32_i2c_sendstart(priv);
|
/* Send the start cmd */
|
||||||
|
|
||||||
|
esp32_i2c_sendstart(priv);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_I2C_POLLED
|
#ifndef CONFIG_I2C_POLLED
|
||||||
if (esp32_i2c_sem_waitdone(priv) < 0)
|
if (esp32_i2c_sem_waitdone(priv) < 0)
|
||||||
@@ -1391,7 +1414,16 @@ static inline void esp32_i2c_process(struct esp32_i2c_priv_s *priv,
|
|||||||
|
|
||||||
if (priv->bytes == msg->length)
|
if (priv->bytes == msg->length)
|
||||||
{
|
{
|
||||||
priv->i2cstate = I2CSTATE_STOP;
|
if ((msg->flags & I2C_M_NOSTOP) == 0)
|
||||||
|
{
|
||||||
|
priv->i2cstate = I2CSTATE_STOP;
|
||||||
|
}
|
||||||
|
#ifndef CONFIG_I2C_POLLED
|
||||||
|
else
|
||||||
|
{
|
||||||
|
priv->i2cstate = I2CSTATE_FINISH;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user