Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2c: change clock polarity #316

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tools/communication/src/i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ static void writeBit(struct i2c_desc *desc, std::vector<unsigned short> &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);
}
Expand All @@ -106,7 +106,7 @@ static void writeByte(struct i2c_desc *desc, std::vector<unsigned short> &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
Expand Down