summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZixun LI <[email protected]>2026-06-29 14:58:32 +0200
committerZixun LI <[email protected]>2026-06-29 14:58:32 +0200
commite657a8705252e0d41f045232852ccce09aede816 (patch)
tree539dc08547488f9f9eee06c6baeb92455c6995f2
parent2ec4d7a437834fe304b2717eaa1f9baee438793f (diff)
Fix merged example Sonar warningsmerge_os
-rw-r--r--examples/device/audio_4_channel_mic/src/main.c42
-rw-r--r--examples/device/audio_test/src/main.c46
-rw-r--r--examples/device/cdc_msc/src/main.c100
-rw-r--r--examples/device/hid_composite/src/main.c82
-rw-r--r--examples/device/midi_test/src/main.c97
-rw-r--r--examples/device/uac2_speaker_fb/src/main.c58
-rw-r--r--examples/host/cdc_msc_hid/src/main.c4
-rw-r--r--examples/host/msc_file_explorer/src/main.c4
8 files changed, 219 insertions, 214 deletions
diff --git a/examples/device/audio_4_channel_mic/src/main.c b/examples/device/audio_4_channel_mic/src/main.c
index 38f42d11f..0729b4da1 100644
--- a/examples/device/audio_4_channel_mic/src/main.c
+++ b/examples/device/audio_4_channel_mic/src/main.c
@@ -111,6 +111,7 @@ int main(void) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
freertos_init();
+ return 0;
#else
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
@@ -126,8 +127,6 @@ int main(void) {
audio_task(NULL);
}
#endif
-
- return 0;
}
//--------------------------------------------------------------------+
@@ -168,19 +167,19 @@ void audio_task(void *param) {
(void) param;
static uint32_t start_ms = 0;
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
while (1) {
- uint32_t curr_ms = tusb_time_millis_api();
- if (start_ms != curr_ms) {
- start_ms = curr_ms;
- tud_audio_write(i2s_dummy_buffer, AUDIO_SAMPLE_RATE / 1000 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX);
- }
+#endif
+ uint32_t curr_ms = tusb_time_millis_api();
+ if (start_ms != curr_ms) {
+ start_ms = curr_ms;
+ tud_audio_write(i2s_dummy_buffer, AUDIO_SAMPLE_RATE / 1000 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX);
+ }
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(1);
-#else
- return;
-#endif
+ vTaskDelay(1);
}
+#endif
}
//--------------------------------------------------------------------+
@@ -427,21 +426,24 @@ void led_blinking_task(void *param) {
(void) param;
static bool led_state = false;
- while (1) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ while (1) {
vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
#else
- static uint32_t start_ms = 0;
- // Blink every interval ms
- if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
- return; // not enough time
- }
- start_ms += blink_interval_ms;
+ static uint32_t start_ms = 0;
+ // Blink every interval ms
+ if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
+ return; // not enough time
+ }
+ start_ms += blink_interval_ms;
#endif
- board_led_write(led_state);
- led_state = 1 - led_state;// toggle
+ board_led_write(led_state);
+ led_state = 1 - led_state;// toggle
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
}
+#endif
}
//--------------------------------------------------------------------+
diff --git a/examples/device/audio_test/src/main.c b/examples/device/audio_test/src/main.c
index 4f0fa3040..e286dc4f0 100644
--- a/examples/device/audio_test/src/main.c
+++ b/examples/device/audio_test/src/main.c
@@ -93,6 +93,7 @@ int main(void) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
freertos_init();
+ return 0;
#else
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
@@ -108,8 +109,6 @@ int main(void) {
audio_task(NULL);
}
#endif
-
- return 0;
}
//--------------------------------------------------------------------+
@@ -151,22 +150,22 @@ void audio_task(void *param) {
(void) param;
static uint32_t start_ms = 0;
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
while (1) {
- uint32_t curr_ms = tusb_time_millis_api();
- if (start_ms != curr_ms) {
- start_ms = curr_ms;
- for (size_t cnt = 0; cnt < sizeof(test_buffer_audio) / 2; cnt++) {
- test_buffer_audio[cnt] = startVal++;
- }
- tud_audio_write((uint8_t *) test_buffer_audio, sizeof(test_buffer_audio));
+#endif
+ uint32_t curr_ms = tusb_time_millis_api();
+ if (start_ms != curr_ms) {
+ start_ms = curr_ms;
+ for (size_t cnt = 0; cnt < sizeof(test_buffer_audio) / 2; cnt++) {
+ test_buffer_audio[cnt] = startVal++;
}
+ tud_audio_write((uint8_t *) test_buffer_audio, sizeof(test_buffer_audio));
+ }
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(1);
-#else
- return;
-#endif
+ vTaskDelay(1);
}
+#endif
}
//--------------------------------------------------------------------+
@@ -421,21 +420,24 @@ void led_blinking_task(void *param) {
(void) param;
static bool led_state = false;
- while (1) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ while (1) {
vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
#else
- static uint32_t start_ms = 0;
- // Blink every interval ms
- if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
- return; // not enough time
- }
- start_ms += blink_interval_ms;
+ static uint32_t start_ms = 0;
+ // Blink every interval ms
+ if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
+ return; // not enough time
+ }
+ start_ms += blink_interval_ms;
#endif
- board_led_write(led_state);
- led_state = 1 - led_state;// toggle
+ board_led_write(led_state);
+ led_state = 1 - led_state;// toggle
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
}
+#endif
}
//--------------------------------------------------------------------+
diff --git a/examples/device/cdc_msc/src/main.c b/examples/device/cdc_msc/src/main.c
index 1318f6f32..f47da4d1e 100644
--- a/examples/device/cdc_msc/src/main.c
+++ b/examples/device/cdc_msc/src/main.c
@@ -59,6 +59,7 @@ int main(void) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
freertos_init();
+ return 0;
#else
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {.role = TUSB_ROLE_DEVICE, .speed = TUSB_SPEED_AUTO};
@@ -74,8 +75,6 @@ int main(void) {
cdc_task(NULL);
}
#endif
-
- return 0;
}
//--------------------------------------------------------------------+
@@ -112,47 +111,47 @@ void tud_resume_cb(void) {
void cdc_task(void *param) {
(void) param;
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
while (1) {
- // connected() check for DTR bit
- // Most but not all terminal client set this when making connection
- // if ( tud_cdc_connected() )
- {
- // connected and there are data available
- while (tud_cdc_available()) {
- // read data
- char buf[64];
- uint32_t count = tud_cdc_read(buf, sizeof(buf));
- (void)count;
+#endif
+ // connected() check for DTR bit
+ // Most but not all terminal client set this when making connection
+ // if ( tud_cdc_connected() )
+ {
+ // connected and there are data available
+ while (tud_cdc_available()) {
+ // read data
+ char buf[64];
+ uint32_t count = tud_cdc_read(buf, sizeof(buf));
+ (void)count;
- // Echo back
- // Note: Skip echo by commenting out write() and write_flush()
- // for throughput test e.g
- // $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
- tud_cdc_write(buf, count);
- }
+ // Echo back
+ // Note: Skip echo by commenting out write() and write_flush()
+ // for throughput test e.g
+ // $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
+ tud_cdc_write(buf, count);
+ }
- tud_cdc_write_flush();
+ tud_cdc_write_flush();
- // Press on-board button to send Uart status notification
- static cdc_notify_uart_state_t uart_state = {.value = 0};
+ // Press on-board button to send Uart status notification
+ static cdc_notify_uart_state_t uart_state = {.value = 0};
- static uint32_t btn_prev = 0;
- const uint32_t btn = board_button_read();
+ static uint32_t btn_prev = 0;
+ const uint32_t btn = board_button_read();
- if ((btn_prev == 0u) && (btn != 0u)) {
- uart_state.dsr ^= 1;
- uart_state.dcd ^= 1;
- tud_cdc_notify_uart_state(&uart_state);
- }
- btn_prev = btn;
+ if ((btn_prev == 0u) && (btn != 0u)) {
+ uart_state.dsr ^= 1;
+ uart_state.dcd ^= 1;
+ tud_cdc_notify_uart_state(&uart_state);
}
+ btn_prev = btn;
+ }
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(1);
-#else
- break;
-#endif
+ vTaskDelay(1);
}
+#endif
}
// Invoked when cdc when line state changed e.g connected/disconnected
@@ -185,33 +184,34 @@ void led_blinking_task(void *param) {
static uint32_t start_ms = 0;
#endif
- while (1) {
- if (!blink_enable) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(1);
- continue;
+ while (1) {
+ if (!blink_enable) {
+ vTaskDelay(1);
+ continue;
+ }
#else
- return;
+ if (!blink_enable) {
+ return;
+ }
#endif
- }
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
+ vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
#else
- // Blink every interval ms
- if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
- return; // not enough time
- }
- start_ms += blink_interval_ms;
+ // Blink every interval ms
+ if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
+ return; // not enough time
+ }
+ start_ms += blink_interval_ms;
#endif
- board_led_write(led_state);
- led_state = !led_state;
+ board_led_write(led_state);
+ led_state = !led_state;
-#if CFG_TUSB_OS != OPT_OS_FREERTOS
- break;
-#endif
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
}
+#endif
}
//--------------------------------------------------------------------+
diff --git a/examples/device/hid_composite/src/main.c b/examples/device/hid_composite/src/main.c
index 089ff3ff1..5bfd048a1 100644
--- a/examples/device/hid_composite/src/main.c
+++ b/examples/device/hid_composite/src/main.c
@@ -63,6 +63,7 @@ int main(void) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
freertos_init();
+ return 0;
#else
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {.role = TUSB_ROLE_DEVICE, .speed = TUSB_SPEED_AUTO};
@@ -76,8 +77,6 @@ int main(void) {
hid_task(NULL);
}
#endif
-
- return 0;
}
//--------------------------------------------------------------------+
@@ -218,36 +217,35 @@ static void send_hid_report(uint8_t report_id, uint32_t btn) {
void hid_task(void *param) {
(void) param;
- while (1) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ while (1) {
vTaskDelay(pdMS_TO_TICKS(10));
#else
- // Poll every 10ms
- const uint32_t interval_ms = 10;
- static uint32_t start_ms = 0;
+ // Poll every 10ms
+ const uint32_t interval_ms = 10;
+ static uint32_t start_ms = 0;
- if (tusb_time_millis_api() - start_ms < interval_ms) {
- return; // not enough time
- }
- start_ms += interval_ms;
+ if (tusb_time_millis_api() - start_ms < interval_ms) {
+ return; // not enough time
+ }
+ start_ms += interval_ms;
#endif
- uint32_t const btn = board_button_read();
+ uint32_t const btn = board_button_read();
- // Remote wakeup
- if (tud_suspended() && btn != 0u) {
- // Wake up host if we are in suspend mode
- // and REMOTE_WAKEUP feature is enabled by host
- tud_remote_wakeup();
- } else {
- // Send the 1st of report chain, the rest will be sent by tud_hid_report_complete_cb()
- send_hid_report(REPORT_ID_KEYBOARD, btn);
- }
+ // Remote wakeup
+ if (tud_suspended() && btn != 0u) {
+ // Wake up host if we are in suspend mode
+ // and REMOTE_WAKEUP feature is enabled by host
+ tud_remote_wakeup();
+ } else {
+ // Send the 1st of report chain, the rest will be sent by tud_hid_report_complete_cb()
+ send_hid_report(REPORT_ID_KEYBOARD, btn);
+ }
-#if CFG_TUSB_OS != OPT_OS_FREERTOS
- break;
-#endif
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
}
+#endif
}
// Invoked when sent REPORT successfully to host
@@ -318,34 +316,36 @@ void led_blinking_task(void *param) {
static uint32_t start_ms = 0;
#endif
- while (1) {
- // blink is disabled
- if (0u == blink_interval_ms) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(1);
- continue;
+ while (1) {
+ // blink is disabled
+ if (0u == blink_interval_ms) {
+ vTaskDelay(1);
+ continue;
+ }
#else
- return;
+ // blink is disabled
+ if (0u == blink_interval_ms) {
+ return;
+ }
#endif
- }
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
+ vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
#else
- // Blink every interval ms
- if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
- return; // not enough time
- }
- start_ms += blink_interval_ms;
+ // Blink every interval ms
+ if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
+ return; // not enough time
+ }
+ start_ms += blink_interval_ms;
#endif
- board_led_write(led_state);
- led_state = 1 - led_state; // toggle
+ board_led_write(led_state);
+ led_state = 1 - led_state; // toggle
-#if CFG_TUSB_OS != OPT_OS_FREERTOS
- break;
-#endif
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
}
+#endif
}
//--------------------------------------------------------------------+
diff --git a/examples/device/midi_test/src/main.c b/examples/device/midi_test/src/main.c
index 3e86d2dd6..95dc11433 100644
--- a/examples/device/midi_test/src/main.c
+++ b/examples/device/midi_test/src/main.c
@@ -68,6 +68,7 @@ int main(void) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
freertos_init();
+ return 0;
#else
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
@@ -84,8 +85,6 @@ int main(void) {
midi_task(NULL);
}
#endif
-
- return 0;
}
//--------------------------------------------------------------------+
@@ -134,55 +133,56 @@ void midi_task(void *param) {
uint8_t const cable_num = 0; // MIDI jack associated with USB endpoint
uint8_t const channel = 0; // 0 for channel 1
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
while (1) {
- // The MIDI interface always creates input and output port/jack descriptors
- // regardless of these being used or not. Therefore incoming traffic should be read
- // (possibly just discarded) to avoid the sender blocking in IO
- while (tud_midi_available()) {
- uint8_t packet[4];
- tud_midi_packet_read(packet);
- }
+#endif
+ // The MIDI interface always creates input and output port/jack descriptors
+ // regardless of these being used or not. Therefore incoming traffic should be read
+ // (possibly just discarded) to avoid the sender blocking in IO
+ while (tud_midi_available()) {
+ uint8_t packet[4];
+ tud_midi_packet_read(packet);
+ }
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(286 / portTICK_PERIOD_MS);
+ vTaskDelay(286 / portTICK_PERIOD_MS);
#else
- static uint32_t start_ms = 0;
- // send note periodically
- if (tusb_time_millis_api() - start_ms < 286) {
- return; // not enough time
- }
- start_ms += 286;
+ static uint32_t start_ms = 0;
+ // send note periodically
+ if (tusb_time_millis_api() - start_ms < 286) {
+ return; // not enough time
+ }
+ start_ms += 286;
#endif
- // Previous positions in the note sequence.
- int previous = (int) (note_pos - 1);
+ // Previous positions in the note sequence.
+ int previous = (int) (note_pos - 1);
- // If we currently are at position 0, set the
- // previous position to the last note in the sequence.
- if (previous < 0) {
- previous = sizeof(note_sequence) - 1;
- }
+ // If we currently are at position 0, set the
+ // previous position to the last note in the sequence.
+ if (previous < 0) {
+ previous = sizeof(note_sequence) - 1;
+ }
- // Send Note On for current position at full velocity (127) on channel 1.
- uint8_t note_on[3] = { 0x90 | channel, note_sequence[note_pos], 127 };
- tud_midi_stream_write(cable_num, note_on, 3);
+ // Send Note On for current position at full velocity (127) on channel 1.
+ uint8_t note_on[3] = { 0x90 | channel, note_sequence[note_pos], 127 };
+ tud_midi_stream_write(cable_num, note_on, 3);
- // Send Note Off for previous note.
- uint8_t note_off[3] = { 0x80 | channel, note_sequence[previous], 0};
- tud_midi_stream_write(cable_num, note_off, 3);
+ // Send Note Off for previous note.
+ uint8_t note_off[3] = { 0x80 | channel, note_sequence[previous], 0};
+ tud_midi_stream_write(cable_num, note_off, 3);
- // Increment position
- note_pos++;
+ // Increment position
+ note_pos++;
- // If we are at the end of the sequence, start over.
- if (note_pos >= sizeof(note_sequence)) {
- note_pos = 0;
- }
+ // If we are at the end of the sequence, start over.
+ if (note_pos >= sizeof(note_sequence)) {
+ note_pos = 0;
+ }
-#if CFG_TUSB_OS != OPT_OS_FREERTOS
- break;
-#endif
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
}
+#endif
}
//--------------------------------------------------------------------+
@@ -195,24 +195,23 @@ void led_blinking_task(void *param) {
static uint32_t start_ms = 0;
#endif
- while (1) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ while (1) {
vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
#else
- // Blink every interval ms
- if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
- return; // not enough time
- }
- start_ms += blink_interval_ms;
+ // Blink every interval ms
+ if (tusb_time_millis_api() - start_ms < blink_interval_ms) {
+ return; // not enough time
+ }
+ start_ms += blink_interval_ms;
#endif
- board_led_write(led_state);
- led_state = 1 - led_state; // toggle
+ board_led_write(led_state);
+ led_state = 1 - led_state; // toggle
-#if CFG_TUSB_OS != OPT_OS_FREERTOS
- break;
-#endif
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
}
+#endif
}
//--------------------------------------------------------------------+
diff --git a/examples/device/uac2_speaker_fb/src/main.c b/examples/device/uac2_speaker_fb/src/main.c
index e09015382..c57203a8c 100644
--- a/examples/device/uac2_speaker_fb/src/main.c
+++ b/examples/device/uac2_speaker_fb/src/main.c
@@ -95,6 +95,7 @@ int main(void) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
freertos_init();
+ return 0;
#else
// init device stack on configured roothub port
tusb_rhport_init_t dev_init = {
@@ -115,8 +116,6 @@ int main(void) {
audio_task(NULL);
}
#endif
-
- return 0;
}
//--------------------------------------------------------------------+
@@ -602,32 +601,32 @@ void audio_task(void *param) {
(void) param;
static uint32_t start_ms = 0;
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
while (1) {
- uint32_t curr_ms = tusb_time_millis_api();
- if (start_ms != curr_ms) {
- start_ms = curr_ms;
-
- uint16_t length = (uint16_t) (current_sample_rate / 1000 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX);
+#endif
+ uint32_t curr_ms = tusb_time_millis_api();
+ if (start_ms != curr_ms) {
+ start_ms = curr_ms;
- if (current_sample_rate == 44100 && (curr_ms % 10 == 0)) {
- // Take one more sample every 10 cycles, to have a average reading speed of 44.1
- // This correction is not needed in real world cases
- length += CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX;
- } else if (current_sample_rate == 88200 && (curr_ms % 5 == 0)) {
- // Take one more sample every 5 cycles, to have a average reading speed of 88.2
- // This correction is not needed in real world cases
- length += CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX;
- }
+ uint16_t length = (uint16_t) (current_sample_rate / 1000 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX);
- tud_audio_read(i2s_dummy_buffer, length);
+ if (current_sample_rate == 44100 && (curr_ms % 10 == 0)) {
+ // Take one more sample every 10 cycles, to have a average reading speed of 44.1
+ // This correction is not needed in real world cases
+ length += CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX;
+ } else if (current_sample_rate == 88200 && (curr_ms % 5 == 0)) {
+ // Take one more sample every 5 cycles, to have a average reading speed of 88.2
+ // This correction is not needed in real world cases
+ length += CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX;
}
+ tud_audio_read(i2s_dummy_buffer, length);
+ }
+
#if CFG_TUSB_OS == OPT_OS_FREERTOS
- vTaskDelay(1);
-#else
- return;
-#endif
+ vTaskDelay(1);
}
+#endif
}
//--------------------------------------------------------------------+
@@ -637,19 +636,22 @@ void led_blinking_task(void *param) {
(void) param;
static bool led_state = false;
- while (1) {
#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ while (1) {
vTaskDelay(blink_interval_ms / portTICK_PERIOD_MS);
#else
- static uint32_t start_ms = 0;
- // Blink every interval ms
- if (tusb_time_millis_api() - start_ms < blink_interval_ms) return;
- start_ms += blink_interval_ms;
+ static uint32_t start_ms = 0;
+ // Blink every interval ms
+ if (tusb_time_millis_api() - start_ms < blink_interval_ms) return;
+ start_ms += blink_interval_ms;
#endif
- board_led_write(led_state);
- led_state = 1 - led_state;
+ board_led_write(led_state);
+ led_state = 1 - led_state;
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
}
+#endif
}
#if CFG_AUDIO_DEBUG
diff --git a/examples/host/cdc_msc_hid/src/main.c b/examples/host/cdc_msc_hid/src/main.c
index c2685e847..3ed5883a2 100644
--- a/examples/host/cdc_msc_hid/src/main.c
+++ b/examples/host/cdc_msc_hid/src/main.c
@@ -87,6 +87,8 @@ int main(void) {
#ifndef ESP_PLATFORM
vTaskStartScheduler();
#endif
+
+ return 0;
#else
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
@@ -112,8 +114,6 @@ int main(void) {
hid_app_task();
}
#endif
-
- return 0;
}
#ifdef ESP_PLATFORM
diff --git a/examples/host/msc_file_explorer/src/main.c b/examples/host/msc_file_explorer/src/main.c
index 58b51761b..d1002bbee 100644
--- a/examples/host/msc_file_explorer/src/main.c
+++ b/examples/host/msc_file_explorer/src/main.c
@@ -87,6 +87,8 @@ int main(void) {
#ifndef ESP_PLATFORM
vTaskStartScheduler();
#endif
+
+ return 0;
#else
// init host stack on configured roothub port
tusb_rhport_init_t host_init = {
@@ -107,8 +109,6 @@ int main(void) {
led_blinking_task();
}
#endif
-
- return 0;
}
#ifdef ESP_PLATFORM