File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ if RT_USING_I2C
9797 default y
9898
9999 if RT_USING_I2C_BITOPS
100- config RT_I2C_BITOPS_DEBUG
100+ config RT_I2C_BITOPS_DEBUG
101101 bool "Use simulate I2C debug message"
102102 default n
103103 endif
Original file line number Diff line number Diff line change @@ -375,8 +375,6 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
375375 rt_int32_t i , ret ;
376376 rt_uint16_t ignore_nack ;
377377
378- LOG_D ("send start condition" );
379- i2c_start (ops );
380378 for (i = 0 ; i < num ; i ++ )
381379 {
382380 msg = & msgs [i ];
@@ -387,6 +385,11 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
387385 {
388386 i2c_restart (ops );
389387 }
388+ else
389+ {
390+ LOG_D ("send start condition" );
391+ i2c_start (ops );
392+ }
390393 ret = i2c_bit_send_address (bus , msg );
391394 if ((ret != RT_EOK ) && !ignore_nack )
392395 {
@@ -423,8 +426,11 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
423426 ret = i ;
424427
425428out :
426- LOG_D ("send stop condition" );
427- i2c_stop (ops );
429+ if (!(msg -> flags & RT_I2C_NO_STOP ))
430+ {
431+ LOG_D ("send stop condition" );
432+ i2c_stop (ops );
433+ }
428434
429435 return ret ;
430436}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ extern "C" {
2323#define RT_I2C_NO_START (1u << 4)
2424#define RT_I2C_IGNORE_NACK (1u << 5)
2525#define RT_I2C_NO_READ_ACK (1u << 6) /* when I2C reading, we do not ACK */
26+ #define RT_I2C_NO_STOP (1u << 7)
2627
2728struct rt_i2c_msg
2829{
@@ -83,6 +84,17 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
8384 rt_uint16_t flags ,
8485 rt_uint8_t * buf ,
8586 rt_uint32_t count );
87+
88+ rt_inline rt_err_t rt_i2c_bus_lock (struct rt_i2c_bus_device * bus , rt_tick_t timeout )
89+ {
90+ return rt_mutex_take (& bus -> lock , timeout );
91+ }
92+
93+ rt_inline rt_err_t rt_i2c_bus_unlock (struct rt_i2c_bus_device * bus )
94+ {
95+ return rt_mutex_release (& bus -> lock );
96+ }
97+
8698int rt_i2c_core_init (void );
8799
88100#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments