Clean up handling PS_ON_PIN and STEPPER_ENABLE_PIN.

This means moving power_on() from a macro to a function and
initializing the STEPPER_ENABLE_PIN in mendel.c.
This commit is contained in:
Markus Hitter 2011-07-24 18:43:05 +02:00
parent fa0381341b
commit 090da8ddad
3 changed files with 35 additions and 13 deletions

View File

@ -66,6 +66,18 @@ void io_init(void) {
ACSR = MASK(ACD);
// setup I/O pins
// Common Stepper Enable
#ifdef STEPPER_ENABLE_PIN
#ifdef STEPPER_ENABLE_INVERT
WRITE(STEPPER_ENABLE_PIN, 0);
#else
WRITE(STEPPER_ENABLE_PIN, 1);
#endif
SET_OUTPUT(STEPPER_ENABLE_PIN);
#endif
// X Stepper
WRITE(X_STEP_PIN, 0); SET_OUTPUT(X_STEP_PIN);
WRITE(X_DIR_PIN, 0); SET_OUTPUT(X_DIR_PIN);
#ifdef X_MIN_PIN
@ -88,6 +100,7 @@ void io_init(void) {
WRITE(X_ENABLE_PIN, 1); SET_OUTPUT(X_ENABLE_PIN);
#endif
// Y Stepper
WRITE(Y_STEP_PIN, 0); SET_OUTPUT(Y_STEP_PIN);
WRITE(Y_DIR_PIN, 0); SET_OUTPUT(Y_DIR_PIN);
#ifdef Y_MIN_PIN
@ -110,6 +123,7 @@ void io_init(void) {
WRITE(Y_ENABLE_PIN, 1); SET_OUTPUT(Y_ENABLE_PIN);
#endif
// Z Stepper
#if defined Z_STEP_PIN && defined Z_DIR_PIN
WRITE(Z_STEP_PIN, 0); SET_OUTPUT(Z_STEP_PIN);
WRITE(Z_DIR_PIN, 0); SET_OUTPUT(Z_DIR_PIN);

21
pinio.c
View File

@ -1,5 +1,20 @@
#include "pinio.h"
void power_on() {
#ifdef STEPPER_ENABLE_PIN
#ifdef STEPPER_ENABLE_INVERT
WRITE(STEPPER_ENABLE_PIN, 0);
#else
WRITE(STEPPER_ENABLE_PIN, 1);
#endif
#endif
#ifdef PS_ON_PIN
WRITE(PS_ON_PIN, 0);
SET_OUTPUT(PS_ON_PIN);
#endif
}
void power_off() {
x_disable();
@ -7,7 +22,11 @@ void power_off() {
z_disable();
#ifdef STEPPER_ENABLE_PIN
WRITE(STEPPER_ENABLE_PIN, STEPPER_ENABLE_INVERT ^ 1);
#ifdef STEPPER_ENABLE_INVERT
WRITE(STEPPER_ENABLE_PIN, 1);
#else
WRITE(STEPPER_ENABLE_PIN, 0);
#endif
#endif
#ifdef PS_ON_PIN
SET_INPUT(PS_ON_PIN);

13
pinio.h
View File

@ -23,22 +23,11 @@
#define E_INVERT_ENABLE 0
#endif
#ifndef STEPPER_ENABLE_INVERT
#define STEPPER_ENABLE_INVERT 0
#endif
/*
Power
*/
#ifdef STEPPER_ENABLE_PIN
#define power_on() do { WRITE(STEPPER_ENABLE_PIN, STEPPER_ENABLE_INVERT); SET_OUTPUT(STEPPER_ENABLE_PIN); } while (0)
#elif defined PS_ON_PIN
#define power_on() do { WRITE(PS_ON_PIN, 0); SET_OUTPUT(PS_ON_PIN); } while (0)
#else
#define power_on() do { } while (0)
#endif
void power_on(void);
void power_off(void);
/*