void usb_configuration_changed( usb_device_t* const device ) { /* Reset transceiver to idle state until other commands are received */ set_transceiver_mode(TRANSCEIVER_MODE_OFF); if( device->configuration->number == 1 ) { // transceiver configuration led_on(LED1); } else { /* Configuration number equal 0 means usb bus reset. */ led_off(LED1); } }
usb_request_status_t usb_vendor_request_set_transceiver_mode( usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage ) { if( stage == USB_TRANSFER_STAGE_SETUP ) { switch( endpoint->setup.value ) { case TRANSCEIVER_MODE_OFF: case TRANSCEIVER_MODE_RX: case TRANSCEIVER_MODE_TX: set_transceiver_mode(endpoint->setup.value); usb_endpoint_schedule_ack(endpoint->in); return USB_REQUEST_STATUS_OK; default: return USB_REQUEST_STATUS_STALL; } } else { return USB_REQUEST_STATUS_OK; } }