فهرست منبع

Merge avr_isp from https://github.com/flipperdevices/flipperzero-good-faps

Willy-JL 8 ماه پیش
والد
کامیت
9d4e4b6c26

+ 2 - 0
avr_isp/.catalog/changelog.md

@@ -1,3 +1,5 @@
+## 1.5
+  - Updated for latest SDK API changes
 ## 1.4
  - Removed call to legacy SDK API
 ## 1.3

+ 1 - 1
avr_isp/.gitsubtree

@@ -1,2 +1,2 @@
 https://github.com/xMasterX/all-the-plugins dev base_pack/avr_isp_programmer e4bf49882c5f590746e35583d821a926c757d9e7
-https://github.com/flipperdevices/flipperzero-good-faps dev avr_isp_programmer b791dea234f855155027bb46215dc60f3ddeb243
+https://github.com/flipperdevices/flipperzero-good-faps dev avr_isp_programmer a9c6700663c0eb8b9bed884eff5545c4ab818358

+ 1 - 1
avr_isp/application.fam

@@ -6,7 +6,7 @@ App(
     requires=["gui"],
     stack_size=4 * 1024,
     fap_description="Application for flashing AVR microcontrollers",
-    fap_version="1.4",
+    fap_version="1.5",
     fap_icon="avr_app_icon_10px.png",
     fap_category="GPIO/Debug",
     fap_icon_assets="images",

+ 19 - 0
avr_isp/avr_isp_app.c

@@ -168,6 +168,25 @@ void avr_isp_app_free(AvrIspApp* app) {
 
 int32_t avr_isp_app(void* p) {
     UNUSED(p);
+
+    if(furi_hal_usb_is_locked()) {
+        DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
+        DialogMessage* message = dialog_message_alloc();
+        dialog_message_set_header(message, "Connection\nis active!", 3, 2, AlignLeft, AlignTop);
+        dialog_message_set_text(
+            message,
+            "Disconnect\ncompanion app to\nuse this function.",
+            3,
+            30,
+            AlignLeft,
+            AlignTop);
+        dialog_message_set_icon(message, &I_ActiveConnection_50x64, 78, 0);
+        dialog_message_show(dialogs, message);
+        dialog_message_free(message);
+        furi_record_close(RECORD_DIALOGS);
+        return -1;
+    }
+
     AvrIspApp* avr_isp_app = avr_isp_app_alloc();
 
     view_dispatcher_run(avr_isp_app->view_dispatcher);

+ 15 - 24
avr_isp/helpers/avr_isp_worker.c

@@ -1,10 +1,11 @@
 #include "avr_isp_worker.h"
-#include <furi_hal_pwm.h>
 #include "../lib/driver/avr_isp_prog.h"
 #include "../lib/driver/avr_isp_prog_cmd.h"
 #include "../lib/driver/avr_isp_chip_arr.h"
 
 #include <furi.h>
+#include <furi_hal_pwm.h>
+#include <cli/cli_vcp.h>
 
 #define TAG "AvrIspWorker"
 
@@ -26,6 +27,7 @@ struct AvrIspWorker {
     uint8_t connect_usb;
     AvrIspWorkerCallback callback;
     void* context;
+    CliVcp* cli_vcp;
 };
 
 #define AVR_ISP_WORKER_PROG_ALL_EVENTS (AvrIspWorkerEvtStop)
@@ -35,8 +37,6 @@ struct AvrIspWorker {
 
 //########################/* VCP CDC */#############################################
 #include "usb_cdc.h"
-#include <cli/cli_vcp.h>
-#include <cli/cli.h>
 #include <furi_hal_usb_cdc.h>
 
 #define AVR_ISP_VCP_CDC_CH           1
@@ -89,34 +89,25 @@ static void vcp_on_line_config(void* context, struct usb_cdc_line_coding* config
     UNUSED(config);
 }
 
-static void avr_isp_worker_vcp_cdc_init(void* context) {
-    furi_hal_usb_unlock();
-    CliVcp* cli_vcp = furi_record_open(RECORD_CLI_VCP);
-    //close cli
-    cli_vcp_disable(cli_vcp);
-    //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);
-    //open cli VCP_CDC=0
-    cli_vcp_enable(cli_vcp);
-    furi_record_close(RECORD_CLI_VCP);
+    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);
 
-    CliVcp* cli_vcp = furi_record_open(RECORD_CLI_VCP);
-    //close cli
-    cli_vcp_disable(cli_vcp);
+    cli_vcp_disable(worker->cli_vcp);
     furi_hal_usb_unlock();
-    //set 1 cdc
     furi_check(furi_hal_usb_set_config(&usb_cdc_single, NULL) == true);
-    //open cli VCP_CDC=0
-    cli_vcp_enable(cli_vcp);
+    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);
     furi_hal_pwm_stop(FuriHalPwmOutputIdLptim2PA4);
-    avr_isp_worker_vcp_cdc_deinit();
+    avr_isp_worker_vcp_cdc_deinit(instance);
     return 0;
 }
 

BIN
avr_isp/images/ActiveConnection_50x64.png