reqcode.c
上传用户:ids068
上传日期:2013-04-04
资源大小:639k
文件大小:17k
源码类别:

USB编程

开发平台:

C/C++

  1. /****************************************Copyright (c)**************************************************
  2. **                               广州周立功单片机发展有限公司
  3. **                                     研    究    所
  4. **                                 http://www.zlgmcu.com
  5. **--------------当前版本修订------------------------------------------------------------------------------
  6. ** 修改人: 刘英斌
  7. ** 日 期:2003-03-13
  8. ** 描 述:ISP1581 V1.0
  9. **------------------------------------------------------------------------------------------------------
  10. ********************************************************************************************************/
  11. #include "standard.h"
  12. #include "Usb.h"
  13. #include "kernel.h"
  14. //***********************************************************************
  15. //*                *
  16. //*                      Variable Definition        *
  17. //*                *
  18. //***********************************************************************
  19. //***********************************************************************
  20. //*                *
  21. //*                      Routine Definition    *
  22. //*                *
  23. //***********************************************************************
  24. //***********************************************************************
  25. //*                     *
  26. //* Routine  :  Standard Device Descriptor                        *
  27. //* Input :  None                        *
  28. //* Output   :  None                                    *
  29. //* Function :  None                                          *
  30. //*                *
  31. //***********************************************************************
  32. DEVICE_DESCRIPTOR code   Standard_Device_Descriptor[] =
  33. {
  34.     
  35.     sizeof(DEVICE_DESCRIPTOR), /*        length  */
  36. 0x01,     /*  1.    bDescriptorType            */
  37. SWAP(0x0110),    /*  2.-3. Version 1.1 USB spec Word  */
  38. 0x00,       /*  4.    Class                      */
  39. 0x00,     /*  5.    bDeviceSubClass            */
  40. 0x00,     /*  6.    bDeviceProtocol            */
  41. 0x40, /*  7.    bMaxPacketSize0            */
  42. SWAP(0x04CC), /* 8.-9.  idVendor                   */
  43. SWAP(0x1B49),    /* a.-b.  idProduct for no Filter Driver      */
  44. SWAP(0x0000),    /* c.-d.  bcdDevice                  */
  45. 0x01,    /* e.    iManufacturer             */
  46. 0x02,     /* f.    iProduct      */
  47. 0x00,     /* 10.    iSerialNumber              */
  48. 0x01      /* 11.    bNumConfigurations  */
  49. };
  50. DEVICE_DESCRIPTOR code  HS_Device_Descriptor[] =
  51. {
  52.     
  53.     sizeof(DEVICE_DESCRIPTOR), /*        length  */
  54. 0x01,     /*  1.    bDescriptorType            */
  55. SWAP(0x0200),    /*  2.-3. Version 2.0 USB spec Word  */
  56. 0x00,       /*  4.    Class                      */
  57. 0x00,     /*  5.    bDeviceSubClass            */
  58. 0x00,     /*  6.    bDeviceProtocol            */
  59. 0x40, /*  7.    bMaxPacketSize0            */
  60. SWAP(0x04CC), /* 8.-9.  idVendor                   */
  61. SWAP(0x1B49),    /* a.-b.  idProduct                  */
  62. SWAP(0x0000),    /* c.-d.  bcdDevice                  */
  63. 0x01,    /* e.    iManufacturer             */
  64. 0x02,     /* f.    iProduct      */
  65. 0x00,     /* 10.    iSerialNumber              */
  66. 0x01      /* 11.    bNumConfigurations  */
  67. };
  68. //***********************************************************************
  69. //*                     *
  70. //* Routine  :  HS Device Qualifier                               *
  71. //* Input :  None                        *
  72. //* Output :  None                                    *
  73. //* Function :  None                                          *
  74. //*                *
  75. //***********************************************************************
  76. HS_DEVICE_QUALIFIER code HS_Device_Qualifier[] =
  77. {
  78. sizeof(HS_DEVICE_QUALIFIER), //length of HS Device Descriptor
  79. 0x06, //HS Device Qualifier Type
  80. SWAP(0x0200), // USB 2.0 version
  81. 0x00, //Device class
  82. 0x00, //Device SubClass
  83. 0x00,  //Device Protocol Code
  84. 0x40, //Maximum Packet SIze for other speed
  85. 0x01, //Number of Other speed configurations
  86. 0x00 //Reserved
  87. };
  88. //***********************************************************************
  89. //*                     *
  90. //* Routine  :  Standard Configuration Descriptor                 *
  91. //* Input :  None                        *
  92. //* Output   :  None                                    *
  93. //* Function :  None                                          *
  94. //*                *
  95. //***********************************************************************
  96. CONFIGURATION_DESCRIPTOR code Standard_Config_Descriptor[] =
  97. {
  98. sizeof(CONFIGURATION_DESCRIPTOR), //Length of the configuration Descriptor
  99. 0x02,   //Configuration Descriptor
  100. SWAP(CONFIG_LENGTH),      //Total length of the configurations,interface and class/endpoint
  101. 0x01,   //No. of interface supported
  102. 0x01,   //Configuration Value
  103. 0x00,   //Index of string descriptor
  104. 0xC0,   //Configurations Characteristic
  105. 0x32   //Maximun Power
  106. };
  107. //***********************************************************************
  108. //*                     *
  109. //* Routine  :  Other speed Configuration Descriptor              *
  110. //* Input :  None                        *
  111. //* Output :  None                                    *
  112. //* Function :  None                                          *
  113. //*                *
  114. //***********************************************************************
  115. OTHER_SPEED_CONFIG_DESCRIPTOR code Other_Speed_Config_Descriptor[] =
  116. {
  117. sizeof(OTHER_SPEED_CONFIG_DESCRIPTOR), //length of other speed configuration descriptor
  118. 0x07, //Other speed configuration Type
  119. SWAP(CONFIG_LENGTH), //Total length
  120. 0x01, //No of interface supported
  121. 0x01, //Configuration Value
  122. 0x00, //Index of string descriptor
  123. 0xC0, //Configurations Characteristic
  124. 0x32 //Maximun Power
  125. };
  126. //***********************************************************************
  127. //*                     *
  128. //* Routine  :  Standard Interface Descriptor                     *
  129. //* Input :  None                        *
  130. //* Output :  None                                    *
  131. //* Function :  None                                          *
  132. //*                *
  133. //***********************************************************************
  134. INTERFACE_DESCRIPTOR code Bulk_Interface_Descriptor[] =
  135. {
  136. sizeof(INTERFACE_DESCRIPTOR), //Length of standard interface descriptor
  137. 0x04, //Standard Interface Type
  138. 0x00, //No of Interface
  139. 0x00, //Alternate Setting Selector
  140. 0x04, //No of Endpoints
  141. 0x00, //Interface Class
  142. 0x00, //ATAPI Interface Sub Class
  143. 0x00, //Bulk Only Interface Protocol
  144. 0x00 //Index of interface string desriptor
  145. };
  146. INTERFACE_DESCRIPTOR code HS_Bulk_Interface_Descriptor[] =
  147. {
  148. sizeof(INTERFACE_DESCRIPTOR), //Length of standard interface descriptor
  149. 0x04, //Standard Interface Type
  150. 0x00, //No of Interface
  151. 0x00, //Alternate Setting Selector
  152. 0x04, //No of Endpoints
  153. 0x00, //Interface Class
  154. 0x00, //ATAPI Interface Sub Class
  155. 0x00, //Bulk Only Interface Protocol
  156. 0x00 //Index of interface string desriptor
  157. };
  158. //***********************************************************************
  159. //*                     *
  160. //* Routine  :  Standard Endpoint Descriptor                     *
  161. //* Input :  None                        *
  162. //* Output :  None                                    *
  163. //* Function :  None                                          *
  164. //*                *
  165. //***********************************************************************
  166. ENDPOINT_DESCRIPTOR code Bulk_Out_Descriptor[] =
  167. {
  168. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  169. 0x05, //Standard Endpoint Type
  170. 0x02,  //Set Bulk endpoint to 1 for ATAPI mode
  171. 0x02, //Endpoint Characteristic
  172. SWAP(0x0040), //Endpoint Max Packet Size
  173. 0x00 //Interval for Polling Endpoint for data transfer
  174. };
  175. ENDPOINT_DESCRIPTOR code Bulk_In_Descriptor[] =
  176. {
  177. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  178. 0x05, //Standard Endpoint Type
  179. 0x82,  //Set Bulk endpoint to 1 for ATAPI mode
  180. 0x02, //Endpoint Characteristic
  181. SWAP(0x0040), //Endpoint Max Packet Size
  182. 0x00 //Interval for Polling Endpoint for data transfer
  183. };
  184. ENDPOINT_DESCRIPTOR code HS_Bulk_Out_Descriptor[] =
  185. {
  186. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  187. 0x05, //Standard Endpoint Type
  188. 0x02,  //Set Bulk endpoint to 1 for ATAPI mode
  189. 0x02, //Endpoint Characteristic
  190. SWAP(0x0200), //Endpoint Max Packet Size
  191. 0x00 //Interval for Polling Endpoint for data transfer
  192. };
  193. ENDPOINT_DESCRIPTOR code HS_Bulk_In_Descriptor[] =
  194. {
  195. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  196. 0x05, //Standard Endpoint Type
  197. 0x82,  //Set Bulk endpoint to 1 for ATAPI mode
  198. 0x02, //Endpoint Characteristic
  199. SWAP(0x0200), //Endpoint Max Packet Size
  200. 0x00 //Interval for Polling Endpoint for data transfer
  201. };
  202. ENDPOINT_DESCRIPTOR code Int_Out_Descriptor[] =
  203. {
  204. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  205. 0x05, //Standard Endpoint Type
  206. 0x01,  //Set Int endpoint to 2 for ATAPI mode
  207. 0x03, //Endpoint Characteristic
  208. SWAP(0x0040), //Endpoint Max Packet Size
  209. 0x01 //Interval for Polling Endpoint for data transfer
  210. };
  211. ENDPOINT_DESCRIPTOR code Int_In_Descriptor[] =
  212. {
  213. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  214. 0x05, //Standard Endpoint Type
  215. 0x81,  //Set Int endpoint to 2 for ATAPI mode
  216. 0x03,   //Endpoint Characteristic
  217. SWAP(0x0040), //Endpoint Max Packet Size
  218. 0x01 //Interval for Polling Endpoint for data transfer
  219. };
  220. ENDPOINT_DESCRIPTOR code HS_Int_Out_Descriptor[] =
  221. {
  222. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  223. 0x05, //Standard Endpoint Type
  224. 0x01,  //Set Int endpoint to 2 for ATAPI mode
  225. 0x03, //Endpoint Characteristic
  226. SWAP(0x0040), //Endpoint Max Packet Size
  227. 0x01 //Interval for Polling Endpoint for data transfer
  228. };
  229. ENDPOINT_DESCRIPTOR code HS_Int_In_Descriptor[] =
  230. {
  231. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  232. 0x05, //Standard Endpoint Type
  233. 0x81,  //Set Int endpoint to 2 for ATAPI mode
  234. 0x03,   //Endpoint Characteristic
  235. SWAP(0x0040), //Endpoint Max Packet Size
  236. 0x01 //Interval for Polling Endpoint for data transfer
  237. };
  238. //***********************************************************************
  239. //*                     *
  240. //* Routine  :  Standard Interface Descriptor                     *
  241. //* Input :  None                        *
  242. //* Output :  None                                    *
  243. //* Function :  None                                          *
  244. //*                *
  245. //***********************************************************************
  246. INTERFACE_DESCRIPTOR code Iso_Interface_Descriptor[] =
  247. {
  248. sizeof(INTERFACE_DESCRIPTOR), //Length of standard interface descriptor
  249. 0x04, //Standard Interface Type
  250. 0x00, //No of Interface
  251. 0x01, //Alternate Setting Selector
  252. 0x02, //No of Endpoints
  253. 0x00, //Interface Class
  254. 0x00, //Interface Sub Class
  255. 0x00, //Interface Protocol
  256. 0x00 //Index of interface string desriptor
  257. };
  258. ENDPOINT_DESCRIPTOR code Iso_Out_Descriptor[] =
  259. {
  260. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  261. 0x05, //Standard Endpoint Type
  262. 0x03,  //Enndpoint Address
  263. 0x01, //Endpoint Characteristic
  264. SWAP(0x0040), //Endpoint Max Packet Size
  265. 0x01 //Interval for Polling Endpoint for data transfer
  266. };
  267. ENDPOINT_DESCRIPTOR code Iso_In_Descriptor[] =
  268. {
  269. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  270. 0x05, //Standard Endpoint Type
  271. 0x83,  //Enndpoint Address
  272. 0x01, //Endpoint Characteristic
  273. SWAP(0x0040), //Endpoint Max Packet Size
  274. 0x01 //Interval for Polling Endpoint for data transfer
  275. };
  276. ENDPOINT_DESCRIPTOR code Iso_Out_Zero_Descriptor[] =
  277. {
  278. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  279. 0x05, //Standard Endpoint Type
  280. 0x03,  //Enndpoint Address
  281. 0x01, //Endpoint Characteristic
  282. SWAP(0x0000), //Endpoint Max Packet Size
  283. 0x01 //Interval for Polling Endpoint for data transfer
  284. };
  285. ENDPOINT_DESCRIPTOR code Iso_In_Zero_Descriptor[] =
  286. {
  287. sizeof(ENDPOINT_DESCRIPTOR), //Length of Standard Endpoint Descriptor
  288. 0x05, //Standard Endpoint Type
  289. 0x83,  //Enndpoint Address
  290. 0x01, //Endpoint Characteristic
  291. SWAP(0x0000), //Endpoint Max Packet Size
  292. 0x01 //Interval for Polling Endpoint for data transfer
  293. };
  294. //***********************************************************************
  295. //*                     *
  296. //* Routine  :  Standard String Descriptor                        *
  297. //* Input :  None                        *
  298. //* Output :  None                                    *
  299. //* Function :  None                                          *
  300. //*                *
  301. //***********************************************************************
  302. STRING_DESCRIPTOR code Standard_Product_String[] =      
  303. {  0x30,    /* length                   */
  304. 0x03,     /* descriptor type = string */
  305. 'P' , 0x00,
  306. 'h' , 0x00,
  307. 'i' , 0x00,
  308. 'l' , 0x00,
  309. 'i' , 0x00,
  310. 'p' , 0x00,
  311. 's' , 0x00,
  312. ' ' , 0x00,
  313. 'I' , 0x00,
  314. 'S' , 0x00,
  315. 'P' , 0x00,
  316. '1' , 0x00,
  317. '5' , 0x00,
  318. '8' , 0x00,
  319. '1' , 0x00,
  320. ' ' , 0x00,
  321. 'V' , 0x00,
  322. 'e' , 0x00,
  323. 'r' , 0x00,
  324. ' ' , 0x00,
  325. '1' , 0x00,
  326. '.' , 0x00,
  327. '0' , 0x00
  328. };
  329. //***********************************************************************
  330. //*                     *
  331. //* Routine  :  Standard String Descriptor                        *
  332. //* Input :  None                        *
  333. //* Output :  None                                    *
  334. //* Function :  None                                          *
  335. //*                *
  336. //***********************************************************************
  337. STRING_DESCRIPTOR code Standard_Manufacturer_String[] =      
  338. {  0x1C,    /* length                   */
  339. 0x03,     /* descriptor type = string */
  340. 'P' , 0x00,
  341. 'h' , 0x00,
  342. 'i' , 0x00,
  343. 'l' , 0x00,
  344. 'i' , 0x00,
  345. 'p' , 0x00,
  346. ' ' , 0x00,
  347. '-' , 0x00,
  348. ' ' , 0x00,
  349. 'A' , 0x00,
  350. 'P' , 0x00,
  351. 'I' , 0x00,
  352. 'C' , 0x00
  353. };
  354. //***********************************************************************
  355. //*                     *
  356. //* Routine  :  Standard String Identifications                   *
  357. //* Input :  None                        *
  358. //* Output :  None                                    *
  359. //* Function :  None                                          *
  360. //*                *
  361. //***********************************************************************
  362. STRING_ID  code Standard_String_ID[] = 
  363. {
  364. 0x04,
  365. 0x03,
  366. 0x09,
  367. 0x04
  368. };  
  369. //***********************************************************************
  370. //*                     *
  371. //* Routine  :  Standard Mass Storage Identifications                 *
  372. //* Input :  None                        *
  373. //* Output :  None                                    *
  374. //* Function :  None                                          *
  375. //*                *
  376. //***********************************************************************
  377. UC code  Test_Packet[] =
  378. {
  379. // 0x00, 0x00,
  380. // 0x00, 0x80, // syn pattern
  381. 0xc3,
  382. 0x00, 0x00,
  383. 0x00, 0x00,
  384. 0x00, 0x00,
  385. 0x00, 0x00,
  386. 0x00, 0xaa,
  387. 0xaa, 0xaa,
  388. 0xaa, 0xaa,
  389. 0xaa, 0xaa,
  390. 0xaa, 0xee,  //aa*4
  391. 0xee, 0xee,
  392. 0xee, 0xee,
  393. 0xee, 0xee,
  394. 0xee, 0xfe,  //ee*4
  395. 0xff, 0xff,
  396. 0xff, 0xff,
  397. 0xff, 0xff,
  398. 0xff, 0xff,
  399. 0xff, 0xff,  //FF*6
  400. 0xff, 0x7f,
  401. 0xbf, 0xdf,
  402. 0xef, 0xf7,
  403. 0xfb, 0xfd,
  404. 0xfc, 0x7e,
  405. 0xbf, 0xdf,
  406. 0xef, 0xf7,
  407. 0xfb, 0xfd,
  408. 0x7e,
  409. 0xb6, 0xce  // crc
  410. // 0xff, 0xf7
  411. };