From 995719d1515ae111c2f3ca4de261ed7ed1339c79 Mon Sep 17 00:00:00 2001 From: Adrian Suciu Date: Mon, 20 Jun 2022 12:35:45 +0300 Subject: [PATCH] i2c: change clock polarity Signed-off-by: Adrian Suciu --- tools/communication/src/i2c.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/communication/src/i2c.cpp b/tools/communication/src/i2c.cpp index 028e0abb..a5cb7bd5 100644 --- a/tools/communication/src/i2c.cpp +++ b/tools/communication/src/i2c.cpp @@ -83,18 +83,18 @@ static void writeBit(struct i2c_desc *desc, std::vector &buffer, { auto *m2KI2CDesc = (m2k_i2c_desc *) desc->extra; auto samplesPerHalfBit = (unsigned int) (m2KI2CDesc->sample_rate / desc->max_speed_hz) / 2; - //scl high + //scl low for (unsigned int i = 0; i < samplesPerHalfBit; ++i) { unsigned short sample = 0; - setBit(sample, m2KI2CDesc->scl); if (bit) { setBit(sample, m2KI2CDesc->sda); } buffer.push_back(sample); } - //scl low + //scl high for (unsigned int i = 0; i < samplesPerHalfBit; ++i) { unsigned short sample = 0; + setBit(sample, m2KI2CDesc->scl); if (bit) { setBit(sample, m2KI2CDesc->sda); } @@ -106,7 +106,7 @@ static void writeByte(struct i2c_desc *desc, std::vector &buffer { auto *m2KI2CDesc = (m2k_i2c_desc *) desc->extra; auto samplesPerHalfBit = (unsigned int) (m2KI2CDesc->sample_rate / desc->max_speed_hz) / 2; - bool clockPolarity = true; + bool clockPolarity = false; for (int i = 0; i < 16; i++) { //encode data