mirror of https://github.com/EspoTek/Labrador.git
more i2c flesh
This commit is contained in:
parent
2d1bd5f438
commit
b414923fd3
|
@ -1,5 +1,7 @@
|
||||||
#include "i2cdecoder.h"
|
#include "i2cdecoder.h"
|
||||||
|
|
||||||
|
using namespace i2c;
|
||||||
|
|
||||||
i2cDecoder::i2cDecoder(isoBuffer* sda_in, isoBuffer* scl_in, uint32_t clockRate) : QObject(nullptr)
|
i2cDecoder::i2cDecoder(isoBuffer* sda_in, isoBuffer* scl_in, uint32_t clockRate) : QObject(nullptr)
|
||||||
{
|
{
|
||||||
sda = sda_in;
|
sda = sda_in;
|
||||||
|
@ -48,3 +50,15 @@ void i2cDecoder::runStateMachine()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edge i2cDecoder::edgeDetection(uint8_t current, uint8_t prev)
|
||||||
|
{
|
||||||
|
if (current && prev)
|
||||||
|
return edge::held_high;
|
||||||
|
if (!current && !prev)
|
||||||
|
return edge::held_low;
|
||||||
|
if (current && !prev)
|
||||||
|
return edge::rising;
|
||||||
|
if (!current &&!prev)
|
||||||
|
return edge::falling;
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,24 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "isobuffer.h"
|
#include "isobuffer.h"
|
||||||
|
|
||||||
|
namespace i2c
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class transmissionState: uint8_t
|
||||||
|
{
|
||||||
|
idle,
|
||||||
|
address,
|
||||||
|
data
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class edge: uint8_t
|
||||||
|
{
|
||||||
|
rising,
|
||||||
|
falling,
|
||||||
|
held_high,
|
||||||
|
held_low
|
||||||
|
};
|
||||||
|
|
||||||
class i2cDecoder : public QObject
|
class i2cDecoder : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -13,7 +31,9 @@ private:
|
||||||
isoBuffer* sda;
|
isoBuffer* sda;
|
||||||
isoBuffer* scl;
|
isoBuffer* scl;
|
||||||
uint8_t currentSdaValue;
|
uint8_t currentSdaValue;
|
||||||
|
uint8_t previousSdaValue;
|
||||||
uint8_t currentSclValue;
|
uint8_t currentSclValue;
|
||||||
|
uint8_t previousSclValue;
|
||||||
uint64_t serialPtr_bit = 0;
|
uint64_t serialPtr_bit = 0;
|
||||||
void updateBitValues();
|
void updateBitValues();
|
||||||
uint32_t stepSize;
|
uint32_t stepSize;
|
||||||
|
@ -21,8 +41,12 @@ private:
|
||||||
void runStateMachine();
|
void runStateMachine();
|
||||||
void run();
|
void run();
|
||||||
int serialDistance(isoBuffer* buffer);
|
int serialDistance(isoBuffer* buffer);
|
||||||
|
edge edgeDetection(uint8_t current, uint8_t prev);
|
||||||
signals:
|
signals:
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // Namespace i2c
|
||||||
|
|
||||||
#endif // UARTSTYLEDECODER_H
|
#endif // UARTSTYLEDECODER_H
|
||||||
|
|
Loading…
Reference in New Issue