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 #include "config.h"
00048 #include "conf_usb.h"
00049 #include "lib_mcu/usb/usb_drv.h"
00050 #include "usb_descriptors.h"
00051 #include "modules/usb/device_chap9/usb_standard_request.h"
00052 #include "usb_specific_request.h"
00053 #if ((USB_DEVICE_SN_USE==ENABLE) && (USE_DEVICE_SN_UNIQUE==ENABLE))
00054 #include "lib_mcu/flash/flash_drv.h"
00055 #endif
00056
00057
00058
00059 #ifdef __GNUC__
00060 extern PGM_VOID_P pbuffer;
00061 #else
00062 extern U8 code *pbuffer;
00063 #endif
00064 extern U8 data_to_transfer;
00065
00066
00067
00068
00077 Bool usb_user_read_request(U8 type, U8 request)
00078 {
00079 U8 wValue_msb;
00080 U8 wValue_lsb;
00081
00082
00083 wValue_lsb = Usb_read_byte();
00084 wValue_msb = Usb_read_byte();
00085
00086
00087 if( USB_SETUP_GET_STAND_INTERFACE == type )
00088 {
00089 switch( request )
00090 {
00091 case SETUP_GET_DESCRIPTOR:
00092 switch( wValue_msb )
00093 {
00094 default:
00095
00096 break;
00097 }
00098 break;
00099 }
00100 }
00101 if( USB_SETUP_SET_CLASS_INTER == type )
00102 {
00103 switch( request )
00104 {
00105 default:
00106 break;
00107 }
00108 }
00109 if( USB_SETUP_GET_CLASS_INTER == type )
00110 {
00111 switch( request )
00112 {
00113 default:
00114 break;
00115 }
00116 }
00117 return FALSE;
00118 }
00119
00120
00125 void usb_user_endpoint_init(U8 conf_nb)
00126 {
00127 usb_configure_endpoint(EP_TEMP_IN, \
00128 TYPE_BULK, \
00129 DIRECTION_IN, \
00130 SIZE_64, \
00131 ONE_BANK, \
00132 NYET_ENABLED);
00133 usb_configure_endpoint(EP_TEMP_OUT, \
00134 TYPE_BULK, \
00135 DIRECTION_OUT, \
00136 SIZE_64, \
00137 ONE_BANK, \
00138 NYET_ENABLED);
00139 usb_configure_endpoint(EP_TEMP_INT_IN,\
00140 TYPE_BULK, \
00141 TYPE_INTERRUPT,\
00142 SIZE_64, \
00143 ONE_BANK, \
00144 NYET_ENABLED);
00145 }
00146
00147
00154 U8 usb_user_interface_get( U16 wInterface )
00155 {
00156 return 0;
00157 }
00158
00159
00165 void usb_user_interface_reset(U16 wInterface, U8 alternate_setting)
00166 {
00167
00168 if( INTERFACE_NB_TEMP == wInterface )
00169 {
00170
00171 Usb_select_endpoint(EP_TEMP_IN);
00172 Usb_disable_stall_handshake();
00173 Usb_reset_endpoint(EP_TEMP_IN);
00174 Usb_reset_data_toggle();
00175 Usb_select_endpoint(EP_TEMP_OUT);
00176 Usb_disable_stall_handshake();
00177 Usb_reset_endpoint(EP_TEMP_OUT);
00178 Usb_reset_data_toggle();
00179 }
00180 if( INTERFACE_NB_SECOND_TEMP == wInterface )
00181 {
00182
00183 Usb_select_endpoint(EP_TEMP_INT_IN);
00184 Usb_disable_stall_handshake();
00185 Usb_reset_endpoint(EP_TEMP_INT_IN);
00186 Usb_reset_data_toggle();
00187 }
00188 }
00189
00190
00198 Bool usb_user_get_descriptor(U8 type, U8 string)
00199 {
00200 switch(type)
00201 {
00202 case DESCRIPTOR_STRING:
00203 switch (string)
00204 {
00205 case LANG_ID:
00206 data_to_transfer = sizeof (usb_user_language_id);
00207 pbuffer = &(usb_user_language_id.bLength);
00208 return TRUE;
00209 break;
00210
00211 case MAN_INDEX:
00212 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
00213 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
00214 return TRUE;
00215 break;
00216
00217 case PROD_INDEX:
00218 data_to_transfer = sizeof (usb_user_product_string_descriptor);
00219 pbuffer = &(usb_user_product_string_descriptor.bLength);
00220 return TRUE;
00221 break;
00222
00223 #if (USB_DEVICE_SN_USE==ENABLE)
00224 case SN_INDEX:
00225 data_to_transfer = sizeof (usb_user_serial_number);
00226 pbuffer = &(usb_user_serial_number.bLength);
00227 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00228 f_get_serial_string=TRUE;
00229 data_to_transfer += (SN_LENGTH*4);
00230 #endif
00231 return TRUE;
00232 break;
00233 #endif
00234 }
00235 break;
00236 }
00237 return FALSE;
00238 }
00239
00240