Skip to content

Commit f2530c5

Browse files
robertalexa2000xiaoxiang781216
authored andcommitted
esp32: port support for I2C_M_NOSTART and I2C_M_NOSTOP
Signed-off-by: Robert-Ionut Alexa <[email protected]>
1 parent d48114a commit f2530c5

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

arch/xtensa/src/esp32/esp32_i2c.c

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -895,16 +895,39 @@ static int esp32_i2c_transfer(struct i2c_master_s *dev,
895895

896896
esp32_i2c_init_clock(priv, msgs[i].frequency);
897897

898-
/* Reset I2C trace logic */
898+
if ((msgs[i].flags & I2C_M_NOSTART) != 0)
899+
{
900+
esp32_i2c_traceevent(priv, I2CEVENT_SENDBYTE, priv->bytes,
901+
esp32_i2c_get_reg(priv, I2C_SR_OFFSET));
902+
esp32_i2c_senddata(priv);
903+
904+
if (priv->bytes == msgs[i].length)
905+
{
906+
if ((msgs[i].flags & I2C_M_NOSTOP) == 0)
907+
{
908+
priv->i2cstate = I2CSTATE_STOP;
909+
}
910+
#ifndef CONFIG_I2C_POLLED
911+
else
912+
{
913+
priv->i2cstate = I2CSTATE_FINISH;
914+
}
915+
#endif
916+
}
917+
}
918+
else
919+
{
920+
/* Reset I2C trace logic */
899921

900-
esp32_i2c_tracereset(priv);
922+
esp32_i2c_tracereset(priv);
901923

902-
esp32_i2c_traceevent(priv, I2CEVENT_SENDADDR, msgs[i].addr,
903-
esp32_i2c_get_reg(priv, I2C_SR_OFFSET));
924+
esp32_i2c_traceevent(priv, I2CEVENT_SENDADDR, msgs[i].addr,
925+
esp32_i2c_get_reg(priv, I2C_SR_OFFSET));
904926

905-
/* Send the start cmd */
927+
/* Send the start cmd */
906928

907-
esp32_i2c_sendstart(priv);
929+
esp32_i2c_sendstart(priv);
930+
}
908931

909932
#ifndef CONFIG_I2C_POLLED
910933
if (esp32_i2c_sem_waitdone(priv) < 0)
@@ -1391,7 +1414,16 @@ static inline void esp32_i2c_process(struct esp32_i2c_priv_s *priv,
13911414

13921415
if (priv->bytes == msg->length)
13931416
{
1394-
priv->i2cstate = I2CSTATE_STOP;
1417+
if ((msg->flags & I2C_M_NOSTOP) == 0)
1418+
{
1419+
priv->i2cstate = I2CSTATE_STOP;
1420+
}
1421+
#ifndef CONFIG_I2C_POLLED
1422+
else
1423+
{
1424+
priv->i2cstate = I2CSTATE_FINISH;
1425+
}
1426+
#endif
13951427
}
13961428
}
13971429
}

0 commit comments

Comments
 (0)