FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error. * GUI: view and viewdispatcher bones * GUI: view implementation, view models, view dispatcher * GUI: view navigation, model refinement. Power: use view, view dispatcher. * HAL Flash: proper page write. Dolphin: views. Power: views * Dolphin: transition idle scree to Views * Dolphin: input events on stats view. Format sources. * HAL: flash erase. Dolphin: permanent state storage. * Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch. * NFC: rewrite worker * NFC: add support for B,F,V. * NFC: replace rfal irq hanlder with realtime thread, more details about cards. * Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error. * F4: stop in Error_Handler * BLE: handle working FUS, but empty radio stack. * HAL: alive FUS is now sufficient for flash controller access * Dolphin: update model after state load * NFC: detect navigation * RFAL: use osPriorityISR for isr thread * NFC: emulation * Bootloader: rollback incorrectly merged rename * Dolphin: rollback incorrectly merged changes * RFAL: remove volatile from thread attr * RFAL: do not call platform ErrorHandler, error codes is enough * NFC: improved error handling * Format sources * NFC: reset detect view model on start * Format sources * update codeowners * NFC: hide last info if no card detected
This commit is contained in:
@@ -1,7 +1,34 @@
|
||||
#include "platform.h"
|
||||
#include <assert.h>
|
||||
#include <main.h>
|
||||
#include <spi.h>
|
||||
#include <api-hal-spi.h>
|
||||
|
||||
static osThreadAttr_t platform_irq_thread_attr;
|
||||
static volatile osThreadId_t platform_irq_thread_id = NULL;
|
||||
static volatile PlatformIrqCallback platform_irq_callback = NULL;
|
||||
|
||||
void nfc_isr() {
|
||||
if(platform_irq_callback && platformGpioIsHigh( ST25R_INT_PORT, ST25R_INT_PIN )) {
|
||||
osThreadFlagsSet(platform_irq_thread_id, 0x1);
|
||||
}
|
||||
}
|
||||
|
||||
void platformIrqWorker() {
|
||||
while(1) {
|
||||
uint32_t flags = osThreadFlagsWait(0x1, osFlagsWaitAny, osWaitForever);
|
||||
if (flags & 0x1) {
|
||||
platform_irq_callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void platformSetIrqCallback(PlatformIrqCallback callback) {
|
||||
platform_irq_callback = callback;
|
||||
platform_irq_thread_attr.name = "rfal_irq_worker";
|
||||
platform_irq_thread_attr.stack_size = 512;
|
||||
platform_irq_thread_attr.priority = osPriorityISR;
|
||||
platform_irq_thread_id = osThreadNew(platformIrqWorker, NULL, &platform_irq_thread_attr);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len) {
|
||||
HAL_StatusTypeDef ret;
|
||||
@@ -14,18 +41,17 @@ HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t
|
||||
}
|
||||
|
||||
if(ret != HAL_OK) {
|
||||
exit(250);
|
||||
asm("bkpt 1");
|
||||
exit(255);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void platformProtectST25RComm()
|
||||
{
|
||||
void platformProtectST25RComm() {
|
||||
api_hal_spi_lock(&SPI_R);
|
||||
NFC_SPI_Reconfigure();
|
||||
}
|
||||
|
||||
void platformUnprotectST25RComm()
|
||||
{
|
||||
|
||||
void platformUnprotectST25RComm() {
|
||||
api_hal_spi_unlock(&SPI_R);
|
||||
}
|
||||
|
@@ -11,6 +11,9 @@
|
||||
#include "spi.h"
|
||||
#include "main.h"
|
||||
|
||||
typedef void (*PlatformIrqCallback)();
|
||||
void platformSetIrqCallback(PlatformIrqCallback cb);
|
||||
|
||||
HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len);
|
||||
void platformProtectST25RComm();
|
||||
void platformUnprotectST25RComm();
|
||||
@@ -21,8 +24,8 @@ void platformUnprotectST25RComm();
|
||||
#define ST25R_INT_PIN NFC_IRQ_Pin
|
||||
#define ST25R_INT_PORT NFC_IRQ_GPIO_Port
|
||||
|
||||
#define PLATFORM_LED_RX_PIN LED_GREEN_Pin
|
||||
#define PLATFORM_LED_RX_PORT LED_GREEN_GPIO_Port
|
||||
#define PLATFORM_LED_RX_PIN LED_RED_Pin
|
||||
#define PLATFORM_LED_RX_PORT LED_RED_GPIO_Port
|
||||
#define PLATFORM_LED_FIELD_PIN LED_BLUE_Pin
|
||||
#define PLATFORM_LED_FIELD_PORT LED_BLUE_GPIO_Port
|
||||
|
||||
@@ -52,6 +55,7 @@ void platformUnprotectST25RComm();
|
||||
#define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN 512U /*!< ISO-DEP APDU max length. */
|
||||
#define RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN 512U /*!< NFC-DEP PDU max length. */
|
||||
|
||||
#define platformIrqST25RSetCallback( cb ) platformSetIrqCallback(cb)
|
||||
|
||||
#define platformProtectST25RIrqStatus() platformProtectST25RComm() /*!< Protect unique access to IRQ status var - IRQ disable on single thread environment (MCU) ; Mutex lock on a multi thread environment */
|
||||
#define platformUnprotectST25RIrqStatus() platformUnprotectST25RComm() /*!< Unprotect the IRQ status var - IRQ enable on a single thread environment (MCU) ; Mutex unlock on a multi thread environment */
|
||||
@@ -72,7 +76,7 @@ void platformUnprotectST25RComm();
|
||||
#define platformGetSysTick() osKernelGetTickCount() /*!< Get System Tick (1 tick = 1 ms) */
|
||||
|
||||
#define platformAssert( exp ) assert_param( exp ) /*!< Asserts whether the given expression is true*/
|
||||
#define platformErrorHandle() Error_Handler() /*!< Global error handle\trap */
|
||||
// #define platformErrorHandle() Error_Handler() /*!< Global error handle\trap */
|
||||
|
||||
#define platformSpiSelect() platformGpioClear( ST25R_SS_PORT, ST25R_SS_PIN ) /*!< SPI SS\CS: Chip|Slave Select */
|
||||
#define platformSpiDeselect() platformGpioSet( ST25R_SS_PORT, ST25R_SS_PIN ) /*!< SPI SS\CS: Chip|Slave Deselect */
|
||||
|
Reference in New Issue
Block a user