SvetlAl / STM32_FS_USB_CDC_device_CMSIS

STM32F105 STM32F407 STM32H730 USB FS CDC Device (Virtual Com Port) CMSIS, no HAL
GNU General Public License v3.0
10 stars 0 forks source link

Not an issue but a question #1

Open simon88 opened 2 days ago

simon88 commented 2 days ago

Hi, I'm trying to use your library with f405 it's working well but I have a questiona bout the TX max size. If I understand well, the max size in TX are 64 am I right ? So If I want to send for example a big char string > 64 I have to chunk it in multiple packet ?

Other question : is it possible to deinit the driver ? Because I wan to put my device into DFU mode from soft and i think I have a conflict with USB OTG. SO I'd like to stop USB OTG before callng my function who jump to bootloader

Or maybe should I change some settings in USB_OTG_FS_init_device to accept DFU.

Thanks

SvetlAl commented 10 hours ago

Hi! If you're asking about Endpoint (1) size, the answer is yes, USB FullSpeed standart supports max 64 bytes packets, But!!! Maximum transmission size per one SOF is defined here "#define TX_EP1_FIFO_SIZE 320-(RX_FIFO_SIZE+TX_EP0_FIFO_SIZE) // 128" Be careful, STM has some unfixed bugs here in Endpoint size allocation. And there is no information about this in Erratas. And of course you don't need to split data into 64 byte packets. It is better to use a circular buffer. Put data there and let the USB interrupt do the rest.

Is it possible to deinit the driver? Yes, but I can't say for sure, what you need to do.

There is a function "void USB_OTG_FS_init_device()" You need to make a kind of "void USB_OTG_FS_deinit_device()" with all the values set vice versa. Also probably you need to do something with the interrupt handler. I've never worked with DFU, but I assume, that you need to define a flag, USB mode: DFU or CDC. Then, the USB interrupt checks the flag: if CDC, do Virtual COM port code. Id DFU - add your DFU code here. But I'm not sure, I think it would look like this.