mirror of https://github.com/EspoTek/Labrador.git
i2c state invalidation
This commit is contained in:
parent
0f00af0c08
commit
2772fee1cd
|
@ -7,12 +7,17 @@ static const uint32_t kClockMultiplier = 10;
|
||||||
i2cDecoder::i2cDecoder(isoBuffer* sda_in, isoBuffer* scl_in, uint32_t clockRate) :
|
i2cDecoder::i2cDecoder(isoBuffer* sda_in, isoBuffer* scl_in, uint32_t clockRate) :
|
||||||
QObject(nullptr),
|
QObject(nullptr),
|
||||||
sda(sda_in),
|
sda(sda_in),
|
||||||
scl(scl_in),
|
scl(scl_in)
|
||||||
serialPtr_bit(sda->back * 8)
|
|
||||||
{
|
{
|
||||||
setStepSize(clockRate, kClockMultiplier);
|
setStepSize(clockRate, kClockMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void i2cDecoder::reset()
|
||||||
|
{
|
||||||
|
serialPtr_bit = sda->back * 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void i2cDecoder::run()
|
void i2cDecoder::run()
|
||||||
{
|
{
|
||||||
qDebug() << "i2cDecoder::run()";
|
qDebug() << "i2cDecoder::run()";
|
||||||
|
@ -75,7 +80,7 @@ void i2cDecoder::runStateMachine()
|
||||||
{
|
{
|
||||||
state = transmissionState::unknown;
|
state = transmissionState::unknown;
|
||||||
qDebug() << "Dumping I2C state and aborting...";
|
qDebug() << "Dumping I2C state and aborting...";
|
||||||
for (uint8_t i=0; i < 32; i++)
|
for (int i=32; i>=0; i--)
|
||||||
qDebug("%x\t%x", sda->buffer[serialPtr_bit/8 - i] & 0xFF, scl->buffer[serialPtr_bit/8 - i] & 0xFF);
|
qDebug("%x\t%x", sda->buffer[serialPtr_bit/8 - i] & 0xFF, scl->buffer[serialPtr_bit/8 - i] & 0xFF);
|
||||||
throw std::runtime_error("unknown i2c transmission state");
|
throw std::runtime_error("unknown i2c transmission state");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
uint8_t previousSdaValue = 0;
|
uint8_t previousSdaValue = 0;
|
||||||
uint8_t currentSclValue = 0;
|
uint8_t currentSclValue = 0;
|
||||||
uint8_t previousSclValue = 0;
|
uint8_t previousSclValue = 0;
|
||||||
uint64_t serialPtr_bit;
|
uint64_t serialPtr_bit = 0;
|
||||||
transmissionState state = transmissionState::unknown;
|
transmissionState state = transmissionState::unknown;
|
||||||
|
|
||||||
// Data Transmission
|
// Data Transmission
|
||||||
|
@ -60,6 +60,7 @@ public:
|
||||||
void startCondition();
|
void startCondition();
|
||||||
void stopCondition();
|
void stopCondition();
|
||||||
void dataByteCompleted(uint8_t byte, bool ACKed);
|
void dataByteCompleted(uint8_t byte, bool ACKed);
|
||||||
|
void reset();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -74,6 +74,8 @@ void isoDriver::timerTick(void){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Do we need to invalidate state when the device is reconnected?
|
||||||
|
bool invalidateTwoWireState = true;
|
||||||
switch(driver->deviceMode){
|
switch(driver->deviceMode){
|
||||||
case 0:
|
case 0:
|
||||||
frameActionGeneric(1,0);
|
frameActionGeneric(1,0);
|
||||||
|
@ -104,7 +106,12 @@ void isoDriver::timerTick(void){
|
||||||
internalBuffer375_CH2->serialManage(baudRate_CH2, 0);
|
internalBuffer375_CH2->serialManage(baudRate_CH2, 0);
|
||||||
}
|
}
|
||||||
if (serialDecodeEnabled_CH1 && serialType == 1)
|
if (serialDecodeEnabled_CH1 && serialType == 1)
|
||||||
|
{
|
||||||
|
if (twoWireStateInvalid)
|
||||||
|
twoWire->reset();
|
||||||
twoWire->run();
|
twoWire->run();
|
||||||
|
invalidateTwoWireState = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
break;
|
break;
|
||||||
|
@ -117,6 +124,8 @@ void isoDriver::timerTick(void){
|
||||||
default:
|
default:
|
||||||
qFatal("Error in isoDriver::timerTick. Invalid device mode.");
|
qFatal("Error in isoDriver::timerTick. Invalid device mode.");
|
||||||
}
|
}
|
||||||
|
if (invalidateTwoWireState)
|
||||||
|
twoWireStateInvalid = true;
|
||||||
//free(isoTemp);
|
//free(isoTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ private:
|
||||||
unsigned char serialType = 0;
|
unsigned char serialType = 0;
|
||||||
i2c::i2cDecoder* twoWire = nullptr;
|
i2c::i2cDecoder* twoWire = nullptr;
|
||||||
uint32_t i2cClockRate = 100000;
|
uint32_t i2cClockRate = 100000;
|
||||||
|
bool twoWireStateInvalid = true;
|
||||||
//Generic Vars
|
//Generic Vars
|
||||||
double windowAtPause = 0.01;
|
double windowAtPause = 0.01;
|
||||||
QTimer* isoTimer = NULL, *slowTimer = NULL, *fileTimer = NULL;
|
QTimer* isoTimer = NULL, *slowTimer = NULL, *fileTimer = NULL;
|
||||||
|
|
Loading…
Reference in New Issue