//! usb_set_configuration. //! //! This function manages the SET CONFIGURATION request. If the selected //! configuration is valid, this function call the usb_user_endpoint_init() //! function that will configure the endpoints following the configuration //! number. //! //! @warning Code:xx bytes (function code length) //! //! @param none //! //! @return none //! void usb_set_configuration( void ) { U8 configuration_number; configuration_number = Usb_read_byte(); if (configuration_number <= NB_CONFIGURATION) { Usb_ack_receive_setup(); usb_configuration_nb = configuration_number; } else { //!< 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(); return; } Usb_send_control_in(); //!< send a ZLP for STATUS phase usb_user_endpoint_init(usb_configuration_nb); //!< endpoint configuration Usb_set_configuration_action(); }
//! usb_set_configuration. //! //! This function manages the SET CONFIGURATION request. If the selected //! configuration is valid, this function call the usb_user_endpoint_init() //! function that will configure the endpoints following the configuration //! number. //! //! @warning Code:xx bytes (function code length) //! void usb_set_configuration( void ) { U8 configuration_number; configuration_number = Usb_read_byte(); // TODO: Verify configuration_number! Usb_ack_receive_setup(); usb_configuration_nb = configuration_number; Usb_send_control_in(); //!< send a ZLP for STATUS phase while(!Is_usb_in_ready()); usb_user_endpoint_init(usb_configuration_nb); //!< endpoint configuration Usb_set_configuration_action(); }
//! This function manages the SET CONFIGURATION request. If the selected //! configuration is valid, this function call the usb_user_endpoint_init() //! function that will configure the endpoints following the configuration //! number. //! Bool usb_set_configuration( void ) { U8 configuration_number; // Get/Check new configuration configuration_number = Usb_read_byte(); if (configuration_number > NB_CONFIGURATION) return FALSE; // Bad configuration number then stall request Usb_ack_receive_setup(); usb_configuration_nb = configuration_number; Usb_send_control_in(); // send a ZLP for STATUS phase usb_user_endpoint_init(usb_configuration_nb); // endpoint configuration Usb_set_configuration_action(); return TRUE; }
//! This function manages the SET CONFIGURATION request. If the selected //! configuration is valid, this function call the usb_user_endpoint_init() //! function that will configure the endpoints following the configuration //! number. //! void usb_set_configuration(void) { U8 configuration_number = Usb_read_endpoint_data(EP_CONTROL, 8); U8 u8_i; if (configuration_number <= NB_CONFIGURATION) { Usb_ack_setup_received_free(); usb_configuration_nb = configuration_number; for( u8_i=0; u8_i<NB_INTERFACE; u8_i++) usb_interface_status[u8_i]=0; usb_user_endpoint_init(usb_configuration_nb); //!< endpoint configuration Usb_set_configuration_action(); Usb_ack_control_in_ready_send(); //!< send a ZLP for STATUS phase } else { //!< keep that order (set StallRq/clear RxSetup) or a //!< OUT request following the SETUP may be acknowledged Usb_enable_stall_handshake(EP_CONTROL); Usb_ack_setup_received_free(); } }