2022-01-05 19:10:18 +03:00
|
|
|
#include "lfrfid_debug_app_scene_tune.h"
|
|
|
|
#include <furi_hal.h>
|
2021-12-07 15:49:44 +03:00
|
|
|
|
2022-03-23 20:59:20 +03:00
|
|
|
static void comparator_trigger_callback(bool level, void* comp_ctx) {
|
|
|
|
hal_gpio_write(&gpio_ext_pa7, !level);
|
2021-12-07 15:49:44 +03:00
|
|
|
}
|
2021-06-28 17:42:30 +03:00
|
|
|
|
|
|
|
void LfRfidDebugAppSceneTune::on_enter(LfRfidDebugApp* app, bool need_restore) {
|
|
|
|
app->view_controller.switch_to<LfRfidViewTuneVM>();
|
2021-12-07 15:49:44 +03:00
|
|
|
hal_gpio_init_simple(&gpio_ext_pa7, GpioModeOutputPushPull);
|
|
|
|
|
2022-03-23 20:59:20 +03:00
|
|
|
furi_hal_rfid_comp_set_callback(comparator_trigger_callback, this);
|
|
|
|
furi_hal_rfid_comp_start();
|
2021-06-28 17:42:30 +03:00
|
|
|
|
2021-08-08 21:03:25 +03:00
|
|
|
furi_hal_rfid_pins_read();
|
|
|
|
furi_hal_rfid_tim_read(125000, 0.5);
|
|
|
|
furi_hal_rfid_tim_read_start();
|
2021-06-28 17:42:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) {
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
LfRfidViewTuneVM* tune = app->view_controller;
|
|
|
|
|
|
|
|
if(tune->is_dirty()) {
|
2021-08-08 21:03:25 +03:00
|
|
|
furi_hal_rfid_set_read_period(tune->get_ARR());
|
|
|
|
furi_hal_rfid_set_read_pulse(tune->get_CCR());
|
2021-06-28 17:42:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LfRfidDebugAppSceneTune::on_exit(LfRfidDebugApp* app) {
|
2022-03-23 20:59:20 +03:00
|
|
|
furi_hal_rfid_comp_stop();
|
|
|
|
furi_hal_rfid_comp_set_callback(NULL, NULL);
|
2021-12-07 15:49:44 +03:00
|
|
|
|
|
|
|
hal_gpio_init_simple(&gpio_ext_pa7, GpioModeAnalog);
|
2021-08-08 21:03:25 +03:00
|
|
|
furi_hal_rfid_tim_read_stop();
|
|
|
|
furi_hal_rfid_tim_reset();
|
|
|
|
furi_hal_rfid_pins_reset();
|
2022-03-23 20:59:20 +03:00
|
|
|
}
|