Skip to content

Commit 81f163e

Browse files
yperessnashif
authored andcommitted
i2c: Add/update utility inline functions
- Change the argument for i2c_is_read_op to a const pointer - Add function i2c_is_stop_op to test if a message has a stop flag. Signed-off-by: Yuval Peress <peress@google.com>
1 parent c394b2e commit 81f163e

File tree

1 file changed

+14
-2
lines changed
  • include/zephyr/drivers

1 file changed

+14
-2
lines changed

include/zephyr/drivers/i2c.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,26 @@ static inline bool i2c_is_ready_dt(const struct i2c_dt_spec *spec)
474474
* @brief Check if the current message is a read operation
475475
*
476476
* @param msg The message to check
477-
* @return true if the I2C message is sa read operation
477+
* @return true if the I2C message is a read operation
478478
* @return false if the I2C message is a write operation
479479
*/
480-
static inline bool i2c_is_read_op(struct i2c_msg *msg)
480+
static inline bool i2c_is_read_op(const struct i2c_msg *msg)
481481
{
482482
return (msg->flags & I2C_MSG_READ) == I2C_MSG_READ;
483483
}
484484

485+
/**
486+
* @brief Check if the current message includes a stop.
487+
*
488+
* @param msg The message to check
489+
* @return true if the I2C message includes a stop
490+
* @return false if the I2C message includes a stop
491+
*/
492+
static inline bool i2c_is_stop_op(const struct i2c_msg *msg)
493+
{
494+
return (msg->flags & I2C_MSG_STOP) == I2C_MSG_STOP;
495+
}
496+
485497
/**
486498
* @brief Dump out an I2C message
487499
*

0 commit comments

Comments
 (0)