From c64052b4912f56554835504c3c5f112380ce20dc Mon Sep 17 00:00:00 2001 From: SG Date: Fri, 24 Sep 2021 22:16:59 +1000 Subject: [PATCH] [FL-1042][FL-1485][FL-1747] Metakom emulation fix (#721) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * iButton: Metakom emulation fix * iButton: do not threat NVIC * iButton: use proper GPIO from resources Co-authored-by: あく --- applications/ibutton/helpers/key-emulator.cpp | 2 +- applications/ibutton/helpers/key-reader.cpp | 14 +++++--------- applications/ibutton/helpers/pulse-sequencer.cpp | 3 --- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/applications/ibutton/helpers/key-emulator.cpp b/applications/ibutton/helpers/key-emulator.cpp index 09d775ea..7c8c5c97 100644 --- a/applications/ibutton/helpers/key-emulator.cpp +++ b/applications/ibutton/helpers/key-emulator.cpp @@ -144,7 +144,7 @@ void KeyEmulator::start_metakom_emulate(iButtonKey* key) { uint8_t* key_data = key->get_data(); // start pulse - pulse_data[0] = metakom_period_full * 4; + pulse_data[0] = metakom_period_full; // start triplet set_pulse_data_metakom(pd_index, metakom_period_zero); diff --git a/applications/ibutton/helpers/key-reader.cpp b/applications/ibutton/helpers/key-reader.cpp index 91ada058..fcb2a480 100644 --- a/applications/ibutton/helpers/key-reader.cpp +++ b/applications/ibutton/helpers/key-reader.cpp @@ -116,15 +116,11 @@ bool KeyReader::verify_key(iButtonKeyType key_type, const uint8_t* const data, u void KeyReader::start_comaparator(void) { // pulldown lf-rfid pins to prevent interference - // TODO open record - GpioPin rfid_pull_pin = {.port = RFID_PULL_GPIO_Port, .pin = RFID_PULL_Pin}; - hal_gpio_init(&rfid_pull_pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); - hal_gpio_write(&rfid_pull_pin, false); + hal_gpio_init(&gpio_rfid_pull, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); + hal_gpio_write(&gpio_rfid_pull, false); - // TODO open record - GpioPin rfid_out_pin = {.port = RFID_OUT_GPIO_Port, .pin = RFID_OUT_Pin}; - hal_gpio_init(&rfid_out_pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); - hal_gpio_write(&rfid_out_pin, false); + hal_gpio_init(&gpio_rfid_carrier_out, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); + hal_gpio_write(&gpio_rfid_carrier_out, false); comparator_callback_pointer = cbc::obtain_connector(this, &KeyReader::comparator_trigger_callback); @@ -149,7 +145,7 @@ void KeyReader::comparator_trigger_callback(void* hcomp, void* comp_ctx) { _this->metakom_decoder.process_front( hal_gpio_get_rfid_in_level(), current_dwt_value - last_dwt_value); - last_dwt_value = DWT->CYCCNT; + last_dwt_value = current_dwt_value; } } diff --git a/applications/ibutton/helpers/pulse-sequencer.cpp b/applications/ibutton/helpers/pulse-sequencer.cpp index 21818a3b..22fbad79 100644 --- a/applications/ibutton/helpers/pulse-sequencer.cpp +++ b/applications/ibutton/helpers/pulse-sequencer.cpp @@ -54,9 +54,6 @@ void PulseSequencer::init_timer(uint32_t period) { Error_Handler(); } - HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn); - hal_gpio_init(&ibutton_gpio, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); }