Xmega Application Note


usb_specific_request.c File Reference


Detailed Description

User call-back functions.

This file contains the user call-back functions corresponding to the application: CDC

Application note:
AVR1907: Xplain Evaluation Board
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Revision
3119
Date
2010-01-12 15:53:30 +0100 (ti, 12 jan 2010)

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"

Include dependency graph for usb_specific_request.c:

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


Function Documentation

void cdc_get_line_coding ( void   ) 

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().

Here is the call graph for this function:

void usb_user_endpoint_init ( uint8_t  conf_nb  ) 

This function configures the endpoints.

Parameters:
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.

Parameters:
type of the request
string with the request desciption
Returns:
bool True if type and string is valid, false otherwise.

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 }

Here is the call graph for this function:


Variable Documentation

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().

@DOC_TITLE@
Generated on Mon Jan 18 09:26:13 2010 for AVR1907 Xplain USB Gateway by doxygen 1.5.5