Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IRQ-safe tud_cdc_n_write variant (lock/stall when flush) #2864

Open
1 task done
MrJake222 opened this issue Nov 1, 2024 · 0 comments
Open
1 task done

IRQ-safe tud_cdc_n_write variant (lock/stall when flush) #2864

MrJake222 opened this issue Nov 1, 2024 · 0 comments
Labels

Comments

@MrJake222
Copy link

Operating System

Linux

Board

RP2040

Firmware

Specifically this version, this fragment: https://github.com/MrJake222/pico-ice-sdk/blob/473e38978f7f8caab7e20c6b49f9f48623158dcf/src/ice_usb.c#L169-L175

What happened ?

When transmitting data over CDC from UART interrupt, the tud_cdc_n_write function can cause a flush, which is highly unwanted in an IRQ. I want to write 64/512 bytes to the buffer, and the rest shouldn't be written (return 0 for example). Flush will be called in main loop (or done automatically by tud_task().

This could be achieved by writing at most BULK_PACKET_SIZE - 1 bytes, but there is no function exposing current fifo level. While possible to calculate the number of bytes currently in the fifo by using tud_cdc_n_write_available, it will be rather cumbersome.

I'm aware that I can just write my own fifo (that's what the library runs right now), but why? There is a perfectly good fifo in TinyUSB code. Or is it really a good idea to use my own fifo?

How to reproduce ?

.

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

.

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant