Xmega Application Note | |||||
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_specific_request.h.
#include "config.h"
Go to the source code of this file.
Data Structures | |
struct | S_line_coding |
Defines | |
#define | ACM_CAP_BREAK 0x04 |
#define | ACM_CAP_COMM_FEATURE 0x01 |
#define | ACM_CAP_LINE_CODING 0x02 |
#define | ACM_CAP_NETWORK_CONN 0x08 |
#define | CALL_MGM_CAP_DATA_CLASS 0x02 |
#define | CALL_MGM_CAP_SELF_MGM 0x01 |
#define | CS_ACM_FD 0x02 |
#define | CS_CALL_MGM_FD 0x01 |
#define | CS_COUNTRY_FD 0x07 |
#define | CS_DL_MGM_FD 0x03 |
#define | CS_ENDPOINT 0x25 |
#define | CS_HEADER_FD 0x00 |
#define | CS_INTERFACE 0x24 |
#define | CS_TLF_CLSRC_FD 0x05 |
#define | CS_TLF_OP_MOD_FD 0x08 |
#define | CS_TLF_RING_FD 0x04 |
#define | CS_UNION_FD 0x06 |
#define | CS_USB_TERM_FD 0x09 |
#define | GET_ENCAPSULATED_COMMAND 0x01 |
#define | GET_LINE_CODING 0x21 |
#define | SEND_BREAK 0x23 |
#define | SEND_ENCAPSULATED_COMMAND 0x00 |
#define | SET_CONTROL_LINE_STATE 0x22 |
#define | SET_LINE_CODING 0x20 |
Functions | |
void | cdc_get_line_coding () |
This function manages reception of line coding parameters (baudrate...). | |
void | cdc_set_control_line_state (void) |
This function manages the SET_CONTROL_LINE_LINE_STATE CDC request. | |
void | cdc_set_line_coding () |
This function manages reception of line coding parameters (baudrate...). | |
void | usb_user_endpoint_init (uint8_t) |
This function configures the endpoints. | |
bool | usb_user_get_descriptor (uint8_t, uint8_t) |
This function returns the size and the pointer on a user information structure. | |
bool | usb_user_read_request (uint8_t, uint8_t) |
This function is called by the standard usb read request function when the Usb request is not supported. | |
Variables | |
code S_usb_user_configuration_descriptor | usb_conf_desc |
code S_usb_device_descriptor | usb_dev_desc |
code S_usb_if0_descript | usb_if0_descriptor |
code S_usb_user_configuration_descriptor | usb_other_conf_desc |
code S_usb_device_qualifier_descriptor | usb_qual_desc |
code S_usb_language_id | usb_user_language_id |
code S_usb_manufacturer_string_descriptor | usb_user_manufacturer_string_descriptor |
code S_usb_product_string_descriptor | usb_user_product_string_descriptor |
code S_usb_serial_number | usb_user_serial_number |
#define ACM_CAP_BREAK 0x04 |
Definition at line 76 of file usb_specific_request.h.
#define ACM_CAP_COMM_FEATURE 0x01 |
Definition at line 74 of file usb_specific_request.h.
#define ACM_CAP_LINE_CODING 0x02 |
Definition at line 75 of file usb_specific_request.h.
#define ACM_CAP_NETWORK_CONN 0x08 |
Definition at line 77 of file usb_specific_request.h.
#define CALL_MGM_CAP_DATA_CLASS 0x02 |
Definition at line 71 of file usb_specific_request.h.
#define CALL_MGM_CAP_SELF_MGM 0x01 |
Definition at line 70 of file usb_specific_request.h.
#define CS_ACM_FD 0x02 |
Definition at line 60 of file usb_specific_request.h.
#define CS_CALL_MGM_FD 0x01 |
Definition at line 59 of file usb_specific_request.h.
#define CS_COUNTRY_FD 0x07 |
Definition at line 65 of file usb_specific_request.h.
#define CS_DL_MGM_FD 0x03 |
Definition at line 61 of file usb_specific_request.h.
#define CS_ENDPOINT 0x25 |
Definition at line 56 of file usb_specific_request.h.
#define CS_HEADER_FD 0x00 |
Definition at line 58 of file usb_specific_request.h.
#define CS_INTERFACE 0x24 |
Definition at line 55 of file usb_specific_request.h.
#define CS_TLF_CLSRC_FD 0x05 |
Definition at line 63 of file usb_specific_request.h.
#define CS_TLF_OP_MOD_FD 0x08 |
Definition at line 66 of file usb_specific_request.h.
#define CS_TLF_RING_FD 0x04 |
Definition at line 62 of file usb_specific_request.h.
#define CS_UNION_FD 0x06 |
Definition at line 64 of file usb_specific_request.h.
#define CS_USB_TERM_FD 0x09 |
Definition at line 67 of file usb_specific_request.h.
#define GET_ENCAPSULATED_COMMAND 0x01 |
Definition at line 85 of file usb_specific_request.h.
#define GET_LINE_CODING 0x21 |
#define SEND_BREAK 0x23 |
Definition at line 83 of file usb_specific_request.h.
#define SEND_ENCAPSULATED_COMMAND 0x00 |
Definition at line 84 of file usb_specific_request.h.
#define SET_CONTROL_LINE_STATE 0x22 |
#define SET_LINE_CODING 0x20 |
void cdc_get_line_coding | ( | ) |
This function manages reception of line coding parameters (baudrate...).
Definition at line 184 of file usb_specific_request.c.
References S_line_coding::bCharFormat, S_line_coding::bDataBits, S_line_coding::bParityType, S_line_coding::dwDTERate, Is_usb_read_control_enabled, Is_usb_receive_out, LSB0, LSB1, LSB2, LSB3, Usb_ack_receive_out, Usb_ack_receive_setup, Usb_send_control_in, and Usb_write_byte.
Referenced by usb_user_read_request().
00185 { 00186 Usb_ack_receive_setup(); 00187 Usb_write_byte(LSB0(line_coding.dwDTERate)); 00188 Usb_write_byte(LSB1(line_coding.dwDTERate)); 00189 Usb_write_byte(LSB2(line_coding.dwDTERate)); 00190 Usb_write_byte(LSB3(line_coding.dwDTERate)); 00191 Usb_write_byte(line_coding.bCharFormat); 00192 Usb_write_byte(line_coding.bParityType); 00193 Usb_write_byte(line_coding.bDataBits); 00194 00195 Usb_send_control_in(); 00196 while(!(Is_usb_read_control_enabled())); 00197 00198 while(!Is_usb_receive_out()); 00199 Usb_ack_receive_out(); 00200 }
void cdc_set_control_line_state | ( | void | ) |
This function manages the SET_CONTROL_LINE_LINE_STATE CDC request.
Definition at line 229 of file usb_specific_request.c.
References Is_usb_read_control_enabled, Usb_ack_receive_setup, and Usb_send_control_in.
Referenced by usb_user_read_request().
00230 { 00231 Usb_ack_receive_setup(); 00232 Usb_send_control_in(); 00233 while(!(Is_usb_read_control_enabled())); 00234 00235 }
void cdc_set_line_coding | ( | ) |
This function manages reception of line coding parameters (baudrate...).
Definition at line 205 of file usb_specific_request.c.
References S_line_coding::bCharFormat, S_line_coding::bDataBits, S_line_coding::bParityType, S_line_coding::dwDTERate, Is_usb_read_control_enabled, Is_usb_receive_out, LSB0, LSB1, LSB2, LSB3, SW_USART_Set_Baudrate(), Usb_ack_receive_out, Usb_ack_receive_setup, Usb_read_byte, and Usb_send_control_in.
Referenced by usb_user_read_request().
00206 { 00207 Usb_ack_receive_setup(); 00208 while (!(Is_usb_receive_out())); 00209 00210 LSB0(line_coding.dwDTERate) = Usb_read_byte(); 00211 LSB1(line_coding.dwDTERate) = Usb_read_byte(); 00212 LSB2(line_coding.dwDTERate) = Usb_read_byte(); 00213 LSB3(line_coding.dwDTERate) = Usb_read_byte(); 00214 00215 line_coding.bCharFormat = Usb_read_byte(); 00216 line_coding.bParityType = Usb_read_byte(); 00217 line_coding.bDataBits = Usb_read_byte(); 00218 Usb_ack_receive_out(); 00219 00220 /* Send a ZLP for STATUS phase */ 00221 Usb_send_control_in(); 00222 while(!(Is_usb_read_control_enabled())); 00223 SW_USART_Set_Baudrate(line_coding.dwDTERate); 00224 }
void usb_user_endpoint_init | ( | uint8_t | conf_nb | ) |
This function configures the endpoints.
conf_nb | Configuration number |
Definition at line 154 of file usb_specific_request.c.
References DIRECTION_IN, DIRECTION_OUT, INT_EP, NYET_ENABLED, ONE_BANK, RX_EP, SIZE_32, TWO_BANKS, TX_EP, TYPE_BULK, TYPE_INTERRUPT, usb_configure_endpoint, and Usb_reset_endpoint.
Referenced by usb_set_configuration().
00155 { 00156 usb_configure_endpoint(INT_EP, \ 00157 TYPE_INTERRUPT, \ 00158 DIRECTION_IN, \ 00159 SIZE_32, \ 00160 ONE_BANK, \ 00161 NYET_ENABLED); 00162 00163 usb_configure_endpoint(TX_EP, \ 00164 TYPE_BULK, \ 00165 DIRECTION_IN, \ 00166 SIZE_32, \ 00167 ONE_BANK, \ 00168 NYET_ENABLED); 00169 00170 usb_configure_endpoint(RX_EP, \ 00171 TYPE_BULK, \ 00172 DIRECTION_OUT, \ 00173 SIZE_32, \ 00174 TWO_BANKS, \ 00175 NYET_ENABLED); 00176 00177 Usb_reset_endpoint(INT_EP); 00178 Usb_reset_endpoint(TX_EP); 00179 Usb_reset_endpoint(RX_EP); 00180 }
bool usb_user_get_descriptor | ( | uint8_t | type, | |
uint8_t | string | |||
) |
This function returns the size and the pointer on a user information structure.
type | of the request | |
string | with the request desciption |
Definition at line 107 of file usb_specific_request.c.
References S_usb_if0_descript::bLength, S_usb_product_string_descriptor::bLength, S_usb_manufacturer_string_descriptor::bLength, S_usb_language_id::bLength, data_to_transfer, IF0_INDEX, LANG_INDEX, MAN_INDEX, pbuffer, PROD_INDEX, STRING_DESCRIPTOR, usb_if0_descriptor, usb_user_language_id, usb_user_manufacturer_string_descriptor, and usb_user_product_string_descriptor.
Referenced by usb_get_descriptor().
00108 { 00109 bool status = true; 00110 switch(type) 00111 { 00112 case STRING_DESCRIPTOR: 00113 switch (string) 00114 { 00115 case LANG_INDEX: 00116 data_to_transfer = sizeof (usb_user_language_id); 00117 pbuffer = &(usb_user_language_id.bLength); 00118 break; 00119 case MAN_INDEX: 00120 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor); 00121 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength); 00122 break; 00123 case PROD_INDEX: 00124 data_to_transfer = sizeof (usb_user_product_string_descriptor); 00125 pbuffer = &(usb_user_product_string_descriptor.bLength); 00126 break; 00127 00128 /* Include this if serial number should be fixed and not given by OS. */ 00129 /* case SN_INDEX: 00130 data_to_transfer = sizeof (usb_user_serial_number); 00131 pbuffer = &(usb_user_serial_number.bLength); 00132 break; 00133 */ case IF0_INDEX: 00134 data_to_transfer = sizeof (usb_if0_descriptor); 00135 pbuffer = &(usb_if0_descriptor.bLength); 00136 break; 00137 default: 00138 status = false; 00139 break; 00140 } 00141 break; 00142 default: 00143 status = false; 00144 break; 00145 } 00146 00147 return status; 00148 }
bool usb_user_read_request | ( | uint8_t | type, | |
uint8_t | 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.
Definition at line 72 of file usb_specific_request.c.
References cdc_get_line_coding(), cdc_set_control_line_state(), cdc_set_line_coding(), GET_LINE_CODING, SET_CONTROL_LINE_STATE, SET_LINE_CODING, and Usb_read_byte.
Referenced by usb_process_request().
00073 { 00074 bool status = true; 00075 uint8_t descriptor_type ; 00076 uint8_t string_type ; 00077 00078 string_type = Usb_read_byte(); 00079 descriptor_type = Usb_read_byte(); 00080 switch(request) 00081 { 00082 case GET_LINE_CODING: 00083 cdc_get_line_coding(); 00084 break; 00085 case SET_LINE_CODING: 00086 cdc_set_line_coding(); 00087 break; 00088 case SET_CONTROL_LINE_STATE: 00089 cdc_set_control_line_state(); 00090 break; 00091 default: 00092 status = false; 00093 break; 00094 } 00095 return status; 00096 }
usb_user_configuration_descriptor FS
Definition at line 79 of file usb_descriptors.c.
usb_user_device_descriptor
Definition at line 59 of file usb_descriptors.c.
usb_if0_descriptor
Definition at line 206 of file usb_descriptors.c.
Referenced by usb_user_get_descriptor().
usb_user_language_id
Definition at line 197 of file usb_descriptors.c.
Referenced by usb_user_get_descriptor().
usb_user_manufacturer_string_descriptor
Definition at line 170 of file usb_descriptors.c.
Referenced by usb_user_get_descriptor().
usb_user_product_string_descriptor
Definition at line 179 of file usb_descriptors.c.
Referenced by usb_user_get_descriptor().
usb_user_serial_number
Definition at line 188 of file usb_descriptors.c.
Generated on Mon Jan 18 09:26:13 2010 for AVR1907 Xplain USB Gateway by ![]() |