//! This function reads the SETUP request sent to the default control endpoint //! and calls the appropriate function. When exiting of the usb_read_request //! function, the device is ready to manage the next request. //! //! If the received request is not supported or a non-standard USB request, the function //! will call the custom decoding function in usb_specific_request module. //! //! @note List of supported requests: //! GET_DESCRIPTOR //! GET_CONFIGURATION //! SET_ADDRESS //! SET_CONFIGURATION //! CLEAR_FEATURE //! SET_FEATURE //! GET_STATUS //! void usb_process_request(void) { U8 bmRequest; Usb_reset_endpoint_fifo_access(EP_CONTROL); bmRequestType = Usb_read_endpoint_data(EP_CONTROL, 8); bmRequest = Usb_read_endpoint_data(EP_CONTROL, 8); switch (bmRequest) { case GET_DESCRIPTOR: if (bmRequestType == 0x80) usb_get_descriptor(); else { asm volatile ("breakpoint"); goto unsupported_request; } break; case GET_CONFIGURATION: if (bmRequestType == 0x80) usb_get_configuration(); else { asm volatile ("breakpoint"); goto unsupported_request; } break; case SET_ADDRESS: if (bmRequestType == 0x00) usb_set_address(); else { asm volatile ("breakpoint"); goto unsupported_request; } break; case SET_CONFIGURATION: if (bmRequestType == 0x00) usb_set_configuration(); else { asm volatile ("breakpoint"); goto unsupported_request; } break; case CLEAR_FEATURE: /*if (bmRequestType <= 0x02)*/ usb_clear_feature(); //else { asm volatile ("breakpoint"); goto unsupported_request; } break; case SET_FEATURE: if (bmRequestType <= 0x02) usb_set_feature(); else { asm volatile ("breakpoint"); goto unsupported_request; } break; case GET_STATUS: if (0x7F < bmRequestType && bmRequestType <= 0x82) usb_get_status(); else { asm volatile ("breakpoint"); goto unsupported_request; } break; case GET_INTERFACE: if (bmRequestType == 0x81) usb_get_interface(); else { asm volatile ("breakpoint"); goto unsupported_request; } break; case SET_INTERFACE: if (bmRequestType == 0x01) usb_set_interface(); else { asm volatile ("breakpoint"); goto unsupported_request; } break; case SET_DESCRIPTOR: case SYNCH_FRAME: default: //!< unsupported request => call to user read request unsupported_request: if (!usb_user_read_request(bmRequestType, bmRequest)) { Usb_enable_stall_handshake(EP_CONTROL); Usb_ack_setup_received_free(); } break; } }