Contiki 3.x
Functions | Variables
usb_standard_request.c File Reference

This file contains the USB endpoint 0 management routines corresponding to the standard enumeration process (refer to chapter 9 of the USB specification. This file calls routines of the usb_specific_request.c file for non-standard request management. The enumeration parameters (descriptor tables) are contained in the usb_descriptors.c file. More...

#include "config.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_specific_request.h"
#include <string.h>

Go to the source code of this file.

Functions

static void usb_get_descriptor (void)
 usb_get_descriptor. More...
 
static void usb_set_address (void)
 usb_set_address. More...
 
static void usb_set_configuration (void)
 usb_set_configuration. More...
 
static void usb_clear_feature (void)
 usb_clear_feature. More...
 
static void usb_set_feature (void)
 usb_set_feature. More...
 
static void usb_get_status (void)
 usb_get_status. More...
 
static void usb_get_configuration (void)
 usb_get_configuration. More...
 
static void usb_get_interface (void)
 usb_get_interface. More...
 
static void usb_set_interface (void)
 usb_set_interface. More...
 
void usb_process_request (void)
 usb_process_request. More...
 
void usb_get_string_descriptor_sram (U8 string_type)
 
void usb_get_string_descriptor (U8 string_type)
 

Variables

U8 usb_configuration_nb
 Public : (U8) usb_configuration_nb Store the number of the USB configuration used by the USB device when its value is different from zero, it means the device mode is enumerated Used with USB_DEVICE_FEATURE == ENABLED only /.
 
bit usb_connected
 Public : (bit) 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 == ENABLED only /.
 

Detailed Description

This file contains the USB endpoint 0 management routines corresponding to the standard enumeration process (refer to chapter 9 of the USB specification. This file calls routines of the usb_specific_request.c file for non-standard request management. The enumeration parameters (descriptor tables) are contained in the usb_descriptors.c file.

Definition in file usb_standard_request.c.

Function Documentation

void usb_clear_feature ( void  )
static

usb_clear_feature.

This function manages the SET FEATURE request.

Warning
Code:xx bytes (function code length)

< dummy read

Definition at line 663 of file usb_standard_request.c.

References Is_usb_endpoint_enabled, Usb_ack_receive_setup, Usb_disable_stall_handshake, Usb_read_byte, Usb_reset_data_toggle, Usb_reset_endpoint, Usb_select_endpoint, and Usb_send_control_in.

Referenced by usb_process_request().

void usb_get_configuration ( void  )
static

usb_get_configuration.

This function manages the GET CONFIGURATION request. The current configuration number is returned.

Warning
Code:xx bytes (function code length)

Definition at line 548 of file usb_standard_request.c.

References Usb_ack_receive_out, Usb_ack_receive_setup, usb_configuration_nb, Usb_send_control_in, and Usb_write_byte.

Referenced by usb_process_request().

void usb_get_descriptor ( void  )
static

usb_get_descriptor.

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.

Warning
Code:xx bytes (function code length)

< sizeof (usb_user_device_descriptor);

< sizeof (usb_user_configuration_descriptor);

< don't care of wIndex field

< read wLength

< clear the receive setup flag

< send only requested number of data

Send data until necessary

< Check endpoint 0 size

abort from Host

Definition at line 440 of file usb_standard_request.c.

References FALSE, Is_usb_receive_out, TRUE, Usb_ack_receive_out, Usb_ack_receive_setup, Usb_enable_stall_handshake, usb_get_string_descriptor(), Usb_read_byte, Usb_send_control_in, usb_user_get_descriptor(), and Usb_write_byte.

Referenced by usb_process_request().

void usb_get_interface ( void  )
static

usb_get_interface.

TThis function manages the GET_INTERFACE request.

Warning
Code:xx bytes (function code length)

Definition at line 720 of file usb_standard_request.c.

Referenced by usb_process_request().

void usb_get_status ( void  )
static

usb_get_status.

This function manages the GET STATUS request. The device, interface or endpoint status is returned.

Warning
Code:xx bytes (function code length)

< dummy read

< dummy read

Definition at line 566 of file usb_standard_request.c.

References Usb_ack_receive_out, Usb_ack_receive_setup, Usb_enable_stall_handshake, Usb_read_byte, Usb_send_control_in, and Usb_write_byte.

Referenced by usb_process_request().

void usb_get_string_descriptor ( U8  string_type)

< don't care of wIndex field

< read wLength

< clear the receive setup flag

< Send data until necessary

< Check endpoint 0 size

abort from Host

Definition at line 331 of file usb_standard_request.c.

References Is_usb_receive_out, TRUE, Usb_ack_receive_out, Usb_ack_receive_setup, Usb_enable_stall_handshake, usb_get_string_descriptor_sram(), Usb_read_byte, Usb_send_control_in, and Usb_write_byte.

Referenced by usb_get_descriptor().

void usb_get_string_descriptor_sram ( U8  string_type)

< don't care of wIndex field

< read wLength

< clear the receive setup flag

< Send data until necessary

< Check endpoint 0 size

abort from Host

Definition at line 244 of file usb_standard_request.c.

References Is_usb_receive_out, TRUE, Usb_ack_receive_out, Usb_ack_receive_setup, Usb_enable_stall_handshake, Usb_read_byte, Usb_send_control_in, and Usb_write_byte.

Referenced by usb_get_string_descriptor().

void usb_process_request ( void  )

usb_process_request.

This function reads the SETUP request sent to the default control endpoint and calls the appropriate function. When exiting of the usb_read_request function, the device is ready to manage the next request.

Note
list of supported requests: GET_DESCRIPTOR GET_CONFIGURATION SET_ADDRESS SET_CONFIGURATION CLEAR_FEATURE SET_FEATURE GET_STATUS

< un-supported request => call to user read request

Definition at line 118 of file usb_standard_request.c.

References CLEAR_FEATURE, Is_usb_receive_setup, SET_FEATURE, Usb_ack_in_ready, Usb_ack_receive_out, Usb_ack_receive_setup, usb_clear_feature(), Usb_enable_stall_handshake, usb_get_configuration(), usb_get_descriptor(), usb_get_interface(), usb_get_status(), Usb_read_byte, Usb_select_endpoint, usb_set_address(), usb_set_configuration(), usb_set_feature(), usb_set_interface(), and usb_user_read_request().

Referenced by pollhandler(), and usb_mass_storage_csw().

void usb_set_address ( void  )
static

usb_set_address.

This function manages the SET ADDRESS request. When complete, the device will filter the requests using the new address.

Warning
Code:xx bytes (function code length)

< send a ZLP for STATUS phase

< waits for status phase done before using the new address

Definition at line 202 of file usb_standard_request.c.

References Is_usb_in_ready, Usb_ack_receive_setup, Usb_configure_address, Usb_enable_address, Usb_read_byte, and Usb_send_control_in.

Referenced by usb_process_request().

void usb_set_configuration ( void  )
static

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)

< send a ZLP for STATUS phase

< endpoint configuration

Definition at line 223 of file usb_standard_request.c.

References Is_usb_in_ready, Usb_ack_receive_setup, usb_configuration_nb, Usb_read_byte, Usb_send_control_in, and usb_user_endpoint_init().

Referenced by usb_process_request().

void usb_set_feature ( void  )
static

usb_set_feature.

This function manages the SET FEATURE request. The USB test modes are supported by this function.

Warning
Code:xx bytes (function code length)

< dummy read

Definition at line 610 of file usb_standard_request.c.

References Is_usb_endpoint_enabled, Usb_ack_receive_setup, Usb_enable_stall_handshake, Usb_read_byte, Usb_select_endpoint, and Usb_send_control_in.

Referenced by usb_process_request().

void usb_set_interface ( void  )
static

usb_set_interface.

TThis function manages the SET_INTERFACE request.

Warning
Code:xx bytes (function code length)

< send a ZLP for STATUS phase

Definition at line 731 of file usb_standard_request.c.

References Is_usb_in_ready, Usb_ack_receive_out, Usb_ack_receive_setup, Usb_read_byte, and Usb_send_control_in.

Referenced by usb_process_request().