From fd05ff73e619ed3f8d2cea31e0e97463409e383c Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Tue, 7 Jan 2025 15:13:31 +0300 Subject: [PATCH] some fixes, now speed is big enough --- .../USB_NEW_concept_CDC/main.c | 1 + .../USB_NEW_concept_CDC/someusb.bin | Bin 4164 -> 4180 bytes .../USB_NEW_concept_CDC/usb_descr.c | 10 ++++++++-- .../USB_NEW_concept_CDC/usb_descr.h | 4 ++-- .../USB_NEW_concept_CDC/usb_dev.c | 3 ++- .../USB_NEW_concept_CDC/usb_lib.c | 9 ++++----- .../USB_NEW_concept_PL2303/main.c | 14 +++++++++++--- .../USB_NEW_concept_PL2303/someusb.bin | Bin 3912 -> 4400 bytes .../USB_NEW_concept_PL2303/usb_dev.c | 13 ++++++------- .../USB_NEW_concept_PL2303/usb_dev.h | 5 +++-- .../USB_NEW_concept_PL2303/usb_lib.c | 17 ++++++++--------- .../USB_NEW_concept_PL2303/usb_lib.h | 3 +++ 12 files changed, 48 insertions(+), 31 deletions(-) diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/main.c b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/main.c index 2ccc120..b921cc0 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/main.c +++ b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/main.c @@ -38,6 +38,7 @@ int main(void){ SysTick_Config(72000); #ifdef EBUG usart_setup(); + DBG("Start"); uint32_t tt = 0; #endif USB_setup(); diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/someusb.bin b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/someusb.bin index b8c2a6cee27aadf90e17c55faeaef44b2b71925f..a0be886e4c422a457993cd71699fe751a3dd06e7 100755 GIT binary patch delta 1193 zcmZ8geM}o=7=Pbuq2IJig%zmgXx9`hu)~>5hR$-pNn04q4i$B#)S8qVadqd{ZAsLo+nh@O|EgNwG35_OpZRggKjysX|e9!oY@lAejo_n5O z?)i9s&-eH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8jhM$@`W{ zSQ<7SMFvFPUVC#u6N1o$c+Trv0Ww$_`j#F;{<=`$xki`}p39W_B)4+Wg zIkVgq>ZeaHE{OJF;H5fEiYN#$1-wQ&eB5=HN18newm-kBSZ)hDuHcbf2;d1MdJ2GK z*R?ytt|kA`nOG>K5ji0}RsP zbp8+j4>*&=eGxGJd*ta%J$*HaOM{?X5~?ziFrSr#>MW5M5dXA)6_sZy+Fs_ykI(&C z7NY1t`Sbj;toB7^Gf6OFqaU+|8?p|lbX*d4Wij*S`lDt}+J7qvF*%tJaS}O2Y%MlpslG`W}@(e>h&;?x%v_uzVf68wLength); - else EP_WriteIRQ(0, NULL, 0); + if(descridx < iDESCR_AMOUNT){ + wr0((const uint8_t *)StringDescriptor[descridx], *((uint8_t*)StringDescriptor[descridx]), pack->wLength); + DBGs(StringDescriptor[descridx]); + }else{ + EP_WriteIRQ(0, NULL, 0); + DBG("Wrong index"); + DBGs(uhex2str(descridx)); + } break; case DEVICE_QUALIFIER_DESCRIPTOR: DBG("DEVICE_QUALIFIER_DESCRIPTOR"); diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_descr.h b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_descr.h index 6ac6fbf..0874763 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_descr.h +++ b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_descr.h @@ -21,8 +21,8 @@ #include "usb_lib.h" // definition of parts common for USB_DeviceDescriptor & USB_DeviceQualifierDescriptor -// bcdUSB: 2.00 -#define bcdUSB 0x0200 +// bcdUSB: 1.10 +#define bcdUSB 0x0110 // Class - Misc (EF), subclass - common (2), protocol - interface association descr (1) #define bDeviceSubClass 0x02 #define bDeviceProtocol 0x01 diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_dev.c b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_dev.c index 7f1be59..13b5ddb 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_dev.c +++ b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_dev.c @@ -101,6 +101,7 @@ static void rxtx_handler(){ } rcvbuflen = EP_Read(1, (uint8_t*)rcvbuf); USB->EPnR[1] = epstatus & ~(USB_EPnR_CTR_RX | USB_EPnR_STAT_RX | USB_EPnR_STAT_TX); // keep RX in STALL state until read data + chkin(); // try to write current data into RXbuf if it's not busy }else{ // tx successfull DBG("Tx OK"); USB->EPnR[1] = (epstatus & ~(USB_EPnR_CTR_TX | USB_EPnR_STAT_TX)) ^ USB_EPnR_STAT_RX; @@ -124,6 +125,7 @@ void WEAK clstate_handler(uint16_t val){ // SEND_BREAK void WEAK break_handler(){ + CDCready = 0; DBG("break_handler()"); } @@ -159,7 +161,6 @@ void usb_class_request(config_pack_t *req, uint8_t *data, uint16_t datalen){ break; case SEND_BREAK: DBG("SEND_BREAK"); - CDCready = 0; break_handler(); break; default: diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_lib.c b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_lib.c index b1fad0e..ad3c79b 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_lib.c +++ b/F1:F103/USB_New_concept/USB_NEW_concept_CDC/usb_lib.c @@ -21,12 +21,12 @@ #include "usb_descr.h" #include "usb_dev.h" -/* + #undef DBG #define DBG(x) #undef DBGs #define DBGs(x) -*/ + static ep_t endpoints[STM32ENDPOINTS]; @@ -54,6 +54,7 @@ static inline void std_d2h_req(){ default: DBG("Wrong"); DBGs(uhex2str(setup_packet->bRequest)); + EP_WriteIRQ(0, NULL, 0); break; } } @@ -90,19 +91,17 @@ void WEAK usb_standard_request(){ std_d2h_req(); }else{ std_h2d_req(); - //EP_WriteIRQ(0, NULL, 0); } break; case REQ_RECIPIENT_INTERFACE: DBG("REQ_RECIPIENT_INTERFACE"); if(dev2host && setup_packet->bRequest == GET_DESCRIPTOR){ get_descriptor(setup_packet); - }//else EP_WriteIRQ(0, NULL, 0); + } break; case REQ_RECIPIENT_ENDPOINT: DBG("REQ_RECIPIENT_ENDPOINT"); if(setup_packet->bRequest == CLEAR_FEATURE){ - //EP_WriteIRQ(0, NULL, 0); }else{ DBG("Wrong"); } diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/main.c b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/main.c index 0ab0398..2ccc120 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/main.c +++ b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/main.c @@ -17,9 +17,7 @@ */ #include "hardware.h" -#ifdef EBUG #include "usart.h" -#endif #include "usb_dev.h" volatile uint32_t Tms = 0; @@ -33,7 +31,7 @@ void sys_tick_handler(void){ int main(void){ char inbuff[RBINSZ]; - uint32_t lastT = 0; + uint32_t lastT = 0, lastS = 0; StartHSE(); hw_setup(); USBPU_OFF(); @@ -61,6 +59,16 @@ int main(void){ __enable_irq(); } #endif + if(Tms - lastS > 9999){ + int n = 0; + USND(uhex2str(Tms)); + do{ + if(USB_send((uint8_t*)"112345678921234567893123456789412345678951234567896123456789712345678981234567899123456789a123456789\n", 101)) ++n; + }while(n < 40 && CDCready); + while(CDCready && !USB_sendstr(uhex2str(Tms))); + newline(); + lastS = Tms; + } int l = USB_receivestr(inbuff, RBINSZ); if(l < 0) USB_sendstr("ERROR: USB buffer overflow or string was too long\n"); else if(l){ diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/someusb.bin b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/someusb.bin index 957f65496d3fb80da62ceb8a8051f046ef62bcf7..1f16cf8400d1a413b89c8c81422497582f8899c6 100755 GIT binary patch delta 2275 zcmZWq4@?{975~0F8~hLK;QTShNsS$9!v%82O%q53j&ZJFhtNViY{fABYf-)8qnTC}keCrYr=rJ1yEb366muelsJPRf%VBaZ28`N6u^ByGD?R{+=*wbD`iu%^{rD;RUt*)bo22c4{X9^)_^yYx6VU*X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AxjG3l{wik1AbQ4b0>AM<(B+40kTrW zXrC>x)zF*{U^do6G+^n_H1_#nV3N#6@vWTnRNqTBjfJlaqf55a@C>TAx5F0^vU7WW z5W0<-$w|z7d>ezwA7d_lPAZiqaeNmMc;n#nt%3%q=byOI;qL-z`0Yn>o0jY%;*5q5 zHg|@~yUL%N>G~eZ+jk_M3H3>E7S>XkD^b8dltW7&c)k-R&lNl`t`S?CZ{v7xd&^U; zF3H?6g+cr}f%xpYu?G(m)~olUHyYM4lm?!pRnT725a=Mg`}*(&U;B6;=|Od4WM;p> z+lQw|$H^U5$mCwFLbK5HDc(M)=YE$52`^EHOKuv+cZ7}$Z7QJ4(x>o+!BfP7zA4({ zTCja!6iJ42z{llCH{gTn*(CIIMrLE4?jF)6P9=}b48@KK@tH4h<;Nha*V-3h(LS*# ztMBaC{rfDm!r2!ZJ2KWqXfMVvJ)X5XT9@Prf~@cS$Rrqa`8qYsja z7jKm{QSa-ykvuH|4-z^f2WB427Q)Y;Dk0^*b(y-T=lJDfqI;L)D51cS) zw9ZN*X3`2*6RBSd0r(2c8n0{MeII0oD6p;xc7mLsj WoiA@8X@El%NzzdMV;qA2Z~F&ZmBDHN diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_dev.c b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_dev.c index 606b8f8..a240e70 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_dev.c +++ b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_dev.c @@ -47,7 +47,7 @@ static uint8_t volatile rcvbuflen = 0; // line coding usb_LineCoding WEAK lineCoding = {115200, 0, 0, 8}; // CDC configured and ready to use -static volatile uint8_t CDCready = 0; +volatile uint8_t CDCready = 0; // ring buffers for incoming and outgoing data static uint8_t obuf[RBOUTSZ], ibuf[RBINSZ]; @@ -87,8 +87,6 @@ static void send_next(){ return; }else if(buflen < 0){ lastdsz = 0; - // Uncomment next line if you want 4Mbit/s instead of 6Mbit/s - //EP_Write(3, NULL, 0); // send ZLP if buffer is in writting state now return; } EP_Write(3, (uint8_t*)usbbuff, buflen); @@ -111,6 +109,7 @@ static void receive_Handler(){ // EP2OUT rcvbuflen = 0; } rcvbuflen = EP_Read(2, (uint8_t*)rcvbuf); + chkin(); USB->EPnR[2] = status & ~USB_EPnR_CTR_RX; } @@ -119,16 +118,19 @@ static void receive_Handler(){ // EP2OUT void WEAK linecoding_handler(usb_LineCoding *lc){ lineCoding = *lc; DBG("linecoding_handler"); + CDCready = 1; } // SET_CONTROL_LINE_STATE -void WEAK clstate_handler(uint16_t _U_ val){ +void WEAK clstate_handler(uint16_t val){ DBG("clstate_handler"); + CDCready = val; } // SEND_BREAK void WEAK break_handler(){ DBG("break_handler()"); + CDCready = 0; } @@ -155,7 +157,6 @@ void usb_class_request(config_pack_t *req, uint8_t *data, uint16_t datalen){ if(!data || !datalen) break; // wait for data if(datalen == sizeof(usb_LineCoding)) linecoding_handler((usb_LineCoding*)data); - CDCready = 1; break; case 0x33: // -//- case GET_LINE_CODING: @@ -164,12 +165,10 @@ void usb_class_request(config_pack_t *req, uint8_t *data, uint16_t datalen){ break; case SET_CONTROL_LINE_STATE: DBG("SET_CONTROL_LINE_STATE"); - CDCready = 1; clstate_handler(req->wValue); break; case SEND_BREAK: DBG("SEND_BREAK"); - CDCready = 0; break_handler(); break; default: diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_dev.h b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_dev.h index 075b7a7..4c1fced 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_dev.h +++ b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_dev.h @@ -34,6 +34,7 @@ typedef struct { } __attribute__ ((packed)) usb_LineCoding; extern usb_LineCoding lineCoding; +extern volatile uint8_t CDCready; void break_handler(); void clstate_handler(uint16_t val); @@ -41,8 +42,8 @@ void linecoding_handler(usb_LineCoding *lc); // sizes of ringbuffers for outgoing and incoming data -#define RBOUTSZ (256) -#define RBINSZ (256) +#define RBOUTSZ (1024) +#define RBINSZ (1024) #define newline() USB_putbyte('\n') #define USND(s) do{USB_sendstr(s); USB_putbyte('\n');}while(0) diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_lib.c b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_lib.c index 9db1799..ad3c79b 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_lib.c +++ b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_lib.c @@ -21,12 +21,12 @@ #include "usb_descr.h" #include "usb_dev.h" -/* + #undef DBG #define DBG(x) #undef DBGs #define DBGs(x) -*/ + static ep_t endpoints[STM32ENDPOINTS]; @@ -54,6 +54,7 @@ static inline void std_d2h_req(){ default: DBG("Wrong"); DBGs(uhex2str(setup_packet->bRequest)); + EP_WriteIRQ(0, NULL, 0); break; } } @@ -90,19 +91,17 @@ void WEAK usb_standard_request(){ std_d2h_req(); }else{ std_h2d_req(); - //EP_WriteIRQ(0, NULL, 0); } break; case REQ_RECIPIENT_INTERFACE: DBG("REQ_RECIPIENT_INTERFACE"); if(dev2host && setup_packet->bRequest == GET_DESCRIPTOR){ get_descriptor(setup_packet); - }//else EP_WriteIRQ(0, NULL, 0); + } break; case REQ_RECIPIENT_ENDPOINT: DBG("REQ_RECIPIENT_ENDPOINT"); if(setup_packet->bRequest == CLEAR_FEATURE){ - //EP_WriteIRQ(0, NULL, 0); }else{ DBG("Wrong"); } @@ -159,11 +158,11 @@ static void EP0_Handler(){ // check direction if(USB->ISTR & USB_ISTR_DIR){ // OUT interrupt - receive data, CTR_RX==1 (if CTR_TX == 1 - two pending transactions: receive following by transmit) if(epstatus & USB_EPnR_SETUP){ // setup packet -> copy data to conf_pack - //DBG("USB_EPnR_SETUP"); + DBG("USB_EPnR_SETUP"); EP_Read(0, setupdatabuf); // interrupt handler will be called later }else if(epstatus & USB_EPnR_CTR_RX){ // data packet -> push received data to ep0databuf - //if(endpoints[0].rx_cnt){ DBG("data");} + if(endpoints[0].rx_cnt){ DBG("data"); DBGs(uhex2str(endpoints[0].rx_cnt));} ep0dbuflen = EP_Read(0, ep0databuf); } } @@ -243,8 +242,8 @@ void EP_WriteIRQ(uint8_t number, const uint8_t *buf, uint16_t size){ void EP_Write(uint8_t number, const uint8_t *buf, uint16_t size){ EP_WriteIRQ(number, buf, size); uint16_t epstatus = KEEP_DTOG(USB->EPnR[number]); - // keep DTOGs, clear CTR_TX & set TX VALID to start transmission - USB->EPnR[number] = (epstatus & ~(USB_EPnR_CTR_TX)) ^ USB_EPnR_STAT_TX; + // keep DTOGs and RX stat, clear CTR_TX & set TX VALID to start transmission + USB->EPnR[number] = (epstatus & ~(USB_EPnR_CTR_TX | USB_EPnR_STAT_RX)) ^ USB_EPnR_STAT_TX; } /* diff --git a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_lib.h b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_lib.h index 86ecc50..c1a180f 100644 --- a/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_lib.h +++ b/F1:F103/USB_New_concept/USB_NEW_concept_PL2303/usb_lib.h @@ -172,6 +172,7 @@ typedef struct{ #define USB_CLASS_MASS_STORAGE 8 #define USB_CLASS_HUB 9 #define USB_CLASS_DATA 10 +#define USB_CLASS_MISC 0xef #define USB_CLASS_VENDOR_SPEC 0xff /* @@ -187,6 +188,7 @@ typedef struct{ #define USB_DT_HID 0x21 #define USB_DT_REPORT 0x22 #define USB_DT_PHYSICAL 0x23 +#define USB_DT_CS_INTERFACE 0x24 #define USB_DT_HUB 0x29 /* @@ -198,6 +200,7 @@ typedef struct{ #define USB_DT_HID_SIZE 9 #define USB_DT_ENDPOINT_SIZE 7 #define USB_DT_QUALIFIER_SIZE 10 +#define USB_DT_CS_INTERFACE_SIZE 5