diff --git a/firmware/hw_layer/hw_layer.mk b/firmware/hw_layer/hw_layer.mk
index c1fe2f6b34..f9b771ae1d 100644
--- a/firmware/hw_layer/hw_layer.mk
+++ b/firmware/hw_layer/hw_layer.mk
@@ -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
\ No newline at end of file
diff --git a/firmware/hw_layer/pin_repository.h b/firmware/hw_layer/pin_repository.h
index bc4e409047..f9d50fcede 100644
--- a/firmware/hw_layer/pin_repository.h
+++ b/firmware/hw_layer/pin_repository.h
@@ -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_
diff --git a/firmware/hw_layer/stepper.cpp b/firmware/hw_layer/stepper.cpp
new file mode 100644
index 0000000000..3b8fd99d80
--- /dev/null
+++ b/firmware/hw_layer/stepper.cpp
@@ -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);
+}
diff --git a/firmware/hw_layer/stepper.h b/firmware/hw_layer/stepper.h
new file mode 100644
index 0000000000..53cd7e42f6
--- /dev/null
+++ b/firmware/hw_layer/stepper.h
@@ -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_ */
diff --git a/firmware/iar/ch.ewp b/firmware/iar/ch.ewp
index 4c88973eda..5b99e5410e 100644
--- a/firmware/iar/ch.ewp
+++ b/firmware/iar/ch.ewp
@@ -2033,14 +2033,14 @@
$PROJ_DIR$\..\config\stm32f4ems\chconf.h
+
+ $PROJ_DIR$\..\config\stm32f4ems\efifeatures.h
+
$PROJ_DIR$\..\config\stm32f4ems\halconf.h
- $PROJ_DIR$\..\config\stm32f4ems\mcuconf.h
-
-
- $PROJ_DIR$\..\config\stm32f4ems\efifeatures.h
+ $PROJ_DIR$\..\config\stm32f4ems\mcuconf.h
@@ -2739,6 +2739,12 @@
$PROJ_DIR$\..\hw_layer\rtc_helper.h
+
+ $PROJ_DIR$\..\hw_layer\stepper.cpp
+
+
+ $PROJ_DIR$\..\hw_layer\stepper.h
+
$PROJ_DIR$\..\hw_layer\stm32f4xx_specific.h