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;
}
+/* 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
}
}