src/hp34comm.cpp

changeset 16
c5e5bdc5ef49
parent 15
ec327bf8f224
child 18
4fd621551d55
equal deleted inserted replaced
15:ec327bf8f224 16:c5e5bdc5ef49
89 tx_ack = true; 89 tx_ack = true;
90 #ifdef DEBUG2 90 #ifdef DEBUG2
91 ack = 1; 91 ack = 1;
92 wait_us(2); 92 wait_us(2);
93 ack = 0; 93 ack = 0;
94 wait_us(2);
95 ack = 1;
96 wait_us(2);
97 ack = 0;
98 #endif 94 #endif
99 } 95 }
100 else 96 else
101 reset(2); 97 reset(2);
102 } 98 }
123 tx_cmd = val; 119 tx_cmd = val;
124 tx_ack = false; 120 tx_ack = false;
125 tx_len = 0xFF; 121 tx_len = 0xFF;
126 } 122 }
127 else if (tx_len == 0xFF) { 123 else if (tx_len == 0xFF) {
128 // got a cmd, expect a payload size 124 if (val == 0x55) {
129 tx_len = val; 125 // packet was in fact a keystroke, tx_cmd is in fact the key
130 tx_ack = false; 126 // stroke and no payload is expected
127 #ifdef DEBUG2
128 statetx = 1;
129 #endif
130 pushCmd((TrState)Tx, tx_cmd, 0, (char*)buf);
131 #ifdef DEBUG2
132 wait_us(2);
133 statetx = 0;
134 #endif
135 reset();
136 } else {
137 // got a cmd, expect a payload size
138 tx_len = val;
139 tx_ack = false;
140 }
131 } 141 }
132 else if (tx_len == 0x55) { 142 else if (tx_len == 0x55) {
133 // packet was in fact a keystroke, tx_cmd is in fact the key 143 // packet was in fact a keystroke, tx_cmd is in fact the key
134 // stroke and no payload is expected 144 // stroke and no payload is expected
135 pushCmd((TrState)Tx, tx_cmd, 0, NULL); 145 #ifdef DEBUG2
146 statetx = 1;
147 #endif
148 pushCmd((TrState)Tx, tx_cmd, 0, (char*)buf);
149 #ifdef DEBUG2
150 wait_us(2);
151 statetx = 0;
152 #endif
136 reset(); 153 reset();
137 } 154 }
138 else if (tx_len > 0) { 155 else if (tx_len > 0) {
139 // a payload char 156 // a payload char
140 buf[head++] = val; 157 buf[head++] = val;

mercurial