Skip to content

Commit 712abe1

Browse files
authored
Merge pull request #63 from BerranRemzi/main
Replace tud_cdc_connected() with tud_ready() to ensure proper USB state detection
2 parents bb28a3f + 4a6e39d commit 712abe1

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

pico_sdk_sigrok/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ include(pico_sdk_import.cmake)
2121
project(pico_sdk_sigrok C CXX ASM)
2222
set(CMAKE_C_STANDARD 11)
2323
set(CMAKE_CXX_STANDARD 17)
24+
# DTR is not used for USB CDC connection, so we can set this to 1
25+
# This will allow PulseView to connect independently of the DTR signal
26+
add_definitions(-DPICO_STDIO_USB_CONNECTION_WITHOUT_DTR=1)
2427
pico_sdk_init()
2528

2629
add_executable(pico_sdk_sigrok
-8.5 KB
Binary file not shown.

pico_sdk_sigrok/pico_sdk_sigrok.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ volatile bool mask_xfer_err;
6767
void my_stdio_usb_out_chars(const char *buf, int length) {
6868
static uint64_t last_avail_time;
6969
uint32_t owner;
70-
if (tud_cdc_connected()) {
70+
if (tud_ready()) {
7171
for (int i = 0; i < length;) {
7272
int n = length - i;
7373
int avail = (int) tud_cdc_write_available();
@@ -81,7 +81,7 @@ void my_stdio_usb_out_chars(const char *buf, int length) {
8181
} else {
8282
tud_task();
8383
tud_cdc_write_flush();
84-
if (!tud_cdc_connected() ||
84+
if (!tud_ready() ||
8585
(!tud_cdc_write_available() && time_us_64() > last_avail_time + PICO_STDIO_USB_STDOUT_TIMEOUT_US)) {
8686
break;
8787
}

0 commit comments

Comments
 (0)