@@ -60,6 +60,8 @@ struct UsbUartBridge {
60
60
61
61
FuriApiLock cfg_lock ;
62
62
63
+ CliVcp * cli_vcp ;
64
+
63
65
uint8_t rx_buf [USB_CDC_PKT_LEN ];
64
66
};
65
67
@@ -105,15 +107,11 @@ static void usb_uart_on_irq_rx_dma_cb(
105
107
static void usb_uart_vcp_init (UsbUartBridge * usb_uart , uint8_t vcp_ch ) {
106
108
furi_hal_usb_unlock ();
107
109
if (vcp_ch == 0 ) {
108
- CliVcp * cli_vcp = furi_record_open (RECORD_CLI_VCP );
109
- cli_vcp_disable (cli_vcp );
110
- furi_record_close (RECORD_CLI_VCP );
110
+ cli_vcp_disable (usb_uart -> cli_vcp );
111
111
furi_check (furi_hal_usb_set_config (& usb_cdc_single , NULL ) == true);
112
112
} else {
113
113
furi_check (furi_hal_usb_set_config (& usb_cdc_dual , NULL ) == true);
114
- CliVcp * cli_vcp = furi_record_open (RECORD_CLI_VCP );
115
- cli_vcp_enable (cli_vcp );
116
- furi_record_close (RECORD_CLI_VCP );
114
+ cli_vcp_enable (usb_uart -> cli_vcp );
117
115
}
118
116
furi_hal_cdc_set_callbacks (vcp_ch , (CdcCallbacks * )& cdc_cb , usb_uart );
119
117
}
@@ -122,9 +120,7 @@ static void usb_uart_vcp_deinit(UsbUartBridge* usb_uart, uint8_t vcp_ch) {
122
120
UNUSED (usb_uart );
123
121
furi_hal_cdc_set_callbacks (vcp_ch , NULL , NULL );
124
122
if (vcp_ch != 0 ) {
125
- CliVcp * cli_vcp = furi_record_open (RECORD_CLI_VCP );
126
- cli_vcp_disable (cli_vcp );
127
- furi_record_close (RECORD_CLI_VCP );
123
+ cli_vcp_disable (usb_uart -> cli_vcp );
128
124
}
129
125
}
130
126
@@ -176,6 +172,8 @@ static int32_t usb_uart_worker(void* context) {
176
172
177
173
memcpy (& usb_uart -> cfg , & usb_uart -> cfg_new , sizeof (UsbUartConfig ));
178
174
175
+ usb_uart -> cli_vcp = furi_record_open (RECORD_CLI_VCP );
176
+
179
177
usb_uart -> rx_stream = furi_stream_buffer_alloc (USB_UART_RX_BUF_SIZE , 1 );
180
178
181
179
usb_uart -> tx_sem = furi_semaphore_alloc (1 , 1 );
@@ -308,8 +306,8 @@ static int32_t usb_uart_worker(void* context) {
308
306
309
307
furi_hal_usb_unlock ();
310
308
furi_check (furi_hal_usb_set_config (& usb_cdc_single , NULL ) == true);
311
- CliVcp * cli_vcp = furi_record_open ( RECORD_CLI_VCP );
312
- cli_vcp_enable ( cli_vcp );
309
+ cli_vcp_enable ( usb_uart -> cli_vcp );
310
+
313
311
furi_record_close (RECORD_CLI_VCP );
314
312
315
313
return 0 ;
0 commit comments