Project

General

Profile

Revision 276

Added by Kevin Woo almost 14 years ago

Optimizations to the card reader

View differences:

trunk/cardbox/cardreader.c
62 62

  
63 63
    // Look for the start sentinal
64 64
    while (start_sentinal == 0) {
65
        byte = (((byte >> 1) & 0x1F) | (cr_buf[i]));
65
        byte = (((byte >> 1) & 0x1F) | (cr_buf[i] << 5));
66 66
        
67 67
        if (cr_dict[byte] == CR_SS) {
68 68
            start_sentinal = 1;
......
109 109
            
110 110
        // Data bits
111 111
        } else {
112
            byte = (((byte >> 1) & 0x1F) | (cr_buf[i]));
112
            byte = (((byte >> 1) & 0x1F) | (cr_buf[i] << 5));
113 113
            byte_idx++;
114
            parity += (cr_buf[i]) ? 0 : 1;
114
            parity += cr_buf[i];
115 115
        }
116 116

  
117 117
        // Goto next bit in cr_buf
......
144 144
    // Read data in on the downtick of the clock
145 145
    if (!(PIND & CR_CLK)) {
146 146
        // Read data from card reader and flip since ours inverts
147
        cr_buf[cr_buf_idx] = (PIND & CR_DATA) ? 0 : 0x20;
147
        cr_buf[cr_buf_idx] = !(PIND & CR_DATA);
148 148
        cr_buf_idx++;
149 149
    }
150 150
}

Also available in: Unified diff