/** * @file request_fifo.h * @brief Read and Write Request FiFo values. * @note * * ------------------------------------------------------------------ Copyright (c) 2023 by Lattice Semiconductor Corporation ALL RIGHTS RESERVED ------------------------------------------------------------------ DISCLAIMER: LATTICE MAKES NO WARRANTIES ON THIS FILE OR ITS CONTENTS, WHETHER EXPRESSED, IMPLIED, STATUTORY, OR IN ANY PROVISION OF THE LATTICE PROPEL LICENSE AGREEMENT OR COMMUNICATION WITH LICENSEE, AND LATTICE SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. LATTICE DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED HEREIN WILL MEET LICENSEE 'S REQUIREMENTS, OR THAT LICENSEE' S OPERATION OF ANY DEVICE, SOFTWARE OR SYSTEM USING THIS FILE OR ITS CONTENTS WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS HEREIN WILL BE CORRECTED. LICENSEE ASSUMES RESPONSIBILITY FOR SELECTION OF MATERIALS TO ACHIEVE ITS INTENDED RESULTS, AND FOR THE PROPER INSTALLATION, USE, AND RESULTS OBTAINED THEREFROM. LICENSEE ASSUMES THE ENTIRE RISK OF THE FILE AND ITS CONTENTS PROVING DEFECTIVE OR FAILING TO PERFORM PROPERLY AND IN SUCH EVENT, LICENSEE SHALL ASSUME THE ENTIRE COST AND RISK OF ANY REPAIR, SERVICE, CORRECTION, OR ANY OTHER LIABILITIES OR DAMAGES CAUSED BY OR ASSOCIATED WITH THE SOFTWARE. IN NO EVENT SHALL LATTICE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS FILE OR ITS CONTENTS, EVEN IF LATTICE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. LATTICE 'S SOLE LIABILITY, AND LICENSEE' S SOLE REMEDY, IS SET FORTH ABOVE. LATTICE DOES NOT WARRANT OR REPRESENT THAT THIS FILE, ITS CONTENTS OR USE THEREOF DOES NOT INFRINGE ON THIRD PARTIES' INTELLECTUAL PROPERTY RIGHTS, INCLUDING ANY PATENT. IT IS THE USER' S RESPONSIBILITY TO VERIFY THE USER SOFTWARE DESIGN FOR CONSISTENCY AND FUNCTIONALITY THROUGH THE USE OF FORMAL SOFTWARE VALIDATION METHODS. ------------------------------------------------------------------ */ #ifndef SRC_REQUEST_FIFO_H_ #define SRC_REQUEST_FIFO_H_ #include "ltcusb.h" #include "trb_fifo.h" #include "descriptor.h" #include "event_fifo.h" #include "initialization_on_setconfiguration.h" #include typedef struct setup_packet_struct { /* * The bmRequestType field will determine the direction of the request, * type of request and designated recipient. */ uint32_t bmRequestType; /* * The bRequest field determines the request being made. */ uint32_t bRequest; /* * The wValue field allow parameters to be passed with the request. */ uint64_t wValue; /* * The wIndex field allow parameters to be passed with the request. */ uint64_t wIndex; /* * wLength is used the specify the number of bytes to be transferred * should there be a data phase. */ uint64_t wLength; }setup_packet; /** * @brief Read data from Request FIFO. * @param request_data_lower Lower 32 bits of data read from Request FIFO. * @param request_data_higher Higher 32 bits of data read from Request FIFO. * @return 0 on Success. * @retval -1 ltcusb_fifo_read failed for lower data. * @retval -2 ltcusb_fifo_read failed for higher data. */ extern int ltcusb_request_fifo_read (uint32_t* request_data_lower, uint32_t* request_data_higher); /** * @brief It reads the data in the Request FIFO and execute a request * depending upon the values of the data * @return 0 on success. * @retval -1 ltcusb_request_read failed. * @retval -2 XferNotReady for EP1 failed. * @retval -3 get_device_descriptor request failed. * @retval -4 get_config_descriptor failed. * @retval -5 get_config_interface_endpoint_descriptor failed. * @retval -6 get_device_qualifier_descriptor failed. * @retval -7 get_string_language_descriptor failed. * @retval -8 get_string_index1_descriptor failed. * @retval -9 get_string_index1_descriptor failed. * @retval -10 get_string_index1_descriptor failed. * @retval -11 XferNotReady event for EP 0 failed. * @retval -12 TRB_control_status3 failed. * @retval -13 XferComplete for EP 0 failed. * @retval -14 ltcusb_set_address_request failed. * @retval -15 Initialization_on_SetConfiguration failed. * @retval -16 XferComplete for EP 1 failed. * @retval -17 ltcusb_control_out_request failed. * @retval -18 ltcusb_control_in_request failed. * @retval -19 XferNotReady event for EP 1 failed. * @retval -20 DEPSSTALL_cmd failed. * @retval -21 TRB_control_setup failed. * @retval -22 get_config_interface_endpoint_ss_descriptor failed. */ extern int usb_enumeration(); /** * @brief This function will get the details of the received Descriptor. * @param request_data_lower Lower 32 bits of data read from Request FIFO. * @param request_data_higher Higher 32 bits of data read from Request FIFO. * @return 0 on success. * @retval -1 get_device_descriptor failed. * @retval -2 get_config_descriptor failed. * @retval -3 TRB_control_data for Configuration & Interface & Endpoint * descriptor failed. * @retval -4 TRB_control_data for Device Qualifier descriptor failed. * @retval -5 TRB_control_data for String language descriptor failed. * @retval -6 TRB_control_data for String index 1 descriptor failed. * @retval -7 TRB_control_data for String index 2 descriptor failed. * @retval -8 TRB_control_data for String index 3 descriptor failed. * @retval -9 TRB_control_status3 failed. * @retval -10 wait for XferNotReady EP1 failed, time limit reached. * @retval -11 wait for XferNotReady EP0 failed, time limit reached. * @retval -12 wait for XferComplete Event on EP0 failed, time limit reached. */ extern int ltcusb_get_descriptor_request(uint32_t request_data_lower, uint32_t request_data_higher); /** * @brief This will write Device Descriptor into Descriptor FIFO. * @return 0 on success. * @retval -1 TRB_control_data for device descriptor failed. */ extern int get_device_descriptor(); /** * @brief This will write BOS Descriptor into Descriptor FIFO. * @return 0 on Success. * @retval -1 TRB_control_data for BOS Descriptor failed. */ extern int get_bos_descriptor(); /** * @brief This will write BOS Device Capability Descriptor into * Descriptor FIFO * @return 0 on Success. * @retval -1 TRB_control_data for BOS device capability descriptor failed. */ extern int get_bos_device_capability_descriptor(); /** * @brief This will write Configuartion Descriptor into Descriptor FIFO. * @return 0 on success. * @retval -1 TRB_control_data for Configuartion descriptor failed. */ extern int get_config_descriptor(); /** * @brief This will create Other Speed Configuration Descriptor into * Descriptor Fifo. * @return 0 on Success. * @retval -1 TRB_Control_data failed for Other Speed Configuration descriptor */ extern int get_other_speed_config_descriptor(); /** * @brief This will write Configuartion,Interface and Endpoint * Descriptor into Descriptor FIFO. * @return 0 on success. * @retval -1 TRB_control_data2 for Configuartion descriptor failed. */ extern int get_config_interface_endpoint_descriptor (); /** * @brief This will write Configuartion,Interface,Endpoint and * SuperSpeed Endpoint Companion Descriptor into Descriptor FIFO. * @return 0 on success. * @retval -1 TRB_control_data2 for Configuartion descriptor failed. */ extern int get_config_interface_endpoint_ss_descriptor (); /** * @brief This will write Other Speed Configuartion,Interface and * Endpoint SuperSpeed Endpoint Companion Descriptor into * Descriptor FIFO. * @return 0 on success. * @retval -1 TRB_control_data2 for Configuartion descriptor failed. */ extern int get_other_speed_config_interface_endpoint_descriptor(); /** * @brief This will write Device Qualifier Descriptor into * Descriptor FIFO. * @return 0 on success. * @retval -1 TRB_control_data2 for Device Qualifier descriptor failed. */ extern int get_device_qualifier_descriptor(); /** * @brief This will write Device Qualifier Descriptor into * Descriptor FIFO. * @return 0 on success. * @retval -1 TRB_control_data2 for Device Qualifier descriptor failed. */ extern int get_string_language_descriptor(); /** * @brief This function will set the Address. * @param request_data_lower Lower 32 bits of data read from Request FIFO. * @return 0 on Success. * @retval -1 DCFG register write failed. * @retval -2 wait for XferNotReady EP1 failed, time limit reached. * @retval -3 TRB_control_status2 failed. * @retval -4 wait for XferComplete Event on EP1 failed, time limit reached. */ extern int ltcusb_set_address_request (uint32_t request_data_lower); /** * @brief Control OUT Transfer * @return 0 on success. * @retval -1 XferNotReady event for EP1 failed. * @retval -2 TRB_control_status2 failed. * @retval -3 XferComplete event for EP1 failed. */ extern int ltcusb_2_stage_control_out_request(); /** * @brief Control OUT Transfer * @return 0 on success. * @retval -1 TRB_control_setup failed in ltcusb_3_stage_control_out_request. * @retval -2 XferComplete for EndPoint 0 failed in * ltcusb_3_stage_control_out_request. * @retval -3 ltcusb_request_fifo_read failed in * ltcusb_3_stage_control_out_request. * @retval -4 XferNotReady for EndPoint 1 failed in * ltcusb_3_stage_control_out_request. * @retval -5 TRB_control_status3 failed in * ltcusb_3_stage_control_out_request. * @retval -6 XferComplete for EndPoint 1 failed in * ltcusb_3_stage_control_out_request. */ extern int ltcusb_3_stage_control_out_request(uint32_t* data_lower, uint32_t* data_higher); /** *@brief Control IN Transfer * @param request_data_lower Lower 32 bits of data read from Request FIFO. * @return 0 on success. * @retval -1 XferNotReady event for EP1 failed. * @retval -2 TRB write failed for Control IN transfer. * @retval -3 DEPSTRTXFER command failed. * @retval -4 XferNotReady event for EP0 failed. * @retval -5 TRB Control Status 3 failed. * @retval -6 XferComplete for EP0 failed. */ extern int ltcusb_control_in_request(uint32_t request_data_higher); extern int get_string_index1_descriptor2(uint8_t* str); extern int get_string_index1_descriptor3(uint8_t* str, uint32_t str_len); extern int set_manufacturer_id(uint8_t* manufacturer_id); extern int set_product_id(uint8_t* product_id); extern int set_serial_id(uint8_t* serial_id); /** * @brief This request returns the current device configuration value. * @return 0 on Success. * @retval -1 XferNotReady for EP1 failed in ltcusb_get_config_request. * @retval -2 TRB_control_data failed in ltcusb_get_config_request. * @retval -3 XferNotReady for EP0 failed in ltcusb_get_config_request. * @retval -4 TRB_control_status3 failed in ltcusb_get_config_request. * @retval -5 XferComplete for EP0 failed in ltcusb_get_config_request. */ extern int ltcusb_get_config_request(); /** * @brief This request returns status for the specified recipient. * If the recipient is an endpoint, then the lower byte of * wIndex identifies the endpoint whose status is being queried. * If the recipient is an interface, then the lower byte of * wIndex identifies the interface whose status is being queried. * @return 0 On Success. * @retval -1 XferNotReady for EP1 failed in ltcusb_get_status_request. * @retval -2 TRB_control_data failed in ltcusb_get_status_request. * @retval -3 XferNotReady for EP0 failed in ltcusb_get_status_request. * @retval -4 TRB_control_status3 failed in ltcusb_get_status_request. * @retval -5 XferComplete for EP0 failed in ltcusb_get_status_request. */ extern int ltcusb_get_status_request(); /** * @brief This request is used to set or enable a specific feature. * @return 0 On Success. * @retval -1 XferNotReady event for EP1 failed in ltcusb_set_feature_request. * @retval -2 TRB_control_status2 failed in ltcusb_set_feature_request. * @retval -3 XferComplete event for EP1 failed in ltcusb_set_feature_request. */ extern int ltcusb_set_feature_request(); /** * @brief This request is used to set or enable a specific feature. * @return 0 On Success. * @retval -1 XferNotReady event for EP1 failed in * ltcusb_clear_feature_request. * @retval -2 TRB_control_status2 failed in * ltcusb_clear_feature_request. * @retval -3 XferComplete event for EP1 failed in * ltcusb_clear_feature_request. */ extern int ltcusb_clear_feature_request(); /** * @brief This request sets both the U1 and U2 System Exit Latency and the U1 * or U2 exit latency for all the links between a device and a root * port on the host. * @return 0 On Success. */ extern int ltcusb_set_sel_request(uint32_t* data_lower, uint32_t* data_higher); #endif /* SRC_REQUEST_FIFO_H_ */