3 #define COINMECH_ID 0x20
10 for (parity = 0; c; c = c>>1) {
11 if (c&1) parity = !parity;
17 * parity_good truth table:
26 bool parity_good(u8 c) {
27 u8 R8 = (_io_ports[M6811_SCCR1] & M6811_R8)?1:0;
28 u8 p = parity_test(c)?1:0;
32 void send_byte(u8 c) {
34 while (!(_io_ports[M6811_SCSR] & M6811_TDRE)); /* wait for TD register empty */
37 bset(&_io_ports[M6811_SCCR1], M6811_T8);
39 bclr(&_io_ports[M6811_SCCR1], M6811_T8);
42 void ask_for_retrans() {
43 /* sends an 0xff down the line */
50 #define IS_CTRL(x) (x & 0x10) /* true if this packet is a control packet */
51 void sci_interrupt() {
53 in = _io_ports[M6811_SCDR];
55 /* test for framing errors & parity bit */
56 if (_io_ports[M6811_SCSR] & M6811_FE || !parity_good(in)) {
57 _io_ports[M6811_SCDR]; /* read of register req'd to clear FE */
62 /* all bytes must have the correct ID in the 3 MSBs */
63 if (in & 0xe0 != COINMECH_ID) return;
65 /* we have a good packet */
67 /* retransmit was requested */
72 if (packet_pos != 0 && !IS_CTRL(x&0x10)) {