Xmega Application Note | |||||
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.
Copyright (c) 2010, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file usb_standard_request.h.
#include "usb_descriptors.h"
Go to the source code of this file.
Defines | |
#define | ADDRESSED 3 |
#define | ATTACHED 0 |
#define | BUS_POWERED 0 |
#define | CLEAR_FEATURE 0x01 |
#define | CONFIGURATION_DESCRIPTOR 0x02 |
#define | CONFIGURED 4 |
#define | DEFAULT 2 |
#define | DEVICE_DESCRIPTOR 0x01 |
#define | DEVICE_QUALIFIER_DESCRIPTOR 0x06 |
#define | ENDPOINT_DESCRIPTOR 0x05 |
#define | ENDPOINT_TYPE 0x02 |
#define | EP_ATTR_BULK 0x02 |
#define | EP_ATTR_CONTROL 0x00 |
#define | EP_ATTR_INTERUPT 0x03 |
#define | EP_ATTR_ISOCHRON 0x01 |
#define | EP_DIR_IN 0x80 |
#define | EP_DIR_OUT 0x00 |
#define | FEATURE_DEVICE_REMOTE_WAKEUP 0x01 |
#define | FEATURE_ENDPOINT_HALT 0x00 |
#define | GET_CONFIGURATION 0x08 |
#define | GET_CONFIGURATION_DESCRIPTOR 4 |
#define | GET_DESCRIPTOR 0x06 |
#define | GET_DEVICE 0x01 |
#define | GET_DEVICE_DESCRIPTOR 1 |
#define | GET_INTERFACE 0x0A |
#define | GET_STATUS 0x00 |
#define | GET_STRING 0x03 |
#define | INTERFACE_ASSOCIATION_DESCRIPTOR 0x0B |
#define | INTERFACE_DESCRIPTOR 0x04 |
#define | INTERFACE_TYPE 0x01 |
#define | Is_device_enumerated() ((usb_configuration_nb!=0) ? true : false) |
#define | Is_device_not_enumerated() ((usb_configuration_nb!=0) ? false : true) |
#define | OTHER_SPEED_CONFIGURATION_DESCRIPTOR 0x07 |
#define | POWERED 1 |
#define | REQUEST_DEVICE_STATUS 0x80 |
#define | REQUEST_ENDPOINT_STATUS 0x82 |
#define | REQUEST_INTERFACE_STATUS 0x81 |
#define | SELF_POWERED 1 |
#define | SET_ADDRESS 0x05 |
#define | SET_CONFIGURATION 0x09 |
#define | SET_DESCRIPTOR 0x07 |
#define | SET_FEATURE 0x03 |
#define | SET_INTERFACE 0x0B |
#define | STRING_DESCRIPTOR 0x03 |
#define | SUSPENDED 5 |
#define | SYNCH_FRAME 0x0C |
#define | TEST_FORCE_ENABLE 0x05 |
#define | TEST_J 0x01 |
#define | TEST_K 0x02 |
#define | TEST_PACKET 0x04 |
#define | TEST_SEO_NAK 0x03 |
#define | USB_CONFIG_ATTRIBUTES_RESERVED 0x80 |
#define | USB_CONFIG_BUSPOWERED (USB_CONFIG_ATTRIBUTES_RESERVED | 0x00) |
#define | USB_CONFIG_REMOTEWAKEUP (USB_CONFIG_ATTRIBUTES_RESERVED | 0x20) |
#define | USB_CONFIG_SELFPOWERED (USB_CONFIG_ATTRIBUTES_RESERVED | 0x40) |
#define | ZERO_TYPE 0x00 |
Functions | |
void | usb_process_request (void) |
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. | |
void | usb_var_init (void) |
Variables | |
uint8_t | usb_configuration_nb |
Store the number of the USB configuration used by the USB device. |
#define ADDRESSED 3 |
Definition at line 123 of file usb_standard_request.h.
#define ATTACHED 0 |
Definition at line 120 of file usb_standard_request.h.
#define BUS_POWERED 0 |
Definition at line 116 of file usb_standard_request.h.
#define CLEAR_FEATURE 0x01 |
see FEATURES below
Definition at line 64 of file usb_standard_request.h.
Referenced by usb_process_request().
#define CONFIGURATION_DESCRIPTOR 0x02 |
#define CONFIGURED 4 |
Definition at line 124 of file usb_standard_request.h.
#define DEFAULT 2 |
Definition at line 122 of file usb_standard_request.h.
#define DEVICE_DESCRIPTOR 0x01 |
#define DEVICE_QUALIFIER_DESCRIPTOR 0x06 |
Definition at line 92 of file usb_standard_request.h.
#define ENDPOINT_DESCRIPTOR 0x05 |
Definition at line 91 of file usb_standard_request.h.
#define ENDPOINT_TYPE 0x02 |
Definition at line 84 of file usb_standard_request.h.
Referenced by usb_clear_feature(), and usb_set_feature().
#define EP_ATTR_BULK 0x02 |
Definition at line 110 of file usb_standard_request.h.
#define EP_ATTR_CONTROL 0x00 |
Definition at line 108 of file usb_standard_request.h.
#define EP_ATTR_INTERUPT 0x03 |
Definition at line 111 of file usb_standard_request.h.
#define EP_ATTR_ISOCHRON 0x01 |
Definition at line 109 of file usb_standard_request.h.
#define EP_DIR_IN 0x80 |
Definition at line 113 of file usb_standard_request.h.
#define EP_DIR_OUT 0x00 |
Definition at line 112 of file usb_standard_request.h.
#define FEATURE_DEVICE_REMOTE_WAKEUP 0x01 |
Definition at line 98 of file usb_standard_request.h.
#define FEATURE_ENDPOINT_HALT 0x00 |
Definition at line 99 of file usb_standard_request.h.
Referenced by usb_clear_feature(), and usb_set_feature().
#define GET_CONFIGURATION 0x08 |
#define GET_CONFIGURATION_DESCRIPTOR 4 |
Definition at line 77 of file usb_standard_request.h.
#define GET_DESCRIPTOR 0x06 |
#define GET_DEVICE 0x01 |
Definition at line 63 of file usb_standard_request.h.
#define GET_DEVICE_DESCRIPTOR 1 |
Definition at line 76 of file usb_standard_request.h.
#define GET_INTERFACE 0x0A |
#define GET_STATUS 0x00 |
#define GET_STRING 0x03 |
Definition at line 65 of file usb_standard_request.h.
#define INTERFACE_ASSOCIATION_DESCRIPTOR 0x0B |
Definition at line 94 of file usb_standard_request.h.
#define INTERFACE_DESCRIPTOR 0x04 |
Definition at line 90 of file usb_standard_request.h.
#define INTERFACE_TYPE 0x01 |
Definition at line 83 of file usb_standard_request.h.
Referenced by usb_clear_feature(), and usb_set_feature().
#define Is_device_enumerated | ( | ) | ((usb_configuration_nb!=0) ? true : false) |
Enumeration test. Returns true when the device is connected and correctly enumerated with an host.
Definition at line 137 of file usb_standard_request.h.
Referenced by cdc_task().
#define Is_device_not_enumerated | ( | ) | ((usb_configuration_nb!=0) ? false : true) |
Enumeration test. Returns true when the device is connected and correctly enumerated with an host.
Definition at line 140 of file usb_standard_request.h.
#define OTHER_SPEED_CONFIGURATION_DESCRIPTOR 0x07 |
Definition at line 93 of file usb_standard_request.h.
#define POWERED 1 |
Definition at line 121 of file usb_standard_request.h.
#define REQUEST_DEVICE_STATUS 0x80 |
#define REQUEST_ENDPOINT_STATUS 0x82 |
#define REQUEST_INTERFACE_STATUS 0x81 |
#define SELF_POWERED 1 |
Definition at line 117 of file usb_standard_request.h.
#define SET_ADDRESS 0x05 |
#define SET_CONFIGURATION 0x09 |
#define SET_DESCRIPTOR 0x07 |
#define SET_FEATURE 0x03 |
see FEATURES below
Definition at line 66 of file usb_standard_request.h.
Referenced by usb_process_request().
#define SET_INTERFACE 0x0B |
#define STRING_DESCRIPTOR 0x03 |
#define SUSPENDED 5 |
Definition at line 125 of file usb_standard_request.h.
#define SYNCH_FRAME 0x0C |
#define TEST_FORCE_ENABLE 0x05 |
Definition at line 105 of file usb_standard_request.h.
#define TEST_J 0x01 |
Definition at line 101 of file usb_standard_request.h.
#define TEST_K 0x02 |
Definition at line 102 of file usb_standard_request.h.
#define TEST_PACKET 0x04 |
Definition at line 104 of file usb_standard_request.h.
#define TEST_SEO_NAK 0x03 |
Definition at line 103 of file usb_standard_request.h.
#define USB_CONFIG_ATTRIBUTES_RESERVED 0x80 |
Definition at line 128 of file usb_standard_request.h.
#define USB_CONFIG_BUSPOWERED (USB_CONFIG_ATTRIBUTES_RESERVED | 0x00) |
Definition at line 129 of file usb_standard_request.h.
#define USB_CONFIG_REMOTEWAKEUP (USB_CONFIG_ATTRIBUTES_RESERVED | 0x20) |
Definition at line 131 of file usb_standard_request.h.
#define USB_CONFIG_SELFPOWERED (USB_CONFIG_ATTRIBUTES_RESERVED | 0x40) |
Definition at line 130 of file usb_standard_request.h.
#define ZERO_TYPE 0x00 |
void usb_process_request | ( | void | ) |
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.
Definition at line 122 of file usb_standard_request.c.
References bmRequestType, CLEAR_FEATURE, GET_CONFIGURATION, GET_DESCRIPTOR, GET_INTERFACE, GET_STATUS, SET_ADDRESS, SET_CONFIGURATION, SET_DESCRIPTOR, SET_FEATURE, SET_INTERFACE, SYNCH_FRAME, 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_set_address(), usb_set_configuration(), usb_set_feature(), usb_set_interface(), and usb_user_read_request().
Referenced by usb_device_task().
00123 { 00124 uint8_t bmRequest; 00125 00126 bmRequestType = Usb_read_byte(); 00127 bmRequest = Usb_read_byte(); 00128 00129 switch (bmRequest) 00130 { 00131 case GET_DESCRIPTOR: 00132 if (0x80 == bmRequestType) { usb_get_descriptor(); } 00133 else { usb_user_read_request(bmRequestType, bmRequest); } 00134 break; 00135 00136 case GET_CONFIGURATION: 00137 if (0x80 == bmRequestType) { usb_get_configuration(); } 00138 else { usb_user_read_request(bmRequestType, bmRequest); } 00139 break; 00140 00141 case SET_ADDRESS: 00142 if (0x00 == bmRequestType) { usb_set_address(); } 00143 else { usb_user_read_request(bmRequestType, bmRequest); } 00144 break; 00145 00146 case SET_CONFIGURATION: 00147 if (0x00 == bmRequestType) { usb_set_configuration(); } 00148 else { usb_user_read_request(bmRequestType, bmRequest); } 00149 break; 00150 00151 case CLEAR_FEATURE: 00152 if (0x02 >= bmRequestType) { usb_clear_feature(); } 00153 else { usb_user_read_request(bmRequestType, bmRequest); } 00154 break; 00155 00156 case SET_FEATURE: 00157 if (0x02 >= bmRequestType) { usb_set_feature(); } 00158 else { usb_user_read_request(bmRequestType, bmRequest); } 00159 break; 00160 00161 case GET_STATUS: 00162 if ((0x7F < bmRequestType) & (0x82 >= bmRequestType)) 00163 { usb_get_status(); } 00164 else { usb_user_read_request(bmRequestType, bmRequest); } 00165 break; 00166 00167 case GET_INTERFACE: 00168 if (bmRequestType == 0x81) { usb_get_interface(); } 00169 else { usb_user_read_request(bmRequestType, bmRequest); } 00170 break; 00171 00172 00173 case SET_INTERFACE: 00174 if (bmRequestType == 0x01) {usb_set_interface();} 00175 break; 00176 00177 /* Un-supported request => call to user read request */ 00178 case SET_DESCRIPTOR: 00179 case SYNCH_FRAME: 00180 default: 00181 if(usb_user_read_request(bmRequestType, bmRequest) == false) 00182 { 00183 Usb_enable_stall_handshake(); 00184 Usb_ack_receive_setup(); 00185 } 00186 break; 00187 } 00188 }
void usb_var_init | ( | void | ) |
uint8_t 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
Definition at line 85 of file usb_standard_request.c.
Generated on Mon Jan 18 09:26:14 2010 for AVR1907 Xplain USB Gateway by ![]() |