// © RiceMotion ( Robert Carl Rice ) 2012-2016 - All rights reserved

// This software makes use of tools and libraries obtained from open source projects or released for

// use by relevant hardware manufactures. However, this software is NOT a part of any open source project.

// It is released only on a "need to know" basis for beta testers of the "RiceCNC Interpolation Engine".

// Recipents of this source code must respect the confidential nature of this software and prevent any

// distribution that could result in counterfeit copies of the "RiceCNC Interpolation Engine".

// © RiceMotion ( Robert Carl Rice ) 2012-2016 - All rights reserved

#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 {


    SsiBuffer( SsiDeviceQueue* aSsiDeviceQueue );

     virtual ~SsiBuffer();

    SsiBuffer*          nextSsiBuffer;

    SsiDeviceQueue*     ssiDeviceQueue;



// dSpin




          receiveByte( byte receivedData ); // TxEOT interrupt

// BOOST-DRV8711




          receiveWord( uint16_t receivedData );


    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


          queueWith( uint8_t aCommand );



               uint8_t          aCommand,

               uint32_t     data,

               uint32_t     aMask );

    virtual void

          getParam( uint8_t param ) {};

    virtual bool


               uint8_t          param,

               uint32_t     value,

               String*          msg ) {};

// BOOST-DRV8711


          queueWithRegister( uint16_t aRegister );