From 45c42e3e9f2149e45f6642ac3fbab9010bc05455 Mon Sep 17 00:00:00 2001 From: Bernard Blackham Date: Wed, 6 Aug 2003 17:20:07 +0000 Subject: [PATCH] more progress --- ROM2/main.c | 26 +++++++++++++++++++++++--- ROM2/vend.h | 20 +++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/ROM2/main.c b/ROM2/main.c index c275801..ffeb9d2 100644 --- a/ROM2/main.c +++ b/ROM2/main.c @@ -58,6 +58,18 @@ void selection_menu() { set_msg("ENTER SELECTION OR INSERT COINS", WRAP_SCROLL); } +void load_default_msg() { + /* FIXME: want this message to be changeable from the server */ + set_msg("UNIVERSITY COMPUTER CLUB *** INSERT COINS OR USER-ID *** ", + WRAP_SCROLL); +} + +void service_menu() { + while (door_open()) { /* don't quit until door is closed */ + + } +} + int main() { /* do stuff */ set_msg("UNIVERSITY", WRAP_NONE); @@ -67,9 +79,7 @@ int main() { set_msg(" CLUB ", WRAP_NONE); delay(1000); - /* FIXME: want this message to be changeable from the server */ - set_msg("UNIVERISTY COMPUTER CLUB *** INSERT COINS OR USER-ID ***", - WRAP_SCROLL); + load_default_msg(); while(1) { /* this needs to be a relatively tight loop to make sure we catch * keypresses at the main menu @@ -82,6 +92,7 @@ int main() { switch (server_authenticate(uid, pin)) { case AUTH_GOOD: selection_menu(); + break; case AUTH_BAD: set_msg(" BAD USER ", WRAP_NONE); delay(1000); @@ -100,7 +111,16 @@ int main() { pin = 0; /* move on */ } + load_default_msg(); } + + /* test door switch */ + if (door_open()) { + service_menu(); + load_default_msg(); + } + + /* check on coin mech */ } } diff --git a/ROM2/vend.h b/ROM2/vend.h index 10d3171..a1ea2cc 100644 --- a/ROM2/vend.h +++ b/ROM2/vend.h @@ -16,14 +16,15 @@ extern inline void bset_##a(const u8 m) { bset(&a, m); *_##a = a; } \ extern inline void bclr_##a(const u8 m) { bclr(&a, m); *_##a = a; } -buffered_addr(switch_input); -buffered_addr(misc_input); -buffered_addr(home_sensors); buffered_addr(changer_output); buffered_addr(misc_output); -extern inline void spi_enable() { bset((void*)&_io_ports[M6811_SPCR], M6811_SPE); } -extern inline void spi_disable() { bclr((void*)&_io_ports[M6811_SPCR], M6811_SPE); } +extern volatile u8 _switch_input; +#define switch_input _switch_input +extern volatile u8 _misc_input; +#define misc_input _misc_input +extern volatile u8 _home_sensors; +#define home_sensors _home_sensors /******* from helpers.c *******/ void delay(u16 ms); @@ -33,6 +34,9 @@ void delay(u16 ms); #define PORTA_CHIME 0x10 /* chime is on when set */ #define PORTD_KEYPAD_ROW 0x20 /* clear for row 0, set for row 1 */ +/* Address 1800 bits */ +#define A1800_DOOR_OPEN 0x20 + /* Address 3800 bits */ #define A3800_DISPLAY_WRITE 0x04 @@ -40,4 +44,10 @@ void delay(u16 ms); int __attribute__((noreturn)) main (void); void __attribute__((interrupt)) rti (void); +/* other one liners */ + +extern inline bool door_open() { return switch_input & A1800_DOOR_OPEN; } +extern inline void spi_enable() { bset((void*)&_io_ports[M6811_SPCR], M6811_SPE); } +extern inline void spi_disable() { bclr((void*)&_io_ports[M6811_SPCR], M6811_SPE); } + #endif /* _VEND_H_ */ -- 2.20.1