Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSG <who.just.the.doctor@gmail.com>2021-05-24 12:57:14 +0300
committerGitHub <noreply@github.com>2021-05-24 12:57:14 +0300
commiteac8626c8c3ef9ba68f5cc2b0912b9d5ff15a061 (patch)
tree3c7bb51076591f609034f9eba64dd38cea34f1cf /applications/accessor
parent89d1b0546ed9ed05d8b41b57a343424c2fb03617 (diff)
[FL-1351] Wiegand read fix (#483)
* App accessor: fix external interrupts binding. Hal: removed InterruptTypeExternalInterrupt. * GPIO hal: add ex and simple init functions to F6 target * GPIO hal: add dummy alt fn to F6 target * RFID hal: update gpio hal usage * F5,F6: synchronize targets, backport VCP fixes, cleanup. Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/accessor')
-rw-r--r--applications/accessor/accessor-app.cpp3
-rw-r--r--applications/accessor/helpers/wiegand.cpp32
-rw-r--r--applications/accessor/helpers/wiegand.h1
3 files changed, 22 insertions, 14 deletions
diff --git a/applications/accessor/accessor-app.cpp b/applications/accessor/accessor-app.cpp
index 5ec1a939..a6f8e59f 100644
--- a/applications/accessor/accessor-app.cpp
+++ b/applications/accessor/accessor-app.cpp
@@ -28,6 +28,9 @@ void AccessorApp::run(void) {
};
scenes[current_scene]->on_exit(this);
+
+ wiegand.end();
+ onewire_master.stop();
}
AccessorApp::AccessorApp()
diff --git a/applications/accessor/helpers/wiegand.cpp b/applications/accessor/helpers/wiegand.cpp
index c6ca9fe0..bc618489 100644
--- a/applications/accessor/helpers/wiegand.cpp
+++ b/applications/accessor/helpers/wiegand.cpp
@@ -35,18 +35,14 @@ bool WIEGAND::available() {
return ret;
}
-void input_isr(void* _pin, void* _ctx) {
- // interrupt manager get us pin constant, so...
- uint32_t pin = (uint32_t)_pin;
+static void input_isr_d0(void* _ctx) {
WIEGAND* _this = static_cast<WIEGAND*>(_ctx);
+ _this->ReadD0();
+}
- if(pin == gpio_ext_pa6.pin) {
- _this->ReadD0();
- }
-
- if(pin == gpio_ext_pa7.pin) {
- _this->ReadD1();
- }
+static void input_isr_d1(void* _ctx) {
+ WIEGAND* _this = static_cast<WIEGAND*>(_ctx);
+ _this->ReadD1();
}
void WIEGAND::begin() {
@@ -60,11 +56,19 @@ void WIEGAND::begin() {
const GpioPin* pinD0 = &gpio_ext_pa6;
const GpioPin* pinD1 = &gpio_ext_pa7;
- hal_gpio_init(pinD0, GpioModeInterruptFall, GpioPullNo, GpioSpeedLow); // Set D0 pin as input
- hal_gpio_init(pinD1, GpioModeInterruptFall, GpioPullNo, GpioSpeedLow); // Set D1 pin as input
+ hal_gpio_init_simple(pinD0, GpioModeInterruptFall); // Set D0 pin as input
+ hal_gpio_init_simple(pinD1, GpioModeInterruptFall); // Set D1 pin as input
+
+ hal_gpio_add_int_callback(pinD0, input_isr_d0, this);
+ hal_gpio_add_int_callback(pinD1, input_isr_d1, this);
+}
+
+void WIEGAND::end() {
+ hal_gpio_remove_int_callback(&gpio_ext_pa6);
+ hal_gpio_remove_int_callback(&gpio_ext_pa7);
- api_interrupt_add(
- input_isr, InterruptTypeExternalInterrupt, this); // Hardware interrupt - high to low pulse
+ hal_gpio_init_simple(&gpio_ext_pa6, GpioModeAnalog);
+ hal_gpio_init_simple(&gpio_ext_pa7, GpioModeAnalog);
}
void WIEGAND::ReadD0() {
diff --git a/applications/accessor/helpers/wiegand.h b/applications/accessor/helpers/wiegand.h
index 782eec77..fed9fa14 100644
--- a/applications/accessor/helpers/wiegand.h
+++ b/applications/accessor/helpers/wiegand.h
@@ -4,6 +4,7 @@ class WIEGAND {
public:
WIEGAND();
void begin();
+ void end();
bool available();
unsigned long getCode();
unsigned long getCodeHigh();