trennfix/sw: Fixed a bit beauty.
[eisenbahn.git] / trennfix / sw / mm / include / mm / mm_switch.h
CommitLineData
70095677
PH
1#ifndef MM_SWITCH_H
2#define MM_SWITCH_H
3
4#include <stdint.h>
d0047978 5#include <config/hardware.h>
70095677 6
27b551dd
PH
7#define MM_FLAVOR_DRIVE 0
8#define MM_FLAVOR_SWITCH 1
7c08d02a
PH
9
10#ifdef MM_USE_REGISTER_VARS
11
12uint8_t register shift_command asm("r2");
13uint8_t register shift_function asm("r3");
14uint8_t register shift_address asm("r4");
27b551dd
PH
15uint8_t register mm_polarity asm("r5");
16uint8_t register mm_bitno asm("r6");
17uint8_t register mm_last_was_short asm("r8");
18uint8_t register mm_time_h asm("r9");
19uint8_t register mm_time_l asm("r10");
20uint8_t register mm_bit_val asm("r11");
21uint8_t register mm_flavor asm("r14");
7c08d02a
PH
22
23static void inline __attribute((unused)) mm_init(void)
24{
27b551dd
PH
25 mm_bitno = 0;
26 mm_time_h = 0;
27 mm_bit_val = 23;
28 mm_polarity = 1;
29 mm_last_was_short = 0;
7c08d02a
PH
30}
31
32#else
33
34#define mm_init(...)
35
36#endif
37
b1a7e65e
PH
38
39
70095677
PH
40/*
41 * mm_switch_command - Callback function!
42 *
43 * This function must be defined whenever the mm_switch module is used.
44 * It will be called from interrupt context whenever a new valid command
45 * has arrived.
46 *
47 * decoder is in the range from 1 to 25. Other values will not occur.
48 *
49 * key is in the range from 0 to 8:
50 *
51 * 1 - key1 green pressed
52 * 2 - key1 red pressed
53 * 3 - key2 green pressed
54 * 4 - key2 red pressed
55 * ...
56 * 0 - all keys up
57 *
58 */
59void mm_switch_command(uint8_t decoder, uint8_t key);
60
56b25f8b
PH
61/*
62 * empty comment :-)
63 */
64void mm_switch_drive_cb(uint8_t address, uint8_t speed, uint8_t functions, uint8_t flags);
65
66void mm_switch_drive(uint8_t decoder, uint8_t function, uint8_t command);
67
d0047978 68void mm_switch_pinchange_callback(void);
70095677 69
70095677 70#endif