solo1/targets/stm32l432/src/nfc.h

67 wiersze
1.8 KiB
C
Czysty Zwykły widok Historia

2019-01-07 23:50:01 +00:00
#ifndef _NFC_H_
#define _NFC_H_
2019-01-08 00:40:20 +00:00
#include <stdint.h>
2019-01-27 21:35:20 +00:00
#include <stdbool.h>
2019-01-27 09:44:33 +00:00
#include "apdu.h"
2019-01-08 00:40:20 +00:00
// Return number of bytes read if any.
int nfc_loop(void);
int nfc_init(void);
2019-01-13 22:25:32 +00:00
typedef struct
2019-01-08 00:40:20 +00:00
{
2019-01-13 22:25:32 +00:00
uint8_t cclen_hi;
uint8_t cclen_lo;
uint8_t version;
uint8_t MLe_hi;
uint8_t MLe_lo;
uint8_t MLc_hi;
uint8_t MLc_lo;
uint8_t tlv[8];
} __attribute__((packed)) CAPABILITY_CONTAINER;
2019-01-13 01:20:47 +00:00
2019-02-01 18:45:36 +00:00
// WTX time in ms
#define WTX_TIME_DEFAULT 300
2019-01-13 05:02:37 +00:00
#define NFC_CMD_REQA 0x26
#define NFC_CMD_WUPA 0x52
#define NFC_CMD_HLTA 0x50
#define NFC_CMD_RATS 0xe0
#define NFC_CMD_PPSS 0xd0
#define IS_PPSS_CMD(x) (((x) & 0xf0) == NFC_CMD_PPSS)
2019-01-24 15:57:42 +00:00
#define NFC_CMD_IBLOCK 0x00
#define IS_IBLOCK(x) ( (((x) & 0xc0) == NFC_CMD_IBLOCK) && (((x) & 0x02) == 0x02) )
#define NFC_CMD_RBLOCK 0xa0
#define NFC_CMD_RBLOCK_ACK 0x10
#define IS_RBLOCK(x) ( (((x) & 0xe0) == NFC_CMD_RBLOCK) && (((x) & 0x02) == 0x02) )
2019-01-24 15:57:42 +00:00
#define NFC_CMD_SBLOCK 0xc0
#define IS_SBLOCK(x) ( (((x) & 0xc0) == NFC_CMD_SBLOCK) && (((x) & 0x02) == 0x02) )
2019-01-13 22:25:32 +00:00
2019-07-04 14:38:34 +00:00
extern uint8_t p14443_block_offset(uint8_t pcb);
2019-01-28 04:55:11 +00:00
#define NFC_SBLOCK_DESELECT 0x30
#define NFC_SBLOCK_WTX 0x30
2019-01-13 22:25:32 +00:00
#define AID_NDEF_TYPE_4 "\xD2\x76\x00\x00\x85\x01\x01"
#define AID_NDEF_MIFARE_TYPE_4 "\xD2\x76\x00\x00\x85\x01\x00"
#define AID_CAPABILITY_CONTAINER "\xE1\x03"
#define AID_NDEF_TAG "\xE1\x04"
2019-01-24 15:57:42 +00:00
#define AID_FIDO "\xa0\x00\x00\x06\x47\x2f\x00\x01"
2019-01-13 22:25:32 +00:00
typedef enum
{
2019-01-28 04:55:11 +00:00
APP_NOTHING = 0,
2019-01-13 22:25:32 +00:00
APP_NDEF_TYPE_4 = 1,
APP_MIFARE_TYPE_4,
APP_CAPABILITY_CONTAINER,
APP_NDEF_TAG,
2019-01-24 15:57:42 +00:00
APP_FIDO,
2019-01-13 22:25:32 +00:00
} APPLETS;
void WTX_timer_exec(void);
2019-01-07 23:50:01 +00:00
#endif