File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -342,6 +342,17 @@ volatile transceiver_request_t transceiver_request = {
342342 .seq = 0 ,
343343};
344344
345+ void transceiver_usb_setup_complete (usb_endpoint_t * const endpoint )
346+ {
347+ if (transceiver_request .mode == TRANSCEIVER_MODE_TX &&
348+ endpoint -> setup .request == 1 ) {
349+ // This is a request to leave TX mode. Do so but NAK for now.
350+ request_transceiver_mode (endpoint -> setup .value );
351+ } else {
352+ usb_setup_complete (endpoint );
353+ }
354+ }
355+
345356// Must be called from an atomic context (normally USB ISR)
346357void request_transceiver_mode (transceiver_mode_t mode )
347358{
@@ -675,6 +686,9 @@ void tx_mode(uint32_t seq)
675686 ;
676687
677688 // All data received from the host has now been transmitted.
689+ // Now we can ACK the control request that took us out of TX mode.
690+ usb_transfer_schedule_ack (usb_endpoint_control_in .in );
691+
678692 transceiver_shutdown ();
679693}
680694
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ typedef struct {
3535
3636extern volatile transceiver_request_t transceiver_request ;
3737
38+ void transceiver_usb_setup_complete (usb_endpoint_t * const endpoint );
39+
3840void set_hw_sync_mode (const hw_sync_mode_t new_hw_sync_mode );
3941usb_request_status_t usb_vendor_request_set_transceiver_mode (
4042 usb_endpoint_t * const endpoint ,
Original file line number Diff line number Diff line change 2626#include <usb_request.h>
2727
2828#include "usb_device.h"
29+ #include "usb_api_transceiver.h"
2930
3031usb_endpoint_t usb_endpoint_control_out = {
3132 .address = 0x00 ,
3233 .device = & usb_device ,
3334 .in = & usb_endpoint_control_in ,
3435 .out = & usb_endpoint_control_out ,
35- .setup_complete = usb_setup_complete ,
36+ .setup_complete = transceiver_usb_setup_complete ,
3637 .transfer_complete = usb_control_out_complete ,
3738};
3839USB_DEFINE_QUEUE (usb_endpoint_control_out , 4 );
You can’t perform that action at this time.
0 commit comments