#ifndef _STP100_H
#define _STP100_H

/****************************************************************************/
/* Copyright (c) 2000 MBARI.                                                */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  : STP100 Stepper Motor Controller - Function Definitions        */
/* Filename : stp100.h                                                      */
/* Author   : Andrew Pearce                                                 */
/* Project  : Dorado AUV Tailcone                                           */
/* Version  : 1.0                                                           */
/* Created  : 01/19/00                                                      */
/* Modified : 01/19/00                                                      */
/* Archived :                                                               */
/****************************************************************************/

typedef struct
{
  quadSerialChan serialChan;            /* Serial IO channel descriptor     */

  Nat32 controlTick;                    /* Schedule controller at this tick */
  Nat16 controlPeriod;                  /* Controller tick rate             */

  Int16 desiredPosition;                /* Desired position. Input to ctrl  */
  Int16 position;                       /* Measured position feedback       */
  Int16 Kp;                             /* Position control gain            */
  Int16 lastPosition;
} stpStruct;

#define STP100_CMD_DELAY  2             /* 20 msec delay between commands   */
#define STP100_TERM      13             /* Carriage return terminator       */
#define STP100_DELTA_POS 20             /* 20 step minimum position change  */


Int16 stp100OpenSerialChan(stpStruct *stp, Byte *boardAddr, Nat16 chan,
    IBC_BoardEntry *IBC_CardTable[], Int16 cardCount);

Int16 stp100ReadData(stpStruct *stp, Byte *buffer, Int16 maxLen);

Int16 stp100WriteData(stpStruct *stp, char *cmd);

Int16 stp100BoardSelect(stpStruct *stp, Int16 board);

Int16 stp100ReadID(stpStruct *stp);

Int16 stp100ReadAtoD(stpStruct *stp, Int16 chan);

Void stp100InitializeController(stpStruct *stp, Nat16 controlPeriod);

Void stp100PositionControl(stpStruct *stp);

#endif



