]> cvs.zerfleddert.de Git - rsbs2/commitdiff
use tristate on outputs. Tested with a PC connected and everything works :-)
authorMichael Gernoth <michael@gernoth.net>
Mon, 23 Aug 2010 17:44:34 +0000 (19:44 +0200)
committerMichael Gernoth <michael@gernoth.net>
Mon, 23 Aug 2010 17:44:34 +0000 (19:44 +0200)
bmc/chassis.c

index 2259d8605eed30ce49c067f789573d5b7453aa0b..29541f288e12e593af3f2efc1aa99dd40089eec1 100644 (file)
@@ -31,7 +31,6 @@ static void chassis_set_pins(uint8_t pins, uint8_t state);
 void chassis_init()
 {
        chassis_set_pins((1<<POWER_PIN) | (1<<RESET_PIN), 0);
-       CDDR |= ((1<<POWER_PIN) | (1<<RESET_PIN));
 
        /* About 1ms */
        OCR0 = ((F_CPU/64)/1000) - 1;
@@ -41,16 +40,27 @@ void chassis_init()
 
 }
 
+/* gracefully transition between tri-state and active */
 static void chassis_set_pins(uint8_t pins, uint8_t state)
 {
-#ifdef ACTIVE_LOW
-       state = !state;
-#endif
-
        if(state) {
+               /* active */
+#ifndef ACTIVE_LOW
+               /* Pull UPs for a short moment... */
                CPORT |= pins;
+#endif
+               CDDR |= pins;
+#ifdef ACTIVE_LOW
+               CPORT &= ~pins;
+#endif
        } else {
+#ifdef ACTIVE_LOW
+               CPORT &= ~pins; /* NoOp... */
+#endif
+               CDDR &= ~pins;
+#ifndef ACTIVE_LOW
                CPORT &= ~pins;
+#endif
        }
 }
 
Impressum, Datenschutz