trennfix/sw: Added smokefix, further modularized the mm decoder
[eisenbahn.git] / trennfix / sw / mm / include / mm / mm_switch.h
index 240bea9b886a21f71d79077c27f1eac6cf5e6825..fb6cccac063ce33a22a3af765448b53279cc69b9 100644 (file)
@@ -33,17 +33,17 @@ static void inline __attribute((unused)) mm_init(void)
 
 #endif
 
-
+#ifdef MM_USE_CALLBACK
 
 /*
- * mm_switch_command - Callback function!
+ * mm_key_cb - Callback function!
  *
  * This function must be defined whenever the mm_switch module is used.
  * It will be called from interrupt context whenever a new valid command
  * has arrived.
  *
  * decoder is in the range from 1 to 25. Other values will not occur.
- * 
+ *
  * key is in the range from 0 to 8:
  *
  *   1 - key1 green pressed
@@ -52,17 +52,33 @@ static void inline __attribute((unused)) mm_init(void)
  *   4 - key2 red pressed
  *   ...
  *   0 - all keys up
- * 
+ *
  */
-void mm_switch_command(uint8_t decoder, uint8_t key);
+void mm_key_cb(uint8_t decoder, uint8_t function, uint8_t key);
+void mm_drive_cb(uint8_t decoder, uint8_t function, uint8_t command);
 
-/*
- *  empty comment :-)
- */
-void mm_switch_drive_cb(uint8_t address, uint8_t speed, uint8_t functions, uint8_t flags);
+#endif
+
+void mm_pinchange_callback(void);
+
+enum mm_recmode {
+       __MM_INIT,
+       __MM_ARMED,
+       MM_SLOW,
+       MM_FAST,
+};
+
+#ifdef MM_USE_QUEUE
+
+struct mm_command {
+       enum mm_recmode recmode; /* Only MM_FAST or MM_SLOW!       */
+       uint8_t address;         /* Undecoded loco/decoder address */
+       uint8_t function;        /* The two function bits          */
+       uint8_t command;         /* Button/Speed/Functions         */
+};
 
-void mm_switch_drive(uint8_t decoder, uint8_t function, uint8_t command);
+struct mm_command *mm_get(void);
 
-void mm_switch_pinchange_callback(void);
+#endif /* MM_USE_QUEUE */
 
 #endif