int usba10_usb_clear_feature( dev_info_t *dip, usb_pipe_handle_t ph, uint_t type, /* bmRequestType */ uint_t feature, uint_t what, /* 0, interface, endpoint number */ usb_flags_t flags) { return (usb_clear_feature(dip, ph, type, feature, what, flags)); }
//! 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 bRequest; Usb_reset_endpoint_fifo_access(EP_CONTROL); bmRequestType = Usb_read_endpoint_data(EP_CONTROL, 8); bRequest = Usb_read_endpoint_data(EP_CONTROL, 8); switch (bRequest) { case GET_DESCRIPTOR: if (bmRequestType == 0x80) usb_get_descriptor(); else goto unsupported_request; break; case GET_CONFIGURATION: if (bmRequestType == 0x80) usb_get_configuration(); else goto unsupported_request; break; case SET_ADDRESS: if (bmRequestType == 0x00) usb_set_address(); else goto unsupported_request; break; case SET_CONFIGURATION: if (bmRequestType == 0x00) usb_set_configuration(); else goto unsupported_request; break; case CLEAR_FEATURE: if (bmRequestType <= 0x02) usb_clear_feature(); else goto unsupported_request; break; case SET_FEATURE: if (bmRequestType <= 0x02) usb_set_feature(); else goto unsupported_request; break; case GET_STATUS: if (0x7F < bmRequestType && bmRequestType <= 0x82) usb_get_status(); else goto unsupported_request; break; case GET_INTERFACE: if (bmRequestType == 0x81) { if(!usb_get_interface()) { Usb_enable_stall_handshake(EP_CONTROL); Usb_ack_setup_received_free(); } } else goto unsupported_request; break; case SET_INTERFACE: if (bmRequestType == 0x01) usb_set_interface(); else 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, bRequest)) { Usb_enable_stall_handshake(EP_CONTROL); Usb_ack_setup_received_free(); } break; } }
//! usb_process_request. //! //! @brief 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. //! //! @param none //! //! @return none //! @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; bmRequestType = Usb_read_byte(); bmRequest = Usb_read_byte(); switch (bmRequest) { case GET_DESCRIPTOR: if (0x80 == bmRequestType) { usb_get_descriptor(); } else { usb_user_read_request(bmRequestType, bmRequest); } break; case GET_CONFIGURATION: if (0x80 == bmRequestType) { usb_get_configuration(); } else { usb_user_read_request(bmRequestType, bmRequest); } break; case SET_ADDRESS: if (0x00 == bmRequestType) { usb_set_address(); } else { usb_user_read_request(bmRequestType, bmRequest); } break; case SET_CONFIGURATION: if (0x00 == bmRequestType) { usb_set_configuration(); } else { usb_user_read_request(bmRequestType, bmRequest); } break; case CLEAR_FEATURE: if (0x02 >= bmRequestType) { usb_clear_feature(); } else { usb_user_read_request(bmRequestType, bmRequest); } break; case SET_FEATURE: if (0x02 >= bmRequestType) { usb_set_feature(); } else { usb_user_read_request(bmRequestType, bmRequest); } break; case GET_STATUS: if ((0x7F < bmRequestType) & (0x82 >= bmRequestType)) { usb_get_status(); } else { usb_user_read_request(bmRequestType, bmRequest); } break; case GET_INTERFACE: if (bmRequestType == 0x81) { usb_get_interface(); } else { usb_user_read_request(bmRequestType, bmRequest); } break; case SET_INTERFACE: if (bmRequestType == 0x01) {usb_set_interface();} break; case SET_DESCRIPTOR: case SYNCH_FRAME: default: //!< un-supported request => call to user read request if(usb_user_read_request(bmRequestType, bmRequest) == FALSE) { Usb_enable_stall_handshake(); Usb_ack_receive_setup(); return; } break; } }
//! usb_process_request. //! //! @brief 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. //! //! @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; bmRequestType = Usb_read_byte(); bmRequest = Usb_read_byte(); switch (bmRequest) { case GET_DESCRIPTOR: if (0x80 == bmRequestType) { usb_get_descriptor(); } else goto user_read; break; case GET_CONFIGURATION: if (0x80 == bmRequestType) { usb_get_configuration(); } else goto user_read; break; case SET_ADDRESS: if (0x00 == bmRequestType) { usb_set_address(); } else goto user_read; break; case SET_CONFIGURATION: if (0x00 == bmRequestType) { usb_set_configuration(); } else goto user_read; break; case CLEAR_FEATURE: if (0x02 >= bmRequestType) { usb_clear_feature(); } else goto user_read; break; case SET_FEATURE: if (0x02 >= bmRequestType) { usb_set_feature(); } else goto user_read; break; case GET_STATUS: if ((0x7F < bmRequestType) & (0x82 >= bmRequestType)) { usb_get_status(); } else goto user_read; break; case GET_INTERFACE: if (bmRequestType == 0x81) { usb_get_interface(); } else goto user_read; break; case SET_INTERFACE: if (bmRequestType == 0x01) {usb_set_interface();} break; case SET_DESCRIPTOR: case SYNCH_FRAME: default: //!< un-supported request => call to user read request user_read: usb_user_read_request(bmRequestType, bmRequest); break; } Usb_select_endpoint(EP_CONTROL); // If the receive setup flag hasn't been cleared // by this point then we can assume that we didn't // support this request and should stall. if(Is_usb_receive_setup()) Usb_enable_stall_handshake(); // Clear some flags. Usb_ack_receive_setup(); Usb_ack_receive_out(); Usb_ack_in_ready(); }
/* * Read the SETUP request sent to the default control endpoint * and call the appropriate function. When exiting this * function, the device is ready to manage the next request. * * Supported requests: * GET_DESCRIPTOR * GET_CONFIGURATION * SET_ADDRESS * SET_CONFIGURATION * CLEAR_FEATURE * SET_FEATURE * GET_STATUS */ void OSUsbDeviceImpl::standardProcessRequest(void) { unsigned char bmRequest; bmRequestType = OSUsbDeviceImpl::readByte(); bmRequest = OSUsbDeviceImpl::readByte(); #if defined(DEBUG) && defined(OS_DEBUG_OSUSBDEVICE_REQUEST) OSDeviceDebug::putString("type/req="); OSDeviceDebug::putHex(bmRequestType); OSDeviceDebug::putString("/"); OSDeviceDebug::putHex(bmRequest); OSDeviceDebug::putString(" "); //OSDeviceDebug::putNewLine(); #endif switch (bmRequest) { case GET_DESCRIPTOR: if (0x80 == bmRequestType) { OSUsbDeviceImpl::usb_get_descriptor(); return; } break; case GET_CONFIGURATION: if (0x80 == bmRequestType) { usb_get_configuration(); return; } break; case SET_ADDRESS: if (0x00 == bmRequestType) { usb_set_address(); return; } break; case SET_CONFIGURATION: if (0x00 == bmRequestType) { usb_set_configuration(); return; } break; case CLEAR_FEATURE: if (0x02 >= bmRequestType) { usb_clear_feature(); return; } break; case SET_FEATURE: if (0x02 >= bmRequestType) { usb_set_feature(); return; } break; case GET_STATUS: if ((0x7F < bmRequestType) & (0x82 >= bmRequestType)) { usb_get_status(); return; } break; case GET_INTERFACE: if (bmRequestType == 0x81) { usb_get_interface(); return; } break; case SET_INTERFACE: if (bmRequestType == 0x01) { usb_set_interface(); return; } break; case SET_DESCRIPTOR: case SYNCH_FRAME: default: break; } // for un-supported requests call the specific read request if (OSUsbDeviceImpl::specificProcessReadRequest(bmRequestType, bmRequest)) return; // if nothing worked, reply with stall OSUsbDeviceImpl::Usb_enable_stall_handshake(); OSUsbDeviceImpl::Usb_ack_receive_setup(); }
//! @brief 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. //! void usb_process_request(void) { U8 bmRequestType; U8 bmRequest; Usb_ack_control_out(); bmRequestType = Usb_read_byte(); bmRequest = Usb_read_byte(); switch (bmRequest) { case SETUP_GET_DESCRIPTOR: if (USB_SETUP_GET_STAND_DEVICE == bmRequestType) { if( usb_get_descriptor() ) return; } break; case SETUP_GET_CONFIGURATION: if (USB_SETUP_GET_STAND_DEVICE == bmRequestType) { usb_get_configuration(); return; } break; case SETUP_SET_ADDRESS: if (USB_SETUP_SET_STAND_DEVICE == bmRequestType) { usb_set_address(); return; } break; case SETUP_SET_CONFIGURATION: if (USB_SETUP_SET_STAND_DEVICE == bmRequestType) { if( usb_set_configuration() ) return; } break; case SETUP_CLEAR_FEATURE: if (usb_clear_feature(bmRequestType)) return; break; case SETUP_SET_FEATURE: if (usb_set_feature(bmRequestType)) return; break; case SETUP_GET_STATUS: if (usb_get_status(bmRequestType)) return; break; case SETUP_GET_INTERFACE: if (USB_SETUP_GET_STAND_INTERFACE == bmRequestType) { if( usb_get_interface() ) return; } break; case SETUP_SET_INTERFACE: if (bmRequestType == USB_SETUP_SET_STAND_INTERFACE) { if( usb_set_interface() ) return; } break; default: break; } // un-supported like standard request => call to user read request if( !usb_user_read_request(bmRequestType, bmRequest) ) { // Request unknow in the specific request list from interface // keep that order (set StallRq/clear RxSetup) or a // OUT request following the SETUP may be acknowledged Usb_enable_stall_handshake(); Usb_ack_receive_setup(); endpoint_status[(EP_CONTROL & MSK_EP_DIR)] = 0x01; } }