From 01f7c9988101040beacb69d89ba50966c9ab28c6 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Thu, 11 Jul 2013 21:28:08 +0200 Subject: [PATCH] config.h: introduce PS_MOSFET_PIN for Sanguish support. --- config.default.h | 1 + config.gen3.h | 1 + config.gen6.h | 1 + config.gen7-v1.1-v1.3.h | 1 + config.gen7-v1.4.h | 1 + config.ramps-v1.2.h | 2 ++ config.ramps-v1.3.h | 1 + config.sanguinololu-v1.1.h | 1 + config.sanguinololu-v1.2.h | 1 + config.teensy.h | 9 ++++----- config.teensypp.h | 9 ++++----- mendel.c | 3 +++ pinio.c | 8 ++++++++ pinio.h | 8 ++++++++ 14 files changed, 37 insertions(+), 10 deletions(-) diff --git a/config.default.h b/config.default.h index 2c46f73..a2908be 100644 --- a/config.default.h +++ b/config.default.h @@ -258,6 +258,7 @@ //#define E_INVERT_ENABLE #define PS_ON_PIN DIO9 +//#define PS_MOSFET_PIN xxxx //#define STEPPER_ENABLE_PIN xxxx //#define STEPPER_INVERT_ENABLE diff --git a/config.gen3.h b/config.gen3.h index 5c646c6..e4dd4d4 100644 --- a/config.gen3.h +++ b/config.gen3.h @@ -263,6 +263,7 @@ #define SD_WRITE_PROTECT DIO3 #define PS_ON_PIN DIO14 +//#define PS_MOSFET_PIN xxxx //#define STEPPER_ENABLE_PIN xxxx //#define STEPPER_INVERT_ENABLE diff --git a/config.gen6.h b/config.gen6.h index cbb2685..6a7a753 100644 --- a/config.gen6.h +++ b/config.gen6.h @@ -258,6 +258,7 @@ #define E_INVERT_ENABLE //#define PS_ON_PIN xxxx +//#define PS_MOSFET_PIN xxxx //#define STEPPER_ENABLE_PIN xxxx //#define STEPPER_INVERT_ENABLE diff --git a/config.gen7-v1.1-v1.3.h b/config.gen7-v1.1-v1.3.h index b2a87fa..8a2e9d1 100644 --- a/config.gen7-v1.1-v1.3.h +++ b/config.gen7-v1.1-v1.3.h @@ -266,6 +266,7 @@ //#define E_INVERT_ENABLE #define PS_ON_PIN DIO15 +//#define PS_MOSFET_PIN xxxx #define STEPPER_ENABLE_PIN DIO24 #define STEPPER_INVERT_ENABLE diff --git a/config.gen7-v1.4.h b/config.gen7-v1.4.h index 3f90aa7..2e3b4bd 100644 --- a/config.gen7-v1.4.h +++ b/config.gen7-v1.4.h @@ -266,6 +266,7 @@ //#define E_INVERT_ENABLE #define PS_ON_PIN DIO15 +//#define PS_MOSFET_PIN xxxx #define STEPPER_ENABLE_PIN DIO25 #define STEPPER_INVERT_ENABLE diff --git a/config.ramps-v1.2.h b/config.ramps-v1.2.h index 255e3f9..0f9f47c 100644 --- a/config.ramps-v1.2.h +++ b/config.ramps-v1.2.h @@ -261,6 +261,8 @@ //#define E_INVERT_DIR #define E_INVERT_ENABLE +//#define PS_ON_PIN DIO9 +//#define PS_MOSFET_PIN xxxx //#define SD_CARD_DETECT DIO2 //#define SD_WRITE_PROTECT DIO3 diff --git a/config.ramps-v1.3.h b/config.ramps-v1.3.h index 690212e..c808fd4 100644 --- a/config.ramps-v1.3.h +++ b/config.ramps-v1.3.h @@ -261,6 +261,7 @@ //#define E_INVERT_ENABLE //#define PS_ON_PIN xxxx +//#define PS_MOSFET_PIN xxxx //#define STEPPER_ENABLE_PIN xxxx //#define STEPPER_INVERT_ENABLE diff --git a/config.sanguinololu-v1.1.h b/config.sanguinololu-v1.1.h index 9c04f10..041835e 100644 --- a/config.sanguinololu-v1.1.h +++ b/config.sanguinololu-v1.1.h @@ -260,6 +260,7 @@ //#define E_INVERT_ENABLE #define PS_ON_PIN DIO9 +//#define PS_MOSFET_PIN xxxx #define STEPPER_ENABLE_PIN DIO4 //#define STEPPER_INVERT_ENABLE diff --git a/config.sanguinololu-v1.2.h b/config.sanguinololu-v1.2.h index 3f93653..afbbe6a 100644 --- a/config.sanguinololu-v1.2.h +++ b/config.sanguinololu-v1.2.h @@ -260,6 +260,7 @@ //#define E_INVERT_ENABLE #define PS_ON_PIN DIO9 +//#define PS_MOSFET_PIN xxxx #define STEPPER_ENABLE_PIN DIO14 #define STEPPER_INVERT_ENABLE diff --git a/config.teensy.h b/config.teensy.h index 322d46a..d5c36f6 100644 --- a/config.teensy.h +++ b/config.teensy.h @@ -271,10 +271,6 @@ to use the other 6 PWMs instead. /* starting down the left side for digital, and later down the right for analog */ /* General layout: ccw from upper left: stops, heaters, E,Z,Y,X, temp sensors */ -//#define PS_ON_PIN DIO0 -#define STEPPER_ENABLE_PIN DIO19 -#define STEPPER_INVERT_ENABLE - #define X_STEP_PIN DIO18 #define X_DIR_PIN DIO17 #define X_MIN_PIN DIO1 @@ -311,8 +307,11 @@ to use the other 6 PWMs instead. #define E_INVERT_DIR //#define E_INVERT_ENABLE +//#define PS_ON_PIN DIO0 +//#define PS_MOSFET_PIN xxxx +#define STEPPER_ENABLE_PIN DIO19 +#define STEPPER_INVERT_ENABLE -//#define PS_ON_PIN xxxx //#define SD_CARD_DETECT DIO2 //#define SD_WRITE_PROTECT DIO3 diff --git a/config.teensypp.h b/config.teensypp.h index f4a44b8..a6af367 100644 --- a/config.teensypp.h +++ b/config.teensypp.h @@ -275,10 +275,6 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a /* starting down the left side for digital, and later down the right for analog */ /* General layout: ccw from upper left: stops, heaters, E,Z,Y,X, temp sensors */ -//#define PS_ON_PIN DIO0 -#define STEPPER_ENABLE_PIN DIO26 -#define STEPPER_INVERT_ENABLE - #define X_STEP_PIN DIO25 #define X_DIR_PIN DIO24 #define X_MIN_PIN DIO2 @@ -315,8 +311,11 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a #define E_INVERT_DIR //#define E_INVERT_ENABLE +//#define PS_ON_PIN DIO0 +//#define PS_MOSFET_PIN xxxx +#define STEPPER_ENABLE_PIN DIO26 +#define STEPPER_INVERT_ENABLE -//#define PS_ON_PIN xxxx //#define SD_CARD_DETECT DIO2 //#define SD_WRITE_PROTECT DIO3 diff --git a/mendel.c b/mendel.c index cf2c1a1..67cccf0 100644 --- a/mendel.c +++ b/mendel.c @@ -217,6 +217,9 @@ void init(void) { // reset watchdog wd_reset(); + // prepare the power supply + power_init(); + // say hi to host serial_writestr_P(PSTR("start\nok\n")); diff --git a/pinio.c b/pinio.c index f43d3e7..e27222b 100644 --- a/pinio.c +++ b/pinio.c @@ -14,6 +14,10 @@ void power_on() { SET_OUTPUT(PS_ON_PIN); delay_ms(500); #endif + #ifdef PS_MOSFET_PIN + WRITE(PS_MOSFET_PIN, 1); + delay_ms(10); + #endif ps_is_on = 1; } @@ -32,5 +36,9 @@ void power_off() { SET_INPUT(PS_ON_PIN); #endif + #ifdef PS_MOSFET_PIN + WRITE(PS_MOSFET_PIN, 0); + #endif + ps_is_on = 0; } diff --git a/pinio.h b/pinio.h index c1774be..ef45106 100644 --- a/pinio.h +++ b/pinio.h @@ -18,6 +18,14 @@ Power /// It is used inside and outside of interrupts, which is why it has been made volatile extern volatile uint8_t psu_timeout; +static void power_init(void); +inline void power_init(void) { + #ifdef PS_MOSFET_PIN + WRITE(PS_MOSFET_PIN, 0); + SET_OUTPUT(PS_MOSFET_PIN); + #endif +} + void power_on(void); void power_off(void);