trennfix/sw: Register variables, restructuring, whatever
[eisenbahn.git] / trennfix / sw / mm / include / mm / mm_switch.h
index fb36036b8826d6adc20cce591dafdf72d3c850e8..94655a903d1830384a3107e8f9d616b07940f2aa 100644 (file)
@@ -3,6 +3,36 @@
 
 #include <stdint.h>
 
+enum mm_recstate {
+       MM_IDLE = 0,
+       MM_FIRST_FAST_SAMPLE,
+       MM_FIRST_SLOW_SAMPLE, /* If clock arrives, we stay on the fast path! */
+       MM_FAST_SAMPLE,
+       MM_FAST_WAIT_FOR_CLOCK,
+       MM_SLOW_SAMPLE,
+       MM_SLOW_WAIT_FOR_CLOCK,
+};
+
+#ifdef MM_USE_REGISTER_VARS
+
+uint8_t register shift_command  asm("r2");
+uint8_t register shift_function asm("r3");
+uint8_t register shift_address asm("r4");
+uint8_t  register recstate asm("r5");
+uint8_t register bitno asm("r6");
+
+static void inline __attribute((unused)) mm_init(void)
+{
+       bitno = 0;
+       recstate = MM_IDLE;
+}
+
+#else
+
+#define mm_init(...)
+
+#endif
+
 /*
  * mm_switch_command - Callback function!
  *
@@ -33,6 +63,5 @@ void mm_switch_drive(uint8_t decoder, uint8_t function, uint8_t command);
 
 void mm_pinchange_handler(void);
 
-void mm_init(void);
 
 #endif