Fixed some I2C edge detection issues

This commit is contained in:
Chris Esposito 2018-11-04 10:07:15 +11:00
parent fb738510e8
commit d65b647ab4
4 changed files with 18 additions and 20 deletions

View File

@ -41,6 +41,8 @@ void i2cDecoder::updateBitValues(){
unsigned char dataByteSda = sda->buffer[coord_byte];
unsigned char dataByteScl = scl->buffer[coord_byte];
unsigned char mask = (1 << coord_bit);
previousSdaValue = currentSdaValue;
previousSclValue = currentSclValue;
currentSdaValue = dataByteSda & mask;
currentSclValue = dataByteScl & mask;
}
@ -57,10 +59,12 @@ void i2cDecoder::runStateMachine()
edge sdaEdge = edgeDetection(currentSdaValue, previousSdaValue);
edge sclEdge = edgeDetection(currentSclValue, previousSclValue);
if (sdaEdge == edge::rising || sdaEdge == edge::falling)
qDebug() << "sdaEdge";
if (sclEdge == edge::rising || sclEdge == edge::falling)
qDebug() << "sclEdge";
// if (sdaEdge == edge::rising || sdaEdge == edge::falling)
// qDebug() << "sdaEdge";
// if (sclEdge == edge::rising || sclEdge == edge::falling)
// qDebug() << "sclEdge";
qDebug() << "sdaEdge" << (uint8_t)sdaEdge << "sclEdge" << (uint8_t)sclEdge;
if ((sdaEdge == edge::rising) && (sclEdge == edge::falling)) // INVALID STATE TRANSITION
{
@ -152,7 +156,7 @@ void i2cDecoder::startCondition()
currentStepIndex = 0;
address = 0x0000;
state = transmissionState::address;
qDebug() << "START";
qDebug() << "I2C START";
}
void i2cDecoder::stopCondition()
@ -169,7 +173,7 @@ void i2cDecoder::stopCondition()
state = transmissionState::idle;
break;
}
qDebug() << "STOP";
qDebug() << "I2C STOP";
}
void i2cDecoder::dataByteCompleted(uint8_t byte, bool ACKed)

View File

@ -1512,7 +1512,6 @@ void isoDriver::setSerialType(unsigned char type)
if (twoWire)
delete twoWire;
twoWire = new i2c::i2cDecoder(internalBuffer375_CH1, internalBuffer375_CH2, i2cClockRate);
twoWire->setStepSize(1000, 1);
}
}

View File

@ -1,13 +1,13 @@
/****************************************************************************
** Resource object code
**
** Created by: The Resource Compiler for Qt version 5.11.1
** Created by: The Resource Compiler for Qt version 5.5.1
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
static const unsigned char qt_resource_data[] = {
// /home/esposch/git/labrador/Desktop_Interface/buffer_0.bmp
// /home/espobuntux86/git/labrador/Desktop_Interface/buffer_0.bmp
0x0,0x0,0x0,0x8d,
0x0,
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0xb1,0xd,0xc2,0x30,0x0,0x45,0xc1,0xb0,0x45,
@ -19,7 +19,7 @@ static const unsigned char qt_resource_data[] = {
0xab,0x8f,0xd5,0xc7,0xea,0x63,0xf5,0xb1,0xfa,0x58,0x7d,0xac,0x3e,0x56,0x1f,0xab,
0x8f,0xd5,0xc7,0xea,0x63,0xf5,0xb1,0xfa,0x58,0x7d,0xac,0x3e,0x56,0x1f,0xab,0x8f,
0xd5,0xc7,0xea,0x63,0x73,0xf6,0xf9,0x2,0xf4,0x4,0x42,0xe7,
// /home/esposch/git/labrador/Desktop_Interface/buffer_2.bmp
// /home/espobuntux86/git/labrador/Desktop_Interface/buffer_2.bmp
0x0,0x0,0x0,0x7b,
0x0,
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0x31,0xd,0x80,0x30,0x14,0x45,0xd1,0xe2,0x82,
@ -30,7 +30,7 @@ static const unsigned char qt_resource_data[] = {
0x3e,0x99,0xf1,0xe1,0xc3,0x87,0xf,0x9f,0xcc,0xf8,0xf0,0xe1,0xc3,0x87,0x4f,0x66,
0x7c,0xf8,0xf0,0xe1,0xc3,0x27,0x33,0x3e,0x7c,0xf8,0xf0,0xe1,0x93,0x19,0x1f,0x3e,
0x7c,0xf8,0xf0,0x19,0x7b,0x1,0x6d,0x5a,0xf,0xce,
// /home/esposch/git/labrador/Desktop_Interface/buffer_1.bmp
// /home/espobuntux86/git/labrador/Desktop_Interface/buffer_1.bmp
0x0,0x0,0x0,0x97,
0x0,
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0xb1,0xd,0xc2,0x30,0x10,0x40,0xd1,0xb0,0x5,
@ -73,19 +73,14 @@ static const unsigned char qt_resource_name[] = {
static const unsigned char qt_resource_struct[] = {
// :
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// :/bitmap
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x2,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// :/bitmap/buffer_2.bmp
0x0,0x0,0x0,0x30,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x91,
0x0,0x0,0x1,0x64,0xad,0x34,0xc4,0x61,
// :/bitmap/buffer_0.bmp
0x0,0x0,0x0,0x12,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
0x0,0x0,0x1,0x64,0xad,0x34,0xc4,0x61,
// :/bitmap/buffer_1.bmp
0x0,0x0,0x0,0x4e,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0x10,
0x0,0x0,0x1,0x64,0xad,0x34,0xc4,0x61,
};
@ -117,7 +112,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources_resources)();
int QT_RCC_MANGLE_NAMESPACE(qInitResources_resources)()
{
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
(0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
@ -125,7 +120,7 @@ int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_resources)();
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_resources)()
{
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
(0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}