// © 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 SsiDeviceQueue_h

#define SsiDeviceQueue_h

#include "Energia.h"

class SSI;

class SsiBuffer;


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 {


    SsiDeviceQueue( SSI* ssi, uint32_t number );     // constructor

    virtual ~SsiDeviceQueue();   // destructor - will perform hard stop

     SSI*                    ssi;

    uint32_t               number;

    SsiDeviceQueue*     nextSsiDeviceQueue; // chain for SSI

    SsiBuffer*               startPointer; // pending queue

    SsiBuffer*               currentCR;    // pending queue

//    SsiBuffer*  setupBuffer;

// dSpins get alternate calls to getByte and receiveByte from SSI TxEOT ISR

// And pass the calls on to the active buffer if one




          receiveByte( uint32_t data );

// End Interrupt Service Routines




          queue( SsiBuffer* request );