Atmel Software Framework

usb_standard_request.c File Reference
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "usb_specific_request.h"
#include "usb_task.h"

Macros

#define USB_REMOTE_WAKEUP_FEATURE   false
 

Functions

static void usb_clear_feature (void)
 This function manages the CLEAR FEATURE request. More...
 
static void usb_get_configuration (void)
 This function manages the GET CONFIGURATION request. More...
 
static void usb_get_descriptor (void)
 This function manages the GET DESCRIPTOR request. More...
 
static bool usb_get_interface (void)
 This function manages the SETUP_GET_INTERFACE request. More...
 
static void usb_get_status (void)
 This function manages the GET STATUS request. More...
 
void usb_process_request (void)
 This function reads the SETUP request sent to the default control endpoint and calls the appropriate function. More...
 
static void usb_set_address (void)
 This function manages the SET ADDRESS request. More...
 
static void usb_set_configuration (void)
 This function manages the SET CONFIGURATION request. More...
 
static void usb_set_feature (void)
 This function manages the SET FEATURE request. More...
 
static void usb_set_interface (void)
 This function manages the SET INTERFACE request. More...
 

Variables

static U8 bmRequestType
 
U16 data_to_transfer
 
static U8 device_status = DEVICE_STATUS
 
const void * pbuffer
 
U8 remote_wakeup_feature
 
volatile U8 usb_configuration_nb
 
volatile bool usb_connected
 Public : (bool) usb_connected usb_connected is set to true when VBus has been detected usb_connected is set to false otherwise. More...
 
static U8 usb_interface_status [NB_INTERFACE]
 
const
S_usb_user_configuration_descriptor 
usb_user_configuration_descriptor
 
const S_usb_device_descriptor usb_user_device_descriptor
 

#define USB_REMOTE_WAKEUP_FEATURE   false

void usb_get_configuration ( void  )
static

This function manages the GET CONFIGURATION request.

The current configuration number is returned.

References EP_CONTROL, Is_usb_control_out_received, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_setup_received_free, usb_configuration_nb, Usb_reset_endpoint_fifo_access, and Usb_write_endpoint_data.

Referenced by usb_process_request().

void usb_get_descriptor ( void  )
static

This function manages the GET DESCRIPTOR request.

The device descriptor, the configuration descriptor and the device qualifier are supported. All other descriptors must be supported by the usb_user_get_descriptor function. Only 1 configuration is supported.

< sizeof(usb_dev_desc);

< sizeof(usb_conf_desc);

< read wIndex and wLength with a 32-bit access since this access is aligned with a 32-bit boundary from the beginning of the endpoint

< ignore wIndex, keep and format wLength

< clear the setup received flag

< zero length packet condition

< send only requested number of data bytes

< Send data until necessary

References CONFIGURATION_DESCRIPTOR, data_to_transfer, DEVICE_DESCRIPTOR, DEVICE_QUALIFIER_DESCRIPTOR, EP_CONTROL, EP_CONTROL_LENGTH, Is_usb_control_in_ready, Is_usb_control_out_received, Is_usb_full_speed_mode, Is_usb_nak_out, NULL, OTHER_SPEED_CONFIGURATION_DESCRIPTOR, pbuffer, temp, Union32::u16, Union32::u32, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_nak_out, Usb_ack_setup_received_free, Usb_enable_stall_handshake, usb_format_usb_to_mcu_data, Usb_get_conf_desc_fs_length, Usb_get_conf_desc_fs_pointer, Usb_get_conf_desc_hs_length, Usb_get_conf_desc_hs_pointer, Usb_get_conf_desc_length, Usb_get_conf_desc_pointer, Usb_get_dev_desc_length, Usb_get_dev_desc_pointer, Usb_get_qualifier_desc_length, Usb_get_qualifier_desc_pointer, Usb_read_endpoint_data, Usb_reset_endpoint_fifo_access, usb_user_get_descriptor(), and usb_write_ep_txpacket().

Referenced by usb_process_request().

void usb_set_address ( void  )
static

This function manages the SET ADDRESS request.

When complete, the device will filter the requests using the new address.

< send a ZLP for STATUS phase

< waits for status phase done before using the new address

References EP_CONTROL, Is_usb_control_in_ready, Usb_ack_control_in_ready_send, Usb_ack_setup_received_free, Usb_configure_address, Usb_enable_address, and Usb_read_endpoint_data.

Referenced by usb_process_request().

void usb_set_configuration ( void  )
static

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.

< endpoint configuration

< send a ZLP for STATUS phase

< keep that order (set StallRq/clear RxSetup) or a OUT request following the SETUP may be acknowledged

References EP_CONTROL, NB_CONFIGURATION, NB_INTERFACE, Usb_ack_control_in_ready_send, Usb_ack_setup_received_free, usb_configuration_nb, Usb_enable_stall_handshake, Usb_read_endpoint_data, Usb_set_configuration_action, and usb_user_endpoint_init().

Referenced by usb_process_request().

U8 device_status = DEVICE_STATUS
static
U8 remote_wakeup_feature
volatile bool usb_connected

Public : (bool) usb_connected usb_connected is set to true when VBus has been detected usb_connected is set to false otherwise.

Public: bool usb_connected usb_connected is set to true when VBus has been detected usb_connected is set to false otherwise Used with USB_DEVICE_FEATURE == true only.

const S_usb_user_configuration_descriptor usb_user_configuration_descriptor
const S_usb_device_descriptor usb_user_device_descriptor