usb_specific_request.c File Reference


Detailed Description

Processing of USB device specific enumeration requests.

This file contains the specific request decoding for enumeration process.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file usb_specific_request.c.

#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "usb_specific_request.h"

Go to the source code of this file.

Functions

static void hid_get_descriptor (U8 size_of_report, const U8 *p_usb_hid_report)
 This function manages the HID Get_Descriptor request.
void usb_hid_get_idle (U8 u8_report_id)
 This function manages hid get idle request.
void usb_hid_set_idle (U8 u8_report_id, U8 u8_duration)
 This function manages hid set idle request.
void usb_user_endpoint_init (U8 conf_nb)
 This function configures the endpoints of the device application.
Bool usb_user_get_descriptor (U8 type, U8 string)
 This function returns the size and the pointer on a user information structure.
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.

Variables

U16 data_to_transfer
U8 g_u8_report_rate = 0
const void * pbuffer
volatile U8 usb_hid_report_mouse []


Function Documentation

static void hid_get_descriptor ( U8  size_of_report,
const U8 *  p_usb_hid_report 
) [static]

This function manages the HID Get_Descriptor request.

< clear the setup received flag

< zero length packet condition

< send only requested number of data bytes

< Send data until necessary

Definition at line 129 of file usb_specific_request.c.

References data_to_transfer, EP_CONTROL_LENGTH, and pbuffer.

Referenced by usb_user_read_request().

00130 {
00131   Bool  zlp;
00132   U16   wIndex;
00133   U16   wLength;
00134 
00135   zlp = FALSE;                                              /* no zero length packet */
00136 
00137   data_to_transfer = size_of_report;
00138   pbuffer          = p_usb_hid_report;
00139 
00140   wIndex = Usb_read_endpoint_data(EP_CONTROL, 16);
00141   wIndex = usb_format_usb_to_mcu_data(16, wIndex);
00142   wLength = Usb_read_endpoint_data(EP_CONTROL, 16);
00143   wLength = usb_format_usb_to_mcu_data(16, wLength);
00144   Usb_ack_setup_received_free();                          
00145 
00146   if (wLength > data_to_transfer)
00147   {
00148     zlp = !(data_to_transfer % EP_CONTROL_LENGTH);  
00149   }
00150   else
00151   {
00152     data_to_transfer = wLength; 
00153   }
00154 
00155   Usb_ack_nak_out(EP_CONTROL);
00156 
00157   while (data_to_transfer && (!Is_usb_nak_out(EP_CONTROL)))
00158   {
00159     while( !Is_usb_control_in_ready() && !Is_usb_nak_out(EP_CONTROL) );
00160 
00161     if( Is_usb_nak_out(EP_CONTROL) )
00162        break;    // don't clear the flag now, it will be cleared after
00163 
00164     Usb_reset_endpoint_fifo_access(EP_CONTROL);
00165     data_to_transfer = usb_write_ep_txpacket(EP_CONTROL, pbuffer,
00166                                              data_to_transfer, &pbuffer);
00167     if( Is_usb_nak_out(EP_CONTROL) )
00168        break;
00169     else
00170        Usb_ack_control_in_ready_send();  
00171   }
00172 
00173   if ( zlp && (!Is_usb_nak_out(EP_CONTROL)) )
00174   {
00175     while (!Is_usb_control_in_ready());
00176     Usb_ack_control_in_ready_send();
00177   }
00178 
00179   while (!(Is_usb_nak_out(EP_CONTROL)));
00180   Usb_ack_nak_out(EP_CONTROL);
00181   while (!Is_usb_control_out_received());
00182   Usb_ack_control_out_received_free();
00183 }

void usb_hid_get_idle ( U8  u8_report_id  ) 

This function manages hid get idle request.

Parameters:
u8_report_id 0 the idle rate applies to all input reports, else only applies to the Report ID

Definition at line 106 of file usb_specific_request.c.

References g_u8_report_rate, and INTERFACE_NB_MOUSE.

Referenced by usb_user_read_request().

00107 {
00108    U16 wLength;
00109    U16 wInterface;
00110 
00111    // Get interface number to put in idle mode
00112    wInterface=Usb_read_endpoint_data(EP_CONTROL, 16);
00113    wLength   =Usb_read_endpoint_data(EP_CONTROL, 16);
00114    Usb_ack_setup_received_free();
00115    
00116    if( (wLength != 0) && (wInterface == INTERFACE_NB_MOUSE) )
00117    {
00118       Usb_write_endpoint_data(EP_CONTROL, 8, g_u8_report_rate);
00119       Usb_ack_control_in_ready_send();
00120    }
00121    
00122    while (!Is_usb_control_out_received());
00123    Usb_ack_control_out_received_free();
00124 }

void usb_hid_set_idle ( U8  u8_report_id,
U8  u8_duration 
)

This function manages hid set idle request.

Parameters:
u8_report_id 0 the idle rate applies to all input reports, else only applies to the Report ID
u8_duration When the upper byte of wValue is 0 (zero), the duration is indefinite else from 0.004 to 1.020 seconds

Definition at line 86 of file usb_specific_request.c.

References g_u8_report_rate, and INTERFACE_NB_MOUSE.

Referenced by usb_user_read_request().

00087 {
00088    U16 wInterface;
00089    
00090    // Get interface number to put in idle mode
00091    wInterface=Usb_read_endpoint_data(EP_CONTROL, 16);
00092    Usb_ack_setup_received_free();
00093   
00094    if( wInterface == INTERFACE_NB_MOUSE )
00095      g_u8_report_rate = u8_duration;
00096    
00097    Usb_ack_control_in_ready_send();
00098    while (!Is_usb_control_in_ready());
00099 }


Variable Documentation

Definition at line 70 of file usb_specific_request.c.

Referenced by usb_hid_get_idle(), and usb_hid_set_idle().

const void* pbuffer

volatile U8 usb_hid_report_mouse[]


Generated on Fri Feb 19 02:33:00 2010 for AVR32 - USB HID FreeRTOS Example by  doxygen 1.5.5