2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file stepper.h
|
|
|
|
*
|
|
|
|
* @date Dec 24, 2014
|
2018-12-30 16:13:28 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2018
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
#ifndef STEPPER_H_
|
|
|
|
#define STEPPER_H_
|
|
|
|
|
2018-09-16 19:26:57 -07:00
|
|
|
#include "global.h"
|
2019-03-29 06:11:13 -07:00
|
|
|
#include "efi_gpio.h"
|
2017-12-22 05:49:03 -08:00
|
|
|
#include "backup_ram.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
class StepperMotor {
|
|
|
|
public:
|
|
|
|
StepperMotor();
|
2017-06-13 06:28:05 -07:00
|
|
|
void initialize(brain_pin_e stepPin, brain_pin_e directionPin, pin_output_mode_e directionPinMode, float reactionTime, int totalSteps,
|
2019-03-28 23:44:52 -07:00
|
|
|
brain_pin_e enablePin, pin_output_mode_e enablePinMode, Logging *sharedLogger);
|
2015-07-10 06:01:56 -07:00
|
|
|
void pulse();
|
|
|
|
void setTargetPosition(int targetPosition);
|
|
|
|
int getTargetPosition();
|
2018-01-28 11:44:01 -08:00
|
|
|
void setDirection(bool isIncrementing);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-06-13 06:28:05 -07:00
|
|
|
OutputPin directionPin;
|
2015-07-10 06:01:56 -07:00
|
|
|
int currentPosition;
|
2018-01-28 11:44:01 -08:00
|
|
|
bool currentDirection;
|
2015-07-10 06:01:56 -07:00
|
|
|
float reactionTime;
|
|
|
|
int totalSteps;
|
|
|
|
private:
|
|
|
|
int targetPosition;
|
2016-02-04 09:01:41 -08:00
|
|
|
ioportid_t stepPort;
|
2015-07-10 06:01:56 -07:00
|
|
|
ioportmask_t stepPin;
|
|
|
|
|
2016-02-04 09:01:41 -08:00
|
|
|
ioportid_t enablePort;
|
2015-07-10 06:01:56 -07:00
|
|
|
ioportmask_t enablePin;
|
|
|
|
|
2017-06-13 06:28:05 -07:00
|
|
|
pin_output_mode_e directionPinMode;
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* STEPPER_H_ */
|