Skip to content

Commit 00ba4e9

Browse files
committed
cdch: de-configure when closing, rename configured to mounted
1 parent 82be247 commit 00ba4e9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/class/cdc/cdc_host.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ typedef struct {
5353
uint8_t bInterfaceSubClass;
5454
uint8_t bInterfaceProtocol;
5555

56+
uint8_t ep_notif;
5657
uint8_t serial_drid; // Serial Driver ID
58+
bool mounted; // Enumeration is complete
5759
cdc_acm_capability_t acm_capability;
58-
uint8_t ep_notif;
5960

60-
uint8_t line_state; // DTR (bit0), RTS (bit1)
6161
TU_ATTR_ALIGNED(4) cdc_line_coding_t line_coding; // Baudrate, stop bits, parity, data width
62+
uint8_t line_state; // DTR (bit0), RTS (bit1)
6263

6364
#if CFG_TUH_CDC_FTDI || CFG_TUH_CDC_CP210X || CFG_TUH_CDC_CH34X
6465
cdc_line_coding_t requested_line_coding;
@@ -77,8 +78,6 @@ typedef struct {
7778
uint8_t rx_ff_buf[CFG_TUH_CDC_TX_BUFSIZE];
7879
CFG_TUH_MEM_ALIGN uint8_t rx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
7980
} stream;
80-
81-
bool configured;
8281
} cdch_interface_t;
8382

8483
CFG_TUH_MEM_SECTION
@@ -259,7 +258,6 @@ static cdch_interface_t* make_new_itf(uint8_t daddr, tusb_desc_interface_t const
259258
p_cdc->bInterfaceSubClass = itf_desc->bInterfaceSubClass;
260259
p_cdc->bInterfaceProtocol = itf_desc->bInterfaceProtocol;
261260
p_cdc->line_state = 0;
262-
p_cdc->configured = false;
263261
return p_cdc;
264262
}
265263
}
@@ -309,7 +307,7 @@ bool tuh_cdc_itf_get_info(uint8_t idx, tuh_itf_info_t* info) {
309307
bool tuh_cdc_mounted(uint8_t idx) {
310308
cdch_interface_t* p_cdc = get_itf(idx);
311309
TU_VERIFY(p_cdc);
312-
return p_cdc->configured;
310+
return p_cdc->mounted;
313311
}
314312

315313
bool tuh_cdc_get_dtr(uint8_t idx) {
@@ -648,9 +646,9 @@ void cdch_close(uint8_t daddr) {
648646
// Invoke application callback
649647
if (tuh_cdc_umount_cb) tuh_cdc_umount_cb(idx);
650648

651-
//tu_memclr(p_cdc, sizeof(cdch_interface_t));
652649
p_cdc->daddr = 0;
653650
p_cdc->bInterfaceNumber = 0;
651+
p_cdc->mounted = false;
654652
tu_edpt_stream_close(&p_cdc->stream.tx);
655653
tu_edpt_stream_close(&p_cdc->stream.rx);
656654
}
@@ -751,7 +749,7 @@ bool cdch_open(uint8_t rhport, uint8_t daddr, tusb_desc_interface_t const *itf_d
751749

752750
static void set_config_complete(cdch_interface_t * p_cdc, uint8_t idx, uint8_t itf_num) {
753751
TU_LOG_DRV("CDCh Set Configure complete\r\n");
754-
p_cdc->configured = true;
752+
p_cdc->mounted = true;
755753
if (tuh_cdc_mount_cb) tuh_cdc_mount_cb(idx);
756754

757755
// Prepare for incoming data

0 commit comments

Comments
 (0)