Xmega Application Note | |||||
This file contains the user call-back functions corresponding to the application: CDC
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.c.
#include "config.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "usb_specific_request.h"
#include "sw_usart.h"
Go to the source code of this file.
Functions | |
void | cdc_get_line_coding (void) |
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 (void) |
This function manages reception of line coding parameters (baudrate...). | |
void | usb_user_endpoint_init (uint8_t conf_nb) |
This function configures the endpoints. | |
bool | usb_user_get_descriptor (uint8_t type, uint8_t string) |
This function returns the size and the pointer on a user information structure. | |
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. | |
Variables | |
uint8_t | data_to_transfer |
S_line_coding | line_coding |
uint8_t code * | pbuffer |
void cdc_get_line_coding | ( | void | ) |
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 | ( | void | ) |
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 }
uint8_t data_to_transfer |
Definition at line 82 of file usb_standard_request.c.
Referenced by usb_get_descriptor(), and usb_user_get_descriptor().
Definition at line 59 of file cdc_task.c.
uint8_t code* pbuffer |
Definition at line 81 of file usb_standard_request.c.
Referenced by usb_get_descriptor(), and usb_user_get_descriptor().
Generated on Mon Jan 18 09:26:13 2010 for AVR1907 Xplain USB Gateway by ![]() |