From 5fc1bda310209140cb3223843099d2d38a79c944 Mon Sep 17 00:00:00 2001 From: gornekich Date: Sat, 28 Oct 2023 18:22:07 +0400 Subject: [PATCH] [FL-3637] NFC RC fixes (#3165) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * firmware: remove nfc lib build settings section * furi hal nfc: fix nfc irq gpio deinit * lib nfc: remove deprecated exception from sources * nfc: use ASK demodulator in transparent mode * mf ultralight: add upper page bound for NTAGI2C1K * furi hal nfc: set event if nfc event was started * nfc: fix PVS warnings * lib signal reader: remove gpio pull setting in alloc * furi: added math.h include for compatibility with existing apps * nfc: remove resolved TODO in mf desfire poller * bump api symbol version Co-authored-by: hedger Co-authored-by: あく --- firmware.scons | 9 --------- firmware/targets/f18/api_symbols.csv | 2 +- firmware/targets/f7/api_symbols.csv | 2 +- firmware/targets/f7/furi_hal/furi_hal_nfc_event.c | 5 +++-- firmware/targets/f7/furi_hal/furi_hal_nfc_irq.c | 2 +- firmware/targets/f7/furi_hal/furi_hal_nfc_iso15693.c | 2 +- furi/furi.h | 3 +++ lib/nfc/SConscript | 2 +- lib/nfc/protocols/mf_ultralight/mf_ultralight.c | 2 +- .../protocols/mf_ultralight/mf_ultralight_listener_i.c | 2 ++ lib/signal_reader/parsers/iso15693/iso15693_parser.c | 2 +- 11 files changed, 15 insertions(+), 18 deletions(-) diff --git a/firmware.scons b/firmware.scons index d8e96ad7d035..82f775d719c8 100644 --- a/firmware.scons +++ b/firmware.scons @@ -71,15 +71,6 @@ env = ENV.Clone( "FURI_DEBUG" if ENV["DEBUG"] else "FURI_NDEBUG", ], }, - "nfc": { - "CCFLAGS": [ - "-Og", - ], - "CPPDEFINES": [ - "NDEBUG", - "FURI_DEBUG", - ], - }, }, FW_API_TABLE=None, _APP_ICONS=None, diff --git a/firmware/targets/f18/api_symbols.csv b/firmware/targets/f18/api_symbols.csv index 8e15030a94ab..4789d316d628 100644 --- a/firmware/targets/f18/api_symbols.csv +++ b/firmware/targets/f18/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,40.0,, +Version,+,40.1,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index af8ea54d7fe5..01d7250f0036 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,40.0,, +Version,+,40.1,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, diff --git a/firmware/targets/f7/furi_hal/furi_hal_nfc_event.c b/firmware/targets/f7/furi_hal/furi_hal_nfc_event.c index cce16c5dc9bb..266b606fd1bf 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_nfc_event.c +++ b/firmware/targets/f7/furi_hal/furi_hal_nfc_event.c @@ -25,9 +25,10 @@ FuriHalNfcError furi_hal_nfc_event_stop() { void furi_hal_nfc_event_set(FuriHalNfcEventInternalType event) { furi_assert(furi_hal_nfc_event); - furi_assert(furi_hal_nfc_event->thread); - furi_thread_flags_set(furi_hal_nfc_event->thread, event); + if(furi_hal_nfc_event->thread) { + furi_thread_flags_set(furi_hal_nfc_event->thread, event); + } } FuriHalNfcError furi_hal_nfc_abort() { diff --git a/firmware/targets/f7/furi_hal/furi_hal_nfc_irq.c b/firmware/targets/f7/furi_hal/furi_hal_nfc_irq.c index 63dc3541550c..170d8dee619c 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_nfc_irq.c +++ b/firmware/targets/f7/furi_hal/furi_hal_nfc_irq.c @@ -23,6 +23,6 @@ void furi_hal_nfc_init_gpio_isr() { } void furi_hal_nfc_deinit_gpio_isr() { - furi_hal_gpio_init(&gpio_nfc_irq_rfid_pull, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); furi_hal_gpio_remove_int_callback(&gpio_nfc_irq_rfid_pull); + furi_hal_gpio_init(&gpio_nfc_irq_rfid_pull, GpioModeAnalog, GpioPullNo, GpioSpeedLow); } diff --git a/firmware/targets/f7/furi_hal/furi_hal_nfc_iso15693.c b/firmware/targets/f7/furi_hal/furi_hal_nfc_iso15693.c index 19ac6dc034f5..cc936644b4ea 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_nfc_iso15693.c +++ b/firmware/targets/f7/furi_hal/furi_hal_nfc_iso15693.c @@ -48,7 +48,7 @@ static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener_alloc() { instance->signal = iso15693_signal_alloc(&gpio_spi_r_mosi); instance->parser = - iso15693_parser_alloc(&gpio_spi_r_miso, FURI_HAL_NFC_ISO15693_MAX_FRAME_SIZE); + iso15693_parser_alloc(&gpio_nfc_irq_rfid_pull, FURI_HAL_NFC_ISO15693_MAX_FRAME_SIZE); return instance; } diff --git a/furi/furi.h b/furi/furi.h index cfdeb2c0f405..b1299c9a9523 100644 --- a/furi/furi.h +++ b/furi/furi.h @@ -24,6 +24,9 @@ // FreeRTOS timer, REMOVE AFTER REFACTORING #include +// Workaround for math.h leaking through HAL in older versions +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/lib/nfc/SConscript b/lib/nfc/SConscript index 0e09b693923d..6c55cf5d2bf1 100644 --- a/lib/nfc/SConscript +++ b/lib/nfc/SConscript @@ -51,7 +51,7 @@ env.Append( libenv = env.Clone(FW_LIB_NAME="nfc") libenv.ApplyLibFlags() -sources = libenv.GlobRecursive("*.c*", exclude="deprecated/*c") +sources = libenv.GlobRecursive("*.c*") lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources) libenv.Install("${LIB_DIST_DIR}", lib) diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight.c b/lib/nfc/protocols/mf_ultralight/mf_ultralight.c index 40d997686364..fd845f3c085e 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight.c +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight.c @@ -297,7 +297,7 @@ bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t vers uint32_t pages_total = 0; if(!flipper_format_read_uint32(ff, MF_ULTRALIGHT_PAGES_TOTAL_KEY, &pages_total, 1)) break; uint32_t pages_read = 0; - if(data_format_version < mf_ultralight_data_format_version) { + if(data_format_version < mf_ultralight_data_format_version) { //-V547 pages_read = pages_total; } else { if(!flipper_format_read_uint32(ff, MF_ULTRALIGHT_PAGES_READ_KEY, &pages_read, 1)) diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight_listener_i.c b/lib/nfc/protocols/mf_ultralight/mf_ultralight_listener_i.c index 3d6b9a94fdf7..64647492de10 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight_listener_i.c +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight_listener_i.c @@ -518,6 +518,8 @@ static uint16_t mf_ultralight_get_upper_page_bound(MfUltralightType type) { upper_page_bound = 511; else if(type == MfUltralightTypeNTAGI2C2K) upper_page_bound = 479; + else if(type == MfUltralightTypeNTAGI2C1K) + upper_page_bound = 225; else { upper_page_bound = mf_ultralight_get_config_page_num(type) - 2; } diff --git a/lib/signal_reader/parsers/iso15693/iso15693_parser.c b/lib/signal_reader/parsers/iso15693/iso15693_parser.c index a398516c9258..c5326a354d74 100644 --- a/lib/signal_reader/parsers/iso15693/iso15693_parser.c +++ b/lib/signal_reader/parsers/iso15693/iso15693_parser.c @@ -68,7 +68,7 @@ Iso15693Parser* iso15693_parser_alloc(const GpioPin* pin, size_t max_frame_size) signal_reader_set_sample_rate( instance->signal_reader, SignalReaderTimeUnit64Mhz, ISO15693_PARSER_BITRATE_F64MHZ); signal_reader_set_pull(instance->signal_reader, GpioPullDown); - signal_reader_set_polarity(instance->signal_reader, SignalReaderPolarityInverted); + signal_reader_set_polarity(instance->signal_reader, SignalReaderPolarityNormal); signal_reader_set_trigger(instance->signal_reader, SignalReaderTriggerRisingFallingEdge); return instance;