]> git.zerfleddert.de Git - rsbs2/blobdiff - bmc/chassis.c
firmware: fix firmware extraction
[rsbs2] / 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