usb_specific_request.c File Reference

,vuser call-back functions More...

#include "config.h"
#include "conf_usb.h"
#include "lib_mcu\usb\usb_drv.h"
#include "usb_descriptors.h"
#include "modules\usb\device_chap9\usb_standard_request.h"
#include "usb_specific_request.h"
#include "lib_mcu\uart\uart_lib.h"

Include dependency graph for usb_specific_request.c:

Go to the source code of this file.

Functions

Bool usb_user_read_request (U8 type, U8 request)
 This function is called by the standard usb read request function when the Usb request is not supported.
Bool usb_user_get_descriptor (U8 type, U8 string)
 usb_user_get_descriptor.This function returns the size and the pointer on a user information structure
void usb_user_endpoint_init (U8 conf_nb)
 usb_user_endpoint_init.This function configures the endpoints.
void cdc_get_line_coding (void)
 cdc_get_line_coding.This function manages reception of line coding parameters (baudrate...).
void cdc_set_line_coding (void)
 cdc_set_line_coding.This function manages reception of line coding parameters (baudrate...).
void cdc_set_control_line_state (void)
 cdc_set_control_line_state.This function manages the SET_CONTROL_LINE_LINE_STATE CDC request.

Variables

U8 code * pbuffer
U8 data_to_transfer
S_line_coding line_coding


Detailed Description

,vuser call-back functions

Copyright (c) 2004 Atmel.

Use of this program is subject to Atmel's End User License Agreement. Please read file license.txt for copyright notice.

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

Version:
1.1 at90usb162-cdc-1_0_1
Id
usb_specific_request.c,v 1.1 2006/09/08 10:55:11 rletendu Exp
Todo:
Bug:

Definition in file usb_specific_request.c.


Function Documentation

Bool usb_user_read_request ( U8  type,
U8  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.

Parameters:
none 
Returns:
none

Definition at line 51 of file usb_specific_request.c.

References cdc_get_line_coding(), cdc_set_control_line_state(), cdc_set_line_coding(), FALSE, GET_LINE_CODING, SET_CONTROL_LINE_STATE, SET_LINE_CODING, TRUE, and Usb_read_byte.

Referenced by usb_process_request().

00052 {
00053 U8  descriptor_type ;
00054 U8  string_type     ;
00055 
00056    string_type     = Usb_read_byte();
00057    descriptor_type = Usb_read_byte();
00058    switch(request)
00059    {
00060       case GET_LINE_CODING:
00061          cdc_get_line_coding();
00062                return TRUE;
00063                break;
00064 
00065       case SET_LINE_CODING:
00066          cdc_set_line_coding();
00067                return TRUE;
00068                break;
00069 
00070       case SET_CONTROL_LINE_STATE:
00071          cdc_set_control_line_state();
00072       return TRUE;
00073       break;
00074 
00075       default:
00076          return FALSE;
00077          break;
00078 
00079    }
00080    return FALSE;
00081 }

Here is the call graph for this function:

Bool usb_user_get_descriptor ( U8  type,
U8  string 
)

usb_user_get_descriptor.This function returns the size and the pointer on a user information structure

Parameters:
none 
Returns:
none

Definition at line 93 of file usb_specific_request.c.

References FALSE.

Referenced by usb_get_descriptor().

00094 { /*
00095    switch(type)
00096    {
00097       case STRING_DESCRIPTOR:
00098          switch (string)
00099          {
00100             case LANG_ID:
00101                data_to_transfer = sizeof (usb_user_language_id);
00102                pbuffer = &(usb_user_language_id.bLength);
00103                return TRUE;
00104                break;
00105             case MAN_INDEX:
00106                data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
00107                pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
00108                return TRUE;
00109                break;
00110             case PROD_INDEX:
00111                data_to_transfer = sizeof (usb_user_product_string_descriptor);
00112                pbuffer = &(usb_user_product_string_descriptor.bLength);
00113                return TRUE;
00114                break;
00115             case SN_INDEX:
00116                data_to_transfer = sizeof (usb_user_serial_number);
00117                pbuffer = &(usb_user_serial_number.bLength);
00118                return TRUE;
00119                break;
00120             default:
00121                return FALSE;
00122          }
00123       default:
00124          return FALSE;
00125    }*/
00126 
00127    return FALSE;
00128 }

void usb_user_endpoint_init ( U8  conf_nb  ) 

usb_user_endpoint_init.This function configures the endpoints.

Parameters:
none 
Returns:
none

Definition at line 138 of file usb_specific_request.c.

References DIRECTION_IN, DIRECTION_OUT, INT_EP, NYET_ENABLED, ONE_BANK, RX_EP, SIZE_32, TX_EP, TYPE_BULK, TYPE_INTERRUPT, usb_configure_endpoint, and Usb_reset_endpoint.

Referenced by usb_set_configuration().

00139 {
00140   usb_configure_endpoint(INT_EP,      \
00141                          TYPE_INTERRUPT,     \
00142                          DIRECTION_IN,  \
00143                          SIZE_32,       \
00144                          ONE_BANK,     \
00145                          NYET_ENABLED);
00146 
00147   usb_configure_endpoint(TX_EP,      \
00148                          TYPE_BULK,  \
00149                          DIRECTION_IN,  \
00150                          SIZE_32,     \
00151                          ONE_BANK,     \
00152                          NYET_ENABLED);
00153 
00154   usb_configure_endpoint(RX_EP,      \
00155                          TYPE_BULK,     \
00156                          DIRECTION_OUT,  \
00157                          SIZE_32,       \
00158                          ONE_BANK,     \
00159                          NYET_ENABLED);
00160 
00161   Usb_reset_endpoint(INT_EP);
00162   Usb_reset_endpoint(TX_EP);
00163   Usb_reset_endpoint(RX_EP);
00164 
00165 
00166 }

void cdc_get_line_coding ( void   ) 

cdc_get_line_coding.This function manages reception of line coding parameters (baudrate...).

Parameters:
none 
Returns:
none

Definition at line 176 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, line_coding, 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().

void cdc_set_line_coding ( void   ) 

cdc_set_line_coding.This function manages reception of line coding parameters (baudrate...).

Parameters:
none 
Returns:
none

Definition at line 204 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, line_coding, LSB0, LSB1, LSB2, LSB3, Uart_set_baudrate, Usb_ack_receive_out, Usb_ack_receive_setup, Usb_read_byte, and Usb_send_control_in.

Referenced by usb_user_read_request().

00205 {
00206    Usb_ack_receive_setup();
00207    while (!(Is_usb_receive_out()));
00208    LSB0(line_coding.dwDTERate) = Usb_read_byte();
00209    LSB1(line_coding.dwDTERate) = Usb_read_byte();
00210    LSB2(line_coding.dwDTERate) = Usb_read_byte();
00211    LSB3(line_coding.dwDTERate) = Usb_read_byte();
00212    line_coding.bCharFormat = Usb_read_byte();
00213    line_coding.bParityType = Usb_read_byte();
00214    line_coding.bDataBits = Usb_read_byte();
00215    Usb_ack_receive_out();
00216 
00217    Usb_send_control_in();                // send a ZLP for STATUS phase
00218    while(!(Is_usb_read_control_enabled()));
00219 #ifdef UART_U2
00220    Uart_set_baudrate((line_coding.dwDTERate)/2);
00221 #else
00222    Uart_set_baudrate(line_coding.dwDTERate);
00223 #endif
00224 }

void cdc_set_control_line_state ( void   ) 

cdc_set_control_line_state.This function manages the SET_CONTROL_LINE_LINE_STATE CDC request.

Todo:
Manages here hardware flow control...
Parameters:
none 
Returns:
none

Definition at line 237 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().

00238 {
00239    Usb_ack_receive_setup();
00240    Usb_send_control_in();
00241    while(!(Is_usb_read_control_enabled()));
00242 
00243 }


Variable Documentation

U8 code* pbuffer

Definition at line 63 of file usb_standard_request.c.

Referenced by usb_get_descriptor().

U8 data_to_transfer

Definition at line 65 of file usb_standard_request.c.

Referenced by usb_get_descriptor().

S_line_coding line_coding

Definition at line 45 of file cdc_task.c.

Referenced by cdc_get_line_coding(), and cdc_set_line_coding().


Generated on Fri Jun 15 14:15:50 2007 for Atmel by  doxygen 1.5.1-p1