Fix for error where USB host could send NAK, but isn't considered in jackdaw, resulting in jackdaw hanging
This commit is contained in:
parent
123c612614
commit
15ffaeed86
2 changed files with 25 additions and 14 deletions
|
@ -210,23 +210,32 @@ uint8_t send_encapsulated_command(uint16_t wLength)
|
||||||
|
|
||||||
uint8_t nb_counter;
|
uint8_t nb_counter;
|
||||||
|
|
||||||
|
//Clear NAK bit
|
||||||
|
Usb_ack_nak_in();
|
||||||
|
|
||||||
while (wLength) {
|
while (wLength) {
|
||||||
nb_counter = EP_CONTROL_LENGTH;
|
nb_counter = EP_CONTROL_LENGTH;
|
||||||
|
|
||||||
//Wait for data to come in
|
//Wait for data to come in or nak
|
||||||
while (!(Is_usb_receive_out()));
|
while((!Is_usb_receive_out()) & (!Is_usb_receive_nak_in()));
|
||||||
|
|
||||||
while(nb_counter && wLength) {
|
//Received OUT
|
||||||
encapsulated_buffer[i] = Usb_read_byte();
|
if (Is_usb_receive_out()) {
|
||||||
i++;
|
while(nb_counter && wLength) {
|
||||||
wLength--;
|
encapsulated_buffer[i] = Usb_read_byte();
|
||||||
nb_counter--;
|
i++;
|
||||||
}
|
wLength--;
|
||||||
|
nb_counter--;
|
||||||
|
}
|
||||||
|
|
||||||
Usb_ack_receive_out();
|
Usb_ack_receive_out();
|
||||||
|
|
||||||
}
|
//Received NAK, no more data
|
||||||
|
} else {
|
||||||
|
Usb_ack_nak_in();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Usb_send_control_in();
|
Usb_send_control_in();
|
||||||
|
|
||||||
|
|
|
@ -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))
|
#define Usb_ack_nak_out() (UEINTX &= ~(1<<NAKOUTI))
|
||||||
//! acks receive SETUP
|
//! acks receive SETUP
|
||||||
#define Usb_ack_receive_setup() (UEINTX &= ~(1<<RXSTPI))
|
#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
|
//! acks reveive OUT
|
||||||
#define Usb_ack_receive_out() (UEINTX &= ~(1<<RXOUTI), Usb_ack_fifocon())
|
#define Usb_ack_receive_out() (UEINTX &= ~(1<<RXOUTI), Usb_ack_fifocon())
|
||||||
//! acks STALL sent
|
//! acks STALL sent
|
||||||
|
|
Loading…
Reference in a new issue