more i2 skeleton

This commit is contained in:
Chris Esposito 2018-08-02 18:27:09 +10:00
parent 4c61a0a327
commit 634a046097
2 changed files with 28 additions and 7 deletions

View File

@ -1,14 +1,20 @@
#include "i2cdecoder.h"
i2cDecoder::i2cDecoder(isoBuffer* sda_in, isoBuffer* scl_in) : QObject(nullptr)
i2cDecoder::i2cDecoder(isoBuffer* sda_in, isoBuffer* scl_in, uint32_t clockRate) : QObject(nullptr)
{
sda = sda_in;
scl = scl_in;
setStepSize(clockRate);
}
void i2cDecoder::run()
{
while (serialDistance(sda) > SERIAL_DELAY * sda->sampleRate_bit)
{
updateBitValues();
runStateMachine();
serialPtr_bit += stepSize;
}
}
int i2cDecoder::serialDistance(isoBuffer* buffer)
@ -30,3 +36,15 @@ void i2cDecoder::updateBitValues(){
currentSdaValue = dataByteSda & mask;
currentSclValue = dataByteScl & mask;
}
void i2cDecoder::setStepSize(uint32_t clockRate)
{
stepSize = (double)((sda->sampleRate_bit)/clockRate)/2.0;
if (stepSize > (SERIAL_DELAY * sda->sampleRate_bit)/2)
stepSize = SERIAL_DELAY * sda->sampleRate_bit / 2;
}
void i2cDecoder::runStateMachine()
{
}

View File

@ -8,16 +8,19 @@ class i2cDecoder : public QObject
{
Q_OBJECT
public:
explicit i2cDecoder(isoBuffer* sda_in, isoBuffer* scl_in);
void run();
int serialDistance(isoBuffer* buffer);
explicit i2cDecoder(isoBuffer* sda_in, isoBuffer* scl_in, uint32_t clockRate);
private:
isoBuffer* sda;
isoBuffer* scl;
uint8_t currentSdaValue;
uint8_t currentSclValue;
int serialPtr_bit = 0;
uint64_t serialPtr_bit = 0;
void updateBitValues();
uint32_t stepSize;
void setStepSize(uint32_t clockRate);
void runStateMachine();
void run();
int serialDistance(isoBuffer* buffer);
signals:
public slots:
};