From 3d5563b169f6c752c06e06879b240a1ae7907f3b Mon Sep 17 00:00:00 2001 From: coreglitch Date: Mon, 16 Nov 2020 21:26:34 +0600 Subject: [PATCH] init nfc later (#239) --- applications/nfc/nfc.c | 28 ++++++++++++++++++++++++++-- firmware/targets/f2/Src/spi.c | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/applications/nfc/nfc.c b/applications/nfc/nfc.c index 719d3c37..26ae41bf 100644 --- a/applications/nfc/nfc.c +++ b/applications/nfc/nfc.c @@ -68,6 +68,12 @@ void nfc_test_callback(void* context) { nfc->screen = 0; widget_enabled_set(nfc->widget, true); + // TODO only for workaround + if(nfc->ret != ERR_NONE) { + nfc->ret = rfalNfcInitialize(); + rfalLowPowerModeStart(); + } + if(nfc->ret == ERR_NONE && !nfc->worker) { // TODO change to fuirac_start nfc->worker = osThreadNew(nfc_worker_task, nfc, &nfc->worker_attr); @@ -77,11 +83,29 @@ void nfc_test_callback(void* context) { } void nfc_field_on_callback(void* context) { + furi_assert(context); + Nfc* nfc = context; + + // TODO only for workaround + if(nfc->ret != ERR_NONE) { + nfc->ret = rfalNfcInitialize(); + rfalLowPowerModeStart(); + } + st25r3916OscOn(); st25r3916TxRxOn(); } void nfc_field_off_callback(void* context) { + furi_assert(context); + Nfc* nfc = context; + + // TODO only for workaround + if(nfc->ret != ERR_NONE) { + nfc->ret = rfalNfcInitialize(); + rfalLowPowerModeStart(); + } + st25r3916TxRxOff(); } @@ -158,8 +182,8 @@ void nfc_task(void* p) { furiac_exit(NULL); } - nfc->ret = rfalNfcInitialize(); - rfalLowPowerModeStart(); + // TODO only for workaround + nfc->ret = ERR_WRONG_STATE; furiac_ready(); diff --git a/firmware/targets/f2/Src/spi.c b/firmware/targets/f2/Src/spi.c index 7e767e11..72c50b01 100644 --- a/firmware/targets/f2/Src/spi.c +++ b/firmware/targets/f2/Src/spi.c @@ -120,7 +120,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) */ GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLDOWN; + GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);