{"id":263570,"date":"2015-08-14T13:38:02","date_gmt":"2015-08-14T09:38:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=263570"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=263570","title":{"rendered":"\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 USB \u0441\u0442\u0435\u043a\u043e\u043c nRF24LU1+. \u0427\u0430\u0441\u0442\u044c 2"},"content":{"rendered":"<p>     \t\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435, \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c <a href=\"http:\/\/geektimes.ru\/post\/260142\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<br \/>  \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 USB. \u0412\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f USBIRQ \u0438 USBWU<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/703\/6b2\/dd7\/7036b2dd75044ad7b37b8c1901bec6e4.PNG\"\/><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f USB<\/h4>\n<p>  \u041d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0434\u0430\u0442\u0430\u0448\u0438\u0442\u0435. \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c endpoint 0-2, \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u0443\u0444\u0435\u0440\u044b \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. (Endpoint 2 \u0438 3 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 double buffer \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0445\u043e\u0441\u0442\u0443)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f USB<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">void usb_init(void) { \t\/\/ Setup state information \tusb_state = DEFAULT; \tusb_bm_state = 0;  \t\/\/ Setconfig configuration information \tusb_current_config = 0; \tusb_current_alt_interface = 0; \t \t\/\/ Disconnect from USB-bus since we are in this routine from a power on and not a soft reset:  \tusbcs |= 0x08; \tdelay_ms(50); \tusbcs &= ~0x08;  \t\/*intterrupt enable uresie,suspie,sutokie,sudavie *\/ \tusbien = 0x1d;  \t\/*Endpoint 0 to 5 IN interrupt enables (in_ien)*\/ \tin_ien = 0x01; \t\/*Endpoints 0 to 5 IN interrupt request register (in_irq)  - clear interrupt*\/ \tin_irq = 0x1f; \t\/*Endpoint 0 to 5 OUT interrupt enables (out_ien)*\/ \tout_ien = 0x01; \t\/*Endpoints 0 to 5 OUT interrupt request register (out_irq) - clear in interrupt*\/ \tout_irq = 0x1f;  \t\/\/ Setup the USB RAM with some OK default values: \tbout1addr = MAX_PACKET_SIZE_EP0\/2; \tbout2addr = MAX_PACKET_SIZE_EP0\/2 + USB_EP1_SIZE\/2; \tbout3addr = MAX_PACKET_SIZE_EP0\/2 + 2*USB_EP1_SIZE\/2; \tbout4addr = MAX_PACKET_SIZE_EP0\/2 + 3*USB_EP1_SIZE\/2; \tbout5addr = MAX_PACKET_SIZE_EP0\/2 + 4*USB_EP1_SIZE\/2; \tbinstaddr = 0xc0; \tbin1addr = MAX_PACKET_SIZE_EP0\/2; \tbin2addr = MAX_PACKET_SIZE_EP0\/2 + USB_EP1_SIZE\/2; \tbin3addr = MAX_PACKET_SIZE_EP0\/2 + 2*USB_EP1_SIZE\/2; \tbin4addr = MAX_PACKET_SIZE_EP0\/2 + 3*USB_EP1_SIZE\/2; \tbin5addr = MAX_PACKET_SIZE_EP0\/2 + 4*USB_EP1_SIZE\/2;  \t\/\/ Set all endpoints to not valid (except EP0IN and EP0OUT) \t\/*Endpoints 0 to 5 IN valid bits (Inbulkval)*\/ \tinbulkval = 0x01; \t\/*Endpoints 0 to 5 OUT valid bits (outbulkval)*\/ \toutbulkval = 0x01; \t\/*Isochronous IN endpoint valid bits (inisoval)*\/ \tinisoval = 0x00; \t\/*Isochronous OUT endpoint valid bits (outisoval)*\/ \toutisoval = 0x00;  \t\/* Switch ON Endpoint 1 *\/ \t \t\/*Endpoint 0 to 5 OUT interrupt enables (out_ien)* - out1ien *\/ \tin_ien |= 0x02;  \t \t\/*Endpoints 0 to 5 OUT valid bits (outbulkval)*\/ \tinbulkval |= 0x02; \t \t\/*Endpoint 0 to 5 OUT interrupt enables (out_ien)*\/ \tout_ien |= 0x02; \t \t\/*Endpoints 0 to 5 OUT valid bits (outbulkval)*\/ \toutbulkval |= 0x02; \t\/* Endpoint 0 to 5 OUT byte count registers (outxbc) ?Maybe 0xff is register clear*\/ \tout1bc = 0xff; \t \t\/* Switch ON Endpoint 2 *\/ \t \t\/*Endpoint 0 to 5 OUT interrupt enables (out_ien)* - out1ien *\/ \tin_ien |= 0x04;  \t \t\/*Endpoints 0 to 5 OUT valid bits (outbulkval)*\/ \tinbulkval |= 0x04; \t \t\/*Endpoint 0 to 5 OUT interrupt enables (out_ien)*\/ \tout_ien |= 0x04; \t \t\/*Endpoints 0 to 5 OUT valid bits (outbulkval)*\/ \toutbulkval |= 0x04; \t\/* Endpoint 0 to 5 OUT byte count registers (outxbc) ?Maybe 0xff is register clear*\/ \tout2bc = 0xff;\t\t \t \t\/* Switch ON Endpoint 3 *\/ \t \t\/*Endpoint 0 to 5 OUT interrupt enables (out_ien)* - out1ien *\/ \tin_ien |= 0x08;  \t \t\/*Endpoints 0 to 5 OUT valid bits (outbulkval)*\/ \tinbulkval |= 0x08; \t \t\/*Endpoint 0 to 5 OUT interrupt enables (out_ien)*\/ \tout_ien |= 0x08; \t \t\/*Endpoints 0 to 5 OUT valid bits (outbulkval)*\/ \toutbulkval |= 0x08; \t \t\/* Endpoint 0 to 5 OUT byte count registers (outxbc) ?Maybe 0xff is register clear*\/ \tout3bc = 0xff;\t\t \t } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u043d\u0438\u0435 USBIRQ (\u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u043b\u0430\u0433\u0438) \u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e:  <\/p>\n<pre><code class=\"cpp\">USB = 1; \/\/ USBIRQ is mapped to IEN1.4 EA = 1; \/\/ enable global interrupt  <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0438 \u0432\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f. \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0438, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">\/* USB interrupt request *\/ void usb_irq_handler(void) interrupt INTERRUPT_USB_INT  { \t\tusb_irq(); } <\/code><\/pre>\n<h4>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f USB<\/h4>\n<p>  \u042d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u0430 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f \u0437\u0434\u0435\u0441\u044c. \u041a\u0430\u043a\u043e\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 IVEC.  <\/p>\n<pre><code class=\"cpp\">void usb_irq(void) { \tuint8_t i; \tuint8_t temp_irq;  \tif (ivec == INT_USBRESET) \t{ \t\t\/*The USB interrupt request register (usbirq)  - clear USB reset interrupt request*\/ \t\tusbirq = 0x10; \t\tusb_state = DEFAULT; \t\tusb_current_config = 0; \t\tusb_current_alt_interface = 0; \t\tusb_bm_state = 0; \t} \telse \t{ \t\tswitch(ivec) \t\t{ \t\tcase INT_SUDAV: \/*Setup data valid interrupt*\/ \t\t\tusbirq = 0x01; \t\t\tisr_sudav(); \t\t\tbreak; \t\tcase INT_SOF: \/*Start of frame interrupt (sofir)*\/ \t\t\tusbirq = 0x02; \t\t\tbreak; \t\tcase INT_SUTOK: \/*Setup token interrupt*\/ \t\t\tusbirq = 0x04; \t\t\tpacketizer_data_ptr = NULL; \t\t\tpacketizer_data_size = 0; \t\t\tpacketizer_pkt_size = 0; \t\t\tbreak; \t\tcase INT_SUSPEND: \/*Suspend interrupt (suspir)*\/ \t\t\tusbirq = 0x08; \t\t\tbreak; \t\tcase INT_EP0IN: \t\t\tin_irq = 0x01; \t\t\tpacketizer_isr_ep0_in(); \t\t\tbreak; \t\tcase INT_EP0OUT: \t\t\tout_irq = 0x01; \t\t\tpacketizer_data_size = 0; \t\t\tUSB_EP0_HSNAK(); \t\t\tbreak; \t\tcase INT_EP1IN: \t\t\tin_irq = 0x02; \t\t\tint_ep1in_handler(); \t\t\tbreak; \t\tcase INT_EP1OUT: \t\t\tout_irq = 0x02;      \t\t\tout1bc = 0xff; \t\t\tbreak; \t\tcase INT_EP2IN: \t\t\tin_irq = 0x04; \t\t\tbreak; \t\tdefault: \t\t\tbreak; \t\t} \t} } <\/code><\/pre>\n<h4>\u042d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f<\/h4>\n<p>  \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0446\u0438\u0442\u0430\u0442\u043e\u0439 \u0438\u0437 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 <a href=\"http:\/\/microsin.net\/programming\/arm-working-with-usb\/usb-in-a-nutshell-part2.html\">USB in a NutShell \u2014 \u043f\u0443\u0442\u0435\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 USB<\/a>  <\/p>\n<blockquote><p>\u042d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u2013 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u043a\u0442\u0430, \u0447\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u043a \u0448\u0438\u043d\u0435 USB \u0438 \u043a\u0430\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u044d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u2013 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c\u0430\u044f \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c, <br \/>  \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438 \u0442\u0438\u043f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 (\u0438\u043b\u0438 \u0442\u043e\u0447\u0435\u043a), \u043a\u043b\u0430\u0441\u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0442. \u0434. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u044d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0438 \u0445\u043e\u0441\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u0430\u0434\u0440\u0435\u0441 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, <br \/>  \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0443\u044e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0448\u0438\u043d\u0435. [&#8230;]<br \/>  \u041e\u0431\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u044d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0434 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 Windows \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<\/p>\n<p>  1. \u0425\u043e\u0441\u0442 \u0438\u043b\u0438 \u0445\u0430\u0431 \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pull-up \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043a \u043f\u0430\u0440\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u043e\u0434\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (D+ \u0438 D-). \u0425\u043e\u0441\u0442 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 100 \u043c\u0441, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0437\u0430\u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0438\u0442\u0430\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. <br \/>  2. \u0425\u043e\u0441\u0442 \u0432\u044b\u0434\u0430\u0435\u0442 \u043d\u0430 \u0448\u0438\u043d\u0443 \u0441\u0431\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u043e\u0436\u0435\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0430\u0434\u0440\u0435\u0441. <br \/>  3. \u0425\u043e\u0441\u0442 MS Windows \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0435 64 \u0431\u0430\u0439\u0442\u0430 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 (Device Descriptor). <br \/>  4. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u0435\u043c\u0430 \u043f\u0435\u0440\u0432\u044b\u0445 8 \u0431\u0430\u0439\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0445\u043e\u0441\u0442 \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0432\u044b\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u0431\u0440\u043e\u0441 \u0448\u0438\u043d\u044b. <br \/>  5. \u0422\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0441\u0442 \u0432\u044b\u0434\u0430\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 Set Address, \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u0430\u0434\u0440\u0435\u0441\u0443\u0435\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. <br \/>  6. \u0425\u043e\u0441\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 18 \u0431\u0430\u0439\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. <br \/>  7. \u0417\u0430\u0442\u0435\u043c \u043e\u043d \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 9 \u0431\u0430\u0439\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 (Configuration Descriptor), \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u0435\u0451 \u0440\u0430\u0437\u043c\u0435\u0440. <br \/>  8. \u0425\u043e\u0441\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 255 \u0431\u0430\u0439\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. <br \/>  9. \u0425\u043e\u0441\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b (String Descriptors), \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442\u0441\u044f.  <\/p><\/blockquote>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438 WinUSB \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430:  <\/p>\n<ul>\n<li>\u041d\u0430 \u0448\u0430\u0433\u0435 9 Windows \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 0xEE. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043d\u0435\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f WinUSB.<\/li>\n<li>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 Extended Compat ID OS Descriptor.<\/li>\n<li>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u2014 Extended Properties OS Descriptor. \u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0434\u0435\u0432\u0430\u0439\u0441 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 GUID.<\/li>\n<\/ul>\n<p>  \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 <a href=\"http:\/\/searchingforbit.blogspot.ru\/2014\/05\/winusb-communication-with-stm32-round-2.html\">\u043c\u0430\u043d\u0443\u0430\u043b<\/a> \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u044d\u0442\u043e \u2014 UART \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 USB \u043d\u0430 \u0445\u043e\u0441\u0442\u0435. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 <a href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=44226\">Microsoft Message Analyzer<\/a>.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u0441\u044f \u044d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f (\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 vendor requset \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b) \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 isr_sudav() (Setup data valid interrupt).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">isr_sudav()<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">static void isr_sudav() { \tbmRequestType = setupbuf[0]; \t \t\/* Host-to-device standart request *\/ \tif((bmRequestType & 0x60 ) == 0x00) \t{ \t\tswitch(setupbuf[1]) \t\t{ \t\tcase USB_REQ_GET_DESCRIPTOR: \t\t\tusb_process_get_descriptor(); \t\t\tbreak;  \t\tcase USB_REQ_GET_STATUS: \t\t\tusb_process_get_status(); \t\t\tbreak;  \t\tcase USB_REQ_SET_ADDRESS: \t\t\tusb_state = ADDRESSED; \t\t\tusb_current_config = 0x00; \t\t\tbreak;  \t\tcase USB_REQ_GET_CONFIGURATION: \t\t\tswitch(usb_state) \t\t\t{ \t\t\tcase ADDRESSED: \t\t\t\tin0buf[0] = 0x00; \t\t\t\tin0bc = 0x01; \t\t\t\tbreak; \t\t\tcase CONFIGURED: \t\t\t\tin0buf[0] = usb_current_config; \t\t\t\tin0bc = 0x01; \t\t\t\tbreak; \t\t\tcase ATTACHED: \t\t\tcase POWERED: \t\t\tcase SUSPENDED: \t\t\tcase DEFAULT: \t\t\tdefault: \t\t\t\tUSB_EP0_STALL(); \t\t\t\tbreak; \t\t\t} \t\t\tbreak;  \t\tcase USB_REQ_SET_CONFIGURATION: \t\t\tswitch(setupbuf[2]) \t\t\t{ \t\t\tcase 0x00: \t\t\t\tusb_state = ADDRESSED; \t\t\t\tusb_current_config = 0x00; \t\t\t\tUSB_EP0_HSNAK(); \t\t\t\tbreak; \t\t\tcase 0x01: \t\t\t\tusb_state = CONFIGURED; \t\t\t\tusb_bm_state |= USB_BM_STATE_CONFIGURED; \t\t\t\tusb_current_config = 0x01; \t\t\t\tUSB_EP0_HSNAK(); \t\t\t\tbreak; \t\t\tdefault: \t\t\t\tUSB_EP0_STALL(); \t\t\t\tbreak; \t\t\t} \t\t\tbreak;  \t\tcase USB_REQ_GET_INTERFACE: \/\/ GET_INTERFACE \t\t\tin0buf[0] = usb_current_alt_interface; \t\t\tin0bc = 0x01; \t\t\tbreak;  \t\tcase USB_REQ_SET_DESCRIPTOR: \t\tcase USB_REQ_SET_INTERFACE: \/\/ SET_INTERFACE \t\tcase USB_REQ_SYNCH_FRAME:   \/\/ SYNCH_FRAME \t\tdefault: \t\t\tUSB_EP0_STALL(); \t\t\tbreak; \t\t} \t}  \t\/\/ bmRequestType = 0 01 xxxxx : Data transfer direction: Host-to-device, Type: Class \telse if((bmRequestType & 0x60 ) == 0x20)  \/\/ Class request \t{ \t\tif(setupbuf[6] != 0 && ((bmRequestType & 0x80) == 0x00)) \t\t{ \t\t\t\/\/ If there is a OUT-transaction associated with the Control-Transfer-Write we call the callback \t\t\t\/\/ when the OUT-transaction is finished. Note that this function do not handle several out transactions. \t\t\tout0bc = 0xff; \t\t} \t\telse \t\t{ \t\t\tUSB_EP0_HSNAK(); \t\t} \t}  \t\/* Extended Compat ID OS Descriptor setupbuf[1] (bRequest) is equal to MS_VendorCode (0xAA is current program)*\/ \telse if(bmRequestType == 0xC0 && setupbuf[1] == MS_VENDORCODE)  \t{ \t\tpacketizer_pkt_size = MAX_PACKET_SIZE_EP0; \t\t\/\/xprintf(&quot;Extended Compat ID\\r&quot;); \t\tpacketizer_data_ptr = g_usb_extended_compat_id; \t\tpacketizer_data_size = MIN(setupbuf[6], packetizer_data_ptr[0]); \t\tpacketizer_isr_ep0_in();\t \t} \t\/* Extended Properties OS Descriptor *\/ \telse if(bmRequestType == 0xC1 && setupbuf[1] == MS_VENDORCODE) \t{ \t\tpacketizer_pkt_size = MAX_PACKET_SIZE_EP0; \t\t\/\/xprintf(&quot;Extended Properties ID\\r&quot;); \t\tpacketizer_data_ptr = g_usb_extended_proper_os; \t\tpacketizer_data_size = MIN(setupbuf[6], packetizer_data_ptr[0]); \t\tpacketizer_isr_ep0_in();\t\t\t\t \t} \telse  \/\/ Unknown request type \t{ \t\tUSB_EP0_STALL(); \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0434\u0432\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b \u0437\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b Extended Compat ID OS Descriptor \u0438 Extended Properties OS Descriptor. <br \/>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u044d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043f\u0440\u0438\u043c\u0443\/\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>Bulk Tranfer<\/h4>\n<p>  <\/p>\n<h5>In Tranfer<\/h5>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/606\/5e2\/8dc\/6065e28dce21448a8dbf21969dd16a45.PNG\"\/><br \/>  \u0425\u043e\u0441\u0442 \u0445\u043e\u0447\u0435\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 In token. \u0415\u0441\u043b\u0438 \u0431\u0438\u0442 inxbsy (x \u2014 \u043d\u043e\u043c\u0435\u0440 \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0430) \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u0442\u043e USB \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0445\u043e\u0441\u0442. \u0427\u0442\u043e \u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0431\u0438\u0442, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 inxbuf[] \u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 inxbc, \u0442.\u0435. \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0434\u043e \u043f\u0440\u0435\u0434\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f.   <\/p>\n<pre><code class=\"cpp\">void int_ep1in_handler(void) { \t\tuint8_t i; \t\tfor(i=0;i&lt;64;i++){ \t\t\tin1buf[i]=i; \t\t} \t\tin1bc = 64; } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 ACK \u2014 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 INT_EP1IN (\u0444\u0443\u043d\u043a\u0446\u0438\u044f usb_irq) \u0438 \u0432 \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u0443\u0441\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h5>Out Tranfer<\/h5>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a84\/bab\/66b\/a84bab66bcc540faa978062c17781ba7.PNG\"\/><br \/>  \u0425\u043e\u0441\u0442 \u0445\u043e\u0447\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 OUT token. \u0421\u043b\u0435\u0434\u043e\u043c \u0437\u0430 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0438\u0434\u0443\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u044b \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 INT_EP1OUT. \u0414\u0430\u043d\u043d\u044b\u0435 \u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 outxbuf[]. \u0420\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 outxbc. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 outxbc \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0434\u0430\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c USB \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0443 \u0447\u0442\u043e \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u0443\u0441\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445.  <\/p>\n<pre><code class=\"cpp\">void int_ep1out_handler(void) { \tdo_anything(out1buf,in1bc); \tin1bc = 0xFF; \/\/dummy write } <\/code><\/pre>\n<h5>Double buffering<\/h5>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u041f\u043e\u043a\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0437\u0430\u043d\u044f\u0442 \u043f\u0440\u0438\u0435\u043c\u043e\u043c \u0438\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u044b (inxbuf \u0438 outxbuf) \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c \u0447\u0442\u043e, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440, \u043a\u0443\u0434\u0430 \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043d\u044f\u0442\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0445 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c.<br \/>  \u0417\u0430 \u044d\u0442\u043e\u0442 \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 usbpair. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0442\u0443\u0434\u0430 0x01 \u043c\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c 2 \u0438 3 in endpoint. \u0411\u0443\u0444\u0435\u0440 endpoint 3 \u0438 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0444\u0435\u0440\u043e\u043c.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4ce\/9fd\/880\/4ce9fd88028c43b3b12d742ac3896923.PNG\"\/><br \/>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0435\u0436\u0438\u043c \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u0430\u044f \u0438 \u043f\u043e\u0440\u043e\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f. \u041f\u0443\u0442\u0435\u043c \u0434\u043e\u043b\u0433\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043d\u0430 \u0445\u043e\u0441\u0442:  <\/p>\n<pre><code class=\"cpp\">while(1) { \twhile(in2cs != 0); \tif(i%2){ \t\t\/\/first buffer \t\tfor(i=0;i&lt;64;i++) \t\t\tin2buf[i]=0xAA; \t\tin2bc = 64; \t} else { \t\t\/\/second buffer \t\tfor(i=0;i&lt;64;i++) \t\t\tin3buf[i]=0xBB; \t\tin2bc = 64;\t\t\t\t \t} \ti++; } <\/code><\/pre>\n<p>  \u0416\u0434\u0435\u043c \u043f\u043e\u043a\u0430 IN 2 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043b\u044c\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u043e \u0432 in2buf \u0442\u043e in3buf, \u0442\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c in2bc (!!!). <i>\u041a\u043e\u0434 \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0439\u0442\u0435 \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e.<\/i><\/p>\n<h4>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u043c Host<\/h4>\n<p>  \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0438\u0441\u0430\u043b\u0441\u044f \u043d\u0430 Visual Studio 2013. \u0421\u0440\u0430\u0437\u0443 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0441\u0435\u0431\u0435 Windows Driver Kit (WDK). \u041e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 USB. \u0421\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043c\u0430\u043d\u0443\u0430\u043b\u043e\u0432 \u043e\u0442 Microsoft, \u0442\u0430\u043c \u0432\u0441\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u043e:  <\/p>\n<ul>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/hardware\/dn376872(v=vs.85).aspx\">Write a Windows desktop app based on the WinUSB template<\/a><\/li>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/hardware\/ff540174(v=vs.85).aspx\">How to Access a USB Device by Using WinUSB Functions<\/a><\/li>\n<\/ul>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u0430 \u0434\u043e \u043d\u0435\u043b\u044c\u0437\u044f: \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0434\u0435\u0432\u0430\u0439\u0441, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440, \u0447\u0438\u0442\u0430\u0435\u043c \u0438 \u043f\u0438\u0448\u0435\u043c \u0432 \u043f\u0430\u0439\u043f. \u0412\u0441\u0435.<\/p>\n<h4>\u0417\u0430\u043c\u0435\u0440\u044b \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438<\/h4>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f:  <\/p>\n<table>\n<tr>\n<td>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0445\u043e\u0441\u0442 \u0432 single buffer<\/td>\n<td>360 \u043a\u0431\/\u0441<\/td>\n<\/tr>\n<tr>\n<td>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0445\u043e\u0441\u0442 \u0432 double buffer<\/td>\n<td>510 \u043a\u0431\/\u0441<\/td>\n<\/tr>\n<tr>\n<td>\u041f\u0440\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0445\u043e\u0441\u0442\u0430 single buffer<\/td>\n<td>230 \u043a\u0431\/c<\/td>\n<\/tr>\n<tr>\n<td>\u041f\u0440\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0445\u043e\u0441\u0442\u0430 double buffer<\/td>\n<td>\u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f<\/td>\n<\/tr>\n<\/table>\n<p>  <\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u0443 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e. \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043f\u0440\u0438\u0447\u0435\u0441\u0430\u043d\u044b, \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043f\u0438\u043d\u0430\u0439\u0442\u0435, \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431, \u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435.<br \/>  <a href=\"https:\/\/github.com\/covsh\/workingtitle\/tree\/master\/nRF24LU1P\">github.com\/covsh\/workingtitle\/tree\/master\/nRF24LU1P<\/a>     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/geektimes.ru\/post\/260210\/\"> http:\/\/geektimes.ru\/post\/260210\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435, \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c <a href=\"http:\/\/geektimes.ru\/post\/260142\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<br \/>  \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 USB. \u0412\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f USBIRQ \u0438 USBWU<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/703\/6b2\/dd7\/7036b2dd75044ad7b37b8c1901bec6e4.PNG\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-263570","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=263570"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263570\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}