2016-04-06 20:28:13 -07:00
# include "globals.h"
2015-08-25 20:27:50 -07:00
# define STEPPER_FORWARD 0
# define STEPPER_BACKWARD 1
2015-08-20 06:21:27 -07:00
# define IDLE_TABLE_SIZE 10
2015-05-29 00:33:00 -07:00
2015-08-25 20:27:50 -07:00
enum StepperStatus { SOFF , STEPPING , COOLING } ; //The 2 statuses that a stepper can have. STEPPING means that a high pulse is currently being sent and will need to be turned off at some point.
2015-05-29 00:33:00 -07:00
struct StepperIdle
{
2015-08-25 20:27:50 -07:00
unsigned int curIdleStep ; //Tracks the current location of the stepper
unsigned int targetIdleStep ; //What the targetted step is
2015-05-29 00:33:00 -07:00
volatile StepperStatus stepperStatus ;
volatile unsigned long stepStartTime ; //The time the curren
} ;
2015-08-20 06:21:27 -07:00
struct table2D iacClosedLoopTable ;
struct table2D iacPWMTable ;
struct table2D iacStepTable ;
//Open loop tables specifically for cranking
struct table2D iacCrankStepsTable ;
struct table2D iacCrankDutyTable ;
2015-08-20 21:14:47 -07:00
struct StepperIdle idleStepper ;
2015-08-20 06:21:27 -07:00
bool idleOn ; //Simply tracks whether idle was on last time around
2017-01-12 03:33:26 -08:00
byte idleInitComplete = 99 ; //TRacks which idle method was initialised. 99 is a method that will never exist
2015-08-25 20:27:50 -07:00
unsigned int iacStepTime ;
2016-12-11 04:23:54 -08:00
unsigned int completedHomeSteps ;
2015-05-29 00:33:00 -07:00
2015-09-25 17:12:59 -07:00
volatile byte * idle_pin_port ;
volatile byte idle_pin_mask ;
2016-01-12 22:06:55 -08:00
volatile byte * idle2_pin_port ;
volatile byte idle2_pin_mask ;
2015-09-25 17:12:59 -07:00
volatile bool idle_pwm_state ;
unsigned int idle_pwm_max_count ; //Used for variable PWM frequency
2015-09-29 16:27:37 -07:00
volatile unsigned int idle_pwm_cur_value ;
2016-04-06 20:28:13 -07:00
long idle_pwm_target_value ;
long idle_cl_target_rpm ;
2015-09-25 17:12:59 -07:00
2015-05-29 00:33:00 -07:00
void initialiseIdle ( ) ;
2016-10-06 23:34:27 -07:00
static inline void disableIdle ( ) ;
static inline void enableIdle ( ) ;