Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
Language: Cpp
BasedOnStyle: LLVM
AlignAfterOpenBracket: AlwaysBreak
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
Expand Down Expand Up @@ -38,6 +38,7 @@ AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
Expand All @@ -57,11 +58,14 @@ BraceWrapping:
SplitEmptyRecord: true
SplitEmptyNamespace: true
BracedInitializerIndentWidth: 2
BreakBeforeBinaryOperators: None
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
ContinuationIndentWidth: 2
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: true
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<.*'
Priority: 1
Expand All @@ -78,6 +82,8 @@ MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PenaltyBreakBeforeFirstCallParameter: 1000000
PenaltyBreakOpenParenthesis: 1000000
QualifierAlignment: Custom
QualifierOrder: ['static', 'const', 'volatile', 'restrict', 'type']
ReflowComments: false
Expand Down
2 changes: 1 addition & 1 deletion examples/device/net_lwip_webserver/src/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, const tusb_contro

switch (request->bmRequestType_bit.type) {
case TUSB_REQ_TYPE_VENDOR:
switch (request->bRequest) { //-V2520 //-V2659
switch (request->bRequest) {
case 1:
if (request->wIndex == 7) {
// Get Microsoft OS 2.0 compatible descriptor
Expand Down
26 changes: 18 additions & 8 deletions examples/dual/host_info_to_device_cdc/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ enum {

static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;

static bool is_print[CFG_TUH_DEVICE_MAX+1] = { 0 };
static bool is_printable[CFG_TUH_DEVICE_MAX + 1] = {0};
static tusb_desc_device_t descriptor_device[CFG_TUH_DEVICE_MAX+1];

static void print_utf16(uint16_t *temp_buf, size_t buf_len);
Expand Down Expand Up @@ -106,6 +106,10 @@ static void usb_device_init(void) {
.speed = TUSB_SPEED_AUTO
};
tusb_init(BOARD_TUD_RHPORT, &dev_init);
tud_cdc_configure_t cdc_cfg = TUD_CDC_CONFIGURE_DEFAULT();
cdc_cfg.tx_persistent = true;
cdc_cfg.tx_overwritabe_if_not_connected = false;
tud_cdc_configure(&cdc_cfg);
board_init_after_tusb();
}

Expand Down Expand Up @@ -206,17 +210,23 @@ void tud_resume_cb(void) {
}

void cdc_task(void) {
static uint32_t connected_ms = 0;

if (!tud_cdc_connected()) {
// delay a bit otherwise we can outpace host's terminal. Linux will set LineState (DTR) then Line Coding.
// If we send data before Linux's terminal set Line Coding, it can be ignored --> missing data with hardware test loop
tusb_time_delay_ms_api(20);
connected_ms = board_millis();
return;
}

// delay a bit otherwise we can outpace host's terminal. Linux will set LineState (DTR) then Line Coding.
// If we send data before Linux's terminal set Line Coding, it can be ignored --> missing data with hardware test loop
if (board_millis() - connected_ms < 100) {
return; // wait for stable connection
}

for (uint8_t daddr = 1; daddr <= CFG_TUH_DEVICE_MAX; daddr++) {
if (tuh_mounted(daddr)) {
if (is_print[daddr]) {
is_print[daddr] = false;
if (is_printable[daddr]) {
is_printable[daddr] = false;
print_device_info(daddr, &descriptor_device[daddr]);
tud_cdc_write_flush();
}
Expand Down Expand Up @@ -283,13 +293,13 @@ void tuh_enum_descriptor_device_cb(uint8_t daddr, tusb_desc_device_t const* desc
void tuh_mount_cb(uint8_t daddr) {
cdc_printf("mounted device %u\r\n", daddr);
tud_cdc_write_flush();
is_print[daddr] = true;
is_printable[daddr] = true;
}

void tuh_umount_cb(uint8_t daddr) {
cdc_printf("unmounted device %u\r\n", daddr);
tud_cdc_write_flush();
is_print[daddr] = false;
is_printable[daddr] = false;
}

//--------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion examples/dual/host_info_to_device_cdc/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@

// CDC FIFO size of TX and RX
#define CFG_TUD_CDC_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
#define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
#define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 256)

// CDC Endpoint transfer buffer size, more is faster
#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
Expand Down
Loading