[FL-3122] Re-init NFC when starting the worker (#2399)
* Re-init NFC when starting the worker * FuriHal: cleanup nfc init/deinit sequence * FuriHal: a little bit more defensive nfc init Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
738e0df4f4
commit
b15c4afea1
@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,14.0,,
|
||||
Version,+,14.1,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@ -1171,6 +1171,7 @@ Function,+,furi_hal_mpu_protect_disable,void,FuriHalMpuRegion
|
||||
Function,+,furi_hal_mpu_protect_no_access,void,"FuriHalMpuRegion, uint32_t, FuriHalMPURegionSize"
|
||||
Function,+,furi_hal_mpu_protect_read_only,void,"FuriHalMpuRegion, uint32_t, FuriHalMPURegionSize"
|
||||
Function,+,furi_hal_nfc_activate_nfca,_Bool,"uint32_t, uint32_t*"
|
||||
Function,-,furi_hal_nfc_deinit,void,
|
||||
Function,+,furi_hal_nfc_detect,_Bool,"FuriHalNfcDevData*, uint32_t"
|
||||
Function,+,furi_hal_nfc_emulate_nfca,_Bool,"uint8_t*, uint8_t, uint8_t*, uint8_t, FuriHalNfcEmulateCallback, void*, uint32_t"
|
||||
Function,+,furi_hal_nfc_exit_sleep,void,
|
||||
|
|
@ -24,13 +24,29 @@ FuriEventFlag* event = NULL;
|
||||
#define FURI_HAL_NFC_UID_INCOMPLETE (0x04)
|
||||
|
||||
void furi_hal_nfc_init() {
|
||||
furi_assert(!event);
|
||||
event = furi_event_flag_alloc();
|
||||
|
||||
ReturnCode ret = rfalNfcInitialize();
|
||||
if(ret == ERR_NONE) {
|
||||
furi_hal_nfc_start_sleep();
|
||||
event = furi_event_flag_alloc();
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
} else {
|
||||
FURI_LOG_W(TAG, "Initialization failed, RFAL returned: %d", ret);
|
||||
FURI_LOG_W(TAG, "Init Failed, RFAL returned: %d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_nfc_deinit() {
|
||||
ReturnCode ret = rfalDeinitialize();
|
||||
if(ret == ERR_NONE) {
|
||||
FURI_LOG_I(TAG, "Deinit OK");
|
||||
} else {
|
||||
FURI_LOG_W(TAG, "Deinit Failed, RFAL returned: %d", ret);
|
||||
}
|
||||
|
||||
if(event) {
|
||||
furi_event_flag_free(event);
|
||||
event = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,10 @@ typedef struct {
|
||||
*/
|
||||
void furi_hal_nfc_init();
|
||||
|
||||
/** Deinit nfc
|
||||
*/
|
||||
void furi_hal_nfc_deinit();
|
||||
|
||||
/** Check if nfc worker is busy
|
||||
*
|
||||
* @return true if busy
|
||||
|
@ -56,6 +56,8 @@ void nfc_worker_start(
|
||||
while(furi_hal_nfc_is_busy()) {
|
||||
furi_delay_ms(10);
|
||||
}
|
||||
furi_hal_nfc_deinit();
|
||||
furi_hal_nfc_init();
|
||||
|
||||
nfc_worker->callback = callback;
|
||||
nfc_worker->context = context;
|
||||
|
Loading…
Reference in New Issue
Block a user