X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fcoinmech.c;h=d3b099205741042e7a6e9a914bc6ad7dc0f2ce87;hb=b3523cf99eff476642609ad6537e460595f84e72;hp=e24fe621af9aef10a3c7e328778f5d518a7cd7fa;hpb=2b2e02c163f430f0745e5d7ed081fb7c65f85fc3;p=uccvend-snackrom.git diff --git a/ROM2/coinmech.c b/ROM2/coinmech.c index e24fe62..d3b0992 100644 --- a/ROM2/coinmech.c +++ b/ROM2/coinmech.c @@ -4,14 +4,14 @@ #define COINMECH_ID 0x20 volatile u8 last_byte; -volatile u8 packet_pos = 0; -volatile u16 value_1 = 0; -volatile u8 value_2 = 0; -volatile u8 dec_point = 0; +volatile u8 packet_pos; +volatile u16 value_1; +volatile u8 value_2; +volatile u8 dec_point; -volatile u16 coin_value = 0; -u8 item_cost = 0; -volatile bool have_change = 0; +volatile u16 coin_value; +u8 item_cost; +volatile bool have_change; u8 parity_test(u8 c) { u8 parity = 0; @@ -130,3 +130,16 @@ void coin_cost(u16 cost) { item_cost = cost; while(coin_value); /* wait until coin mech cleared */ } + +void coinmech_init() { + packet_pos = 0; + value_1 = value_2 = 0; + dec_point = 0; + coin_value = 0; + item_cost = 0; + have_change = 0; + _io_ports[M6811_SCCR1] = 0x10; + _io_ports[M6811_SCCR2] = 0x2e; + _io_ports[M6811_BAUD] = 0x03; + send_byte(0xff); +}