auto-sync

This commit is contained in:
rusEfi 2014-12-24 18:05:31 -06:00
parent 8300b62b8a
commit f44bdd4e44
5 changed files with 90 additions and 11 deletions

View File

@ -21,5 +21,6 @@ HW_LAYER_SRC_CPP = $(PROJECT_DIR)/hw_layer/hardware.cpp \
$(PROJECT_DIR)/hw_layer/pwm_generator.cpp \
$(PROJECT_DIR)/hw_layer/trigger_input.cpp \
$(PROJECT_DIR)/hw_layer/HIP9011.cpp \
$(PROJECT_DIR)/hw_layer/stepper.cpp \
$(PROJECT_DIR)/hw_layer/stm32f4/mpu_util.cpp

View File

@ -1,13 +1,11 @@
/*
* pin_repository.h
*
* @date Jan 15, 2013
* @author Andrey Belomutskiy, (c) 2012-2014
*/
/**
* @file pin_repository.h
* @brief I/O pin registry header
*
*
*
* @date Jan 15, 2013
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#ifndef PIN_REPOSITORY_H_

View File

@ -0,0 +1,45 @@
/**
* @file stepper.cpp
*
* http://rusefi.com/wiki/index.php?title=Hardware:Stepper_motor
*
* @date Dec 24, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#include "stepper.h"
#include "pin_repository.h"
#define ST_DELAY_MS 20
#define ST_COUNT 200
static msg_t stThread(StepperMotor *motor) {
chRegSetThreadName("stepper");
// let's part the motor in a known position to begin with
for (int i = 0; i < ST_COUNT; i++) {
motor->pulse();
}
}
void StepperMotor::pulse() {
palWritePad(stepPort, stepPin, true);
chThdSleepMilliseconds(ST_DELAY_MS);
palWritePad(stepPort, stepPin, false);
chThdSleepMilliseconds(ST_DELAY_MS);
}
void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin) {
position = 0;
stepPort = getHwPort(stepPin);
this->stepPin = getHwPin(stepPin);
mySetPadMode("st step", stepPort, this->stepPin, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode("st dir", getHwPort(directionPin), getHwPin(directionPin), PAL_MODE_OUTPUT_PUSHPULL);
chThdCreateStatic(stThreadStack, sizeof(stThreadStack), NORMALPRIO, (tfunc_t) stThread, this);
}

View File

@ -0,0 +1,29 @@
/**
* @file stepper.h
*
* @date Dec 24, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#ifndef STEPPER_H_
#define STEPPER_H_
#include "main.h"
class StepperMotor {
public:
void initialize(brain_pin_e stepPin, brain_pin_e directionPin);
void pulse();
private:
GPIO_TypeDef * stepPort;
ioportmask_t stepPin;
GPIO_TypeDef * directionPort;
ioportmask_t directionPin;
int position;
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
};
#endif /* STEPPER_H_ */

View File

@ -2033,14 +2033,14 @@
<file>
<name>$PROJ_DIR$\..\config\stm32f4ems\chconf.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\config\stm32f4ems\efifeatures.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\config\stm32f4ems\halconf.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\config\stm32f4ems\mcuconf.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\config\stm32f4ems\efifeatures.h</name>
<name>$PROJ_DIR$\..\config\stm32f4ems\mcuconf.h</name>
</file>
</group>
</group>
@ -2739,6 +2739,12 @@
<file>
<name>$PROJ_DIR$\..\hw_layer\rtc_helper.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\hw_layer\stepper.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\hw_layer\stepper.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\hw_layer\stm32f4xx_specific.h</name>
</file>