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

Update porting.rst #2030

Merged
merged 2 commits into from Apr 28, 2023
Merged

Update porting.rst #2030

merged 2 commits into from Apr 28, 2023

Conversation

slc-tl
Copy link
Contributor

@slc-tl slc-tl commented Apr 14, 2023

Adds more in depth documentation of how tud_task does not need to be polled in implementations that use an RTOS / scheduler.

Describe the PR
This adds documentaiton showing how tud_task doesn't need to hold the CPU through polling when tusb_config.h is set to use an RTOS.

Additional context
If applicable, add any other context about the PR and/or screenshots here.

Adds more in depth documentation of how tud_task does not need to be polled in implementations that use an RTOS / scheduler.
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look good, thank you. Though can you move the note for RTOS to OSAL porting guide per review.

PS: the ci pre-commit failed is due to extra trailing space after the text, simply remove that to fix ci.

@@ -69,7 +69,7 @@ The code is almost entirely agnostic of MCU and lives in ``src/osal``.
Device API
^^^^^^^^^^

After the USB device is setup, the USB device code works by processing events on the main thread (by calling ``tud_task``\ ). These events are queued by the USB interrupt handler. So, there are three parts to the device low-level API: device setup, endpoint setup and interrupt processing.
After the USB device is setup, the USB device code works by processing events on the main thread (by calling ``tud_task``\ ). In RTOS configurations, tud_task blocks behind a synchronization structure when the event queue is empty, so that the scheduler may give the CPU to a different task. To take advantage of the library's capability to yield the CPU when there are no actionable USB device events, ensure that the `CFG_TUSB_OS` symbol is defined in your modified ``tusb_config.h``. For example `#define CFG_TUSB_OS OPT_OS_FREERTOS` enables the FreeRTOS scheduler to schedule other threads than that which calls `tud_task`. These events are queued by the USB interrupt handler. So, there are three parts to the device low-level API: device setup, endpoint setup and interrupt processing.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move this explanation into above OSAL, since this is porting guide and is talking about API that needs to be ported for device.

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for your PR, I moved the note to OSAL

@hathach hathach merged commit 2afef45 into hathach:master Apr 28, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants