trennfix/sw: Makefile: Move objects etc into build folder
[eisenbahn.git] / trennfix / sw / config / trennfix_0.4.h
index b0c78157b65925bd4a105e93a68f50cf2be3223c..ffa98a9dd3b8e67caf03ee13005251987636f72b 100644 (file)
@@ -12,7 +12,7 @@
 
 #define STOP_TIMER1 ({TCCR1 = 0; TCNT1 = 1;})
 
-#define PWM_CYCLE 21
+#define PWM_CYCLE 14
 
 static inline void setup_hw(void)
 {
@@ -20,13 +20,15 @@ static inline void setup_hw(void)
        CLKPR = (1 << CLKPCE);
        CLKPR = 0;
 
+       setpin(PIN_LED, 0);
+       setpin(PIN_TRIGGER, 0);
+       setpin(PIN_BTN, 1);   /* Need pullup              */
        INPUT_PIN(PIN_SENSE);
        INPUT_PIN(PIN_BTN);
        OUTPUT_PIN(PIN_DRIVE);
        OUTPUT_PIN(PIN_LED);
        OUTPUT_PIN(PIN_TRIGGER);
-       setpin(PIN_BTN, 1);   /* Need pullup              */
-       
+
        GIMSK |= _BV(PCIE);     /* Enable pin change interrupt for sense port */
        PCMSK |= _BV(PCINT4);    /* PB4, Rail sense input */
 
@@ -36,10 +38,11 @@ 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;
 
-#ifdef WITH_PWM        
+       TIMSK |= _BV(TOIE0);
+       TCCR0B = 2;
+
+#ifdef WITH_PWM
        /* Timer 1 as PWM */
        OCR1C = PWM_CYCLE;
        OCR1B = PWM_CYCLE;
@@ -62,7 +65,6 @@ static inline void __attribute__((unused)) trigger(void)
        setpin(PIN_TRIGGER, 0);
 }
 
-
 static inline void __attribute__((unused)) trigger_on(void)
 {
        setpin(PIN_TRIGGER, 1);
@@ -76,19 +78,23 @@ 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_SENSE (PINVAL(PIN_SENSE))
+#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)
+//#define MM_USE_QUEUE
+#define MM_QUEUE_DEPTH 8
+#define MM_USE_CALLBACK
 
 #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