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();

View File

@ -530,6 +530,8 @@ typedef enum endpoint_parameter{ep_num, ep_type, ep_direction, ep_size, ep_bank,
#define Usb_ack_nak_out() (UEINTX &= ~(1<<NAKOUTI))
//! acks receive SETUP
#define Usb_ack_receive_setup() (UEINTX &= ~(1<<RXSTPI))
//! tests if NAK IN received
#define Is_usb_receive_nak_in() (UEINTX &(1<<NAKINI))
//! acks reveive OUT
#define Usb_ack_receive_out() (UEINTX &= ~(1<<RXOUTI), Usb_ack_fifocon())
//! acks STALL sent