|
@@ -1,10 +1,11 @@
|
|
|
#include "avr_isp_worker.h"
|
|
#include "avr_isp_worker.h"
|
|
|
-#include <furi_hal_pwm.h>
|
|
|
|
|
#include "../lib/driver/avr_isp_prog.h"
|
|
#include "../lib/driver/avr_isp_prog.h"
|
|
|
#include "../lib/driver/avr_isp_prog_cmd.h"
|
|
#include "../lib/driver/avr_isp_prog_cmd.h"
|
|
|
#include "../lib/driver/avr_isp_chip_arr.h"
|
|
#include "../lib/driver/avr_isp_chip_arr.h"
|
|
|
|
|
|
|
|
#include <furi.h>
|
|
#include <furi.h>
|
|
|
|
|
+#include <furi_hal_pwm.h>
|
|
|
|
|
+#include <cli/cli_vcp.h>
|
|
|
|
|
|
|
|
#define TAG "AvrIspWorker"
|
|
#define TAG "AvrIspWorker"
|
|
|
|
|
|
|
@@ -26,6 +27,7 @@ struct AvrIspWorker {
|
|
|
uint8_t connect_usb;
|
|
uint8_t connect_usb;
|
|
|
AvrIspWorkerCallback callback;
|
|
AvrIspWorkerCallback callback;
|
|
|
void* context;
|
|
void* context;
|
|
|
|
|
+ CliVcp* cli_vcp;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
#define AVR_ISP_WORKER_PROG_ALL_EVENTS (AvrIspWorkerEvtStop)
|
|
#define AVR_ISP_WORKER_PROG_ALL_EVENTS (AvrIspWorkerEvtStop)
|
|
@@ -35,12 +37,10 @@ struct AvrIspWorker {
|
|
|
|
|
|
|
|
//########################/* VCP CDC */#############################################
|
|
//########################/* VCP CDC */#############################################
|
|
|
#include "usb_cdc.h"
|
|
#include "usb_cdc.h"
|
|
|
-#include <cli/cli_vcp.h>
|
|
|
|
|
-#include <cli/cli.h>
|
|
|
|
|
#include <furi_hal_usb_cdc.h>
|
|
#include <furi_hal_usb_cdc.h>
|
|
|
|
|
|
|
|
-#define AVR_ISP_VCP_CDC_CH 1
|
|
|
|
|
-#define AVR_ISP_VCP_CDC_PKT_LEN CDC_DATA_SZ
|
|
|
|
|
|
|
+#define AVR_ISP_VCP_CDC_CH 1
|
|
|
|
|
+#define AVR_ISP_VCP_CDC_PKT_LEN CDC_DATA_SZ
|
|
|
#define AVR_ISP_VCP_UART_RX_BUF_SIZE (AVR_ISP_VCP_CDC_PKT_LEN * 5)
|
|
#define AVR_ISP_VCP_UART_RX_BUF_SIZE (AVR_ISP_VCP_CDC_PKT_LEN * 5)
|
|
|
|
|
|
|
|
static void vcp_on_cdc_tx_complete(void* context);
|
|
static void vcp_on_cdc_tx_complete(void* context);
|
|
@@ -89,35 +89,26 @@ static void vcp_on_line_config(void* context, struct usb_cdc_line_coding* config
|
|
|
UNUSED(config);
|
|
UNUSED(config);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void avr_isp_worker_vcp_cdc_init(void* context) {
|
|
|
|
|
- furi_hal_usb_unlock();
|
|
|
|
|
- Cli* cli = furi_record_open(RECORD_CLI);
|
|
|
|
|
- //close cli
|
|
|
|
|
- cli_session_close(cli);
|
|
|
|
|
- //disable callbacks VCP_CDC=0
|
|
|
|
|
- furi_hal_cdc_set_callbacks(0, NULL, NULL);
|
|
|
|
|
- //set 2 cdc
|
|
|
|
|
|
|
+static void avr_isp_worker_vcp_cdc_init(AvrIspWorker* worker) {
|
|
|
|
|
+ worker->cli_vcp = furi_record_open(RECORD_CLI_VCP);
|
|
|
|
|
+
|
|
|
|
|
+ cli_vcp_disable(worker->cli_vcp);
|
|
|
furi_check(furi_hal_usb_set_config(&usb_cdc_dual, NULL) == true);
|
|
furi_check(furi_hal_usb_set_config(&usb_cdc_dual, NULL) == true);
|
|
|
- //open cli VCP_CDC=0
|
|
|
|
|
- cli_session_open(cli, &cli_vcp);
|
|
|
|
|
- furi_record_close(RECORD_CLI);
|
|
|
|
|
|
|
+ furi_hal_usb_lock();
|
|
|
|
|
+ cli_vcp_enable(worker->cli_vcp);
|
|
|
|
|
|
|
|
- furi_hal_cdc_set_callbacks(AVR_ISP_VCP_CDC_CH, (CdcCallbacks*)&cdc_cb, context);
|
|
|
|
|
|
|
+ furi_hal_cdc_set_callbacks(AVR_ISP_VCP_CDC_CH, (CdcCallbacks*)&cdc_cb, worker);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void avr_isp_worker_vcp_cdc_deinit(void) {
|
|
|
|
|
- //disable callbacks AVR_ISP_VCP_CDC_CH
|
|
|
|
|
|
|
+static void avr_isp_worker_vcp_cdc_deinit(AvrIspWorker* worker) {
|
|
|
furi_hal_cdc_set_callbacks(AVR_ISP_VCP_CDC_CH, NULL, NULL);
|
|
furi_hal_cdc_set_callbacks(AVR_ISP_VCP_CDC_CH, NULL, NULL);
|
|
|
|
|
|
|
|
- Cli* cli = furi_record_open(RECORD_CLI);
|
|
|
|
|
- //close cli
|
|
|
|
|
- cli_session_close(cli);
|
|
|
|
|
|
|
+ cli_vcp_disable(worker->cli_vcp);
|
|
|
furi_hal_usb_unlock();
|
|
furi_hal_usb_unlock();
|
|
|
- //set 1 cdc
|
|
|
|
|
furi_check(furi_hal_usb_set_config(&usb_cdc_single, NULL) == true);
|
|
furi_check(furi_hal_usb_set_config(&usb_cdc_single, NULL) == true);
|
|
|
- //open cli VCP_CDC=0
|
|
|
|
|
- cli_session_open(cli, &cli_vcp);
|
|
|
|
|
- furi_record_close(RECORD_CLI);
|
|
|
|
|
|
|
+ cli_vcp_enable(worker->cli_vcp);
|
|
|
|
|
+
|
|
|
|
|
+ furi_record_close(RECORD_CLI_VCP);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//#################################################################################
|
|
//#################################################################################
|
|
@@ -209,7 +200,7 @@ static int32_t avr_isp_worker_thread(void* context) {
|
|
|
|
|
|
|
|
avr_isp_prog_free(prog);
|
|
avr_isp_prog_free(prog);
|
|
|
furi_hal_pwm_stop(FuriHalPwmOutputIdLptim2PA4);
|
|
furi_hal_pwm_stop(FuriHalPwmOutputIdLptim2PA4);
|
|
|
- avr_isp_worker_vcp_cdc_deinit();
|
|
|
|
|
|
|
+ avr_isp_worker_vcp_cdc_deinit(instance);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|