mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-02 17:29:14 +00:00
c1e0d02afc
* nfc: st25tb: rework async poller * nfc: st25tb: introduce sync poller * nfc: st25tb: add write support * nfc: st25tb: rewrite poller to use better states * nfc: st25tb: move to mode request state after success * nfc: st25tb: minor bug fixes * type wasn't properly set on ready event * sending NfcCustomEventPollerFailure on St25tbPollerEventTypeFailure caused poller to being freed and ultimately resulted in a thread crash Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
77 lines
1.8 KiB
C
77 lines
1.8 KiB
C
#pragma once
|
|
|
|
#include "st25tb.h"
|
|
#include <lib/nfc/nfc.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct St25tbPoller St25tbPoller;
|
|
|
|
typedef enum {
|
|
St25tbPollerEventTypeReady,
|
|
St25tbPollerEventTypeRequestMode,
|
|
St25tbPollerEventTypeFailure,
|
|
St25tbPollerEventTypeSuccess,
|
|
} St25tbPollerEventType;
|
|
|
|
typedef struct {
|
|
St25tbType type;
|
|
} St25tbPollerReadyData;
|
|
|
|
typedef enum {
|
|
St25tbPollerModeRead,
|
|
St25tbPollerModeWrite,
|
|
|
|
St25tbPollerModeNum,
|
|
} St25tbPollerMode;
|
|
|
|
typedef struct {
|
|
uint8_t block_number;
|
|
uint32_t block_data;
|
|
} St25tbPollerEventDataModeRequestWriteParams;
|
|
|
|
typedef union {
|
|
St25tbPollerEventDataModeRequestWriteParams write_params;
|
|
} St25tbPollerEventDataModeRequestParams;
|
|
|
|
typedef struct {
|
|
St25tbPollerMode mode;
|
|
St25tbPollerEventDataModeRequestParams params;
|
|
} St25tbPollerEventDataModeRequest;
|
|
|
|
typedef union {
|
|
St25tbPollerReadyData ready;
|
|
St25tbPollerEventDataModeRequest mode_request;
|
|
St25tbError error;
|
|
} St25tbPollerEventData;
|
|
|
|
typedef struct {
|
|
St25tbPollerEventType type;
|
|
St25tbPollerEventData* data;
|
|
} St25tbPollerEvent;
|
|
|
|
St25tbError st25tb_poller_send_frame(
|
|
St25tbPoller* instance,
|
|
const BitBuffer* tx_buffer,
|
|
BitBuffer* rx_buffer,
|
|
uint32_t fwt);
|
|
|
|
St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id_ptr);
|
|
|
|
St25tbError st25tb_poller_select(St25tbPoller* instance, uint8_t* chip_id_ptr);
|
|
|
|
St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid);
|
|
|
|
St25tbError
|
|
st25tb_poller_read_block(St25tbPoller* instance, uint32_t* block, uint8_t block_number);
|
|
|
|
St25tbError
|
|
st25tb_poller_write_block(St25tbPoller* instance, uint32_t block, uint8_t block_number);
|
|
|
|
St25tbError st25tb_poller_halt(St25tbPoller* instance);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|