Fix for error where USB host could send NAK, but isn't considered in jackdaw, resulting in jackdaw hanging

This commit is contained in:
c_oflynn 2010-01-24 13:01:58 +00:00
parent 123c612614
commit 15ffaeed86
2 changed files with 25 additions and 14 deletions

View file

@ -210,23 +210,32 @@ uint8_t send_encapsulated_command(uint16_t wLength)
uint8_t nb_counter;
//Clear NAK bit
Usb_ack_nak_in();
while (wLength) {
nb_counter = EP_CONTROL_LENGTH;
while (wLength) {
nb_counter = EP_CONTROL_LENGTH;
//Wait for data to come in
while (!(Is_usb_receive_out()));
while(nb_counter && wLength) {
encapsulated_buffer[i] = Usb_read_byte();
i++;
wLength--;
nb_counter--;
}
Usb_ack_receive_out();
//Wait for data to come in or nak
while((!Is_usb_receive_out()) & (!Is_usb_receive_nak_in()));
}
//Received OUT
if (Is_usb_receive_out()) {
while(nb_counter && wLength) {
encapsulated_buffer[i] = Usb_read_byte();
i++;
wLength--;
nb_counter--;
}
Usb_ack_receive_out();
//Received NAK, no more data
} else {
Usb_ack_nak_in();
break;
}
}
Usb_send_control_in();