Commit | Line | Data |
---|---|---|
70095677 PH |
1 | #ifndef MM_SWITCH_H |
2 | #define MM_SWITCH_H | |
3 | ||
4 | #include <stdint.h> | |
5 | ||
7c08d02a PH |
6 | enum mm_recstate { |
7 | MM_IDLE = 0, | |
8 | MM_FIRST_FAST_SAMPLE, | |
9 | MM_FIRST_SLOW_SAMPLE, /* If clock arrives, we stay on the fast path! */ | |
10 | MM_FAST_SAMPLE, | |
11 | MM_FAST_WAIT_FOR_CLOCK, | |
9c77e706 | 12 | MM_SLOW_SAMPLE_DELAY, |
7c08d02a | 13 | MM_SLOW_SAMPLE, |
9c77e706 | 14 | MM_SLOW_WAIT_FOR_CLOCK_DELAY, |
7c08d02a PH |
15 | MM_SLOW_WAIT_FOR_CLOCK, |
16 | }; | |
17 | ||
18 | #ifdef MM_USE_REGISTER_VARS | |
19 | ||
20 | uint8_t register shift_command asm("r2"); | |
21 | uint8_t register shift_function asm("r3"); | |
22 | uint8_t register shift_address asm("r4"); | |
23 | uint8_t register recstate asm("r5"); | |
24 | uint8_t register bitno asm("r6"); | |
25 | ||
26 | static void inline __attribute((unused)) mm_init(void) | |
27 | { | |
28 | bitno = 0; | |
29 | recstate = MM_IDLE; | |
30 | } | |
31 | ||
32 | #else | |
33 | ||
34 | #define mm_init(...) | |
35 | ||
36 | #endif | |
37 | ||
70095677 PH |
38 | /* |
39 | * mm_switch_command - Callback function! | |
40 | * | |
41 | * This function must be defined whenever the mm_switch module is used. | |
42 | * It will be called from interrupt context whenever a new valid command | |
43 | * has arrived. | |
44 | * | |
45 | * decoder is in the range from 1 to 25. Other values will not occur. | |
46 | * | |
47 | * key is in the range from 0 to 8: | |
48 | * | |
49 | * 1 - key1 green pressed | |
50 | * 2 - key1 red pressed | |
51 | * 3 - key2 green pressed | |
52 | * 4 - key2 red pressed | |
53 | * ... | |
54 | * 0 - all keys up | |
55 | * | |
56 | */ | |
57 | void mm_switch_command(uint8_t decoder, uint8_t key); | |
58 | ||
56b25f8b PH |
59 | /* |
60 | * empty comment :-) | |
61 | */ | |
62 | void mm_switch_drive_cb(uint8_t address, uint8_t speed, uint8_t functions, uint8_t flags); | |
63 | ||
64 | void mm_switch_drive(uint8_t decoder, uint8_t function, uint8_t command); | |
65 | ||
70095677 PH |
66 | void mm_pinchange_handler(void); |
67 | ||
70095677 | 68 | |
70095677 | 69 | #endif |