/* * request_buffer.h * * Created on: 19-Jun-2023 * Author: vivek */ /** * @file request_buffer.h * @brief Read and Write Request Buffer values. */ #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. */ 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. * @param device_descriptor_data_size size of device descriptor * data used. * @return 0 on success. * @retval -1 TRB_control_data for device descriptor failed. */ extern int get_device_descriptor(); /** * @brief This will write Configuartion Descriptor into Descriptor FIFO. * @param config_descriptor_data_size size of config descriptor * data used. * @return 0 on success. * @retval -1 TRB_control_data for Configuartion descriptor failed. */ extern int get_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 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_status3 failed. * @retval -3 XferComplete event for EP1 failed. */ extern int ltcusb_control_out_request(); /** *@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); ///**@todo Need to add brief */ //extern int get_string_index1_descriptor(); /**@todo Need to add brief */ extern int get_string_index1_descriptor2(uint8_t* str); /**@todo Need to add brief */ extern int get_string_index1_descriptor3(uint8_t* str, uint32_t str_len); /**@todo Need to add brief */ extern int set_manufacturer_id(uint8_t* manufacturer_id); /**@todo Need to add brief */ extern int set_product_id(uint8_t* product_id); /**@todo Need to add brief */ extern int set_serial_id(uint8_t* serial_id); #endif /* SRC_REQUEST_FIFO_H_ */