2022-09-08 16:40:33 +00:00
|
|
|
#include "../lfrfid_debug_i.h"
|
2022-01-05 16:10:18 +00:00
|
|
|
#include <furi_hal.h>
|
2021-12-07 12:49:44 +00:00
|
|
|
|
2022-03-23 17:59:20 +00:00
|
|
|
static void comparator_trigger_callback(bool level, void* comp_ctx) {
|
2022-05-06 13:37:10 +00:00
|
|
|
UNUSED(comp_ctx);
|
2022-03-30 15:23:40 +00:00
|
|
|
furi_hal_gpio_write(&gpio_ext_pa7, !level);
|
2021-12-07 12:49:44 +00:00
|
|
|
}
|
2021-06-28 14:42:30 +00:00
|
|
|
|
2022-09-08 16:40:33 +00:00
|
|
|
void lfrfid_debug_scene_tune_on_enter(void* context) {
|
|
|
|
LfRfidDebug* app = context;
|
|
|
|
|
2022-03-30 15:23:40 +00:00
|
|
|
furi_hal_gpio_init_simple(&gpio_ext_pa7, GpioModeOutputPushPull);
|
2021-12-07 12:49:44 +00:00
|
|
|
|
2022-09-08 16:40:33 +00:00
|
|
|
furi_hal_rfid_comp_set_callback(comparator_trigger_callback, app);
|
2022-03-23 17:59:20 +00:00
|
|
|
furi_hal_rfid_comp_start();
|
2021-06-28 14:42:30 +00:00
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_rfid_pins_read();
|
|
|
|
furi_hal_rfid_tim_read(125000, 0.5);
|
|
|
|
furi_hal_rfid_tim_read_start();
|
2022-09-08 16:40:33 +00:00
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidDebugViewTune);
|
2021-06-28 14:42:30 +00:00
|
|
|
}
|
|
|
|
|
2022-09-08 16:40:33 +00:00
|
|
|
bool lfrfid_debug_scene_tune_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
UNUSED(event);
|
2021-06-28 14:42:30 +00:00
|
|
|
|
2022-09-08 16:40:33 +00:00
|
|
|
LfRfidDebug* app = context;
|
|
|
|
bool consumed = false;
|
2021-06-28 14:42:30 +00:00
|
|
|
|
2022-09-08 16:40:33 +00:00
|
|
|
if(lfrfid_debug_view_tune_is_dirty(app->tune_view)) {
|
|
|
|
furi_hal_rfid_set_read_period(lfrfid_debug_view_tune_get_arr(app->tune_view));
|
|
|
|
furi_hal_rfid_set_read_pulse(lfrfid_debug_view_tune_get_ccr(app->tune_view));
|
2021-06-28 14:42:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
2022-09-08 16:40:33 +00:00
|
|
|
void lfrfid_debug_scene_tune_on_exit(void* context) {
|
|
|
|
UNUSED(context);
|
|
|
|
|
2022-03-23 17:59:20 +00:00
|
|
|
furi_hal_rfid_comp_stop();
|
|
|
|
furi_hal_rfid_comp_set_callback(NULL, NULL);
|
2021-12-07 12:49:44 +00:00
|
|
|
|
2022-03-30 15:23:40 +00:00
|
|
|
furi_hal_gpio_init_simple(&gpio_ext_pa7, GpioModeAnalog);
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_rfid_tim_read_stop();
|
|
|
|
furi_hal_rfid_tim_reset();
|
|
|
|
furi_hal_rfid_pins_reset();
|
2022-03-23 17:59:20 +00:00
|
|
|
}
|