trennfix/sw: Temporary first working time measurement method
[eisenbahn.git] / trennfix / sw / config / trennfix_0.4.h
index b0c78157b65925bd4a105e93a68f50cf2be3223c..b3b6b254f6f495bfd4b4bb7975fd9dc7de309aa0 100644 (file)
@@ -25,6 +25,9 @@ static inline void setup_hw(void)
        OUTPUT_PIN(PIN_DRIVE);
        OUTPUT_PIN(PIN_LED);
        OUTPUT_PIN(PIN_TRIGGER);
+       setpin(PIN_LED, 0);
+       setpin(PIN_TRIGGER, 0);
+               
        setpin(PIN_BTN, 1);   /* Need pullup              */
        
        GIMSK |= _BV(PCIE);     /* Enable pin change interrupt for sense port */
@@ -36,8 +39,10 @@ static inline void setup_hw(void)
        /* Setup timer 0, used for mm_switch */
         TCCR0A = 0; /* Normal mode */
        TCCR0B = 2; /* Prescaler 8 */
-       TIMSK |= _BV(OCIE0A);   /* Get a match interrupt */
-       OCR0A = 100; TCCR0B = 2;
+       //      TIMSK |= _BV(OCIE0A);   /* Get a match interrupt */
+       TIMSK |= _BV(TOIE0);
+       OCR0A = 100; 
+       TCCR0B = 2;
 
 #ifdef WITH_PWM        
        /* Timer 1 as PWM */
@@ -77,18 +82,20 @@ static inline void __attribute__((unused)) trigger_off(void)
  * Configuration for mm receiver code.
  */
 #define MM_SENSE (!PINVAL(PIN_SENSE))
-#define MM_TIMER_INT_VECT TIMER0_COMPA_vect
+#define MM_TIMER_INT_VECT TIMER0_OVF_vect
 
 #define MM_TSTART {                                                    \
                GTCCR  |= _BV(TSM) | _BV(PSR0);                         \
                TCNT0   = 0;                                            \
-               TIFR   |= _BV(OCF0A);                                   \
                GTCCR  &= ~_BV(TSM);                                    \
        }
 
+#define MM_RESETFLAG  TIFR   |= _BV(OVF0)
+
 
 #ifdef USE_REGISTER_VARS
-uint8_t register drive_on asm("r8");
+uint8_t register drive_on asm("r12");
+uint8_t register slope asm("r13");
 #endif
 
 #endif