#ifndef SsiBuffer_h
#define SsiBuffer_h
#include "Energia.h"
#include <driverlib/interrupt.h>
/*
The L6470 needs an 800 ns pause (CS positive) between each byte to process each command and setup
the response. Since the normal SPI framing is only one clock period (0.2 ns) between bytes,
daisy-chaining the dSpins is more efficient.
At 5 MHZ clock, it take only 1.6µs to transfer the 8 bits.
The L6470 needs 350ns to respond to chip select. CS is ignored without motor power
*/
class SsiDeviceQueue;
class SsiBuffer {
public:
SsiBuffer( SsiDeviceQueue* aSsiDeviceQueue );
virtual ~SsiBuffer();
SsiBuffer* nextSsiBuffer;
SsiDeviceQueue* ssiDeviceQueue;
bool
isInQueue();
// dSpin
byte
getByte();
void
receiveByte( byte receivedData ); // TxEOT interrupt
// BOOST-DRV8711
uint32_t
getWord();
void
receiveWord( uint16_t receivedData );
protected:
uint32_t mask;
byte command;
uint8_t dataBytes;
byte* bytePointer;
union { // Byte order is little-endian
uint32_t dataWord;
byte dataByte[4]; } myData;
virtual void
rxComplete() {};
// dSpin
void
queueWith( uint8_t aCommand );
void
queueWith(
uint8_t aCommand,
uint32_t data,
uint32_t aMask );
virtual void
getParam( uint8_t param ) {};
virtual bool
setParam(
uint8_t param,
uint32_t value,
String* msg ) {};
// BOOST-DRV8711
void
queueWithRegister( uint16_t aRegister );
void
queue();
};
#endif