Skip to content

Commit 57aac43

Browse files
committed
add new tusb_int_handler(rhport, in_isr) as common irq handler
update tusb_init() to take rhport and role, defined as macro with optional argument for backward compatible
1 parent ffdf81f commit 57aac43

File tree

59 files changed

+187
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+187
-281
lines changed

docs/reference/getting_started.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@ It is relatively simple to incorporate tinyusb to your project
1212
* Add *your_project/tinyusb/src* to your include path. Also make sure your current include path also contains the configuration file tusb_config.h.
1313
* Make sure all required macros are all defined properly in tusb_config.h (configure file in demo application is sufficient, but you need to add a few more such as CFG_TUSB_MCU, CFG_TUSB_OS since they are passed by IDE/compiler to maintain a unique configure for all boards).
1414
* If you use the device stack, make sure you have created/modified usb descriptors for your own need. Ultimately you need to implement all **tud descriptor** callbacks for the stack to work.
15-
* Add tusb_init() call to your reset initialization code.
16-
* Call ``tud_int_handler()`` (device) and/or ``tuh_int_handler()`` (host) in your USB IRQ Handler
15+
* Add tusb_init(rhport, role) call to your reset initialization code.
16+
* Call ``tusb_int_handler(rhport, in_isr)`` in your USB IRQ Handler
1717
* Implement all enabled classes's callbacks.
1818
* If you don't use any RTOSes at all, you need to continuously and/or periodically call tud_task()/tuh_task() function. All of the callbacks and functionality are handled and invoked within the call of that task runner.
1919

2020
.. code-block::
2121
22-
int main(void)
23-
{
22+
int main(void) {
2423
your_init_code();
25-
tusb_init(); // initialize tinyusb stack
24+
tusb_init(0, TUSB_ROLE_DEVICE); // initialize device stack on roothub port 0
2625
27-
while(1) // the mainloop
28-
{
26+
while(1) { // the mainloop
2927
your_application_code();
30-
3128
tud_task(); // device task
3229
tuh_task(); // host task
3330
}

examples/device/audio_4_channel_mic/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int main(void)
8686
board_init();
8787

8888
// init device stack on configured roothub port
89-
tud_init(BOARD_TUD_RHPORT);
89+
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
9090

9191
if (board_init_after_tusb) {
9292
board_init_after_tusb();

examples/device/audio_4_channel_mic_freertos/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void usb_device_task(void* param)
209209
// init device stack on configured roothub port
210210
// This should be called after scheduler/kernel is started.
211211
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
212-
tud_init(BOARD_TUD_RHPORT);
212+
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
213213

214214
if (board_init_after_tusb) {
215215
board_init_after_tusb();

examples/device/audio_test/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int main(void)
7979
board_init();
8080

8181
// init device stack on configured roothub port
82-
tud_init(BOARD_TUD_RHPORT);
82+
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
8383

8484
if (board_init_after_tusb) {
8585
board_init_after_tusb();

examples/device/audio_test_freertos/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void usb_device_task(void* param)
156156
// init device stack on configured roothub port
157157
// This should be called after scheduler/kernel is started.
158158
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
159-
tud_init(BOARD_TUD_RHPORT);
159+
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
160160

161161
if (board_init_after_tusb) {
162162
board_init_after_tusb();

examples/device/audio_test_multi_rate/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int main(void)
9797
board_init();
9898

9999
// init device stack on configured roothub port
100-
tud_init(BOARD_TUD_RHPORT);
100+
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
101101

102102
if (board_init_after_tusb) {
103103
board_init_after_tusb();

examples/device/board_test/src/tusb_config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
extern "C" {
3131
#endif
3232

33-
// board_test example is special example that doesn't enable device or host stack
34-
// This can cause some TinyUSB API missing, this define hack to allow us to fill those API
35-
// to pass the compilation process
36-
#define tud_int_handler(x)
37-
3833
//--------------------------------------------------------------------
3934
// COMMON CONFIGURATION
4035
//--------------------------------------------------------------------

examples/device/cdc_dual_ports/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main(void) {
5252
board_init();
5353

5454
// init device stack on configured roothub port
55-
tud_init(BOARD_TUD_RHPORT);
55+
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
5656

5757
if (board_init_after_tusb) {
5858
board_init_after_tusb();

examples/device/cdc_msc/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int main(void) {
5151
board_init();
5252

5353
// init device stack on configured roothub port
54-
tud_init(BOARD_TUD_RHPORT);
54+
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
5555

5656
if (board_init_after_tusb) {
5757
board_init_after_tusb();

examples/device/cdc_msc_freertos/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void usb_device_task(void *param) {
132132
// init device stack on configured roothub port
133133
// This should be called after scheduler/kernel is started.
134134
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
135-
tud_init(BOARD_TUD_RHPORT);
135+
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
136136

137137
if (board_init_after_tusb) {
138138
board_init_after_tusb();

0 commit comments

Comments
 (0)