Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

usb_user_enum.h File Reference

#include "config.h"

Go to the source code of this file.

Defines

#define HID_SET_REPORT   0x09
#define HID_SET_IDLE   0x0A
#define HID_GET_IDLE   0x02
#define HID_CONTROL_DATA_LENGTH   4
#define HID_DESCRIPTOR   0x21
#define HID_REPORT_DESCRIPTOR   0x22

Functions

Bool usb_user_read_request (U8, U8)
 usb_user_read_request(type, request);

Bool usb_user_get_descriptor (U8, U8)
 usb_user_get_descriptor.

void usb_user_endpoint_init (U8)
 usb_user_endpoint_init.


Variables

code S_usb_device_descriptor usb_dev_desc_hid
code S_usb_user_configuration_descriptor usb_conf_desc_hid_hs
code S_usb_user_configuration_descriptor usb_conf_desc_hid_fs
code S_usb_user_configuration_descriptor usb_other_conf_desc_ms
code S_usb_device_qualifier_descriptor usb_qual_desc_ms
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
code S_usb_language_id usb_user_language_id


Define Documentation

#define HID_SET_REPORT   0x09
 

Definition at line 35 of file usb_user_enum.h.

Referenced by usb_user_read_request().

#define HID_SET_IDLE   0x0A
 

Definition at line 36 of file usb_user_enum.h.

Referenced by usb_user_read_request().

#define HID_GET_IDLE   0x02
 

Definition at line 37 of file usb_user_enum.h.

Referenced by usb_user_read_request().

#define HID_CONTROL_DATA_LENGTH   4
 

Definition at line 38 of file usb_user_enum.h.

Referenced by usb_user_read_request().

#define HID_DESCRIPTOR   0x21
 

Definition at line 40 of file usb_user_enum.h.

#define HID_REPORT_DESCRIPTOR   0x22
 

Definition at line 41 of file usb_user_enum.h.

Referenced by usb_user_get_descriptor().


Function Documentation

Bool usb_user_read_request U8  type,
U8  request
 

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

Warning:
Code:xx bytes (function code length)
Parameters:
none 
Returns:
none

Definition at line 64 of file usb_user_enum.c.

References S_hid_set_control::arrived, Bool, S_hid_set_control::direction, FALSE, GET_DESCRIPTOR, HID_CONTROL_DATA_LENGTH, HID_GET_IDLE, hid_idle_duration, HID_SET_IDLE, HID_SET_REPORT, Is_usb_in_ready, Is_usb_receive_out, S_hid_set_control::length, pointer, reset_to_bootloader, SetControlBytes, TRUE, S_hid_set_control::type, U8, Usb_ack_in_ready, Usb_ack_receive_out, Usb_ack_receive_setup, usb_get_descriptor(), Usb_read_byte, Usb_send_control_in, Usb_set_DIR, and Usb_write_byte.

Referenced by usb_process_request().

00065 { 00066 U8* pointer; 00067 U8 c; 00068 00069 type = type; // FIXME (added for warnings) 00070 switch (request) 00071 { 00072 case HID_SET_REPORT: 00073 Usb_ack_receive_setup(); 00074 while(!Is_usb_receive_out() ); 00075 SetControlBytes.arrived=1; 00076 pointer = &(SetControlBytes.type); 00077 for (c=HID_CONTROL_DATA_LENGTH; c!=0; c--) 00078 { 00079 *pointer = Usb_read_byte(); 00080 pointer ++; 00081 } 00082 if (SetControlBytes.type == 0x55) 00083 { 00084 if (SetControlBytes.direction == 0xAA) 00085 { 00086 if (SetControlBytes.length == 0x55AA) 00087 { 00088 reset_to_bootloader = TRUE; 00089 } 00090 } 00091 } 00092 Usb_ack_receive_out(); 00093 Usb_send_control_in(); /* send a ZLP for STATUS phase */ 00094 while(!(Is_usb_in_ready())); 00095 Usb_ack_in_ready(); 00096 return TRUE; 00097 break; 00098 00099 case HID_SET_IDLE: 00100 ACC = Usb_read_byte(); 00101 hid_idle_duration = Usb_read_byte(); /* wValue contains the duration */ 00102 Usb_ack_receive_setup(); 00103 00104 Usb_send_control_in(); /* send a ZLP for STATUS phase */ 00105 while(!(Is_usb_in_ready())); 00106 Usb_ack_in_ready(); 00107 return TRUE; 00108 break; 00109 00110 case HID_GET_IDLE: 00111 Usb_ack_receive_setup(); 00112 Usb_set_DIR(); 00113 Usb_write_byte(hid_idle_duration); 00114 Usb_send_control_in(); /* send a ZLP for STATUS phase */ 00115 while(!(Is_usb_in_ready())); 00116 Usb_ack_in_ready(); 00117 00118 while (!(Is_usb_receive_out())); 00119 Usb_ack_receive_out(); 00120 return TRUE; 00121 break; 00122 case GET_DESCRIPTOR: 00123 if (type == 0x81) { usb_get_descriptor(); } 00124 return TRUE; 00125 break; 00126 default: 00127 return FALSE; 00128 break; 00129 } 00130 return FALSE; 00131 }

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

Warning:
Code:xx bytes (function code length)
Parameters:
none 
Returns:
none

Definition at line 145 of file usb_user_enum.c.

References S_usb_hid_descriptor::bLength, S_usb_serial_number::bLength, S_usb_product_string_descriptor::bLength, S_usb_manufacturer_string_descriptor::bLength, S_usb_language_id::bLength, Bool, data_to_transfer, FALSE, S_usb_user_configuration_descriptor::hid, HID_DESCRIPTOR, hid_report, HID_REPORT_DESCRIPTOR, pbuffer, SIZE_OF_REPORT, STRING_DESCRIPTOR, TRUE, usb_conf_desc_hid_fs, usb_user_language_id, usb_user_manufacturer_string_descriptor, usb_user_product_string_descriptor, and usb_user_serial_number.

Referenced by usb_get_descriptor().

00146 { 00147 switch (type) 00148 { 00149 case STRING_DESCRIPTOR: 00150 if (string == 0) 00151 { 00152 data_to_transfer = sizeof (usb_user_language_id); 00153 pbuffer = &usb_user_language_id.bLength; 00154 return TRUE; 00155 } 00156 else 00157 if (string == 1) 00158 { 00159 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor); 00160 pbuffer = &usb_user_manufacturer_string_descriptor.bLength; 00161 return TRUE; 00162 } 00163 else 00164 if (string == 2) 00165 { 00166 data_to_transfer = sizeof (usb_user_product_string_descriptor); 00167 pbuffer = &usb_user_product_string_descriptor.bLength; 00168 return TRUE; 00169 } 00170 else 00171 if (string == 3) 00172 { 00173 data_to_transfer = sizeof (usb_user_serial_number); 00174 pbuffer = &usb_user_serial_number.bLength; 00175 return TRUE; 00176 } 00177 else 00178 { 00179 return FALSE; 00180 } 00181 break; 00182 case HID_REPORT_DESCRIPTOR: 00183 data_to_transfer = SIZE_OF_REPORT; 00184 pbuffer = hid_report; 00185 return TRUE; 00186 break; 00187 case HID_DESCRIPTOR: 00188 data_to_transfer = sizeof(usb_conf_desc_hid_fs.hid); 00189 pbuffer = &(usb_conf_desc_hid_fs.hid.bLength); 00190 return TRUE; 00191 break; 00192 default: 00193 return FALSE; 00194 break; 00195 } 00196 }

void usb_user_endpoint_init U8  conf_nb  ) 
 

usb_user_endpoint_init.

This function configures the endpoints.

Warning:
Code:xx bytes (function code length)
Parameters:
none 
Returns:
none

Definition at line 209 of file usb_user_enum.c.

References DIRECTION_IN, DIRECTION_OUT, EP_HID_IN, EP_HID_OUT, ep_size, Is_usb_high_speed, NYET_ENABLED, send_free, SIZE_512, SIZE_64, TWO_BANKS, TYPE_INTERRUPT, U8, and usb_configure_endpoint.

Referenced by usb_set_configuration().

00210 { 00211 U8 ep_size; 00212 00213 conf_nb = conf_nb; // FIXME (added for warnings) 00214 00215 if(Is_usb_high_speed()) { ep_size = SIZE_512; } else { ep_size = SIZE_64; } 00216 00217 usb_configure_endpoint(EP_HID_IN, \ 00218 TYPE_INTERRUPT,\ 00219 DIRECTION_IN, \ 00220 ep_size, \ 00221 TWO_BANKS, \ 00222 NYET_ENABLED); 00223 usb_configure_endpoint(EP_HID_OUT, \ 00224 TYPE_INTERRUPT,\ 00225 DIRECTION_OUT, \ 00226 ep_size, \ 00227 TWO_BANKS, \ 00228 NYET_ENABLED); 00229 send_free = 1; 00230 }


Variable Documentation

code S_usb_device_descriptor usb_dev_desc_hid
 

Definition at line 25 of file usb_user_enum.h.

code S_usb_user_configuration_descriptor usb_conf_desc_hid_hs
 

Definition at line 26 of file usb_user_enum.h.

code S_usb_user_configuration_descriptor usb_conf_desc_hid_fs
 

Definition at line 27 of file usb_user_enum.h.

Referenced by usb_user_get_descriptor().

code S_usb_user_configuration_descriptor usb_other_conf_desc_ms
 

Definition at line 28 of file usb_user_enum.h.

code S_usb_device_qualifier_descriptor usb_qual_desc_ms
 

Definition at line 29 of file usb_user_enum.h.

code S_usb_manufacturer_string_descriptor usb_user_manufacturer_string_descriptor
 

Definition at line 30 of file usb_user_enum.h.

Referenced by usb_user_get_descriptor().

code S_usb_product_string_descriptor usb_user_product_string_descriptor
 

Definition at line 31 of file usb_user_enum.h.

Referenced by usb_user_get_descriptor().

code S_usb_serial_number usb_user_serial_number
 

Definition at line 32 of file usb_user_enum.h.

Referenced by usb_user_get_descriptor().

code S_usb_language_id usb_user_language_id
 

Definition at line 33 of file usb_user_enum.h.

Referenced by usb_user_get_descriptor().


Generated on Mon Apr 10 17:23:31 2006 for Atmel by doxygen 1.3.7