i2c: improve the message dumps messages

This commit changes the format of printed messages to align the
following strings and make it more readable.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commit is contained in:
Michał Barnaś 2023-03-31 18:44:40 +02:00 committed by Carles Cufí
parent 4aac1756a9
commit 4c49d095fc

View file

@ -35,15 +35,13 @@ void i2c_dump_msgs_rw(const struct device *dev, const struct i2c_msg *msgs, uint
const bool dump_data = dump_read || !is_read;
if (msg->len == 1 && dump_data) {
LOG_DBG(" %c %s%s len=01: %02x", is_read ? 'R' : 'W',
msg->flags & I2C_MSG_RESTART ? "Sr " : "",
msg->flags & I2C_MSG_STOP ? "P" : "",
msg->buf[0]);
LOG_DBG(" %c %2s %1s len=01: %02x", is_read ? 'R' : 'W',
msg->flags & I2C_MSG_RESTART ? "Sr" : "",
msg->flags & I2C_MSG_STOP ? "P" : "", msg->buf[0]);
} else {
LOG_DBG(" %c %s%s len=%02x: ", is_read ? 'R' : 'W',
msg->flags & I2C_MSG_RESTART ? "Sr " : "",
msg->flags & I2C_MSG_STOP ? "P" : "",
msg->len);
LOG_DBG(" %c %2s %1s len=%02x: ", is_read ? 'R' : 'W',
msg->flags & I2C_MSG_RESTART ? "Sr" : "",
msg->flags & I2C_MSG_STOP ? "P" : "", msg->len);
if (dump_data) {
LOG_HEXDUMP_DBG(msg->buf, msg->len, "contents:");
}