Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-firmware into dev
@@ -10,7 +10,7 @@ on:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
TARGETS: f7
|
||||
TARGETS: f7 f18
|
||||
DEFAULT_TARGET: f7
|
||||
FBT_TOOLCHAIN_PATH: /home/runner/work
|
||||
|
||||
@@ -57,8 +57,9 @@ jobs:
|
||||
run: |
|
||||
set -e
|
||||
for TARGET in ${TARGETS}; do
|
||||
./fbt TARGET_HW="$(echo "${TARGET}" | sed 's/f//')" \
|
||||
copro_dist updater_package ${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
|
||||
TARGET="$(echo "${TARGET}" | sed 's/f//')"; \
|
||||
./fbt TARGET_HW=$TARGET copro_dist updater_package \
|
||||
${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
|
||||
done
|
||||
|
||||
- name: 'Move upload files'
|
||||
@@ -154,6 +155,6 @@ jobs:
|
||||
run: |
|
||||
set -e
|
||||
for TARGET in ${TARGETS}; do
|
||||
./fbt TARGET_HW="$(echo "${TARGET}" | sed 's/f//')" \
|
||||
updater_package DEBUG=0 COMPACT=1
|
||||
TARGET="$(echo "${TARGET}" | sed 's/f//')"; \
|
||||
./fbt TARGET_HW=$TARGET DEBUG=0 COMPACT=1 updater_package
|
||||
done
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
*.swp
|
||||
*.swo
|
||||
*.gdb_history
|
||||
|
||||
|
||||
|
||||
@@ -11,5 +11,8 @@
|
||||
"augustocdias.tasks-shell-input"
|
||||
],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": []
|
||||
}
|
||||
"unwantedRecommendations": [
|
||||
"twxs.cmake",
|
||||
"ms-vscode.cmake-tools"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="accessor",
|
||||
name="Accessor",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
targets=["f7"],
|
||||
entry_point="accessor_app",
|
||||
cdefines=["APP_ACCESSOR"],
|
||||
requires=["gui"],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "bt_carrier_test.h"
|
||||
#include "bt_test.h"
|
||||
#include "bt_test_types.h"
|
||||
#include "furi_hal_bt.h"
|
||||
#include <furi_hal_bt.h>
|
||||
|
||||
struct BtCarrierTest {
|
||||
BtTest* bt_test;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "bt_packet_test.h"
|
||||
#include "bt_test.h"
|
||||
#include "bt_test_types.h"
|
||||
#include "furi_hal_bt.h"
|
||||
#include <furi_hal_bt.h>
|
||||
|
||||
struct BtPacketTest {
|
||||
BtTest* bt_test;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <file_browser_test_icons.h>
|
||||
#include "file_browser_app_i.h"
|
||||
#include "gui/modules/file_browser.h"
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <file_browser_test_icons.h>
|
||||
|
||||
#include <gui/modules/file_browser.h>
|
||||
#include <storage/storage.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
static bool file_browser_app_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="lfrfid_debug",
|
||||
name="LF-RFID Debug",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
targets=["f7"],
|
||||
entry_point="lfrfid_debug_app",
|
||||
requires=[
|
||||
"gui",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <archive/views/archive_browser_view.h>
|
||||
#include "archive_files.h"
|
||||
#include "archive_apps.h"
|
||||
#include "archive_browser.h"
|
||||
#include "../views/archive_browser_view.h"
|
||||
|
||||
#include <core/common_defines.h>
|
||||
#include <core/log.h>
|
||||
#include "gui/modules/file_browser_worker.h"
|
||||
#include <gui/modules/file_browser_worker.h>
|
||||
#include <fap_loader/fap_loader_app.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "../helpers/archive_files.h"
|
||||
#include "../helpers/archive_favorites.h"
|
||||
|
||||
#include <gui/gui_i.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/canvas.h>
|
||||
#include <gui/elements.h>
|
||||
#include <furi.h>
|
||||
#include <gui/modules/file_browser_worker.h>
|
||||
#include <storage/storage.h>
|
||||
#include "../helpers/archive_files.h"
|
||||
#include "../helpers/archive_menu.h"
|
||||
#include "../helpers/archive_favorites.h"
|
||||
#include "gui/modules/file_browser_worker.h"
|
||||
#include <furi.h>
|
||||
|
||||
#define MAX_LEN_PX 110
|
||||
#define MAX_NAME_LEN 255
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../bad_usb_app_i.h"
|
||||
#include "furi_hal_power.h"
|
||||
#include "furi_hal_usb.h"
|
||||
#include <furi_hal_power.h>
|
||||
#include <furi_hal_usb.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
static bool bad_usb_file_select(BadUsbApp* bad_usb) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../bad_usb_script.h"
|
||||
#include "../bad_usb_app_i.h"
|
||||
#include "../views/bad_usb_view.h"
|
||||
#include "furi_hal.h"
|
||||
#include <furi_hal.h>
|
||||
#include "toolbox/path.h"
|
||||
|
||||
void bad_usb_scene_work_button_callback(InputKey key, void* context) {
|
||||
|
||||
@@ -25,6 +25,7 @@ GpioApp* gpio_app_alloc() {
|
||||
GpioApp* app = malloc(sizeof(GpioApp));
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->gpio_items = gpio_items_alloc();
|
||||
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
app->scene_manager = scene_manager_alloc(&gpio_scene_handlers, app);
|
||||
@@ -47,7 +48,7 @@ GpioApp* gpio_app_alloc() {
|
||||
app->view_dispatcher,
|
||||
GpioAppViewVarItemList,
|
||||
variable_item_list_get_view(app->var_item_list));
|
||||
app->gpio_test = gpio_test_alloc();
|
||||
app->gpio_test = gpio_test_alloc(app->gpio_items);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, GpioAppViewGpioTest, gpio_test_get_view(app->gpio_test));
|
||||
|
||||
@@ -105,6 +106,7 @@ void gpio_app_free(GpioApp* app) {
|
||||
furi_record_close(RECORD_GUI);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
||||
gpio_items_free(app->gpio_items);
|
||||
free(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "gpio_app.h"
|
||||
#include "gpio_item.h"
|
||||
#include "gpio_items.h"
|
||||
#include "scenes/gpio_scene.h"
|
||||
#include "gpio_custom_event.h"
|
||||
#include "usb_uart_bridge.h"
|
||||
@@ -30,6 +30,7 @@ struct GpioApp {
|
||||
VariableItem* var_item_flow;
|
||||
GpioTest* gpio_test;
|
||||
GpioUsbUart* gpio_usb_uart;
|
||||
GPIOItems* gpio_items;
|
||||
UsbUartBridge* usb_uart_bridge;
|
||||
GpioI2CScanner* gpio_i2c_scanner;
|
||||
GpioI2CSfp* gpio_i2c_sfp;
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#include "gpio_item.h"
|
||||
|
||||
#include <furi_hal_resources.h>
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
const GpioPin* pin;
|
||||
} GpioItem;
|
||||
|
||||
static const GpioItem gpio_item[GPIO_ITEM_COUNT] = {
|
||||
{"1.2: PA7", &gpio_ext_pa7},
|
||||
{"1.3: PA6", &gpio_ext_pa6},
|
||||
{"1.4: PA4", &gpio_ext_pa4},
|
||||
{"1.5: PB3", &gpio_ext_pb3},
|
||||
{"1.6: PB2", &gpio_ext_pb2},
|
||||
{"1.7: PC3", &gpio_ext_pc3},
|
||||
{"2.7: PC1", &gpio_ext_pc1},
|
||||
{"2.8: PC0", &gpio_ext_pc0},
|
||||
};
|
||||
|
||||
void gpio_item_configure_pin(uint8_t index, GpioMode mode) {
|
||||
furi_assert(index < GPIO_ITEM_COUNT);
|
||||
furi_hal_gpio_write(gpio_item[index].pin, false);
|
||||
furi_hal_gpio_init(gpio_item[index].pin, mode, GpioPullNo, GpioSpeedVeryHigh);
|
||||
}
|
||||
|
||||
void gpio_item_configure_all_pins(GpioMode mode) {
|
||||
for(uint8_t i = 0; i < GPIO_ITEM_COUNT; i++) {
|
||||
gpio_item_configure_pin(i, mode);
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_item_set_pin(uint8_t index, bool level) {
|
||||
furi_assert(index < GPIO_ITEM_COUNT);
|
||||
furi_hal_gpio_write(gpio_item[index].pin, level);
|
||||
}
|
||||
|
||||
void gpio_item_set_all_pins(bool level) {
|
||||
for(uint8_t i = 0; i < GPIO_ITEM_COUNT; i++) {
|
||||
gpio_item_set_pin(i, level);
|
||||
}
|
||||
}
|
||||
|
||||
const char* gpio_item_get_pin_name(uint8_t index) {
|
||||
furi_assert(index < GPIO_ITEM_COUNT + 1);
|
||||
if(index == GPIO_ITEM_COUNT) {
|
||||
return "ALL";
|
||||
} else {
|
||||
return gpio_item[index].name;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi_hal_gpio.h>
|
||||
|
||||
#define GPIO_ITEM_COUNT 8
|
||||
|
||||
void gpio_item_configure_pin(uint8_t index, GpioMode mode);
|
||||
|
||||
void gpio_item_configure_all_pins(GpioMode mode);
|
||||
|
||||
void gpio_item_set_pin(uint8_t index, bool level);
|
||||
|
||||
void gpio_item_set_all_pins(bool level);
|
||||
|
||||
const char* gpio_item_get_pin_name(uint8_t index);
|
||||
@@ -0,0 +1,69 @@
|
||||
#include "gpio_items.h"
|
||||
|
||||
#include <furi_hal_resources.h>
|
||||
|
||||
struct GPIOItems {
|
||||
GpioPinRecord* pins;
|
||||
size_t count;
|
||||
};
|
||||
|
||||
GPIOItems* gpio_items_alloc() {
|
||||
GPIOItems* items = malloc(sizeof(GPIOItems));
|
||||
|
||||
items->count = 0;
|
||||
for(size_t i = 0; i < gpio_pins_count; i++) {
|
||||
if(!gpio_pins[i].debug) {
|
||||
items->count++;
|
||||
}
|
||||
}
|
||||
|
||||
items->pins = malloc(sizeof(GpioPinRecord) * items->count);
|
||||
for(size_t i = 0; i < items->count; i++) {
|
||||
if(!gpio_pins[i].debug) {
|
||||
items->pins[i].pin = gpio_pins[i].pin;
|
||||
items->pins[i].name = gpio_pins[i].name;
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
void gpio_items_free(GPIOItems* items) {
|
||||
free(items->pins);
|
||||
free(items);
|
||||
}
|
||||
|
||||
uint8_t gpio_items_get_count(GPIOItems* items) {
|
||||
return items->count;
|
||||
}
|
||||
|
||||
void gpio_items_configure_pin(GPIOItems* items, uint8_t index, GpioMode mode) {
|
||||
furi_assert(index < items->count);
|
||||
furi_hal_gpio_write(items->pins[index].pin, false);
|
||||
furi_hal_gpio_init(items->pins[index].pin, mode, GpioPullNo, GpioSpeedVeryHigh);
|
||||
}
|
||||
|
||||
void gpio_items_configure_all_pins(GPIOItems* items, GpioMode mode) {
|
||||
for(uint8_t i = 0; i < items->count; i++) {
|
||||
gpio_items_configure_pin(items, i, mode);
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_items_set_pin(GPIOItems* items, uint8_t index, bool level) {
|
||||
furi_assert(index < items->count);
|
||||
furi_hal_gpio_write(items->pins[index].pin, level);
|
||||
}
|
||||
|
||||
void gpio_items_set_all_pins(GPIOItems* items, bool level) {
|
||||
for(uint8_t i = 0; i < items->count; i++) {
|
||||
gpio_items_set_pin(items, i, level);
|
||||
}
|
||||
}
|
||||
|
||||
const char* gpio_items_get_pin_name(GPIOItems* items, uint8_t index) {
|
||||
furi_assert(index < items->count + 1);
|
||||
if(index == items->count) {
|
||||
return "ALL";
|
||||
} else {
|
||||
return items->pins[index].name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi_hal_gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct GPIOItems GPIOItems;
|
||||
|
||||
GPIOItems* gpio_items_alloc();
|
||||
|
||||
void gpio_items_free(GPIOItems* items);
|
||||
|
||||
uint8_t gpio_items_get_count(GPIOItems* items);
|
||||
|
||||
void gpio_items_configure_pin(GPIOItems* items, uint8_t index, GpioMode mode);
|
||||
|
||||
void gpio_items_configure_all_pins(GPIOItems* items, GpioMode mode);
|
||||
|
||||
void gpio_items_set_pin(GPIOItems* items, uint8_t index, bool level);
|
||||
|
||||
void gpio_items_set_all_pins(GPIOItems* items, bool level);
|
||||
|
||||
const char* gpio_items_get_pin_name(GPIOItems* items, uint8_t index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "../gpio_app_i.h"
|
||||
#include "furi_hal_power.h"
|
||||
#include "furi_hal_usb.h"
|
||||
#include <furi_hal_power.h>
|
||||
#include <furi_hal_usb.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
enum GpioItem {
|
||||
GpioItemUsbUart,
|
||||
|
||||
@@ -12,8 +12,9 @@ void gpio_scene_test_ok_callback(InputType type, void* context) {
|
||||
}
|
||||
|
||||
void gpio_scene_test_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
GpioApp* app = context;
|
||||
gpio_item_configure_all_pins(GpioModeOutputPushPull);
|
||||
gpio_items_configure_all_pins(app->gpio_items, GpioModeOutputPushPull);
|
||||
gpio_test_set_ok_callback(app->gpio_test, gpio_scene_test_ok_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewGpioTest);
|
||||
}
|
||||
@@ -25,6 +26,7 @@ bool gpio_scene_test_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
|
||||
void gpio_scene_test_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
gpio_item_configure_all_pins(GpioModeAnalog);
|
||||
furi_assert(context);
|
||||
GpioApp* app = context;
|
||||
gpio_items_configure_all_pins(app->gpio_items, GpioModeAnalog);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../usb_uart_bridge.h"
|
||||
#include "../gpio_app_i.h"
|
||||
#include "furi_hal.h"
|
||||
#include <furi_hal.h>
|
||||
|
||||
typedef enum {
|
||||
UsbUartLineIndexVcp,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "usb_uart_bridge.h"
|
||||
#include "furi_hal.h"
|
||||
#include <furi_hal_usb_cdc.h>
|
||||
#include "usb_cdc.h"
|
||||
#include "cli/cli_vcp.h"
|
||||
#include <cli/cli_vcp.h>
|
||||
#include <cli/cli.h>
|
||||
#include <toolbox/api_lock.h>
|
||||
#include "cli/cli.h"
|
||||
#include <furi_hal.h>
|
||||
#include <furi_hal_usb_cdc.h>
|
||||
|
||||
#define USB_CDC_PKT_LEN CDC_DATA_SZ
|
||||
#define USB_UART_RX_BUF_SIZE (USB_CDC_PKT_LEN * 5)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "gpio_test.h"
|
||||
#include "../gpio_item.h"
|
||||
#include "../gpio_items.h"
|
||||
|
||||
#include <gui/elements.h>
|
||||
|
||||
@@ -11,6 +11,7 @@ struct GpioTest {
|
||||
|
||||
typedef struct {
|
||||
uint8_t pin_idx;
|
||||
GPIOItems* gpio_items;
|
||||
} GpioTestModel;
|
||||
|
||||
static bool gpio_test_process_left(GpioTest* gpio_test);
|
||||
@@ -25,7 +26,12 @@ static void gpio_test_draw_callback(Canvas* canvas, void* _model) {
|
||||
elements_multiline_text_aligned(
|
||||
canvas, 64, 16, AlignCenter, AlignTop, "Press < or > to change pin");
|
||||
elements_multiline_text_aligned(
|
||||
canvas, 64, 32, AlignCenter, AlignTop, gpio_item_get_pin_name(model->pin_idx));
|
||||
canvas,
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
AlignTop,
|
||||
gpio_items_get_pin_name(model->gpio_items, model->pin_idx));
|
||||
}
|
||||
|
||||
static bool gpio_test_input_callback(InputEvent* event, void* context) {
|
||||
@@ -64,7 +70,7 @@ static bool gpio_test_process_right(GpioTest* gpio_test) {
|
||||
gpio_test->view,
|
||||
GpioTestModel * model,
|
||||
{
|
||||
if(model->pin_idx < GPIO_ITEM_COUNT) {
|
||||
if(model->pin_idx < gpio_items_get_count(model->gpio_items)) {
|
||||
model->pin_idx++;
|
||||
}
|
||||
},
|
||||
@@ -80,17 +86,17 @@ static bool gpio_test_process_ok(GpioTest* gpio_test, InputEvent* event) {
|
||||
GpioTestModel * model,
|
||||
{
|
||||
if(event->type == InputTypePress) {
|
||||
if(model->pin_idx < GPIO_ITEM_COUNT) {
|
||||
gpio_item_set_pin(model->pin_idx, true);
|
||||
if(model->pin_idx < gpio_items_get_count(model->gpio_items)) {
|
||||
gpio_items_set_pin(model->gpio_items, model->pin_idx, true);
|
||||
} else {
|
||||
gpio_item_set_all_pins(true);
|
||||
gpio_items_set_all_pins(model->gpio_items, true);
|
||||
}
|
||||
consumed = true;
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
if(model->pin_idx < GPIO_ITEM_COUNT) {
|
||||
gpio_item_set_pin(model->pin_idx, false);
|
||||
if(model->pin_idx < gpio_items_get_count(model->gpio_items)) {
|
||||
gpio_items_set_pin(model->gpio_items, model->pin_idx, false);
|
||||
} else {
|
||||
gpio_item_set_all_pins(false);
|
||||
gpio_items_set_all_pins(model->gpio_items, false);
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
@@ -101,11 +107,15 @@ static bool gpio_test_process_ok(GpioTest* gpio_test, InputEvent* event) {
|
||||
return consumed;
|
||||
}
|
||||
|
||||
GpioTest* gpio_test_alloc() {
|
||||
GpioTest* gpio_test_alloc(GPIOItems* gpio_items) {
|
||||
GpioTest* gpio_test = malloc(sizeof(GpioTest));
|
||||
|
||||
gpio_test->view = view_alloc();
|
||||
view_allocate_model(gpio_test->view, ViewModelTypeLocking, sizeof(GpioTestModel));
|
||||
|
||||
with_view_model(
|
||||
gpio_test->view, GpioTestModel * model, { model->gpio_items = gpio_items; }, false);
|
||||
|
||||
view_set_context(gpio_test->view, gpio_test);
|
||||
view_set_draw_callback(gpio_test->view, gpio_test_draw_callback);
|
||||
view_set_input_callback(gpio_test->view, gpio_test_input_callback);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "../gpio_items.h"
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
typedef struct GpioTest GpioTest;
|
||||
typedef void (*GpioTestOkCallback)(InputType type, void* context);
|
||||
|
||||
GpioTest* gpio_test_alloc();
|
||||
GpioTest* gpio_test_alloc(GPIOItems* gpio_items);
|
||||
|
||||
void gpio_test_free(GpioTest* gpio_test);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../usb_uart_bridge.h"
|
||||
#include "../gpio_app_i.h"
|
||||
#include "furi_hal.h"
|
||||
#include <furi_hal.h>
|
||||
#include <gui/elements.h>
|
||||
|
||||
struct GpioUsbUart {
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="ibutton",
|
||||
name="iButton",
|
||||
apptype=FlipperAppType.APP,
|
||||
targets=["f7"],
|
||||
entry_point="ibutton_app",
|
||||
cdefines=["APP_IBUTTON"],
|
||||
requires=[
|
||||
|
||||
@@ -3,6 +3,7 @@ App(
|
||||
name="Infrared",
|
||||
apptype=FlipperAppType.APP,
|
||||
entry_point="infrared_app",
|
||||
targets=["f7"],
|
||||
cdefines=["APP_INFRARED"],
|
||||
requires=[
|
||||
"gui",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../infrared_i.h"
|
||||
#include "gui/canvas.h"
|
||||
#include <gui/canvas.h>
|
||||
|
||||
typedef enum {
|
||||
InfraredRpcStateIdle,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "infrared_debug_view.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gui/canvas.h>
|
||||
#include <gui/elements.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define INFRARED_DEBUG_TEXT_LENGTH 64
|
||||
|
||||
struct InfraredDebugView {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#include <core/check.h>
|
||||
#include "furi_hal_resources.h"
|
||||
#include "assets_icons.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/view.h"
|
||||
#include "input/input.h"
|
||||
#include <gui/elements.h>
|
||||
#include <furi.h>
|
||||
#include "infrared_progress_view.h"
|
||||
#include "gui/modules/button_panel.h"
|
||||
|
||||
#include <assets_icons.h>
|
||||
#include <gui/canvas.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/elements.h>
|
||||
#include <gui/modules/button_panel.h>
|
||||
#include <input/input.h>
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal_resources.h>
|
||||
#include <core/check.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct InfraredProgressView {
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="lfrfid",
|
||||
name="125 kHz RFID",
|
||||
apptype=FlipperAppType.APP,
|
||||
targets=["f7"],
|
||||
entry_point="lfrfid_app",
|
||||
cdefines=["APP_LF_RFID"],
|
||||
requires=[
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="nfc",
|
||||
name="NFC",
|
||||
apptype=FlipperAppType.APP,
|
||||
targets=["f7"],
|
||||
entry_point="nfc_app",
|
||||
cdefines=["APP_NFC"],
|
||||
requires=[
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "nfc_i.h"
|
||||
#include "furi_hal_nfc.h"
|
||||
#include <furi_hal_nfc.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
bool nfc_custom_event_callback(void* context, uint32_t event) {
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="subghz",
|
||||
name="Sub-GHz",
|
||||
apptype=FlipperAppType.APP,
|
||||
targets=["f7"],
|
||||
entry_point="subghz_app",
|
||||
cdefines=["APP_SUBGHZ"],
|
||||
requires=[
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../u2f_app_i.h"
|
||||
#include "../views/u2f_view.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include "furi_hal.h"
|
||||
#include <furi_hal.h>
|
||||
#include "../u2f.h"
|
||||
|
||||
#define U2F_REQUEST_TIMEOUT 500
|
||||
|
||||
|
After Width: | Height: | Size: 172 B |
|
After Width: | Height: | Size: 173 B |
|
After Width: | Height: | Size: 180 B |
|
After Width: | Height: | Size: 177 B |
|
After Width: | Height: | Size: 179 B |
|
After Width: | Height: | Size: 178 B |
|
After Width: | Height: | Size: 177 B |
|
After Width: | Height: | Size: 178 B |
|
After Width: | Height: | Size: 177 B |
|
After Width: | Height: | Size: 176 B |
|
After Width: | Height: | Size: 176 B |
|
After Width: | Height: | Size: 179 B |
@@ -46,11 +46,25 @@ typedef struct {
|
||||
#define KEY_WIDTH 9
|
||||
#define KEY_HEIGHT 12
|
||||
#define KEY_PADDING 1
|
||||
#define ROW_COUNT 6
|
||||
#define ROW_COUNT 7
|
||||
#define COLUMN_COUNT 12
|
||||
|
||||
// 0 width items are not drawn, but there value is used
|
||||
const HidKeyboardKey hid_keyboard_keyset[ROW_COUNT][COLUMN_COUNT] = {
|
||||
{
|
||||
{.width = 1, .icon = &I_ButtonF1_5x8, .value = HID_KEYBOARD_F1},
|
||||
{.width = 1, .icon = &I_ButtonF2_5x8, .value = HID_KEYBOARD_F2},
|
||||
{.width = 1, .icon = &I_ButtonF3_5x8, .value = HID_KEYBOARD_F3},
|
||||
{.width = 1, .icon = &I_ButtonF4_5x8, .value = HID_KEYBOARD_F4},
|
||||
{.width = 1, .icon = &I_ButtonF5_5x8, .value = HID_KEYBOARD_F5},
|
||||
{.width = 1, .icon = &I_ButtonF6_5x8, .value = HID_KEYBOARD_F6},
|
||||
{.width = 1, .icon = &I_ButtonF7_5x8, .value = HID_KEYBOARD_F7},
|
||||
{.width = 1, .icon = &I_ButtonF8_5x8, .value = HID_KEYBOARD_F8},
|
||||
{.width = 1, .icon = &I_ButtonF9_5x8, .value = HID_KEYBOARD_F9},
|
||||
{.width = 1, .icon = &I_ButtonF10_5x8, .value = HID_KEYBOARD_F10},
|
||||
{.width = 1, .icon = &I_ButtonF11_5x8, .value = HID_KEYBOARD_F11},
|
||||
{.width = 1, .icon = &I_ButtonF12_5x8, .value = HID_KEYBOARD_F12},
|
||||
},
|
||||
{
|
||||
{.width = 1, .icon = NULL, .key = "1", .shift_key = "!", .value = HID_KEYBOARD_1},
|
||||
{.width = 1, .icon = NULL, .key = "2", .shift_key = "@", .value = HID_KEYBOARD_2},
|
||||
@@ -224,7 +238,12 @@ static void hid_keyboard_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
canvas_set_font(canvas, FontKeyboard);
|
||||
// Start shifting the all keys up if on the next row (Scrolling)
|
||||
uint8_t initY = model->y - 4 > 0 ? model->y - 4 : 0;
|
||||
uint8_t initY = model->y == 0 ? 0 : 1;
|
||||
|
||||
if(model->y > 5) {
|
||||
initY = model->y - 4;
|
||||
}
|
||||
|
||||
for(uint8_t y = initY; y < ROW_COUNT; y++) {
|
||||
const HidKeyboardKey* keyboardKeyRow = hid_keyboard_keyset[y];
|
||||
uint8_t x = 0;
|
||||
@@ -365,7 +384,10 @@ HidKeyboard* hid_keyboard_alloc(Hid* bt_hid) {
|
||||
with_view_model(
|
||||
hid_keyboard->view,
|
||||
HidKeyboardModel * model,
|
||||
{ model->transport = bt_hid->transport; },
|
||||
{
|
||||
model->transport = bt_hid->transport;
|
||||
model->y = 1;
|
||||
},
|
||||
true);
|
||||
|
||||
return hid_keyboard;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <storage/storage.h>
|
||||
#include <lib/flipper_format/flipper_format.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <m-array.h>
|
||||
|
||||
#define TAG "MusicPlayerWorker"
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="NFC_Magic",
|
||||
name="NFC Magic",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
targets=["f7"],
|
||||
entry_point="nfc_magic_app",
|
||||
requires=[
|
||||
"storage",
|
||||
|
||||
@@ -2,6 +2,7 @@ App(
|
||||
appid="Picopass",
|
||||
name="PicoPass Reader",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
targets=["f7"],
|
||||
entry_point="picopass_app",
|
||||
requires=[
|
||||
"storage",
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "scenes/signal_gen_scene.h"
|
||||
|
||||
#include "furi_hal_clock.h"
|
||||
#include "furi_hal_pwm.h"
|
||||
#include <furi_hal_clock.h>
|
||||
#include <furi_hal_pwm.h>
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../signal_gen_app_i.h"
|
||||
#include "furi_hal.h"
|
||||
#include <furi_hal.h>
|
||||
#include <gui/elements.h>
|
||||
#include <Signal_Generator_icons.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
App(
|
||||
appid="spi_mem_manager",
|
||||
name="SPI Mem Manager",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
entry_point="spi_mem_app",
|
||||
requires=["gui"],
|
||||
stack_size=1 * 2048,
|
||||
order=30,
|
||||
fap_icon="images/Dip8_10px.png",
|
||||
fap_category="Tools",
|
||||
fap_icon_assets="images",
|
||||
fap_private_libs=[
|
||||
Lib(
|
||||
name="spi",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
@@ -0,0 +1 @@
|
||||
2
|
||||
|
After Width: | Height: | Size: 195 B |
|
After Width: | Height: | Size: 977 B |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
@@ -0,0 +1,105 @@
|
||||
#include "spi_mem_chip_i.h"
|
||||
|
||||
const SPIMemChipVendorName spi_mem_chip_vendor_names[] = {
|
||||
{"Adesto", SPIMemChipVendorADESTO},
|
||||
{"AMIC", SPIMemChipVendorAMIC},
|
||||
{"Boya", SPIMemChipVendorBoya},
|
||||
{"EON", SPIMemChipVendorEON},
|
||||
{"PFlash", SPIMemChipVendorPFLASH},
|
||||
{"Terra", SPIMemChipVendorTERRA},
|
||||
{"Generalplus", SPIMemChipVendorGeneralplus},
|
||||
{"Deutron", SPIMemChipVendorDEUTRON},
|
||||
{"EFST", SPIMemChipVendorEFST},
|
||||
{"Excel Semi.", SPIMemChipVendorEXCELSEMI},
|
||||
{"Fidelix", SPIMemChipVendorFIDELIX},
|
||||
{"GigaDevice", SPIMemChipVendorGIGADEVICE},
|
||||
{"ICE", SPIMemChipVendorICE},
|
||||
{"Intel", SPIMemChipVendorINTEL},
|
||||
{"KHIC", SPIMemChipVendorKHIC},
|
||||
{"Macronix", SPIMemChipVendorMACRONIX},
|
||||
{"Micron", SPIMemChipVendorMICRON},
|
||||
{"Mshine", SPIMemChipVendorMSHINE},
|
||||
{"Nantronics", SPIMemChipVendorNANTRONICS},
|
||||
{"Nexflash", SPIMemChipVendorNEXFLASH},
|
||||
{"Numonyx", SPIMemChipVendorNUMONYX},
|
||||
{"PCT", SPIMemChipVendorPCT},
|
||||
{"Spansion", SPIMemChipVendorSPANSION},
|
||||
{"SST", SPIMemChipVendorSST},
|
||||
{"ST", SPIMemChipVendorST},
|
||||
{"Winbond", SPIMemChipVendorWINBOND},
|
||||
{"Zempro", SPIMemChipVendorZEMPRO},
|
||||
{"Zbit", SPIMemChipVendorZbit},
|
||||
{"Berg Micro.", SPIMemChipVendorBerg_Micro},
|
||||
{"Atmel", SPIMemChipVendorATMEL},
|
||||
{"ACE", SPIMemChipVendorACE},
|
||||
{"ATO", SPIMemChipVendorATO},
|
||||
{"Douqi", SPIMemChipVendorDOUQI},
|
||||
{"Fremont", SPIMemChipVendorFremont},
|
||||
{"Fudan", SPIMemChipVendorFudan},
|
||||
{"Genitop", SPIMemChipVendorGenitop},
|
||||
{"Paragon", SPIMemChipVendorParagon},
|
||||
{"Unknown", SPIMemChipVendorUnknown}};
|
||||
|
||||
static const char* spi_mem_chip_search_vendor_name(SPIMemChipVendor vendor_enum) {
|
||||
const SPIMemChipVendorName* vendor = spi_mem_chip_vendor_names;
|
||||
while(vendor->vendor_enum != SPIMemChipVendorUnknown && vendor->vendor_enum != vendor_enum)
|
||||
vendor++;
|
||||
return vendor->vendor_name;
|
||||
}
|
||||
|
||||
bool spi_mem_chip_find_all(SPIMemChip* chip_info, found_chips_t found_chips) {
|
||||
const SPIMemChip* chip_info_arr;
|
||||
found_chips_reset(found_chips);
|
||||
for(chip_info_arr = SPIMemChips; chip_info_arr->model_name != NULL; chip_info_arr++) {
|
||||
if(chip_info->vendor_id != chip_info_arr->vendor_id) continue;
|
||||
if(chip_info->type_id != chip_info_arr->type_id) continue;
|
||||
if(chip_info->capacity_id != chip_info_arr->capacity_id) continue;
|
||||
found_chips_push_back(found_chips, chip_info_arr);
|
||||
}
|
||||
if(found_chips_size(found_chips)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void spi_mem_chip_copy_chip_info(SPIMemChip* dest, const SPIMemChip* src) {
|
||||
memcpy(dest, src, sizeof(SPIMemChip));
|
||||
}
|
||||
|
||||
size_t spi_mem_chip_get_size(SPIMemChip* chip) {
|
||||
return (chip->size);
|
||||
}
|
||||
|
||||
const char* spi_mem_chip_get_vendor_name(const SPIMemChip* chip) {
|
||||
return (spi_mem_chip_search_vendor_name(chip->vendor_enum));
|
||||
}
|
||||
|
||||
const char* spi_mem_chip_get_vendor_name_by_enum(uint32_t vendor_enum) {
|
||||
return (spi_mem_chip_search_vendor_name(vendor_enum));
|
||||
}
|
||||
|
||||
const char* spi_mem_chip_get_model_name(const SPIMemChip* chip) {
|
||||
return (chip->model_name);
|
||||
}
|
||||
|
||||
uint8_t spi_mem_chip_get_vendor_id(SPIMemChip* chip) {
|
||||
return (chip->vendor_id);
|
||||
}
|
||||
|
||||
uint8_t spi_mem_chip_get_type_id(SPIMemChip* chip) {
|
||||
return (chip->type_id);
|
||||
}
|
||||
|
||||
uint8_t spi_mem_chip_get_capacity_id(SPIMemChip* chip) {
|
||||
return (chip->capacity_id);
|
||||
}
|
||||
|
||||
SPIMemChipWriteMode spi_mem_chip_get_write_mode(SPIMemChip* chip) {
|
||||
return (chip->write_mode);
|
||||
}
|
||||
|
||||
size_t spi_mem_chip_get_page_size(SPIMemChip* chip) {
|
||||
return (chip->page_size);
|
||||
}
|
||||
|
||||
uint32_t spi_mem_chip_get_vendor_enum(const SPIMemChip* chip) {
|
||||
return ((uint32_t)chip->vendor_enum);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include <m-array.h>
|
||||
|
||||
typedef struct SPIMemChip SPIMemChip;
|
||||
|
||||
ARRAY_DEF(found_chips, const SPIMemChip*, M_POD_OPLIST)
|
||||
|
||||
typedef enum {
|
||||
SPIMemChipStatusBusy,
|
||||
SPIMemChipStatusIdle,
|
||||
SPIMemChipStatusError
|
||||
} SPIMemChipStatus;
|
||||
|
||||
typedef enum {
|
||||
SPIMemChipWriteModeUnknown = 0,
|
||||
SPIMemChipWriteModePage = (0x01 << 0),
|
||||
SPIMemChipWriteModeAAIByte = (0x01 << 1),
|
||||
SPIMemChipWriteModeAAIWord = (0x01 << 2),
|
||||
} SPIMemChipWriteMode;
|
||||
|
||||
const char* spi_mem_chip_get_vendor_name(const SPIMemChip* chip);
|
||||
const char* spi_mem_chip_get_model_name(const SPIMemChip* chip);
|
||||
size_t spi_mem_chip_get_size(SPIMemChip* chip);
|
||||
uint8_t spi_mem_chip_get_vendor_id(SPIMemChip* chip);
|
||||
uint8_t spi_mem_chip_get_type_id(SPIMemChip* chip);
|
||||
uint8_t spi_mem_chip_get_capacity_id(SPIMemChip* chip);
|
||||
SPIMemChipWriteMode spi_mem_chip_get_write_mode(SPIMemChip* chip);
|
||||
size_t spi_mem_chip_get_page_size(SPIMemChip* chip);
|
||||
bool spi_mem_chip_find_all(SPIMemChip* chip_info, found_chips_t found_chips);
|
||||
void spi_mem_chip_copy_chip_info(SPIMemChip* dest, const SPIMemChip* src);
|
||||
uint32_t spi_mem_chip_get_vendor_enum(const SPIMemChip* chip);
|
||||
const char* spi_mem_chip_get_vendor_name_by_enum(uint32_t vendor_enum);
|
||||
@@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include "spi_mem_chip.h"
|
||||
|
||||
typedef enum {
|
||||
SPIMemChipVendorUnknown,
|
||||
SPIMemChipVendorADESTO,
|
||||
SPIMemChipVendorAMIC,
|
||||
SPIMemChipVendorBoya,
|
||||
SPIMemChipVendorEON,
|
||||
SPIMemChipVendorPFLASH,
|
||||
SPIMemChipVendorTERRA,
|
||||
SPIMemChipVendorGeneralplus,
|
||||
SPIMemChipVendorDEUTRON,
|
||||
SPIMemChipVendorEFST,
|
||||
SPIMemChipVendorEXCELSEMI,
|
||||
SPIMemChipVendorFIDELIX,
|
||||
SPIMemChipVendorGIGADEVICE,
|
||||
SPIMemChipVendorICE,
|
||||
SPIMemChipVendorINTEL,
|
||||
SPIMemChipVendorKHIC,
|
||||
SPIMemChipVendorMACRONIX,
|
||||
SPIMemChipVendorMICRON,
|
||||
SPIMemChipVendorMSHINE,
|
||||
SPIMemChipVendorNANTRONICS,
|
||||
SPIMemChipVendorNEXFLASH,
|
||||
SPIMemChipVendorNUMONYX,
|
||||
SPIMemChipVendorPCT,
|
||||
SPIMemChipVendorSPANSION,
|
||||
SPIMemChipVendorSST,
|
||||
SPIMemChipVendorST,
|
||||
SPIMemChipVendorWINBOND,
|
||||
SPIMemChipVendorZEMPRO,
|
||||
SPIMemChipVendorZbit,
|
||||
SPIMemChipVendorBerg_Micro,
|
||||
SPIMemChipVendorATMEL,
|
||||
SPIMemChipVendorACE,
|
||||
SPIMemChipVendorATO,
|
||||
SPIMemChipVendorDOUQI,
|
||||
SPIMemChipVendorFremont,
|
||||
SPIMemChipVendorFudan,
|
||||
SPIMemChipVendorGenitop,
|
||||
SPIMemChipVendorParagon
|
||||
} SPIMemChipVendor;
|
||||
|
||||
typedef enum {
|
||||
SPIMemChipCMDReadJEDECChipID = 0x9F,
|
||||
SPIMemChipCMDReadData = 0x03,
|
||||
SPIMemChipCMDChipErase = 0xC7,
|
||||
SPIMemChipCMDWriteEnable = 0x06,
|
||||
SPIMemChipCMDWriteDisable = 0x04,
|
||||
SPIMemChipCMDReadStatus = 0x05,
|
||||
SPIMemChipCMDWriteData = 0x02,
|
||||
SPIMemChipCMDReleasePowerDown = 0xAB
|
||||
} SPIMemChipCMD;
|
||||
|
||||
enum SPIMemChipStatusBit {
|
||||
SPIMemChipStatusBitBusy = (0x01 << 0),
|
||||
SPIMemChipStatusBitWriteEnabled = (0x01 << 1),
|
||||
SPIMemChipStatusBitBitProtection1 = (0x01 << 2),
|
||||
SPIMemChipStatusBitBitProtection2 = (0x01 << 3),
|
||||
SPIMemChipStatusBitBitProtection3 = (0x01 << 4),
|
||||
SPIMemChipStatusBitTopBottomProtection = (0x01 << 5),
|
||||
SPIMemChipStatusBitSectorProtect = (0x01 << 6),
|
||||
SPIMemChipStatusBitRegisterProtect = (0x01 << 7)
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char* vendor_name;
|
||||
SPIMemChipVendor vendor_enum;
|
||||
} SPIMemChipVendorName;
|
||||
|
||||
struct SPIMemChip {
|
||||
uint8_t vendor_id;
|
||||
uint8_t type_id;
|
||||
uint8_t capacity_id;
|
||||
const char* model_name;
|
||||
size_t size;
|
||||
size_t page_size;
|
||||
SPIMemChipVendor vendor_enum;
|
||||
SPIMemChipWriteMode write_mode;
|
||||
};
|
||||
|
||||
extern const SPIMemChip SPIMemChips[];
|
||||
@@ -0,0 +1,152 @@
|
||||
#include <furi_hal.h>
|
||||
#include <furi_hal_spi_config.h>
|
||||
#include "spi_mem_chip_i.h"
|
||||
#include "spi_mem_tools.h"
|
||||
|
||||
static uint8_t spi_mem_tools_addr_to_byte_arr(uint32_t addr, uint8_t* cmd) {
|
||||
uint8_t len = 3; // TODO(add support of 4 bytes address mode)
|
||||
for(uint8_t i = 0; i < len; i++) {
|
||||
cmd[i] = (addr >> ((len - (i + 1)) * 8)) & 0xFF;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
static bool spi_mem_tools_trx(
|
||||
SPIMemChipCMD cmd,
|
||||
uint8_t* tx_buf,
|
||||
size_t tx_size,
|
||||
uint8_t* rx_buf,
|
||||
size_t rx_size) {
|
||||
bool success = false;
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_external);
|
||||
do {
|
||||
if(!furi_hal_spi_bus_tx(
|
||||
&furi_hal_spi_bus_handle_external, (uint8_t*)&cmd, 1, SPI_MEM_SPI_TIMEOUT))
|
||||
break;
|
||||
if(tx_buf) {
|
||||
if(!furi_hal_spi_bus_tx(
|
||||
&furi_hal_spi_bus_handle_external, tx_buf, tx_size, SPI_MEM_SPI_TIMEOUT))
|
||||
break;
|
||||
}
|
||||
if(rx_buf) {
|
||||
if(!furi_hal_spi_bus_rx(
|
||||
&furi_hal_spi_bus_handle_external, rx_buf, rx_size, SPI_MEM_SPI_TIMEOUT))
|
||||
break;
|
||||
}
|
||||
success = true;
|
||||
} while(0);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_external);
|
||||
return success;
|
||||
}
|
||||
|
||||
static bool spi_mem_tools_write_buffer(uint8_t* data, size_t size, size_t offset) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_external);
|
||||
uint8_t cmd = (uint8_t)SPIMemChipCMDWriteData;
|
||||
uint8_t address[4];
|
||||
uint8_t address_size = spi_mem_tools_addr_to_byte_arr(offset, address);
|
||||
bool success = false;
|
||||
do {
|
||||
if(!furi_hal_spi_bus_tx(&furi_hal_spi_bus_handle_external, &cmd, 1, SPI_MEM_SPI_TIMEOUT))
|
||||
break;
|
||||
if(!furi_hal_spi_bus_tx(
|
||||
&furi_hal_spi_bus_handle_external, address, address_size, SPI_MEM_SPI_TIMEOUT))
|
||||
break;
|
||||
if(!furi_hal_spi_bus_tx(&furi_hal_spi_bus_handle_external, data, size, SPI_MEM_SPI_TIMEOUT))
|
||||
break;
|
||||
success = true;
|
||||
} while(0);
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_external);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool spi_mem_tools_read_chip_info(SPIMemChip* chip) {
|
||||
uint8_t rx_buf[3] = {0, 0, 0};
|
||||
do {
|
||||
if(!spi_mem_tools_trx(SPIMemChipCMDReadJEDECChipID, NULL, 0, rx_buf, 3)) break;
|
||||
if(rx_buf[0] == 0 || rx_buf[0] == 255) break;
|
||||
chip->vendor_id = rx_buf[0];
|
||||
chip->type_id = rx_buf[1];
|
||||
chip->capacity_id = rx_buf[2];
|
||||
return true;
|
||||
} while(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool spi_mem_tools_check_chip_info(SPIMemChip* chip) {
|
||||
SPIMemChip new_chip_info;
|
||||
spi_mem_tools_read_chip_info(&new_chip_info);
|
||||
do {
|
||||
if(chip->vendor_id != new_chip_info.vendor_id) break;
|
||||
if(chip->type_id != new_chip_info.type_id) break;
|
||||
if(chip->capacity_id != new_chip_info.capacity_id) break;
|
||||
return true;
|
||||
} while(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool spi_mem_tools_read_block(SPIMemChip* chip, size_t offset, uint8_t* data, size_t block_size) {
|
||||
if(!spi_mem_tools_check_chip_info(chip)) return false;
|
||||
for(size_t i = 0; i < block_size; i += SPI_MEM_MAX_BLOCK_SIZE) {
|
||||
uint8_t cmd[4];
|
||||
if((offset + SPI_MEM_MAX_BLOCK_SIZE) > chip->size) return false;
|
||||
if(!spi_mem_tools_trx(
|
||||
SPIMemChipCMDReadData,
|
||||
cmd,
|
||||
spi_mem_tools_addr_to_byte_arr(offset, cmd),
|
||||
data,
|
||||
SPI_MEM_MAX_BLOCK_SIZE))
|
||||
return false;
|
||||
offset += SPI_MEM_MAX_BLOCK_SIZE;
|
||||
data += SPI_MEM_MAX_BLOCK_SIZE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t spi_mem_tools_get_file_max_block_size(SPIMemChip* chip) {
|
||||
UNUSED(chip);
|
||||
return (SPI_MEM_FILE_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
SPIMemChipStatus spi_mem_tools_get_chip_status(SPIMemChip* chip) {
|
||||
UNUSED(chip);
|
||||
uint8_t status;
|
||||
if(!spi_mem_tools_trx(SPIMemChipCMDReadStatus, NULL, 0, &status, 1))
|
||||
return SPIMemChipStatusError;
|
||||
if(status & SPIMemChipStatusBitBusy) return SPIMemChipStatusBusy;
|
||||
return SPIMemChipStatusIdle;
|
||||
}
|
||||
|
||||
static bool spi_mem_tools_set_write_enabled(SPIMemChip* chip, bool enable) {
|
||||
UNUSED(chip);
|
||||
uint8_t status;
|
||||
SPIMemChipCMD cmd = SPIMemChipCMDWriteDisable;
|
||||
if(enable) cmd = SPIMemChipCMDWriteEnable;
|
||||
do {
|
||||
if(!spi_mem_tools_trx(cmd, NULL, 0, NULL, 0)) break;
|
||||
if(!spi_mem_tools_trx(SPIMemChipCMDReadStatus, NULL, 0, &status, 1)) break;
|
||||
if(!(status & SPIMemChipStatusBitWriteEnabled) && enable) break;
|
||||
if((status & SPIMemChipStatusBitWriteEnabled) && !enable) break;
|
||||
return true;
|
||||
} while(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool spi_mem_tools_erase_chip(SPIMemChip* chip) {
|
||||
do {
|
||||
if(!spi_mem_tools_set_write_enabled(chip, true)) break;
|
||||
if(!spi_mem_tools_trx(SPIMemChipCMDChipErase, NULL, 0, NULL, 0)) break;
|
||||
return true;
|
||||
} while(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool spi_mem_tools_write_bytes(SPIMemChip* chip, size_t offset, uint8_t* data, size_t block_size) {
|
||||
do {
|
||||
if(!spi_mem_tools_check_chip_info(chip)) break;
|
||||
if(!spi_mem_tools_set_write_enabled(chip, true)) break;
|
||||
if((offset + block_size) > chip->size) break;
|
||||
if(!spi_mem_tools_write_buffer(data, block_size, offset)) break;
|
||||
return true;
|
||||
} while(0);
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "spi_mem_chip.h"
|
||||
|
||||
#define SPI_MEM_SPI_TIMEOUT 1000
|
||||
#define SPI_MEM_MAX_BLOCK_SIZE 256
|
||||
#define SPI_MEM_FILE_BUFFER_SIZE 4096
|
||||
|
||||
bool spi_mem_tools_read_chip_info(SPIMemChip* chip);
|
||||
bool spi_mem_tools_read_block(SPIMemChip* chip, size_t offset, uint8_t* data, size_t block_size);
|
||||
size_t spi_mem_tools_get_file_max_block_size(SPIMemChip* chip);
|
||||
SPIMemChipStatus spi_mem_tools_get_chip_status(SPIMemChip* chip);
|
||||
bool spi_mem_tools_erase_chip(SPIMemChip* chip);
|
||||
bool spi_mem_tools_write_bytes(SPIMemChip* chip, size_t offset, uint8_t* data, size_t block_size);
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "spi_mem_worker_i.h"
|
||||
|
||||
typedef enum {
|
||||
SPIMemEventStopThread = (1 << 0),
|
||||
SPIMemEventChipDetect = (1 << 1),
|
||||
SPIMemEventRead = (1 << 2),
|
||||
SPIMemEventVerify = (1 << 3),
|
||||
SPIMemEventErase = (1 << 4),
|
||||
SPIMemEventWrite = (1 << 5),
|
||||
SPIMemEventAll =
|
||||
(SPIMemEventStopThread | SPIMemEventChipDetect | SPIMemEventRead | SPIMemEventVerify |
|
||||
SPIMemEventErase | SPIMemEventWrite)
|
||||
} SPIMemEventEventType;
|
||||
|
||||
static int32_t spi_mem_worker_thread(void* thread_context);
|
||||
|
||||
SPIMemWorker* spi_mem_worker_alloc() {
|
||||
SPIMemWorker* worker = malloc(sizeof(SPIMemWorker));
|
||||
worker->callback = NULL;
|
||||
worker->thread = furi_thread_alloc();
|
||||
worker->mode_index = SPIMemWorkerModeIdle;
|
||||
furi_thread_set_name(worker->thread, "SPIMemWorker");
|
||||
furi_thread_set_callback(worker->thread, spi_mem_worker_thread);
|
||||
furi_thread_set_context(worker->thread, worker);
|
||||
furi_thread_set_stack_size(worker->thread, 10240);
|
||||
return worker;
|
||||
}
|
||||
|
||||
void spi_mem_worker_free(SPIMemWorker* worker) {
|
||||
furi_thread_free(worker->thread);
|
||||
free(worker);
|
||||
}
|
||||
|
||||
bool spi_mem_worker_check_for_stop(SPIMemWorker* worker) {
|
||||
UNUSED(worker);
|
||||
uint32_t flags = furi_thread_flags_get();
|
||||
return (flags & SPIMemEventStopThread);
|
||||
}
|
||||
|
||||
static int32_t spi_mem_worker_thread(void* thread_context) {
|
||||
SPIMemWorker* worker = thread_context;
|
||||
while(true) {
|
||||
uint32_t flags = furi_thread_flags_wait(SPIMemEventAll, FuriFlagWaitAny, FuriWaitForever);
|
||||
if(flags != (unsigned)FuriFlagErrorTimeout) {
|
||||
if(flags & SPIMemEventStopThread) break;
|
||||
if(flags & SPIMemEventChipDetect) worker->mode_index = SPIMemWorkerModeChipDetect;
|
||||
if(flags & SPIMemEventRead) worker->mode_index = SPIMemWorkerModeRead;
|
||||
if(flags & SPIMemEventVerify) worker->mode_index = SPIMemWorkerModeVerify;
|
||||
if(flags & SPIMemEventErase) worker->mode_index = SPIMemWorkerModeErase;
|
||||
if(flags & SPIMemEventWrite) worker->mode_index = SPIMemWorkerModeWrite;
|
||||
if(spi_mem_worker_modes[worker->mode_index].process) {
|
||||
spi_mem_worker_modes[worker->mode_index].process(worker);
|
||||
}
|
||||
worker->mode_index = SPIMemWorkerModeIdle;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_mem_worker_start_thread(SPIMemWorker* worker) {
|
||||
furi_thread_start(worker->thread);
|
||||
}
|
||||
|
||||
void spi_mem_worker_stop_thread(SPIMemWorker* worker) {
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), SPIMemEventStopThread);
|
||||
furi_thread_join(worker->thread);
|
||||
}
|
||||
|
||||
void spi_mem_worker_chip_detect_start(
|
||||
SPIMemChip* chip_info,
|
||||
found_chips_t* found_chips,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker->mode_index == SPIMemWorkerModeIdle);
|
||||
worker->callback = callback;
|
||||
worker->cb_ctx = context;
|
||||
worker->chip_info = chip_info;
|
||||
worker->found_chips = found_chips;
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), SPIMemEventChipDetect);
|
||||
}
|
||||
|
||||
void spi_mem_worker_read_start(
|
||||
SPIMemChip* chip_info,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker->mode_index == SPIMemWorkerModeIdle);
|
||||
worker->callback = callback;
|
||||
worker->cb_ctx = context;
|
||||
worker->chip_info = chip_info;
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), SPIMemEventRead);
|
||||
}
|
||||
|
||||
void spi_mem_worker_verify_start(
|
||||
SPIMemChip* chip_info,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker->mode_index == SPIMemWorkerModeIdle);
|
||||
worker->callback = callback;
|
||||
worker->cb_ctx = context;
|
||||
worker->chip_info = chip_info;
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), SPIMemEventVerify);
|
||||
}
|
||||
|
||||
void spi_mem_worker_erase_start(
|
||||
SPIMemChip* chip_info,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker->mode_index == SPIMemWorkerModeIdle);
|
||||
worker->callback = callback;
|
||||
worker->cb_ctx = context;
|
||||
worker->chip_info = chip_info;
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), SPIMemEventErase);
|
||||
}
|
||||
|
||||
void spi_mem_worker_write_start(
|
||||
SPIMemChip* chip_info,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker->mode_index == SPIMemWorkerModeIdle);
|
||||
worker->callback = callback;
|
||||
worker->cb_ctx = context;
|
||||
worker->chip_info = chip_info;
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), SPIMemEventWrite);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include "spi_mem_chip.h"
|
||||
|
||||
typedef struct SPIMemWorker SPIMemWorker;
|
||||
|
||||
typedef struct {
|
||||
void (*const process)(SPIMemWorker* worker);
|
||||
} SPIMemWorkerModeType;
|
||||
|
||||
typedef enum {
|
||||
SPIMemCustomEventWorkerChipIdentified,
|
||||
SPIMemCustomEventWorkerChipUnknown,
|
||||
SPIMemCustomEventWorkerBlockReaded,
|
||||
SPIMemCustomEventWorkerChipFail,
|
||||
SPIMemCustomEventWorkerFileFail,
|
||||
SPIMemCustomEventWorkerDone,
|
||||
SPIMemCustomEventWorkerVerifyFail,
|
||||
} SPIMemCustomEventWorker;
|
||||
|
||||
typedef void (*SPIMemWorkerCallback)(void* context, SPIMemCustomEventWorker event);
|
||||
|
||||
SPIMemWorker* spi_mem_worker_alloc();
|
||||
void spi_mem_worker_free(SPIMemWorker* worker);
|
||||
void spi_mem_worker_start_thread(SPIMemWorker* worker);
|
||||
void spi_mem_worker_stop_thread(SPIMemWorker* worker);
|
||||
bool spi_mem_worker_check_for_stop(SPIMemWorker* worker);
|
||||
void spi_mem_worker_chip_detect_start(
|
||||
SPIMemChip* chip_info,
|
||||
found_chips_t* found_chips,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context);
|
||||
void spi_mem_worker_read_start(
|
||||
SPIMemChip* chip_info,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context);
|
||||
void spi_mem_worker_verify_start(
|
||||
SPIMemChip* chip_info,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context);
|
||||
void spi_mem_worker_erase_start(
|
||||
SPIMemChip* chip_info,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context);
|
||||
void spi_mem_worker_write_start(
|
||||
SPIMemChip* chip_info,
|
||||
SPIMemWorker* worker,
|
||||
SPIMemWorkerCallback callback,
|
||||
void* context);
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "spi_mem_worker.h"
|
||||
|
||||
typedef enum {
|
||||
SPIMemWorkerModeIdle,
|
||||
SPIMemWorkerModeChipDetect,
|
||||
SPIMemWorkerModeRead,
|
||||
SPIMemWorkerModeVerify,
|
||||
SPIMemWorkerModeErase,
|
||||
SPIMemWorkerModeWrite
|
||||
} SPIMemWorkerMode;
|
||||
|
||||
struct SPIMemWorker {
|
||||
SPIMemChip* chip_info;
|
||||
found_chips_t* found_chips;
|
||||
SPIMemWorkerMode mode_index;
|
||||
SPIMemWorkerCallback callback;
|
||||
void* cb_ctx;
|
||||
FuriThread* thread;
|
||||
FuriString* file_name;
|
||||
};
|
||||
|
||||
extern const SPIMemWorkerModeType spi_mem_worker_modes[];
|
||||
@@ -0,0 +1,214 @@
|
||||
#include "spi_mem_worker_i.h"
|
||||
#include "spi_mem_chip.h"
|
||||
#include "spi_mem_tools.h"
|
||||
#include "../../spi_mem_files.h"
|
||||
|
||||
static void spi_mem_worker_chip_detect_process(SPIMemWorker* worker);
|
||||
static void spi_mem_worker_read_process(SPIMemWorker* worker);
|
||||
static void spi_mem_worker_verify_process(SPIMemWorker* worker);
|
||||
static void spi_mem_worker_erase_process(SPIMemWorker* worker);
|
||||
static void spi_mem_worker_write_process(SPIMemWorker* worker);
|
||||
|
||||
const SPIMemWorkerModeType spi_mem_worker_modes[] = {
|
||||
[SPIMemWorkerModeIdle] = {.process = NULL},
|
||||
[SPIMemWorkerModeChipDetect] = {.process = spi_mem_worker_chip_detect_process},
|
||||
[SPIMemWorkerModeRead] = {.process = spi_mem_worker_read_process},
|
||||
[SPIMemWorkerModeVerify] = {.process = spi_mem_worker_verify_process},
|
||||
[SPIMemWorkerModeErase] = {.process = spi_mem_worker_erase_process},
|
||||
[SPIMemWorkerModeWrite] = {.process = spi_mem_worker_write_process}};
|
||||
|
||||
static void spi_mem_worker_run_callback(SPIMemWorker* worker, SPIMemCustomEventWorker event) {
|
||||
if(worker->callback) {
|
||||
worker->callback(worker->cb_ctx, event);
|
||||
}
|
||||
}
|
||||
|
||||
static bool spi_mem_worker_await_chip_busy(SPIMemWorker* worker) {
|
||||
while(true) {
|
||||
furi_delay_tick(10); // to give some time to OS
|
||||
if(spi_mem_worker_check_for_stop(worker)) return true;
|
||||
SPIMemChipStatus chip_status = spi_mem_tools_get_chip_status(worker->chip_info);
|
||||
if(chip_status == SPIMemChipStatusError) return false;
|
||||
if(chip_status == SPIMemChipStatusBusy) continue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t spi_mem_worker_modes_get_total_size(SPIMemWorker* worker) {
|
||||
size_t chip_size = spi_mem_chip_get_size(worker->chip_info);
|
||||
size_t file_size = spi_mem_file_get_size(worker->cb_ctx);
|
||||
size_t total_size = chip_size;
|
||||
if(chip_size > file_size) total_size = file_size;
|
||||
return total_size;
|
||||
}
|
||||
|
||||
// ChipDetect
|
||||
static void spi_mem_worker_chip_detect_process(SPIMemWorker* worker) {
|
||||
SPIMemCustomEventWorker event;
|
||||
while(!spi_mem_tools_read_chip_info(worker->chip_info)) {
|
||||
furi_delay_tick(10); // to give some time to OS
|
||||
if(spi_mem_worker_check_for_stop(worker)) return;
|
||||
}
|
||||
if(spi_mem_chip_find_all(worker->chip_info, *worker->found_chips)) {
|
||||
event = SPIMemCustomEventWorkerChipIdentified;
|
||||
} else {
|
||||
event = SPIMemCustomEventWorkerChipUnknown;
|
||||
}
|
||||
spi_mem_worker_run_callback(worker, event);
|
||||
}
|
||||
|
||||
// Read
|
||||
static bool spi_mem_worker_read(SPIMemWorker* worker, SPIMemCustomEventWorker* event) {
|
||||
uint8_t data_buffer[SPI_MEM_FILE_BUFFER_SIZE];
|
||||
size_t chip_size = spi_mem_chip_get_size(worker->chip_info);
|
||||
size_t offset = 0;
|
||||
bool success = true;
|
||||
while(true) {
|
||||
furi_delay_tick(10); // to give some time to OS
|
||||
size_t block_size = SPI_MEM_FILE_BUFFER_SIZE;
|
||||
if(spi_mem_worker_check_for_stop(worker)) break;
|
||||
if(offset >= chip_size) break;
|
||||
if((offset + block_size) > chip_size) block_size = chip_size - offset;
|
||||
if(!spi_mem_tools_read_block(worker->chip_info, offset, data_buffer, block_size)) {
|
||||
*event = SPIMemCustomEventWorkerChipFail;
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
if(!spi_mem_file_write_block(worker->cb_ctx, data_buffer, block_size)) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
offset += block_size;
|
||||
spi_mem_worker_run_callback(worker, SPIMemCustomEventWorkerBlockReaded);
|
||||
}
|
||||
if(success) *event = SPIMemCustomEventWorkerDone;
|
||||
return success;
|
||||
}
|
||||
|
||||
static void spi_mem_worker_read_process(SPIMemWorker* worker) {
|
||||
SPIMemCustomEventWorker event = SPIMemCustomEventWorkerFileFail;
|
||||
do {
|
||||
if(!spi_mem_worker_await_chip_busy(worker)) break;
|
||||
if(!spi_mem_file_create_open(worker->cb_ctx)) break;
|
||||
if(!spi_mem_worker_read(worker, &event)) break;
|
||||
} while(0);
|
||||
spi_mem_file_close(worker->cb_ctx);
|
||||
spi_mem_worker_run_callback(worker, event);
|
||||
}
|
||||
|
||||
// Verify
|
||||
static bool
|
||||
spi_mem_worker_verify(SPIMemWorker* worker, size_t total_size, SPIMemCustomEventWorker* event) {
|
||||
uint8_t data_buffer_chip[SPI_MEM_FILE_BUFFER_SIZE];
|
||||
uint8_t data_buffer_file[SPI_MEM_FILE_BUFFER_SIZE];
|
||||
size_t offset = 0;
|
||||
bool success = true;
|
||||
while(true) {
|
||||
furi_delay_tick(10); // to give some time to OS
|
||||
size_t block_size = SPI_MEM_FILE_BUFFER_SIZE;
|
||||
if(spi_mem_worker_check_for_stop(worker)) break;
|
||||
if(offset >= total_size) break;
|
||||
if((offset + block_size) > total_size) block_size = total_size - offset;
|
||||
if(!spi_mem_tools_read_block(worker->chip_info, offset, data_buffer_chip, block_size)) {
|
||||
*event = SPIMemCustomEventWorkerChipFail;
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
if(!spi_mem_file_read_block(worker->cb_ctx, data_buffer_file, block_size)) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
if(memcmp(data_buffer_chip, data_buffer_file, block_size) != 0) {
|
||||
*event = SPIMemCustomEventWorkerVerifyFail;
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
offset += block_size;
|
||||
spi_mem_worker_run_callback(worker, SPIMemCustomEventWorkerBlockReaded);
|
||||
}
|
||||
if(success) *event = SPIMemCustomEventWorkerDone;
|
||||
return success;
|
||||
}
|
||||
|
||||
static void spi_mem_worker_verify_process(SPIMemWorker* worker) {
|
||||
SPIMemCustomEventWorker event = SPIMemCustomEventWorkerFileFail;
|
||||
size_t total_size = spi_mem_worker_modes_get_total_size(worker);
|
||||
do {
|
||||
if(!spi_mem_worker_await_chip_busy(worker)) break;
|
||||
if(!spi_mem_file_open(worker->cb_ctx)) break;
|
||||
if(!spi_mem_worker_verify(worker, total_size, &event)) break;
|
||||
} while(0);
|
||||
spi_mem_file_close(worker->cb_ctx);
|
||||
spi_mem_worker_run_callback(worker, event);
|
||||
}
|
||||
|
||||
// Erase
|
||||
static void spi_mem_worker_erase_process(SPIMemWorker* worker) {
|
||||
SPIMemCustomEventWorker event = SPIMemCustomEventWorkerChipFail;
|
||||
do {
|
||||
if(!spi_mem_worker_await_chip_busy(worker)) break;
|
||||
if(!spi_mem_tools_erase_chip(worker->chip_info)) break;
|
||||
if(!spi_mem_worker_await_chip_busy(worker)) break;
|
||||
event = SPIMemCustomEventWorkerDone;
|
||||
} while(0);
|
||||
spi_mem_worker_run_callback(worker, event);
|
||||
}
|
||||
|
||||
// Write
|
||||
static bool spi_mem_worker_write_block_by_page(
|
||||
SPIMemWorker* worker,
|
||||
size_t offset,
|
||||
uint8_t* data,
|
||||
size_t block_size,
|
||||
size_t page_size) {
|
||||
for(size_t i = 0; i < block_size; i += page_size) {
|
||||
if(!spi_mem_worker_await_chip_busy(worker)) return false;
|
||||
if(!spi_mem_tools_write_bytes(worker->chip_info, offset, data, page_size)) return false;
|
||||
offset += page_size;
|
||||
data += page_size;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
spi_mem_worker_write(SPIMemWorker* worker, size_t total_size, SPIMemCustomEventWorker* event) {
|
||||
bool success = true;
|
||||
uint8_t data_buffer[SPI_MEM_FILE_BUFFER_SIZE];
|
||||
size_t page_size = spi_mem_chip_get_page_size(worker->chip_info);
|
||||
size_t offset = 0;
|
||||
while(true) {
|
||||
furi_delay_tick(10); // to give some time to OS
|
||||
size_t block_size = SPI_MEM_FILE_BUFFER_SIZE;
|
||||
if(spi_mem_worker_check_for_stop(worker)) break;
|
||||
if(offset >= total_size) break;
|
||||
if((offset + block_size) > total_size) block_size = total_size - offset;
|
||||
if(!spi_mem_file_read_block(worker->cb_ctx, data_buffer, block_size)) {
|
||||
*event = SPIMemCustomEventWorkerFileFail;
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
if(!spi_mem_worker_write_block_by_page(
|
||||
worker, offset, data_buffer, block_size, page_size)) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
offset += block_size;
|
||||
spi_mem_worker_run_callback(worker, SPIMemCustomEventWorkerBlockReaded);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
static void spi_mem_worker_write_process(SPIMemWorker* worker) {
|
||||
SPIMemCustomEventWorker event = SPIMemCustomEventWorkerChipFail;
|
||||
size_t total_size =
|
||||
spi_mem_worker_modes_get_total_size(worker); // need to be executed before opening file
|
||||
do {
|
||||
if(!spi_mem_file_open(worker->cb_ctx)) break;
|
||||
if(!spi_mem_worker_await_chip_busy(worker)) break;
|
||||
if(!spi_mem_worker_write(worker, total_size, &event)) break;
|
||||
if(!spi_mem_worker_await_chip_busy(worker)) break;
|
||||
event = SPIMemCustomEventWorkerDone;
|
||||
} while(0);
|
||||
spi_mem_file_close(worker->cb_ctx);
|
||||
spi_mem_worker_run_callback(worker, event);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "spi_mem_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const spi_mem_on_enter_handlers[])(void*) = {
|
||||
#include "spi_mem_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const spi_mem_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "spi_mem_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const spi_mem_on_exit_handlers[])(void* context) = {
|
||||
#include "spi_mem_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers spi_mem_scene_handlers = {
|
||||
.on_enter_handlers = spi_mem_on_enter_handlers,
|
||||
.on_event_handlers = spi_mem_on_event_handlers,
|
||||
.on_exit_handlers = spi_mem_on_exit_handlers,
|
||||
.scene_num = SPIMemSceneNum,
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) SPIMemScene##id,
|
||||
typedef enum {
|
||||
#include "spi_mem_scene_config.h"
|
||||
SPIMemSceneNum,
|
||||
} SPIMemScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers spi_mem_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "spi_mem_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "spi_mem_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "spi_mem_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../lib/spi/spi_mem_chip.h"
|
||||
|
||||
#define SPI_MEM_VERSION_APP "0.1.0"
|
||||
#define SPI_MEM_DEVELOPER "DrunkBatya"
|
||||
#define SPI_MEM_GITHUB "https://github.com/flipperdevices/flipperzero-firmware"
|
||||
#define SPI_MEM_NAME "\e#\e! SPI Mem Manager \e!\n"
|
||||
#define SPI_MEM_BLANK_INV "\e#\e! \e!\n"
|
||||
|
||||
void spi_mem_scene_about_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
FuriString* tmp_string = furi_string_alloc();
|
||||
|
||||
widget_add_text_box_element(
|
||||
app->widget, 0, 0, 128, 14, AlignCenter, AlignBottom, SPI_MEM_BLANK_INV, false);
|
||||
widget_add_text_box_element(
|
||||
app->widget, 0, 2, 128, 14, AlignCenter, AlignBottom, SPI_MEM_NAME, false);
|
||||
furi_string_printf(tmp_string, "\e#%s\n", "Information");
|
||||
furi_string_cat_printf(tmp_string, "Version: %s\n", SPI_MEM_VERSION_APP);
|
||||
furi_string_cat_printf(tmp_string, "Developed by: %s\n", SPI_MEM_DEVELOPER);
|
||||
furi_string_cat_printf(tmp_string, "Github: %s\n\n", SPI_MEM_GITHUB);
|
||||
furi_string_cat_printf(tmp_string, "\e#%s\n", "Description");
|
||||
furi_string_cat_printf(
|
||||
tmp_string,
|
||||
"SPI memory dumper\n"
|
||||
"Originally written by Hedger, ghettorce and x893 at\n"
|
||||
"Flipper Hackathon 2021\n\n");
|
||||
widget_add_text_scroll_element(app->widget, 0, 16, 128, 50, furi_string_get_cstr(tmp_string));
|
||||
|
||||
furi_string_free(tmp_string);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_about_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void spi_mem_scene_about_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
static void spi_mem_scene_chip_detect_callback(void* context, SPIMemCustomEventWorker event) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void spi_mem_scene_chip_detect_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
notification_message(app->notifications, &sequence_blink_start_yellow);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewDetect);
|
||||
spi_mem_worker_start_thread(app->worker);
|
||||
spi_mem_worker_chip_detect_start(
|
||||
app->chip_info, &app->found_chips, app->worker, spi_mem_scene_chip_detect_callback, app);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_chip_detect_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == SPIMemCustomEventWorkerChipIdentified) {
|
||||
scene_manager_set_scene_state(app->scene_manager, SPIMemSceneSelectVendor, 0);
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneSelectVendor);
|
||||
} else if(event.event == SPIMemCustomEventWorkerChipUnknown) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipDetectFail);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void spi_mem_scene_chip_detect_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_worker_stop_thread(app->worker);
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
popup_reset(app->popup);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../lib/spi/spi_mem_chip.h"
|
||||
|
||||
static void spi_mem_scene_chip_detect_fail_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
SPIMemApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_mem_scene_chip_detect_fail_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
FuriString* str = furi_string_alloc();
|
||||
widget_add_button_element(
|
||||
app->widget,
|
||||
GuiButtonTypeCenter,
|
||||
"Retry",
|
||||
spi_mem_scene_chip_detect_fail_widget_callback,
|
||||
app);
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 9, AlignCenter, AlignBottom, FontPrimary, "Detected");
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 20, AlignCenter, AlignBottom, FontPrimary, "unknown SPI chip");
|
||||
furi_string_printf(str, "Vendor\nid: 0x%02X", spi_mem_chip_get_vendor_id(app->chip_info));
|
||||
widget_add_string_multiline_element(
|
||||
app->widget, 16, 44, AlignCenter, AlignBottom, FontSecondary, furi_string_get_cstr(str));
|
||||
furi_string_printf(str, "Type\nid: 0x%02X", spi_mem_chip_get_type_id(app->chip_info));
|
||||
widget_add_string_multiline_element(
|
||||
app->widget, 64, 44, AlignCenter, AlignBottom, FontSecondary, furi_string_get_cstr(str));
|
||||
furi_string_printf(str, "Capacity\nid: 0x%02X", spi_mem_chip_get_capacity_id(app->chip_info));
|
||||
widget_add_string_multiline_element(
|
||||
app->widget, 110, 44, AlignCenter, AlignBottom, FontSecondary, furi_string_get_cstr(str));
|
||||
furi_string_free(str);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_chip_detect_fail_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SPIMemSceneStart);
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == GuiButtonTypeCenter) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_chip_detect_fail_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
static void spi_mem_scene_chip_detected_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
SPIMemApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
static void spi_mem_scene_chip_detected_print_chip_info(Widget* widget, SPIMemChip* chip_info) {
|
||||
FuriString* tmp_string = furi_string_alloc();
|
||||
widget_add_string_element(
|
||||
widget,
|
||||
40,
|
||||
12,
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
spi_mem_chip_get_vendor_name(chip_info));
|
||||
widget_add_string_element(
|
||||
widget, 40, 20, AlignLeft, AlignTop, FontSecondary, spi_mem_chip_get_model_name(chip_info));
|
||||
furi_string_printf(tmp_string, "Size: %zu KB", spi_mem_chip_get_size(chip_info) / 1024);
|
||||
widget_add_string_element(
|
||||
widget, 40, 28, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_string));
|
||||
furi_string_free(tmp_string);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_chip_detect_draw_next_button(SPIMemApp* app) {
|
||||
FuriString* str = furi_string_alloc();
|
||||
if(app->mode == SPIMemModeRead) furi_string_printf(str, "%s", "Read");
|
||||
if(app->mode == SPIMemModeWrite) furi_string_printf(str, "%s", "Write");
|
||||
if(app->mode == SPIMemModeErase) furi_string_printf(str, "%s", "Erase");
|
||||
if(app->mode == SPIMemModeCompare) furi_string_printf(str, "%s", "Check");
|
||||
widget_add_button_element(
|
||||
app->widget,
|
||||
GuiButtonTypeRight,
|
||||
furi_string_get_cstr(str),
|
||||
spi_mem_scene_chip_detected_widget_callback,
|
||||
app);
|
||||
furi_string_free(str);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_chip_detected_set_previous_scene(SPIMemApp* app) {
|
||||
uint32_t scene = SPIMemSceneStart;
|
||||
if(app->mode == SPIMemModeCompare || app->mode == SPIMemModeWrite)
|
||||
scene = SPIMemSceneSavedFileMenu;
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, scene);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_chip_detected_set_next_scene(SPIMemApp* app) {
|
||||
uint32_t scene = SPIMemSceneStart;
|
||||
if(app->mode == SPIMemModeRead) scene = SPIMemSceneReadFilename;
|
||||
if(app->mode == SPIMemModeWrite) scene = SPIMemSceneErase;
|
||||
if(app->mode == SPIMemModeErase) scene = SPIMemSceneErase;
|
||||
if(app->mode == SPIMemModeCompare) scene = SPIMemSceneVerify;
|
||||
scene_manager_next_scene(app->scene_manager, scene);
|
||||
}
|
||||
|
||||
void spi_mem_scene_chip_detected_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_add_button_element(
|
||||
app->widget, GuiButtonTypeLeft, "Retry", spi_mem_scene_chip_detected_widget_callback, app);
|
||||
spi_mem_scene_chip_detect_draw_next_button(app);
|
||||
widget_add_icon_element(app->widget, 0, 12, &I_Dip8_32x36);
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 9, AlignCenter, AlignBottom, FontPrimary, "Detected SPI chip");
|
||||
spi_mem_scene_chip_detected_print_chip_info(app->widget, app->chip_info);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_chip_detected_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
spi_mem_scene_chip_detected_set_previous_scene(app);
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == GuiButtonTypeLeft) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, SPIMemSceneChipDetect);
|
||||
} else if(event.event == GuiButtonTypeRight) {
|
||||
spi_mem_scene_chip_detected_set_next_scene(app);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_chip_detected_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
static void
|
||||
spi_mem_scene_chip_error_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
SPIMemApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_mem_scene_chip_error_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_add_button_element(
|
||||
app->widget, GuiButtonTypeLeft, "Back", spi_mem_scene_chip_error_widget_callback, app);
|
||||
widget_add_string_element(
|
||||
app->widget, 85, 15, AlignCenter, AlignBottom, FontPrimary, "SPI chip error");
|
||||
widget_add_string_multiline_element(
|
||||
app->widget,
|
||||
85,
|
||||
52,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
FontSecondary,
|
||||
"Error while\ncommunicating\nwith chip");
|
||||
widget_add_icon_element(app->widget, 5, 6, &I_Dip8_32x36);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_chip_error_set_previous_scene(SPIMemApp* app) {
|
||||
uint32_t scene = SPIMemSceneChipDetect;
|
||||
if(app->mode == SPIMemModeRead || app->mode == SPIMemModeErase) scene = SPIMemSceneStart;
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, scene);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_chip_error_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
spi_mem_scene_chip_error_set_previous_scene(app);
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == GuiButtonTypeLeft) {
|
||||
spi_mem_scene_chip_error_set_previous_scene(app);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_chip_error_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
ADD_SCENE(spi_mem, start, Start)
|
||||
ADD_SCENE(spi_mem, chip_detect, ChipDetect)
|
||||
ADD_SCENE(spi_mem, chip_detected, ChipDetected)
|
||||
ADD_SCENE(spi_mem, chip_detect_fail, ChipDetectFail)
|
||||
ADD_SCENE(spi_mem, select_file, SelectFile)
|
||||
ADD_SCENE(spi_mem, saved_file_menu, SavedFileMenu)
|
||||
ADD_SCENE(spi_mem, read, Read)
|
||||
ADD_SCENE(spi_mem, read_filename, ReadFilename)
|
||||
ADD_SCENE(spi_mem, delete_confirm, DeleteConfirm)
|
||||
ADD_SCENE(spi_mem, success, Success)
|
||||
ADD_SCENE(spi_mem, about, About)
|
||||
ADD_SCENE(spi_mem, verify, Verify)
|
||||
ADD_SCENE(spi_mem, file_info, FileInfo)
|
||||
ADD_SCENE(spi_mem, erase, Erase)
|
||||
ADD_SCENE(spi_mem, chip_error, ChipError)
|
||||
ADD_SCENE(spi_mem, verify_error, VerifyError)
|
||||
ADD_SCENE(spi_mem, write, Write)
|
||||
ADD_SCENE(spi_mem, storage_error, StorageError)
|
||||
ADD_SCENE(spi_mem, select_vendor, SelectVendor)
|
||||
ADD_SCENE(spi_mem, select_model, SelectModel)
|
||||
ADD_SCENE(spi_mem, wiring, Wiring)
|
||||
@@ -0,0 +1,62 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../spi_mem_files.h"
|
||||
|
||||
static void spi_mem_scene_delete_confirm_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
SPIMemApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_mem_scene_delete_confirm_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
FuriString* file_name = furi_string_alloc();
|
||||
FuriString* message = furi_string_alloc();
|
||||
path_extract_filename(app->file_path, file_name, true);
|
||||
furi_string_printf(message, "\e#Delete %s?\e#", furi_string_get_cstr(file_name));
|
||||
widget_add_text_box_element(
|
||||
app->widget, 0, 0, 128, 27, AlignCenter, AlignCenter, furi_string_get_cstr(message), true);
|
||||
widget_add_button_element(
|
||||
app->widget,
|
||||
GuiButtonTypeLeft,
|
||||
"Cancel",
|
||||
spi_mem_scene_delete_confirm_widget_callback,
|
||||
app);
|
||||
widget_add_button_element(
|
||||
app->widget,
|
||||
GuiButtonTypeRight,
|
||||
"Delete",
|
||||
spi_mem_scene_delete_confirm_widget_callback,
|
||||
app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
furi_string_free(file_name);
|
||||
furi_string_free(message);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_delete_confirm_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == GuiButtonTypeRight) {
|
||||
app->mode = SPIMemModeDelete;
|
||||
if(spi_mem_file_delete(app)) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneSuccess);
|
||||
} else {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneStorageError);
|
||||
}
|
||||
} else if(event.event == GuiButtonTypeLeft) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, SPIMemSceneSavedFileMenu);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void spi_mem_scene_delete_confirm_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
static void
|
||||
spi_mem_scene_erase_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
SPIMemApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
static void spi_mem_scene_erase_callback(void* context, SPIMemCustomEventWorker event) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void spi_mem_scene_erase_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_add_button_element(
|
||||
app->widget, GuiButtonTypeLeft, "Cancel", spi_mem_scene_erase_widget_callback, app);
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 15, AlignCenter, AlignBottom, FontPrimary, "Erasing SPI chip");
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 27, AlignCenter, AlignBottom, FontSecondary, "Please be patient");
|
||||
notification_message(app->notifications, &sequence_blink_start_magenta);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
spi_mem_worker_start_thread(app->worker);
|
||||
spi_mem_worker_erase_start(app->chip_info, app->worker, spi_mem_scene_erase_callback, app);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_erase_set_previous_scene(SPIMemApp* app) {
|
||||
uint32_t scene = SPIMemSceneStart;
|
||||
if(app->mode == SPIMemModeWrite) scene = SPIMemSceneSavedFileMenu;
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, scene);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_erase_set_next_scene(SPIMemApp* app) {
|
||||
uint32_t scene = SPIMemSceneSuccess;
|
||||
if(app->mode == SPIMemModeWrite) scene = SPIMemSceneWrite;
|
||||
scene_manager_next_scene(app->scene_manager, scene);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_erase_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
spi_mem_scene_erase_set_previous_scene(app);
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == GuiButtonTypeLeft) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
} else if(event.event == SPIMemCustomEventWorkerDone) {
|
||||
spi_mem_scene_erase_set_next_scene(app);
|
||||
} else if(event.event == SPIMemCustomEventWorkerChipFail) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipError);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_erase_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_worker_stop_thread(app->worker);
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../spi_mem_files.h"
|
||||
|
||||
void spi_mem_scene_file_info_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
FuriString* str = furi_string_alloc();
|
||||
furi_string_printf(str, "Size: %zu KB", spi_mem_file_get_size(app) / 1024);
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 9, AlignCenter, AlignBottom, FontPrimary, "File info");
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 20, AlignCenter, AlignBottom, FontSecondary, furi_string_get_cstr(str));
|
||||
furi_string_free(str);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_file_info_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, SPIMemSceneSavedFileMenu);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_file_info_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../spi_mem_files.h"
|
||||
#include "../lib/spi/spi_mem_chip.h"
|
||||
#include "../lib/spi/spi_mem_tools.h"
|
||||
|
||||
void spi_mem_scene_read_progress_view_result_callback(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SPIMemCustomEventViewReadCancel);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_read_callback(void* context, SPIMemCustomEventWorker event) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void spi_mem_scene_read_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_view_progress_set_read_callback(
|
||||
app->view_progress, spi_mem_scene_read_progress_view_result_callback, app);
|
||||
notification_message(app->notifications, &sequence_blink_start_blue);
|
||||
spi_mem_view_progress_set_chip_size(app->view_progress, spi_mem_chip_get_size(app->chip_info));
|
||||
spi_mem_view_progress_set_block_size(
|
||||
app->view_progress, spi_mem_tools_get_file_max_block_size(app->chip_info));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewProgress);
|
||||
spi_mem_worker_start_thread(app->worker);
|
||||
spi_mem_worker_read_start(app->chip_info, app->worker, spi_mem_scene_read_callback, app);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_read_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
UNUSED(app);
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == SPIMemCustomEventViewReadCancel) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, SPIMemSceneChipDetect);
|
||||
} else if(event.event == SPIMemCustomEventWorkerBlockReaded) {
|
||||
spi_mem_view_progress_inc_progress(app->view_progress);
|
||||
} else if(event.event == SPIMemCustomEventWorkerDone) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneVerify);
|
||||
} else if(event.event == SPIMemCustomEventWorkerChipFail) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipError);
|
||||
} else if(event.event == SPIMemCustomEventWorkerFileFail) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneStorageError);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_read_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_worker_stop_thread(app->worker);
|
||||
spi_mem_view_progress_reset(app->view_progress);
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../spi_mem_files.h"
|
||||
|
||||
void spi_mem_scene_read_filename_view_result_callback(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SPIMemCustomEventTextEditResult);
|
||||
}
|
||||
|
||||
void spi_mem_scene_read_set_random_filename(SPIMemApp* app) {
|
||||
if(furi_string_end_with(app->file_path, SPI_MEM_FILE_EXTENSION)) {
|
||||
size_t filename_start = furi_string_search_rchar(app->file_path, '/');
|
||||
furi_string_left(app->file_path, filename_start);
|
||||
}
|
||||
set_random_name(app->text_buffer, SPI_MEM_TEXT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void spi_mem_scene_read_filename_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_scene_read_set_random_filename(app);
|
||||
text_input_set_header_text(app->text_input, "Name the dump");
|
||||
text_input_set_result_callback(
|
||||
app->text_input,
|
||||
spi_mem_scene_read_filename_view_result_callback,
|
||||
app,
|
||||
app->text_buffer,
|
||||
SPI_MEM_FILE_NAME_SIZE,
|
||||
true);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewTextInput);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_read_filename_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
UNUSED(app);
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == SPIMemCustomEventTextEditResult) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneRead);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_read_filename_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
typedef enum {
|
||||
SPIMemSceneSavedFileMenuSubmenuIndexWrite,
|
||||
SPIMemSceneSavedFileMenuSubmenuIndexCompare,
|
||||
SPIMemSceneSavedFileMenuSubmenuIndexInfo,
|
||||
SPIMemSceneSavedFileMenuSubmenuIndexDelete,
|
||||
} SPIMemSceneSavedFileMenuSubmenuIndex;
|
||||
|
||||
static void spi_mem_scene_saved_file_menu_submenu_callback(void* context, uint32_t index) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void spi_mem_scene_saved_file_menu_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Write",
|
||||
SPIMemSceneSavedFileMenuSubmenuIndexWrite,
|
||||
spi_mem_scene_saved_file_menu_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Compare",
|
||||
SPIMemSceneSavedFileMenuSubmenuIndexCompare,
|
||||
spi_mem_scene_saved_file_menu_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Info",
|
||||
SPIMemSceneSavedFileMenuSubmenuIndexInfo,
|
||||
spi_mem_scene_saved_file_menu_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Delete",
|
||||
SPIMemSceneSavedFileMenuSubmenuIndexDelete,
|
||||
spi_mem_scene_saved_file_menu_submenu_callback,
|
||||
app);
|
||||
submenu_set_selected_item(
|
||||
app->submenu, scene_manager_get_scene_state(app->scene_manager, SPIMemSceneSavedFileMenu));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewSubmenu);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_saved_file_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, SPIMemSceneSavedFileMenu, event.event);
|
||||
if(event.event == SPIMemSceneSavedFileMenuSubmenuIndexWrite) {
|
||||
app->mode = SPIMemModeWrite;
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipDetect);
|
||||
success = true;
|
||||
}
|
||||
if(event.event == SPIMemSceneSavedFileMenuSubmenuIndexCompare) {
|
||||
app->mode = SPIMemModeCompare;
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipDetect);
|
||||
success = true;
|
||||
}
|
||||
if(event.event == SPIMemSceneSavedFileMenuSubmenuIndexDelete) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneDeleteConfirm);
|
||||
success = true;
|
||||
}
|
||||
if(event.event == SPIMemSceneSavedFileMenuSubmenuIndexInfo) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneFileInfo);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void spi_mem_scene_saved_file_menu_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../spi_mem_files.h"
|
||||
|
||||
void spi_mem_scene_select_file_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
if(spi_mem_file_select(app)) {
|
||||
scene_manager_set_scene_state(app->scene_manager, SPIMemSceneSavedFileMenu, 0);
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneSavedFileMenu);
|
||||
} else {
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SPIMemSceneStart);
|
||||
}
|
||||
}
|
||||
|
||||
bool spi_mem_scene_select_file_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
void spi_mem_scene_select_file_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
static void spi_mem_scene_select_model_submenu_callback(void* context, uint32_t index) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_chip_copy_chip_info(app->chip_info, *found_chips_get(app->found_chips, index));
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void spi_mem_scene_select_model_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
size_t models_on_vendor = 0;
|
||||
for(size_t index = 0; index < found_chips_size(app->found_chips); index++) {
|
||||
if(spi_mem_chip_get_vendor_enum(*found_chips_get(app->found_chips, index)) !=
|
||||
app->chip_vendor_enum)
|
||||
continue;
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
spi_mem_chip_get_model_name(*found_chips_get(app->found_chips, index)),
|
||||
index,
|
||||
spi_mem_scene_select_model_submenu_callback,
|
||||
app);
|
||||
models_on_vendor++;
|
||||
}
|
||||
if(models_on_vendor == 1) spi_mem_scene_select_model_submenu_callback(context, 0);
|
||||
submenu_set_header(app->submenu, "Choose chip model");
|
||||
submenu_set_selected_item(
|
||||
app->submenu, scene_manager_get_scene_state(app->scene_manager, SPIMemSceneSelectVendor));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewSubmenu);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_select_model_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, SPIMemSceneSelectVendor, event.event);
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipDetected);
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void spi_mem_scene_select_model_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include <m-array.h>
|
||||
#include <m-algo.h>
|
||||
|
||||
ARRAY_DEF(vendors, uint32_t)
|
||||
ALGO_DEF(vendors, ARRAY_OPLIST(vendors))
|
||||
|
||||
static void spi_mem_scene_select_vendor_submenu_callback(void* context, uint32_t index) {
|
||||
SPIMemApp* app = context;
|
||||
app->chip_vendor_enum = index;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_select_vendor_sort_vendors(SPIMemApp* app, vendors_t vendors_arr) {
|
||||
for(size_t index = 0; index < found_chips_size(app->found_chips); index++) {
|
||||
vendors_push_back(
|
||||
vendors_arr, spi_mem_chip_get_vendor_enum(*found_chips_get(app->found_chips, index)));
|
||||
}
|
||||
vendors_uniq(vendors_arr);
|
||||
}
|
||||
|
||||
void spi_mem_scene_select_vendor_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
vendors_t vendors_arr;
|
||||
vendors_init(vendors_arr);
|
||||
spi_mem_scene_select_vendor_sort_vendors(app, vendors_arr);
|
||||
size_t vendors_arr_size = vendors_size(vendors_arr);
|
||||
if(vendors_arr_size == 1)
|
||||
spi_mem_scene_select_vendor_submenu_callback(context, *vendors_get(vendors_arr, 0));
|
||||
for(size_t index = 0; index < vendors_arr_size; index++) {
|
||||
uint32_t vendor_enum = *vendors_get(vendors_arr, index);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
spi_mem_chip_get_vendor_name_by_enum(vendor_enum),
|
||||
vendor_enum,
|
||||
spi_mem_scene_select_vendor_submenu_callback,
|
||||
app);
|
||||
}
|
||||
vendors_clear(vendors_arr);
|
||||
submenu_set_header(app->submenu, "Choose chip vendor");
|
||||
submenu_set_selected_item(
|
||||
app->submenu, scene_manager_get_scene_state(app->scene_manager, SPIMemSceneSelectVendor));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewSubmenu);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_select_vendor_set_previous_scene(SPIMemApp* app) {
|
||||
uint32_t scene = SPIMemSceneStart;
|
||||
if(app->mode == SPIMemModeCompare || app->mode == SPIMemModeWrite)
|
||||
scene = SPIMemSceneSavedFileMenu;
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, scene);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_select_vendor_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
spi_mem_scene_select_vendor_set_previous_scene(app);
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, SPIMemSceneSelectVendor, event.event);
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneSelectModel);
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void spi_mem_scene_select_vendor_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
typedef enum {
|
||||
SPIMemSceneStartSubmenuIndexRead,
|
||||
SPIMemSceneStartSubmenuIndexSaved,
|
||||
SPIMemSceneStartSubmenuIndexErase,
|
||||
SPIMemSceneStartSubmenuIndexWiring,
|
||||
SPIMemSceneStartSubmenuIndexAbout
|
||||
} SPIMemSceneStartSubmenuIndex;
|
||||
|
||||
static void spi_mem_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void spi_mem_scene_start_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Read",
|
||||
SPIMemSceneStartSubmenuIndexRead,
|
||||
spi_mem_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Saved",
|
||||
SPIMemSceneStartSubmenuIndexSaved,
|
||||
spi_mem_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Erase",
|
||||
SPIMemSceneStartSubmenuIndexErase,
|
||||
spi_mem_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Wiring",
|
||||
SPIMemSceneStartSubmenuIndexWiring,
|
||||
spi_mem_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"About",
|
||||
SPIMemSceneStartSubmenuIndexAbout,
|
||||
spi_mem_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_set_selected_item(
|
||||
app->submenu, scene_manager_get_scene_state(app->scene_manager, SPIMemSceneStart));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewSubmenu);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, SPIMemSceneStart, event.event);
|
||||
if(event.event == SPIMemSceneStartSubmenuIndexRead) {
|
||||
app->mode = SPIMemModeRead;
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipDetect);
|
||||
success = true;
|
||||
} else if(event.event == SPIMemSceneStartSubmenuIndexSaved) {
|
||||
furi_string_set(app->file_path, SPI_MEM_FILE_FOLDER);
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneSelectFile);
|
||||
success = true;
|
||||
} else if(event.event == SPIMemSceneStartSubmenuIndexErase) {
|
||||
app->mode = SPIMemModeErase;
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipDetect);
|
||||
success = true;
|
||||
} else if(event.event == SPIMemSceneStartSubmenuIndexWiring) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneWiring);
|
||||
success = true;
|
||||
} else if(event.event == SPIMemSceneStartSubmenuIndexAbout) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneAbout);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void spi_mem_scene_start_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
static void spi_mem_scene_storage_error_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
SPIMemApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_mem_scene_storage_error_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_add_button_element(
|
||||
app->widget, GuiButtonTypeLeft, "Back", spi_mem_scene_storage_error_widget_callback, app);
|
||||
widget_add_string_element(
|
||||
app->widget, 85, 15, AlignCenter, AlignBottom, FontPrimary, "Storage error");
|
||||
widget_add_string_multiline_element(
|
||||
app->widget,
|
||||
85,
|
||||
52,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
FontSecondary,
|
||||
"Error while\nworking with\nfilesystem");
|
||||
widget_add_icon_element(app->widget, 5, 6, &I_SDQuestion_35x43);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_storage_error_set_previous_scene(SPIMemApp* app) {
|
||||
uint32_t scene = SPIMemSceneChipDetect;
|
||||
if(app->mode == SPIMemModeRead) scene = SPIMemSceneStart;
|
||||
if(app->mode == SPIMemModeErase) scene = SPIMemSceneStart;
|
||||
if(app->mode == SPIMemModeDelete) scene = SPIMemSceneStart;
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, scene);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_storage_error_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
spi_mem_scene_storage_error_set_previous_scene(app);
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == GuiButtonTypeLeft) {
|
||||
spi_mem_scene_storage_error_set_previous_scene(app);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_storage_error_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
static void spi_mem_scene_success_popup_callback(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SPIMemCustomEventPopupBack);
|
||||
}
|
||||
|
||||
void spi_mem_scene_success_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
popup_set_icon(app->popup, 32, 5, &I_DolphinNice_96x59);
|
||||
popup_set_header(app->popup, "Success!", 5, 7, AlignLeft, AlignTop);
|
||||
popup_set_callback(app->popup, spi_mem_scene_success_popup_callback);
|
||||
popup_set_context(app->popup, app);
|
||||
popup_set_timeout(app->popup, 1500);
|
||||
popup_enable_timeout(app->popup);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewPopup);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_success_set_previous_scene(SPIMemApp* app) {
|
||||
uint32_t scene = SPIMemSceneSelectFile;
|
||||
if(app->mode == SPIMemModeErase) scene = SPIMemSceneStart;
|
||||
scene_manager_search_and_switch_to_another_scene(app->scene_manager, scene);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_success_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == SPIMemCustomEventPopupBack) {
|
||||
spi_mem_scene_success_set_previous_scene(app);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void spi_mem_scene_success_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
popup_reset(app->popup);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../spi_mem_files.h"
|
||||
#include "../lib/spi/spi_mem_chip.h"
|
||||
#include "../lib/spi/spi_mem_tools.h"
|
||||
|
||||
void spi_mem_scene_verify_view_result_callback(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SPIMemCustomEventViewVerifySkip);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_verify_callback(void* context, SPIMemCustomEventWorker event) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void spi_mem_scene_verify_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_view_progress_set_verify_callback(
|
||||
app->view_progress, spi_mem_scene_verify_view_result_callback, app);
|
||||
notification_message(app->notifications, &sequence_blink_start_cyan);
|
||||
spi_mem_view_progress_set_chip_size(app->view_progress, spi_mem_chip_get_size(app->chip_info));
|
||||
spi_mem_view_progress_set_file_size(app->view_progress, spi_mem_file_get_size(app));
|
||||
spi_mem_view_progress_set_block_size(
|
||||
app->view_progress, spi_mem_tools_get_file_max_block_size(app->chip_info));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewProgress);
|
||||
spi_mem_worker_start_thread(app->worker);
|
||||
spi_mem_worker_verify_start(app->chip_info, app->worker, spi_mem_scene_verify_callback, app);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_verify_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
UNUSED(app);
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == SPIMemCustomEventViewVerifySkip) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneSuccess);
|
||||
} else if(event.event == SPIMemCustomEventWorkerBlockReaded) {
|
||||
spi_mem_view_progress_inc_progress(app->view_progress);
|
||||
} else if(event.event == SPIMemCustomEventWorkerChipFail) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipError);
|
||||
} else if(event.event == SPIMemCustomEventWorkerFileFail) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneStorageError);
|
||||
} else if(event.event == SPIMemCustomEventWorkerDone) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneSuccess);
|
||||
} else if(event.event == SPIMemCustomEventWorkerVerifyFail) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneVerifyError);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_verify_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_worker_stop_thread(app->worker);
|
||||
spi_mem_view_progress_reset(app->view_progress);
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
|
||||
static void spi_mem_scene_verify_error_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
SPIMemApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_mem_scene_verify_error_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_add_button_element(
|
||||
app->widget, GuiButtonTypeLeft, "Back", spi_mem_scene_verify_error_widget_callback, app);
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 9, AlignCenter, AlignBottom, FontPrimary, "Verification error");
|
||||
widget_add_string_element(
|
||||
app->widget, 64, 21, AlignCenter, AlignBottom, FontSecondary, "Data mismatch");
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_verify_error_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, SPIMemSceneChipDetect);
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == GuiButtonTypeLeft) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, SPIMemSceneChipDetect);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_verify_error_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../lib/spi/spi_mem_chip.h"
|
||||
|
||||
void spi_mem_scene_wiring_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_add_icon_element(app->widget, 0, 0, &I_Wiring_SPI_128x64);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_wiring_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void spi_mem_scene_wiring_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#include "../spi_mem_app_i.h"
|
||||
#include "../spi_mem_files.h"
|
||||
#include "../lib/spi/spi_mem_chip.h"
|
||||
#include "../lib/spi/spi_mem_tools.h"
|
||||
|
||||
void spi_mem_scene_write_progress_view_result_callback(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SPIMemCustomEventViewReadCancel);
|
||||
}
|
||||
|
||||
static void spi_mem_scene_write_callback(void* context, SPIMemCustomEventWorker event) {
|
||||
SPIMemApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void spi_mem_scene_write_on_enter(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_view_progress_set_write_callback(
|
||||
app->view_progress, spi_mem_scene_write_progress_view_result_callback, app);
|
||||
notification_message(app->notifications, &sequence_blink_start_cyan);
|
||||
spi_mem_view_progress_set_chip_size(app->view_progress, spi_mem_chip_get_size(app->chip_info));
|
||||
spi_mem_view_progress_set_file_size(app->view_progress, spi_mem_file_get_size(app));
|
||||
spi_mem_view_progress_set_block_size(
|
||||
app->view_progress, spi_mem_tools_get_file_max_block_size(app->chip_info));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewProgress);
|
||||
spi_mem_worker_start_thread(app->worker);
|
||||
spi_mem_worker_write_start(app->chip_info, app->worker, spi_mem_scene_write_callback, app);
|
||||
}
|
||||
|
||||
bool spi_mem_scene_write_on_event(void* context, SceneManagerEvent event) {
|
||||
SPIMemApp* app = context;
|
||||
UNUSED(app);
|
||||
bool success = false;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
success = true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
success = true;
|
||||
if(event.event == SPIMemCustomEventViewReadCancel) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, SPIMemSceneChipDetect);
|
||||
} else if(event.event == SPIMemCustomEventWorkerBlockReaded) {
|
||||
spi_mem_view_progress_inc_progress(app->view_progress);
|
||||
} else if(event.event == SPIMemCustomEventWorkerDone) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneVerify);
|
||||
} else if(event.event == SPIMemCustomEventWorkerChipFail) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipError);
|
||||
} else if(event.event == SPIMemCustomEventWorkerFileFail) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneStorageError);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
void spi_mem_scene_write_on_exit(void* context) {
|
||||
SPIMemApp* app = context;
|
||||
spi_mem_worker_stop_thread(app->worker);
|
||||
spi_mem_view_progress_reset(app->view_progress);
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
#include <furi_hal.h>
|
||||
#include "spi_mem_app_i.h"
|
||||
#include "spi_mem_files.h"
|
||||
#include "lib/spi/spi_mem_chip_i.h"
|
||||
|
||||
static bool spi_mem_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
SPIMemApp* app = context;
|
||||
return scene_manager_handle_custom_event(app->scene_manager, event);
|
||||
}
|
||||
|
||||
static bool spi_mem_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SPIMemApp* app = context;
|
||||
return scene_manager_handle_back_event(app->scene_manager);
|
||||
}
|
||||
|
||||
SPIMemApp* spi_mem_alloc(void) {
|
||||
SPIMemApp* instance = malloc(sizeof(SPIMemApp));
|
||||
|
||||
instance->file_path = furi_string_alloc();
|
||||
instance->gui = furi_record_open(RECORD_GUI);
|
||||
instance->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
instance->view_dispatcher = view_dispatcher_alloc();
|
||||
instance->scene_manager = scene_manager_alloc(&spi_mem_scene_handlers, instance);
|
||||
instance->submenu = submenu_alloc();
|
||||
instance->dialog_ex = dialog_ex_alloc();
|
||||
instance->popup = popup_alloc();
|
||||
instance->worker = spi_mem_worker_alloc();
|
||||
instance->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
instance->storage = furi_record_open(RECORD_STORAGE);
|
||||
instance->widget = widget_alloc();
|
||||
instance->chip_info = malloc(sizeof(SPIMemChip));
|
||||
found_chips_init(instance->found_chips);
|
||||
instance->view_progress = spi_mem_view_progress_alloc();
|
||||
instance->view_detect = spi_mem_view_detect_alloc();
|
||||
instance->text_input = text_input_alloc();
|
||||
instance->mode = SPIMemModeUnknown;
|
||||
|
||||
furi_string_set(instance->file_path, SPI_MEM_FILE_FOLDER);
|
||||
|
||||
view_dispatcher_enable_queue(instance->view_dispatcher);
|
||||
view_dispatcher_set_event_callback_context(instance->view_dispatcher, instance);
|
||||
view_dispatcher_set_custom_event_callback(
|
||||
instance->view_dispatcher, spi_mem_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
instance->view_dispatcher, spi_mem_back_event_callback);
|
||||
view_dispatcher_attach_to_gui(
|
||||
instance->view_dispatcher, instance->gui, ViewDispatcherTypeFullscreen);
|
||||
view_dispatcher_add_view(
|
||||
instance->view_dispatcher, SPIMemViewSubmenu, submenu_get_view(instance->submenu));
|
||||
view_dispatcher_add_view(
|
||||
instance->view_dispatcher, SPIMemViewDialogEx, dialog_ex_get_view(instance->dialog_ex));
|
||||
view_dispatcher_add_view(
|
||||
instance->view_dispatcher, SPIMemViewPopup, popup_get_view(instance->popup));
|
||||
view_dispatcher_add_view(
|
||||
instance->view_dispatcher, SPIMemViewWidget, widget_get_view(instance->widget));
|
||||
view_dispatcher_add_view(
|
||||
instance->view_dispatcher,
|
||||
SPIMemViewProgress,
|
||||
spi_mem_view_progress_get_view(instance->view_progress));
|
||||
view_dispatcher_add_view(
|
||||
instance->view_dispatcher,
|
||||
SPIMemViewDetect,
|
||||
spi_mem_view_detect_get_view(instance->view_detect));
|
||||
view_dispatcher_add_view(
|
||||
instance->view_dispatcher, SPIMemViewTextInput, text_input_get_view(instance->text_input));
|
||||
|
||||
furi_hal_power_enable_otg();
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_external);
|
||||
scene_manager_next_scene(instance->scene_manager, SPIMemSceneStart);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void spi_mem_free(SPIMemApp* instance) {
|
||||
view_dispatcher_remove_view(instance->view_dispatcher, SPIMemViewSubmenu);
|
||||
view_dispatcher_remove_view(instance->view_dispatcher, SPIMemViewDialogEx);
|
||||
view_dispatcher_remove_view(instance->view_dispatcher, SPIMemViewPopup);
|
||||
view_dispatcher_remove_view(instance->view_dispatcher, SPIMemViewWidget);
|
||||
view_dispatcher_remove_view(instance->view_dispatcher, SPIMemViewProgress);
|
||||
view_dispatcher_remove_view(instance->view_dispatcher, SPIMemViewDetect);
|
||||
view_dispatcher_remove_view(instance->view_dispatcher, SPIMemViewTextInput);
|
||||
spi_mem_view_progress_free(instance->view_progress);
|
||||
spi_mem_view_detect_free(instance->view_detect);
|
||||
submenu_free(instance->submenu);
|
||||
dialog_ex_free(instance->dialog_ex);
|
||||
popup_free(instance->popup);
|
||||
widget_free(instance->widget);
|
||||
text_input_free(instance->text_input);
|
||||
view_dispatcher_free(instance->view_dispatcher);
|
||||
scene_manager_free(instance->scene_manager);
|
||||
spi_mem_worker_free(instance->worker);
|
||||
free(instance->chip_info);
|
||||
found_chips_clear(instance->found_chips);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
furi_record_close(RECORD_GUI);
|
||||
furi_string_free(instance->file_path);
|
||||
furi_hal_spi_bus_handle_deinit(&furi_hal_spi_bus_handle_external);
|
||||
furi_hal_power_disable_otg();
|
||||
free(instance);
|
||||
}
|
||||
|
||||
int32_t spi_mem_app(void* p) {
|
||||
UNUSED(p);
|
||||
SPIMemApp* instance = spi_mem_alloc();
|
||||
spi_mem_file_create_folder(instance);
|
||||
view_dispatcher_run(instance->view_dispatcher);
|
||||
spi_mem_free(instance);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct SPIMemApp SPIMemApp;
|
||||