/** stepint.h -- Header for schip's interrupt driven stepper motor control.
 **
 **  REQUIRES that schip's cores/kernel modes be in place with
 **   at minimum SCHIPTCB defined so schipTick() is called from
 **   the 1ms tick interrupt code in wiring.c
 **
 **	Stepper control pins are hardwired to Port D Pin 2-5 on UNO type devices:
 **	 STEP1PIN	Arduino pin 2	// Port D, Bit 2 - mask 0x04
 **	 STEP2PIN	Arduino pin 3	// Port D, Bit 3 - mask 0x08
 **	 STEP3PIN	Arduino pin 4	// Port D, Bit 4 - mask 0x10
 **	 STEP4PIN	Arduino pin 5	// Port D, Bit 5 - mask 0x20
 **
 */
#ifndef stepint_h	// prevent this file from being included multiple times
#define stepint_h
#include <Arduino.h>	// system definitions

// get the prototypes for the schip scheduler additions
//  -- only really need schipTick() --
#include <schip/scheduler.h> // scheduler in cores

// options:

// select one stepper operation mode
//#define FULLSTEP
#define HALFSTEP

// define to turn on UNO LED when motor is running
// #define STEPTRACE

// number of timer ticks to do startup profile
#define PROFILETICKS 15

// stepper motor control pins FYI -- on UNO Port D
#define STEP1PIN	2	// Port D, Bit 2 - mask 0x04
#define STEP2PIN	3	// Port D, Bit 3 - mask 0x08
#define STEP3PIN	4	// Port D, Bit 4 - mask 0x10
#define STEP4PIN	5	// Port D, Bit 5 - mask 0x20

// external interface
extern void initStepper(void);
extern void startStepper( byte dir, byte steps, byte ticks,
							byte prf, byte hold );
extern void setStepSpeed( byte ticks );
extern void setStepDir( byte dir );
extern byte getSteps2do(void);
extern int getStepsDone(void);
extern void setStepsDone(int n);
extern void stopStepper( byte hold );

#endif // stepint_h
