Skip to content

Commit

Permalink
change tusb_init(), tusb_rhport_init() to use init struct for expanda…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
hathach committed Oct 11, 2024
1 parent a4fb835 commit 57c5c37
Show file tree
Hide file tree
Showing 48 changed files with 350 additions and 80 deletions.
7 changes: 6 additions & 1 deletion examples/device/audio_4_channel_mic/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/audio_4_channel_mic_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ void usb_device_task(void* param)
// init device stack on configured roothub port
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/audio_test/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/audio_test_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ void usb_device_task(void* param)
// init device stack on configured roothub port
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/audio_test_multi_rate/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/cdc_dual_ports/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ int main(void) {
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/cdc_msc/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ int main(void) {
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/cdc_msc_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ static void usb_device_task(void *param) {
// init device stack on configured roothub port
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/cdc_uac2/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

#if (CFG_TUSB_MCU == OPT_MCU_RP2040)
stdio_init_all();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/dfu/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/dfu_runtime/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/dynamic_configuration/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/hid_boot_interface/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/hid_composite/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/hid_composite_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ void usb_device_task(void* param)
// init device stack on configured roothub port
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/hid_generic_inout/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/hid_multiple_interface/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/midi_test/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/msc_dual_lun/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ int main(void) {
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/net_lwip_webserver/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ int main(void) {
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/uac2_headset/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/uac2_speaker_fb/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/usbtmc/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ int main(void)
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
14 changes: 12 additions & 2 deletions examples/device/video_capture/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ int main(void) {
freertos_init_task();
#else
// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down Expand Up @@ -319,7 +324,12 @@ void usb_device_task(void *param) {
// init device stack on configured roothub port
// This should be called after scheduler/kernel is started.
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
14 changes: 12 additions & 2 deletions examples/device/video_capture_2ch/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ int main(void) {
freertos_init_task();
#else
// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down Expand Up @@ -327,7 +332,12 @@ void usb_device_task(void *param) {
// init device stack on configured roothub port
// This should be called after scheduler/kernel is started.
// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
7 changes: 6 additions & 1 deletion examples/device/webusb_serial/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ int main(void) {
board_init();

// init device stack on configured roothub port
tusb_init(BOARD_TUD_RHPORT, TUSB_ROLE_DEVICE);
tusb_rhport_init_t dev_init = {
.rhport = BOARD_TUD_RHPORT,
.role = TUSB_ROLE_DEVICE,
.speed = TUSB_SPEED_AUTO
};
tusb_init(&dev_init);

if (board_init_after_tusb) {
board_init_after_tusb();
Expand Down
1 change: 1 addition & 0 deletions examples/dual/host_hid_to_device_cdc/only.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ board:mcb1800
mcu:RP2040
mcu:ra6m5
mcu:MAX3421
mcu:STM32H7
Loading

0 comments on commit 57c5c37

Please sign in to comment.