some fixes, now speed is big enough

This commit is contained in:
Edward Emelianov
2025-01-07 15:13:31 +03:00
parent ea05df117b
commit fd05ff73e6
12 changed files with 48 additions and 31 deletions

View File

@@ -38,6 +38,7 @@ int main(void){
SysTick_Config(72000);
#ifdef EBUG
usart_setup();
DBG("Start");
uint32_t tt = 0;
#endif
USB_setup();

View File

@@ -198,8 +198,14 @@ void get_descriptor(config_pack_t *pack){
break;
case STRING_DESCRIPTOR:
DBG("STRING_DESCRIPTOR");
if(descridx < iDESCR_AMOUNT) wr0((const uint8_t *)StringDescriptor[descridx], *((uint8_t*)StringDescriptor[descridx]), pack->wLength);
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");

View File

@@ -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

View File

@@ -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:

View File

@@ -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");
}