00001
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #include "config.h"
00051 #include "conf_usb.h"
00052 #include "lib_mcu/usb/usb_drv.h"
00053 #include "usb_descriptors.h"
00054 #include "modules/usb/device_chap9/usb_standard_request.h"
00055 #include "usb_specific_request.h"
00056 #if ((USB_DEVICE_SN_USE==ENABLE) && (USE_DEVICE_SN_UNIQUE==ENABLE))
00057 #include "lib_mcu/flash/flash_drv.h"
00058 #endif
00059
00060
00061
00062 #ifdef __GNUC__
00063 extern PGM_VOID_P pbuffer;
00064 #else
00065 extern U8 code *pbuffer;
00066 #endif
00067 extern U8 data_to_transfer;
00068
00069
00070
00071
00080 Bool usb_user_read_request(U8 type, U8 request)
00081 {
00082 U8 wValue_msb;
00083 U8 wValue_lsb;
00084
00085
00086 wValue_lsb = Usb_read_byte();
00087 wValue_msb = Usb_read_byte();
00088
00089
00090 if( USB_SETUP_GET_STAND_INTERFACE == type )
00091 {
00092 switch( request )
00093 {
00094 case SETUP_GET_DESCRIPTOR:
00095 switch( wValue_msb )
00096 {
00097 default:
00098
00099 break;
00100 }
00101 break;
00102 }
00103 }
00104 if( USB_SETUP_SET_CLASS_INTER == type )
00105 {
00106 switch( request )
00107 {
00108 default:
00109 break;
00110 }
00111 }
00112 if( USB_SETUP_GET_CLASS_INTER == type )
00113 {
00114 switch( request )
00115 {
00116 default:
00117 break;
00118 }
00119 }
00120 return FALSE;
00121 }
00122
00123
00128 void usb_user_endpoint_init(U8 conf_nb)
00129 {
00130 usb_configure_endpoint(EP_TEMP_IN, \
00131 TYPE_BULK, \
00132 DIRECTION_IN, \
00133 SIZE_64, \
00134 ONE_BANK, \
00135 NYET_ENABLED);
00136 usb_configure_endpoint(EP_TEMP_OUT, \
00137 TYPE_BULK, \
00138 DIRECTION_OUT, \
00139 SIZE_64, \
00140 ONE_BANK, \
00141 NYET_ENABLED);
00142 usb_configure_endpoint(EP_TEMP_INT_IN,\
00143 TYPE_BULK, \
00144 TYPE_INTERRUPT,\
00145 SIZE_64, \
00146 ONE_BANK, \
00147 NYET_ENABLED);
00148 }
00149
00150
00157 U8 usb_user_interface_get( U16 wInterface )
00158 {
00159 return 0;
00160 }
00161
00162
00168 void usb_user_interface_reset(U16 wInterface, U8 alternate_setting)
00169 {
00170
00171 if( INTERFACE_NB_TEMP == wInterface )
00172 {
00173
00174 Usb_select_endpoint(EP_TEMP_IN);
00175 Usb_disable_stall_handshake();
00176 Usb_reset_endpoint(EP_TEMP_IN);
00177 Usb_reset_data_toggle();
00178 Usb_select_endpoint(EP_TEMP_OUT);
00179 Usb_disable_stall_handshake();
00180 Usb_reset_endpoint(EP_TEMP_OUT);
00181 Usb_reset_data_toggle();
00182 }
00183 if( INTERFACE_NB_SECOND_TEMP == wInterface )
00184 {
00185
00186 Usb_select_endpoint(EP_TEMP_INT_IN);
00187 Usb_disable_stall_handshake();
00188 Usb_reset_endpoint(EP_TEMP_INT_IN);
00189 Usb_reset_data_toggle();
00190 }
00191 }
00192
00193
00201 Bool usb_user_get_descriptor(U8 type, U8 string)
00202 {
00203 switch(type)
00204 {
00205 case DESCRIPTOR_STRING:
00206 switch (string)
00207 {
00208 case LANG_ID:
00209 data_to_transfer = sizeof (usb_user_language_id);
00210 pbuffer = &(usb_user_language_id.bLength);
00211 return TRUE;
00212 break;
00213
00214 case MAN_INDEX:
00215 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
00216 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
00217 return TRUE;
00218 break;
00219
00220 case PROD_INDEX:
00221 data_to_transfer = sizeof (usb_user_product_string_descriptor);
00222 pbuffer = &(usb_user_product_string_descriptor.bLength);
00223 return TRUE;
00224 break;
00225
00226 #if (USB_DEVICE_SN_USE==ENABLE)
00227 case SN_INDEX:
00228 data_to_transfer = sizeof (usb_user_serial_number);
00229 pbuffer = &(usb_user_serial_number.bLength);
00230 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00231 f_get_serial_string=TRUE;
00232 data_to_transfer += (SN_LENGTH*4);
00233 #endif
00234 return TRUE;
00235 break;
00236 #endif
00237 }
00238 break;
00239 }
00240 return FALSE;
00241 }
00242
00243