//! @breif This function checks the specific request and if known then processes it //! //! @param type corresponding at bmRequestType (see USB specification) //! @param request corresponding at bRequest (see USB specification) //! //! @return TRUE, when the request is processed //! @return FALSE, if the request is'nt know (STALL handshake is managed by the main standard request function). //! Bool usb_user_read_request(U8 type, U8 request) { U16 wInterface; U8 wValue_msb; U8 wValue_lsb; // Read wValue wValue_lsb = Usb_read_byte(); wValue_msb = Usb_read_byte(); //** Specific request from Class MassStorage if( USB_SETUP_SET_CLASS_INTER == type ) { switch( request ) { case SETUP_MASS_STORAGE_RESET: // wValue must be 0 // wIndex = Interface if( (0!=wValue_lsb) || (0!=wValue_msb) ) break; LSB(wInterface)=Usb_read_byte(); MSB(wInterface)=Usb_read_byte(); if( INTERFACE_NB != wInterface ) break; Usb_ack_receive_setup(); Usb_send_control_in(); while(!Is_usb_in_ready()); return TRUE; break; } } if( USB_SETUP_GET_CLASS_INTER == type ) { switch( request ) { case SETUP_MASS_STORAGE_GET_MAX_LUN: // wValue must be 0 // wIndex = Interface if( (0!=wValue_lsb) || (0!=wValue_msb) ) break; LSB(wInterface)=Usb_read_byte(); MSB(wInterface)=Usb_read_byte(); if( INTERFACE_NB != wInterface ) break; Usb_ack_receive_setup(); Usb_write_byte( (get_nb_lun()-1) ); Usb_send_control_in(); while(!Is_usb_in_ready()); while( !Is_usb_receive_out() ); Usb_ack_receive_out(); ms_multiple_drive = 1; return TRUE; break; } } return FALSE; // No supported request }
//! This function is called by the standard USB read request function when //! the USB request is not supported. This function returns true when the //! request is processed. This function returns false if the request is not //! supported. In this case, a STALL handshake will be automatically //! sent by the standard USB read request function. //! bool usb_user_read_request(U8 type, U8 request) { Usb_read_endpoint_data(EP_CONTROL, 8); // string_type Usb_read_endpoint_data(EP_CONTROL, 8); // descriptor_type switch (request) { #if( EVK1101_CTRL_PANEL_PID==EVK1101_CTRL_PANEL_DEMO_HID_MS_PID ) case MASS_STORAGE_RESET: Usb_ack_setup_received_free(); Usb_ack_control_in_ready_send(); return true; case GET_MAX_LUN: Usb_ack_setup_received_free(); Usb_reset_endpoint_fifo_access(EP_CONTROL); Usb_write_endpoint_data(EP_CONTROL, 8, get_nb_lun() - 1); Usb_ack_control_in_ready_send(); while (!Is_usb_control_in_ready()); while(!Is_usb_control_out_received()); Usb_ack_control_out_received_free(); ms_multiple_drive = true; return true; #endif /* case HID_SET_REPORT: switch (descriptor_type) { case HID_REPORT_OUTPUT: Usb_ack_setup_received_free(); while (!Is_usb_control_out_received()); Usb_ack_control_out_received_free(); Usb_ack_control_in_ready_send(); while (!Is_usb_control_in_ready()); return true; default: break; } break; case HID_SET_IDLE: Usb_ack_setup_received_free(); Usb_ack_control_in_ready_send(); while (!Is_usb_control_in_ready()); return true; */ default: break; } return false; }
//! This function is called by the standard USB read request function when //! the USB request is not supported. This function returns true when the //! request is processed. This function returns false if the request is not //! supported. In this case, a STALL handshake will be automatically //! sent by the standard USB read request function. //! bool usb_user_read_request(uint8_t type, uint8_t request) { uint16_t wInterface; uint8_t wValue_msb; uint8_t wValue_lsb; wValue_lsb = Usb_read_endpoint_data(EP_CONTROL, 8); wValue_msb = Usb_read_endpoint_data(EP_CONTROL, 8); //** Specific request from Class MassStorage if( USB_SETUP_SET_CLASS_INTER == type ) { switch( request ) { case MASS_STORAGE_RESET: // wValue must be 0 // wIndex = Interface if( (0!=wValue_lsb) || (0!=wValue_msb) ) break; wInterface=Usb_read_endpoint_data(EP_CONTROL, 16); if( INTERFACE_NB != wInterface ) break; Usb_ack_setup_received_free(); Usb_ack_control_in_ready_send(); return true; } } if( USB_SETUP_GET_CLASS_INTER == type ) { switch( request ) { case GET_MAX_LUN: // wValue must be 0 // wIndex = Interface if( (0!=wValue_lsb) || (0!=wValue_msb) ) break; wInterface=Usb_read_endpoint_data(EP_CONTROL, 16); if( INTERFACE_NB != wInterface ) break; Usb_ack_setup_received_free(); Usb_reset_endpoint_fifo_access(EP_CONTROL); Usb_write_endpoint_data(EP_CONTROL, 8, get_nb_lun() - 1); Usb_ack_control_in_ready_send(); while (!Is_usb_control_in_ready()); while(!Is_usb_control_out_received()); Usb_ack_control_out_received_free(); ms_multiple_drive = true; return true; } } return false; }
/** * \brief Application entry point for FatFS example. */ int main(void) { uint32_t disk_dev_num; const usart_serial_options_t usart_serial_options = { .baudrate = CONF_TEST_BAUDRATE, .paritytype = CONF_TEST_PARITY, #if !SAM .charlength = CONF_TEST_CHARLENGTH, .stopbits = CONF_TEST_STOPBITS, #endif }; /* Initialize the system */ sysclk_init(); board_init(); #if XMEGA rtc_init(); #endif #if SAM sysclk_enable_peripheral_clock(CONSOLE_UART_ID); #endif stdio_serial_init(CONF_TEST_USART, &usart_serial_options); /* Intialize the memory device */ memories_initialization(); /* Output example information */ puts(STRING_HEADER); for (disk_dev_num = 0; disk_dev_num < get_nb_lun(); disk_dev_num++) { if (run_fatfs_test(disk_dev_num)) { printf("-I- DISK %d Test passed !\n\r\n\r", disk_dev_num); } else { printf("-F- DISK %d Test Failed !\n\r\n\r", disk_dev_num); } } while (1) { /* Do nothing */ } }
//! This function is called by the standard usb read request function when //! the Usb request is not supported. This function returns TRUE when the //! request is processed. This function returns FALSE if the request is not //! supported. In this case, a STALL handshake will be automatically //! sent by the standard usb read request function. //! //! @param type Not used //! @param request Read request type //! //! @retval FALSE if unknown read type //! @retval TRUE if request type is processed //! Bool usb_user_read_request(U8 type, U8 request) { U16 wLength; //Both protocols have two bytes we throw away Usb_read_byte(); Usb_read_byte(); switch(request) { case SEND_ENCAPSULATED_COMMAND: Usb_read_byte();//wIndex LSB Usb_read_byte();//wIndex MSB LSB(wLength) = Usb_read_byte(); MSB(wLength) = Usb_read_byte(); return send_encapsulated_command(wLength); break; case GET_ENCAPSULATED_COMMAND: Usb_read_byte();//wIndex LSB Usb_read_byte();//wIndex MSB LSB(wLength) = Usb_read_byte(); MSB(wLength) = Usb_read_byte(); return get_encapsulated_command(); break; case MASS_STORAGE_RESET: Usb_ack_receive_setup(); Usb_send_control_in(); return TRUE; break; case GET_MAX_LUN: Usb_ack_receive_setup(); Usb_write_byte( (get_nb_lun()-1) ); Usb_send_control_in(); ms_multiple_drive = 1; return TRUE; break; /* We don't have a real serial port - so these aren't applicable. We advertise that we support nothing, so shouldn't get them anyway */ case GET_LINE_CODING: cdc_get_line_coding(); return TRUE; break; case SET_LINE_CODING: cdc_set_line_coding(); return TRUE; break; case SET_CONTROL_LINE_STATE: cdc_set_control_line_state(); return TRUE; break; default: break; } return FALSE; }