From eb734b173dcffe5dfe804e59c8bb989a36872aa8 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 24 Jul 2011 19:50:44 +0200 Subject: [PATCH] power_on(): add a delay when powering on. This allows the PSU to come up before we get step losses if we step immediately. --- pinio.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pinio.c b/pinio.c index cc37678..22cc1ed 100644 --- a/pinio.c +++ b/pinio.c @@ -1,11 +1,18 @@ #include "pinio.h" +#include "delay.h" + +static char ps_is_on = 0; void power_on() { - #ifdef PS_ON_PIN - WRITE(PS_ON_PIN, 0); - SET_OUTPUT(PS_ON_PIN); - #endif + if (ps_is_on == 0) { + #ifdef PS_ON_PIN + WRITE(PS_ON_PIN, 0); + SET_OUTPUT(PS_ON_PIN); + _delay_ms(500); + #endif + ps_is_on = 1; + } } void power_off() { @@ -19,4 +26,6 @@ void power_off() { #ifdef PS_ON_PIN SET_INPUT(PS_ON_PIN); #endif + + ps_is_on = 0; }