More changes
[uccvend-snackrom.git] / ROM2 / vend.h
1 #ifndef _VEND_H_
2 #define _VEND_H_
3
4 #include "ports.h"
5 #include "types.h"
6 #include "asm.h"
7
8 /* addresses of these set at link time
9  * to add more addresses, define them here with buffered_addr_h, in helpers.c 
10  * with buffered_addr, and also in LDFLAGS in the Makefile
11  */
12 #define buffered_addr(a) \
13         extern volatile u8* _##a;          \
14         u8 a; \
15         extern inline void set_##a(u8 b) { a = *_##a = b; } \
16         extern inline void bset_##a(const u8 m) { bset(&a, m); *_##a = a; } \
17         extern inline void bclr_##a(const u8 m) { bclr(&a, m); *_##a = a; }
18
19 buffered_addr(changer_output);
20 buffered_addr(misc_output);
21
22 extern volatile u8 _switch_input;
23 #define switch_input _switch_input
24 extern volatile u8 _misc_input;
25 #define misc_input _misc_input
26 extern volatile u8 _home_sensors;
27 #define home_sensors _home_sensors
28
29 /******* from helpers.c *******/
30 void delay(u16 ms);
31 void print_amount(u16 amt);
32
33 /******** Some meaningful bits ******/
34 #define PORTA_DISP_RESET    0x80 /* active low */
35 #define PORTA_CHIME         0x10 /* chime is on when set */
36 #define PORTD_KEYPAD_ROW    0x20 /* clear for row 0, set for row 1 */
37
38 /* Address 1800 bits */
39 #define A1800_DOOR_OPEN     0x20
40
41 /* Address 3800 bits */
42 #define A3800_DISPLAY_WRITE  0x04
43
44 /******* from main.c *******/
45 int __attribute__((noreturn)) main (void);
46 void __attribute__((interrupt)) rti (void);
47
48 /* other one liners */
49 extern inline bool door_open() { return switch_input & A1800_DOOR_OPEN; }
50 extern inline void spi_enable()  { bset((void*)&_io_ports[M6811_SPCR], M6811_SPE); }
51 extern inline void spi_disable() { bclr((void*)&_io_ports[M6811_SPCR], M6811_SPE); }
52
53 #endif /* _VEND_H_ */

UCC git Repository :: git.ucc.asn.au