mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Remove tabs & spaces at end of lines
This commit is contained in:
@@ -432,7 +432,7 @@ flash_stlink:
|
||||
|
||||
erase:
|
||||
nrfjprog -f nrf52 --eraseall
|
||||
|
||||
|
||||
# Erase with ST-Link
|
||||
erase_stlink:
|
||||
openocd -f interface/stlink.cfg -f target/nrf52.cfg -c "flash init; init; reset halt; flash erase_sector 0 1 last; exit"
|
||||
|
||||
@@ -64,9 +64,9 @@ data_frame_tx_t* cmd_processor_get_device_mode(uint16_t cmd, uint16_t status, ui
|
||||
|
||||
data_frame_tx_t* cmd_processor_enter_bootloader(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
// restart to boot
|
||||
#define BOOTLOADER_DFU_GPREGRET_MASK (0xB0)
|
||||
#define BOOTLOADER_DFU_START_BIT_MASK (0x01)
|
||||
#define BOOTLOADER_DFU_START (BOOTLOADER_DFU_GPREGRET_MASK | BOOTLOADER_DFU_START_BIT_MASK)
|
||||
#define BOOTLOADER_DFU_GPREGRET_MASK (0xB0)
|
||||
#define BOOTLOADER_DFU_START_BIT_MASK (0x01)
|
||||
#define BOOTLOADER_DFU_START (BOOTLOADER_DFU_GPREGRET_MASK | BOOTLOADER_DFU_START_BIT_MASK)
|
||||
APP_ERROR_CHECK(sd_power_gpregret_clr(0,0xffffffff));
|
||||
APP_ERROR_CHECK(sd_power_gpregret_set(0, BOOTLOADER_DFU_START));
|
||||
nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);
|
||||
@@ -105,7 +105,7 @@ data_frame_tx_t* cmd_processor_set_animation_mode(uint16_t cmd, uint16_t status,
|
||||
settings_set_animation_config(data[0]);
|
||||
}
|
||||
else {
|
||||
status = STATUS_PAR_ERR;
|
||||
status = STATUS_PAR_ERR;
|
||||
}
|
||||
return data_frame_make(cmd, status, 0, NULL);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ data_frame_tx_t* cmd_processor_get_button_press_config(uint16_t cmd, uint16_t st
|
||||
status = STATUS_DEVICE_SUCCESS;
|
||||
} else {
|
||||
length = 0;
|
||||
status = STATUS_PAR_ERR;
|
||||
status = STATUS_PAR_ERR;
|
||||
}
|
||||
return data_frame_make(cmd, status, length, (uint8_t *)(&button_press_config));
|
||||
}
|
||||
@@ -142,7 +142,7 @@ data_frame_tx_t* cmd_processor_set_button_press_config(uint16_t cmd, uint16_t st
|
||||
status = STATUS_DEVICE_SUCCESS;
|
||||
} else {
|
||||
length = 0;
|
||||
status = STATUS_PAR_ERR;
|
||||
status = STATUS_PAR_ERR;
|
||||
}
|
||||
return data_frame_make(cmd, status, 0, NULL);
|
||||
}
|
||||
@@ -569,11 +569,11 @@ data_frame_tx_t* cmd_processor_set_slot_tag_nick_name(uint16_t cmd, uint16_t sta
|
||||
fds_slot_record_map_t map_info;
|
||||
|
||||
get_fds_map_by_slot_sense_type_for_nick(slot, sense_type, &map_info);
|
||||
|
||||
|
||||
uint8_t buffer[36];
|
||||
buffer[0] = length - 2;
|
||||
memcpy(buffer + 1, data + 2, buffer[0]);
|
||||
|
||||
|
||||
bool ret = fds_write_sync(map_info.id, map_info.key, sizeof(buffer) / 4, buffer);
|
||||
if (ret) {
|
||||
status = STATUS_DEVICE_SUCCESS;
|
||||
@@ -818,7 +818,7 @@ static cmd_data_map_t m_data_cmd_map[] = {
|
||||
{ DATA_CMD_GET_ENABLED_SLOTS, NULL, cmd_processor_get_enabled_slots, NULL },
|
||||
{ DATA_CMD_DELETE_SLOT_SENSE_TYPE, NULL, cmd_processor_delete_slot_sense_type, NULL },
|
||||
|
||||
|
||||
|
||||
|
||||
{ DATA_CMD_SET_EM410X_EMU_ID, NULL, cmd_processor_set_em410x_emu_id, NULL },
|
||||
{ DATA_CMD_GET_EM410X_EMU_ID, NULL, cmd_processor_get_em410x_emu_id, NULL },
|
||||
@@ -846,12 +846,12 @@ static cmd_data_map_t m_data_cmd_map[] = {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Auto select source to response
|
||||
*
|
||||
* @brief Auto select source to response
|
||||
*
|
||||
* @param resp data
|
||||
*/
|
||||
void auto_response_data(data_frame_tx_t* resp) {
|
||||
// TODO Please select the reply source automatically according to the message source,
|
||||
// TODO Please select the reply source automatically according to the message source,
|
||||
// and do not reply by checking the validity of the link layer by layer
|
||||
if (is_usb_working()) {
|
||||
usb_cdc_write(resp->buffer, resp->length);
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
#define APP_FW_VER_MINOR 0
|
||||
|
||||
// Merge major and minor version code to U16 value.
|
||||
#define FW_VER_NUM VER_CODE_TO_NUM(APP_FW_VER_MAJOR, APP_FW_VER_MINOR)
|
||||
#define FW_VER_NUM VER_CODE_TO_NUM(APP_FW_VER_MAJOR, APP_FW_VER_MINOR)
|
||||
|
||||
@@ -277,7 +277,7 @@ static void system_off_enter(void) {
|
||||
|
||||
// IOs that need to be configured as push-pull outputs and pulled low
|
||||
uint32_t gpio_cfg_output_low[] = {
|
||||
LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LF_MOD,
|
||||
LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8, LF_MOD,
|
||||
#if defined(PROJECT_CHAMELEON_ULTRA)
|
||||
READER_POWER, LF_ANT_DRIVER
|
||||
#endif
|
||||
@@ -350,7 +350,7 @@ static void check_wakeup_src(void) {
|
||||
uint8_t slot = tag_emulation_get_slot();
|
||||
uint8_t dir = slot > 3 ? 1 : 0;
|
||||
uint8_t color = get_color_by_slot(slot);
|
||||
|
||||
|
||||
if (m_reset_source & NRF_POWER_RESETREAS_OFF_MASK) {
|
||||
NRF_LOG_INFO("WakeUp from button");
|
||||
advertising_start(); // Turn on Bluetooth radio
|
||||
@@ -406,7 +406,7 @@ static void check_wakeup_src(void) {
|
||||
} else if (m_reset_source & NRF_POWER_RESETREAS_VBUS_MASK) {
|
||||
// nrfx_power_usbstatus_get() can check usb attach status
|
||||
NRF_LOG_INFO("WakeUp from VBUS(USB)");
|
||||
|
||||
|
||||
// USB plugged in and open communication break has its own light effect, no need to light up for the time being
|
||||
// set_slot_light_color(color);
|
||||
// light_up_by_slot();
|
||||
@@ -711,7 +711,7 @@ int main(void) {
|
||||
|
||||
// cmd callback register
|
||||
on_data_frame_complete(on_data_frame_received);
|
||||
|
||||
|
||||
check_wakeup_src(); // Detect wake-up source and decide BLE broadcast and subsequent hibernation action according to the wake-up source
|
||||
tag_mode_enter(); // Enter card simulation mode by default
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ uint32_t BATVOL2PERCENT(uint16_t VOL)
|
||||
//#define P40VOL 3790
|
||||
//#define P20VOL 3740
|
||||
//#define P5VOL 3450
|
||||
|
||||
|
||||
//100% 4.20V 1
|
||||
//90 % 4.00V 80%-100% 白
|
||||
//80 % 3.89V 1
|
||||
@@ -236,7 +236,7 @@ uint32_t BATVOL2PERCENT(uint16_t VOL)
|
||||
#define P40VOL 3570
|
||||
#define P20VOL 3510
|
||||
#define P5VOL 3230
|
||||
|
||||
|
||||
|
||||
if(VOL > P80VOL)
|
||||
{
|
||||
@@ -402,7 +402,7 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
|
||||
{
|
||||
case BLE_GAP_EVT_CONNECTED:
|
||||
sleep_timer_stop();
|
||||
|
||||
|
||||
NRF_LOG_INFO("Connected");
|
||||
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
|
||||
err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
//初始化延迟函数
|
||||
void bsp_delay_init(void)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
//延时nms
|
||||
@@ -13,11 +13,11 @@ void bsp_delay_init(void)
|
||||
void bsp_delay_ms(uint16_t nms)
|
||||
{
|
||||
nrf_delay_us(nms * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
//延时nus
|
||||
//nus为要延时的us数.
|
||||
//nus为要延时的us数.
|
||||
void bsp_delay_us(uint32_t nus)
|
||||
{
|
||||
{
|
||||
nrf_delay_us(nus);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ void bsp_timer_start(void) {
|
||||
bsp_timer_state = START;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 停止定时器
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
// CMD for hf reader
|
||||
// Range from 2000 -> 2999
|
||||
// ******************************************************************
|
||||
//
|
||||
//
|
||||
#define DATA_CMD_SCAN_14A_TAG (2000)
|
||||
#define DATA_CMD_MF1_SUPPORT_DETECT (2001)
|
||||
#define DATA_CMD_MF1_NT_LEVEL_DETECT (2002)
|
||||
@@ -61,7 +61,7 @@
|
||||
// CMD for lf reader
|
||||
// Range from 3000 -> 3999
|
||||
// ******************************************************************
|
||||
//
|
||||
//
|
||||
#define DATA_CMD_SCAN_EM410X_TAG (3000)
|
||||
#define DATA_CMD_WRITE_EM410X_TO_T5577 (3001)
|
||||
//
|
||||
@@ -72,7 +72,7 @@
|
||||
// CMD for hf emulator
|
||||
// Range from 4000 -> 4999
|
||||
// ******************************************************************
|
||||
//
|
||||
//
|
||||
#define DATA_CMD_LOAD_MF1_EMU_BLOCK_DATA (4000)
|
||||
#define DATA_CMD_SET_MF1_ANTI_COLLISION_RES (4001)
|
||||
#define DATA_CMD_SET_MF1_ANTICOLLISION_INFO (4002)
|
||||
@@ -99,7 +99,7 @@
|
||||
// CMD for lf emulator
|
||||
// Range from 5000 -> 5999
|
||||
// ******************************************************************
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// ******************************************************************
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @param :len : 存放转换后的数值的字节长度
|
||||
* @param :dest : 存放转换结果的缓冲区
|
||||
* @retval : 无
|
||||
*
|
||||
*
|
||||
*/
|
||||
void num_to_bytes(uint64_t n, uint8_t len, uint8_t* dest)
|
||||
{
|
||||
|
||||
@@ -147,7 +147,7 @@ uint32_t crypto1_word(struct Crypto1State *s, uint32_t in, int is_encrypted) {
|
||||
uint32_t prng_successor(uint32_t x, uint32_t n) {
|
||||
// SWAPENDIAN(x);
|
||||
x = __REV(x);
|
||||
|
||||
|
||||
while (n--)
|
||||
x = x >> 1 | (x >> 16 ^ x >> 18 ^ x >> 19 ^ x >> 21) << 31;
|
||||
|
||||
|
||||
@@ -1051,7 +1051,7 @@ void Crypto1ByteArrayWithParityHasIn(uint8_t *Buffer, uint8_t *Parity, uint8_t C
|
||||
|
||||
while (Count--) {
|
||||
uint8_t In = *Buffer;
|
||||
|
||||
|
||||
/* Bit 0, initialise keystream from parity */
|
||||
SHIFT8(KeyStream, Out);
|
||||
Feedback = Crypto1LFSRbyteFeedback(Even0, Even1, Even2, Odd0, Odd1, Odd2) ^ In;
|
||||
@@ -1190,7 +1190,7 @@ void Crypto1PRNG(uint8_t State[4], uint8_t ClockCount) {
|
||||
*/
|
||||
uint32_t Crypto1FreePRNG(uint32_t x, uint32_t n) {
|
||||
x = __builtin_bswap32(x);
|
||||
|
||||
|
||||
while (n--)
|
||||
x = x >> 1 | (x >> 16 ^ x >> 18 ^ x >> 19 ^ x >> 21) << 31;
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ NRF_LOG_MODULE_REGISTER();
|
||||
|
||||
|
||||
#if NFC_TAG_14A_RX_PARITY_AUTO_DEL_ENABLE
|
||||
#define NRF_NFCT_PARITY_FRAMECONFIG 0x05;
|
||||
#else
|
||||
#define NRF_NFCT_PARITY_FRAMECONFIG 0x04;
|
||||
#define NRF_NFCT_PARITY_FRAMECONFIG 0x05;
|
||||
#else
|
||||
#define NRF_NFCT_PARITY_FRAMECONFIG 0x04;
|
||||
#endif
|
||||
|
||||
// 使用宏定义展开数据的接收使能实现
|
||||
@@ -34,7 +34,7 @@ NRF_LOG_MODULE_REGISTER();
|
||||
NRF_NFCT_INT_RXERROR_MASK); \
|
||||
NRF_NFCT->TASKS_ENABLERXDATA = 1; \
|
||||
} while(0);
|
||||
|
||||
|
||||
|
||||
// 14443a协议状态机
|
||||
nfc_tag_14a_state_t m_tag_state_14a = NFC_TAG_STATE_14A_IDLE;
|
||||
@@ -48,37 +48,37 @@ nfc_tag_14a_handler_t m_tag_handler = {
|
||||
|
||||
// 字节镜像
|
||||
const uint8_t ByteMirror[256] = {
|
||||
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
|
||||
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
|
||||
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
|
||||
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
|
||||
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
|
||||
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
|
||||
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
|
||||
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
|
||||
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
|
||||
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
|
||||
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
|
||||
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
|
||||
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
|
||||
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
|
||||
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
|
||||
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
|
||||
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
|
||||
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
|
||||
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
|
||||
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
|
||||
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
|
||||
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
|
||||
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
|
||||
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
|
||||
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
|
||||
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
|
||||
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
|
||||
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
|
||||
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
|
||||
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
|
||||
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
|
||||
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
|
||||
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
|
||||
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
|
||||
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
|
||||
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
|
||||
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
|
||||
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
|
||||
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
|
||||
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
|
||||
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
|
||||
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
|
||||
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
|
||||
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
|
||||
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
|
||||
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
|
||||
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
|
||||
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
|
||||
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
|
||||
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
|
||||
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
|
||||
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
|
||||
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
|
||||
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
|
||||
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
|
||||
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
|
||||
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
|
||||
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
|
||||
};
|
||||
|
||||
@@ -329,7 +329,7 @@ void nfc_tag_14a_tx_bytes_delay_freerun(uint8_t *data, uint32_t bytes, bool appe
|
||||
* @param[in] data 要发送的bit流数据
|
||||
* @param[in] bits 要发送的bit流的长度
|
||||
*/
|
||||
void nfc_tag_14a_tx_bits(uint8_t *data, uint32_t bits) {
|
||||
void nfc_tag_14a_tx_bits(uint8_t *data, uint32_t bits) {
|
||||
m_is_responded = true;
|
||||
memcpy(m_nfc_tx_buffer, data, (bits / 8) + (bits % 8 > 0 ? 1 : 0));
|
||||
NFC_14A_TX_BITS_CORE(bits, NRF_NFCT_FRAME_DELAY_MODE_FREERUN);
|
||||
@@ -386,7 +386,7 @@ void nfc_tag_14a_data_process(uint8_t *p_data)
|
||||
szDataBits = nfc_tag_14a_unwrap_frame(p_data, szDataBits, p_data, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// 开始处理接收到的数据,如果是比特帧可以将数据交由此环节处理
|
||||
if (szDataBits <= 8) {
|
||||
// 我们可能收到了一个wupa或者reqa指令,或者其他的特殊指令
|
||||
@@ -427,7 +427,7 @@ void nfc_tag_14a_data_process(uint8_t *p_data)
|
||||
// 根据当前卡片的状态做出相应的处理
|
||||
switch (m_tag_state_14a) {
|
||||
// 空闲状态和休眠状态不处理任何任务,就让来自星星的消息随风而去吧~
|
||||
case NFC_TAG_STATE_14A_IDLE:
|
||||
case NFC_TAG_STATE_14A_IDLE:
|
||||
case NFC_TAG_STATE_14A_HALTED: {
|
||||
break;
|
||||
}
|
||||
@@ -595,9 +595,9 @@ void nfc_tag_14a_event_callback(nrfx_nfct_evt_t const *p_event) {
|
||||
|
||||
set_slot_light_color(1);
|
||||
TAG_FIELD_LED_ON()
|
||||
|
||||
|
||||
NRF_LOG_INFO("HF FIELD DETECTED");
|
||||
|
||||
|
||||
// 关闭自动防冲撞,MCU管理所有的交互过程,然后使能NFC外设,使能之后就可以进行IO了
|
||||
// 20221108 修复nrf52840与nrf52832不同的使能切换流程
|
||||
#if defined(NRF52833_XXAA) || defined(NRF52840_XXAA)
|
||||
@@ -616,7 +616,7 @@ void nfc_tag_14a_event_callback(nrfx_nfct_evt_t const *p_event) {
|
||||
g_is_tag_emulating = false;
|
||||
// call sleep_timer_start *after* unsetting g_is_tag_emulating
|
||||
sleep_timer_start(SLEEP_DELAY_MS_FIELD_NFC_LOST);
|
||||
|
||||
|
||||
TAG_FIELD_LED_OFF()
|
||||
m_tag_state_14a = NFC_TAG_STATE_14A_IDLE;
|
||||
|
||||
@@ -637,7 +637,7 @@ void nfc_tag_14a_event_callback(nrfx_nfct_evt_t const *p_event) {
|
||||
case NRFX_NFCT_EVT_RX_FRAMEEND: {
|
||||
set_slot_light_color(1);
|
||||
TAG_FIELD_LED_ON()
|
||||
|
||||
|
||||
// NRF_LOG_INFO("RX FRAMEEND.\n");
|
||||
// TODO 谨记一个BUG,在收到消息后如果不回复消息,就需要手动使能接收
|
||||
// 不然上面的 NRFX_NFCT_EVT_TX_FRAMEEND 条件不会触发,不会调用 NRFX_NFCT_RX_BYTES
|
||||
@@ -732,7 +732,7 @@ void nfc_tag_14a_sense_switch(bool enable) {
|
||||
}
|
||||
|
||||
bool is_valid_uid_size(uint8_t uid_length) {
|
||||
return uid_length == NFC_TAG_14A_UID_SINGLE_SIZE ||
|
||||
uid_length == NFC_TAG_14A_UID_DOUBLE_SIZE ||
|
||||
return uid_length == NFC_TAG_14A_UID_SINGLE_SIZE ||
|
||||
uid_length == NFC_TAG_14A_UID_DOUBLE_SIZE ||
|
||||
uid_length == NFC_TAG_14A_UID_TRIPLE_SIZE;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ void ValueToBlock(uint8_t *Block, uint32_t Value) {
|
||||
* @param nonce 随机数的Buffer
|
||||
*/
|
||||
void nfc_tag_mf1_random_nonce(uint8_t nonce[4], bool isNested) {
|
||||
// 使用rand进行快速产生随机数,性能损耗较小
|
||||
// 使用rand进行快速产生随机数,性能损耗较小
|
||||
// isNested provides more randomness for hardnested attack
|
||||
if (isNested) {
|
||||
nonce[0] = rand() & 0xff;
|
||||
@@ -323,7 +323,7 @@ void nfc_tag_mf1_random_nonce(uint8_t nonce[4], bool isNested) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief mf1追加验证日志,步骤一,存放基础信息
|
||||
* @param isKeyB: 是否是在验证秘钥B
|
||||
* @param isNested: 是否是在进行嵌套验证
|
||||
@@ -476,7 +476,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
uint8_t CardNonce[4];
|
||||
uint8_t BlockStart;
|
||||
uint8_t BlockEnd;
|
||||
|
||||
|
||||
// 获得访问的块对应扇区的起始块,谨记:4K卡有大扇区,以16个block为一个扇区单位
|
||||
// 计算思路:x = (y / n) * n,x = 扇区的起始块,y = 验证的块, n = y所在的扇区内的块的数量
|
||||
// 思路解析:先做除法获取当前所在扇区,然后再做乘法获取所在扇区的块数量
|
||||
@@ -488,7 +488,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
BlockStart = (BlockAuth / 4) * 4;
|
||||
BlockEnd = BlockStart + 4 - 1;
|
||||
}
|
||||
|
||||
|
||||
// 当前模拟卡的类型,不足以支撑起读卡器的访问
|
||||
if (check_block_max_overflow(BlockAuth)) {
|
||||
break;
|
||||
@@ -496,7 +496,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
|
||||
// 将KeyInUse设置为全局使用,以保留有关身份验证的信息
|
||||
KeyInUse = p_data[0] & 1;
|
||||
|
||||
|
||||
// 获得指定的扇区访问控制字节,此处我们直接取巧,将内存转为结构体,让编译器帮我们维护指针的指向
|
||||
m_tag_trailer_info = (nfc_tag_mf1_trailer_info_t*)m_tag_information->memory[BlockEnd];
|
||||
|
||||
@@ -525,10 +525,10 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
|
||||
// 记录验证日志
|
||||
append_mf1_auth_log_step1(KeyInUse, false, BlockAuth, CardNonce);
|
||||
|
||||
|
||||
// 使用随机卡随机数进行响应,并期望在下一帧中从读取器获得进一步的身份验证。
|
||||
m_mf1_state = MF1_STATE_AUTHING;
|
||||
|
||||
|
||||
// 首次验证,回应一个明文的随机数,不带CRC
|
||||
m_tag_tx_buffer.tx_raw_buffer[0] = CardNonce[0];
|
||||
m_tag_tx_buffer.tx_raw_buffer[1] = CardNonce[1];
|
||||
@@ -540,7 +540,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
// 根据当前的指令类型选择验证A或者B秘钥
|
||||
KeyInUse ? m_tag_trailer_info->keyb : m_tag_trailer_info->keya,
|
||||
// 传入当前使用的防冲撞的UID
|
||||
UID_BY_CASCADE_LEVEL,
|
||||
UID_BY_CASCADE_LEVEL,
|
||||
// 传入一个明文的随机数,这个随机数将会被用于解密后续的通信
|
||||
CardNonce
|
||||
);
|
||||
@@ -548,7 +548,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
// 设置crypto1密钥流,丢弃之前的加密状态
|
||||
crypto1_deinit(pcs);
|
||||
// 加载密钥流
|
||||
crypto1_init(pcs,
|
||||
crypto1_init(pcs,
|
||||
// 根据当前的指令类型选择验证A或者B秘钥
|
||||
bytes_to_num(KeyInUse ? m_tag_trailer_info->keyb : m_tag_trailer_info->keya, 6)
|
||||
);
|
||||
@@ -615,7 +615,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
nfc_tag_14a_set_state(NFC_TAG_STATE_14A_IDLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case MF1_STATE_AUTHING: {
|
||||
@@ -666,7 +666,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case MF1_STATE_AUTHED: {
|
||||
if (szDataBits == 32) {
|
||||
// 在这种状态下,所有通信都被加密。因此,我们首先必须解密读头发送过来的数据。
|
||||
@@ -805,7 +805,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
uint8_t CardNonce[4];
|
||||
uint8_t BlockStart;
|
||||
uint8_t BlockEnd;
|
||||
|
||||
|
||||
// 获得访问的块对应扇区的起始块,谨记:4K卡有大扇区,以16个block为一个扇区单位
|
||||
// 计算思路:x = (y / n) * n,x = 扇区的起始块,y = 验证的块, n = y所在的扇区内的块的数量
|
||||
// 思路解析:先做除法获取当前所在扇区,然后再做乘法获取所在扇区的块数量
|
||||
@@ -817,7 +817,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
BlockStart = (BlockAuth / 4) * 4;
|
||||
BlockEnd = BlockStart + 4 - 1;
|
||||
}
|
||||
|
||||
|
||||
// 当前模拟卡的类型,不足以支撑起读卡器的访问
|
||||
if (check_block_max_overflow(BlockAuth)) {
|
||||
break;
|
||||
@@ -825,13 +825,13 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
|
||||
// 将KeyInUse设置为全局使用,以保留有关身份验证的信息
|
||||
KeyInUse = p_data[0] & 1;
|
||||
|
||||
|
||||
// 获得指定的扇区访问控制字节,此处我们直接取巧,将内存转为结构体,让编译器帮我们维护指针的指向
|
||||
m_tag_trailer_info = (nfc_tag_mf1_trailer_info_t*)m_tag_information->memory[BlockEnd];
|
||||
|
||||
|
||||
// 生成随机数
|
||||
nfc_tag_mf1_random_nonce(CardNonce, true);
|
||||
|
||||
|
||||
// 根据卡随机数预先计算读卡器响应
|
||||
for (uint8_t i = 0; i < sizeof(ReaderResponse); i++) {
|
||||
ReaderResponse[i] = CardNonce[i];
|
||||
@@ -851,13 +851,13 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
#else
|
||||
mf1_prng_by_bytes(CardResponse, 32);
|
||||
#endif
|
||||
|
||||
|
||||
// 记录嵌套验证信息
|
||||
append_mf1_auth_log_step1(KeyInUse, true, BlockAuth, CardNonce);
|
||||
|
||||
|
||||
// 使用随机卡随机数进行响应,并期望在下一帧中从读取器获得进一步的身份验证。
|
||||
m_mf1_state = MF1_STATE_AUTHING;
|
||||
|
||||
|
||||
// 复制一份标签的随机数到缓冲区中
|
||||
m_tag_tx_buffer.tx_raw_buffer[0] = CardNonce[0];
|
||||
m_tag_tx_buffer.tx_raw_buffer[1] = CardNonce[1];
|
||||
@@ -868,9 +868,9 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
/* Setup crypto1 cipher. Discard in-place encrypted CardNonce. */
|
||||
Crypto1SetupNested(
|
||||
// 根据当前的指令类型选择验证A或者B秘钥
|
||||
KeyInUse ? m_tag_trailer_info->keyb : m_tag_trailer_info->keya,
|
||||
KeyInUse ? m_tag_trailer_info->keyb : m_tag_trailer_info->keya,
|
||||
// 传入当前使用的防冲撞的UID
|
||||
UID_BY_CASCADE_LEVEL,
|
||||
UID_BY_CASCADE_LEVEL,
|
||||
// 传入一个明文的随机数,这个随机数将被加密并通过此缓冲区传出
|
||||
m_tag_tx_buffer.tx_raw_buffer,
|
||||
// 传入一个保存随机数的奇偶校验位的缓冲区
|
||||
@@ -883,7 +883,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
// 设置crypto1密钥流,丢弃之前的加密状态
|
||||
crypto1_deinit(pcs);
|
||||
// 加载密钥流
|
||||
crypto1_init(pcs,
|
||||
crypto1_init(pcs,
|
||||
// 根据当前的指令类型选择验证A或者B秘钥
|
||||
bytes_to_num(KeyInUse ? m_tag_trailer_info->keyb : m_tag_trailer_info->keya, 6)
|
||||
);
|
||||
@@ -939,7 +939,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case MF1_STATE_WRITE: {
|
||||
uint8_t status;
|
||||
// 当前处于写入状态机,我们需要确保接收到的数据是足够的长度的
|
||||
@@ -979,7 +979,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case MF1_STATE_DECREMENT:
|
||||
case MF1_STATE_INCREMENT:
|
||||
case MF1_STATE_RESTORE: {
|
||||
@@ -1036,7 +1036,7 @@ void nfc_tag_mf1_state_handler(uint8_t* p_data, uint16_t szDataBits) {
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default: {
|
||||
// 未知状态?这永远不会发生,除非开发者脑子有问题!
|
||||
NRF_LOG_INFO("Unknown MF1 State");
|
||||
@@ -1053,7 +1053,7 @@ nfc_tag_14a_coll_res_referen_t* get_mifare_coll_res() {
|
||||
if (m_tag_information->config.use_mf1_coll_res && m_tag_information->res_coll.size == NFC_TAG_14A_UID_SINGLE_SIZE) {
|
||||
// 获得数据区域的厂商信息
|
||||
nfc_tag_mf1_factory_info_t* block0_factory_info = (nfc_tag_mf1_factory_info_t*)m_tag_information->memory[0];
|
||||
m_shadow_coll_res.sak = block0_factory_info->sak; // 替换sak
|
||||
m_shadow_coll_res.sak = block0_factory_info->sak; // 替换sak
|
||||
m_shadow_coll_res.atqa = block0_factory_info->atqa; // 替换atqa
|
||||
m_shadow_coll_res.uid = block0_factory_info->uid; // 替换uid
|
||||
m_shadow_coll_res.size = &(m_tag_information->res_coll.size); // 复用类型
|
||||
@@ -1079,7 +1079,7 @@ void nfc_tag_mf1_reset_handler() {
|
||||
|
||||
#ifndef NFC_MF1_FAST_SIM
|
||||
// Must to reset pcs handler
|
||||
crypto1_deinit(pcs);
|
||||
crypto1_deinit(pcs);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1127,7 +1127,7 @@ int nfc_tag_mf1_data_loadcb(tag_specific_type_t type, tag_data_buffer_t* buffer)
|
||||
// 注册14a通信管理接口
|
||||
nfc_tag_14a_handler_t handler_for_14a = {
|
||||
.get_coll_res = get_mifare_coll_res,
|
||||
.cb_state = nfc_tag_mf1_state_handler,
|
||||
.cb_state = nfc_tag_mf1_state_handler,
|
||||
.cb_reset = nfc_tag_mf1_reset_handler,
|
||||
};
|
||||
nfc_tag_14a_set_handler(&handler_for_14a);
|
||||
@@ -1144,7 +1144,7 @@ bool nfc_tag_mf1_data_factory(uint8_t slot, tag_specific_type_t tag_type) {
|
||||
uint8_t default_blk0[] = { 0xDE, 0xAD, 0xBE, 0xFF, 0x32, 0x08, 0x04, 0x00, 0x01, 0x77, 0xA2, 0xCC, 0x35, 0xAF, 0xA5, 0x1D };
|
||||
uint8_t default_data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
uint8_t default_trail[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x69, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
|
||||
// default mf1 info
|
||||
nfc_tag_mf1_information_t mf1_tmp_information;
|
||||
nfc_tag_mf1_information_t *p_mf1_information;
|
||||
@@ -1159,8 +1159,8 @@ bool nfc_tag_mf1_data_factory(uint8_t slot, tag_specific_type_t tag_type) {
|
||||
memcpy(p_mf1_information->memory[block], default_data, sizeof(default_data));
|
||||
}
|
||||
}
|
||||
|
||||
// default mf1 auto ant-collision res
|
||||
|
||||
// default mf1 auto ant-collision res
|
||||
p_mf1_information->res_coll.atqa[0] = 0x04;
|
||||
p_mf1_information->res_coll.atqa[1] = 0x00;
|
||||
p_mf1_information->res_coll.sak[0] = 0x08;
|
||||
@@ -1170,14 +1170,14 @@ bool nfc_tag_mf1_data_factory(uint8_t slot, tag_specific_type_t tag_type) {
|
||||
p_mf1_information->res_coll.uid[3] = 0xFF;
|
||||
p_mf1_information->res_coll.size = NFC_TAG_14A_UID_SINGLE_SIZE;
|
||||
p_mf1_information->res_coll.ats.length = 0;
|
||||
|
||||
|
||||
// default mf1 config
|
||||
p_mf1_information->config.mode_gen1a_magic = false;
|
||||
p_mf1_information->config.mode_gen2_magic = false;
|
||||
p_mf1_information->config.use_mf1_coll_res = false;
|
||||
p_mf1_information->config.mode_block_write = NFC_TAG_MF1_WRITE_NORMAL;
|
||||
p_mf1_information->config.detection_enable = false;
|
||||
|
||||
|
||||
// save data to flash
|
||||
tag_sense_type_t sense_type = get_sense_type_from_tag_type(tag_type);
|
||||
fds_slot_record_map_t map_info;
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef enum {
|
||||
MF1_STATE_UNAUTH,
|
||||
MF1_STATE_AUTHING,
|
||||
MF1_STATE_AUTHED,
|
||||
|
||||
|
||||
// 操作状态机
|
||||
MF1_STATE_WRITE,
|
||||
MF1_STATE_INCREMENT,
|
||||
|
||||
@@ -23,7 +23,7 @@ NRF_LOG_MODULE_REGISTER();
|
||||
* 如果检索到的卡槽的配置拥有指定的类型的卡片,那么应当进行指定类型的数据的加载,初始化必要的参数
|
||||
* 检测到场入场出时,除了需要对相关的LED进行操作外,还需要根据当前数据是否加载来开始模拟卡
|
||||
* 在模拟卡,所有的操作应当都是基于RAM中加载的数据进行,在模拟卡结束后,应当将修改的数据进行保存更新到flash
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* ......
|
||||
@@ -293,7 +293,7 @@ void tag_emulation_save_data(void) {
|
||||
|
||||
/**
|
||||
* @brief 获取模拟卡的标签类型,从对应卡槽中。
|
||||
*
|
||||
*
|
||||
* @param slot 卡槽
|
||||
* @param tag_type 标签类型
|
||||
*/
|
||||
@@ -522,7 +522,7 @@ uint8_t tag_emulation_slot_find_prev(uint8_t slot_now) {
|
||||
if (i == slot_now) return slot_now; // 一次轮回之后没有发现其他被激活的卡槽
|
||||
if (slotConfig.group[i].enable) return i; // 查看当前遍历的卡槽是否使能,使能则认定当前卡槽为有效使能的卡槽
|
||||
if (i - 1 < 0) { // 继续下一个轮回
|
||||
i = (TAG_MAX_SLOT_NUM - 1);
|
||||
i = (TAG_MAX_SLOT_NUM - 1);
|
||||
} else {
|
||||
i -= 1;
|
||||
}
|
||||
@@ -570,7 +570,7 @@ void tag_emulation_factory_init(void) {
|
||||
bool is_slot1_lf_data_exists = fds_is_exists(map_info.id, map_info.key);
|
||||
// 此处判断卡槽1的高频卡和低频卡都不存在
|
||||
if (!is_slot1_hf_data_exists && !is_slot1_lf_data_exists) {
|
||||
tag_emulation_factory_data(0, slotConfig.group[0].tag_hf);
|
||||
tag_emulation_factory_data(0, slotConfig.group[0].tag_hf);
|
||||
tag_emulation_factory_data(0, slotConfig.group[0].tag_lf);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -53,16 +53,16 @@ uint8_t Darkside_Recover_Key(
|
||||
DarksideCore* dc
|
||||
);
|
||||
uint8_t Nested_Distacne_Detect(
|
||||
uint8_t block,
|
||||
uint8_t type,
|
||||
uint8_t *key,
|
||||
uint8_t block,
|
||||
uint8_t type,
|
||||
uint8_t *key,
|
||||
NestedDist *nd
|
||||
);
|
||||
uint8_t Nested_Recover_Key(
|
||||
uint64_t keyKnown,
|
||||
uint8_t blkKnown,
|
||||
uint8_t typKnown,
|
||||
uint8_t targetBlock,
|
||||
uint64_t keyKnown,
|
||||
uint8_t blkKnown,
|
||||
uint8_t typKnown,
|
||||
uint8_t targetBlock,
|
||||
uint8_t targetType,
|
||||
NestedCore ncs[SETS_NR]
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -86,7 +86,7 @@
|
||||
#define BitFramingReg 0x0D //面向位的帧的调节
|
||||
#define CollReg 0x0E //RF接口上检测到的第一个位冲突的位的位置
|
||||
#define RFU0F 0x0F //保留
|
||||
// PAGE 1
|
||||
// PAGE 1
|
||||
#define RFU10 0x10 //保留
|
||||
#define ModeReg 0x11 //定义发送和接收的常用模式
|
||||
#define TxModeReg 0x12 //定义发送过程的数据传输速率
|
||||
@@ -103,7 +103,7 @@
|
||||
#define MfRxReg 0x1D //控制ISO 14443/ MIFARE模式中106kbit/s的通信 (比如奇偶校验位的计算)
|
||||
#define RFU1E 0x1E //保留
|
||||
#define SerialSpeedReg 0x1F //选择串行UART接口的速率
|
||||
// PAGE 2
|
||||
// PAGE 2
|
||||
#define RFU20 0x20 //保留
|
||||
#define CRCResultRegM 0x21 //显示CRC计算的实际MSB值
|
||||
#define CRCResultRegL 0x22 //显示CRC计算的实际LSB值
|
||||
@@ -118,12 +118,12 @@
|
||||
#define TPrescalerReg 0x2B //定义内部定时器的设置
|
||||
#define TReloadRegH 0x2C //描述16位长的定时器重装值
|
||||
#define TReloadRegL 0x2D //描述16位长的定时器重装值
|
||||
#define TCounterValueRegH 0x2E
|
||||
#define TCounterValueRegH 0x2E
|
||||
#define TCounterValueRegL 0x2F //显示16位长的实际定时器值
|
||||
// PAGE 3
|
||||
// PAGE 3
|
||||
#define RFU30 0x30 //保留
|
||||
#define TestSel1Reg 0x31 //常用测试信号配置
|
||||
#define TestSel2Reg 0x32 //常用测试信号配置和PRBS控制
|
||||
#define TestSel2Reg 0x32 //常用测试信号配置和PRBS控制
|
||||
#define TestPinEnReg 0x33 //D1-D7输出驱动器的使能管脚(仅用于串行接口)
|
||||
#define TestPinValueReg 0x34 //定义D1-D7用作I/O总线时的值
|
||||
#define TestBusReg 0x35 //显示内部测试总线的状态
|
||||
@@ -174,11 +174,11 @@ extern "C" {
|
||||
void write_register_single(uint8_t Address, uint8_t value);
|
||||
void clear_register_mask(uint8_t reg, uint8_t mask);
|
||||
void set_register_mask(uint8_t reg, uint8_t mask);
|
||||
|
||||
|
||||
// Device comunication control
|
||||
uint16_t pcd_14a_reader_timeout_get(void);
|
||||
void pcd_14a_reader_timeout_set(uint16_t timeout_ms);
|
||||
|
||||
|
||||
// Device comunication interface
|
||||
uint8_t pcd_14a_reader_bytes_transfer(uint8_t Command,
|
||||
uint8_t* pIn,
|
||||
@@ -193,16 +193,16 @@ extern "C" {
|
||||
uint8_t* pRxPar,
|
||||
uint16_t* pRxLenBit,
|
||||
uint16_t szRxLenBitMax);
|
||||
|
||||
|
||||
// Device auto append and check 14443-A parity enable or disable.
|
||||
void pcd_14a_reader_parity_on(void);
|
||||
void pcd_14a_reader_parity_off(void);
|
||||
|
||||
|
||||
// 14443-A tag operation
|
||||
uint8_t pcd_14a_reader_scan_auto(picc_14a_tag_t *tag);
|
||||
uint8_t pcd_14a_reader_ats_request(uint8_t *pAts, uint16_t *szAts, uint16_t szAtsBitMax);
|
||||
uint8_t pcd_14a_reader_atqa_request(uint8_t *resp, uint8_t *resp_par, uint16_t resp_max_bit);
|
||||
|
||||
|
||||
// M1 tag operation
|
||||
uint8_t pcd_14a_reader_mf1_auth(picc_14a_tag_t *tag, uint8_t type, uint8_t addr, uint8_t* pKey);
|
||||
void pcd_14a_reader_mf1_unauth(void);
|
||||
@@ -215,17 +215,17 @@ extern "C" {
|
||||
// 休眠卡操作
|
||||
uint8_t pcd_14a_reader_halt_tag(void);
|
||||
void pcd_14a_reader_fast_halt_tag(void);
|
||||
|
||||
|
||||
// UID & UFUID tag operation
|
||||
uint8_t pcd_14a_reader_gen1a_unlock(void);
|
||||
uint8_t pcd_14a_reader_gen1a_uplock(void);
|
||||
|
||||
|
||||
// CRC calulate
|
||||
void pcd_14a_reader_calc_crc(uint8_t* pbtData, size_t szLen, uint8_t* pbtCrc);
|
||||
void crc_14a_calculate(uint8_t* pbtData, size_t szLen, uint8_t* pbtCrc);
|
||||
void crc_14a_append(uint8_t* pbtData, size_t szLen);
|
||||
void pcd_14a_reader_crc_computer(uint8_t use522CalcCRC);
|
||||
|
||||
|
||||
// other
|
||||
uint8_t cascade_to_cmd(uint8_t cascade);
|
||||
uint32_t get_u32_tag_uid(picc_14a_tag_t *tag);
|
||||
|
||||
@@ -35,10 +35,10 @@ static void lf_125khz_gpio_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity
|
||||
// 初始化125khz信号pwm调制
|
||||
void lf_125khz_radio_init(void) {
|
||||
nrfx_err_t err_code;
|
||||
|
||||
|
||||
if (!m_is_125khz_radio_init) {
|
||||
m_is_125khz_radio_init = true;
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
|
||||
// 配置pwm
|
||||
@@ -57,44 +57,44 @@ void lf_125khz_radio_init(void) {
|
||||
// 初始化pwm
|
||||
err_code = nrfx_pwm_init(&m_pwm, &config, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
|
||||
|
||||
// 定义定时器配置结构体,并使用默认配置参数初始化结构体
|
||||
nrfx_timer_config_t timer_cfg = NRFX_TIMER_DEFAULT_CONFIG;
|
||||
timer_cfg.mode = NRF_TIMER_MODE_COUNTER; // 使用计数器模式
|
||||
|
||||
|
||||
// 初始化定时器
|
||||
err_code = nrfx_timer_init(&m_timer_lf_reader, &timer_cfg, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
|
||||
// 使能定时器
|
||||
nrfx_timer_enable(&m_timer_lf_reader);
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
|
||||
|
||||
// 初始化ppi
|
||||
err_code = nrf_drv_ppi_init();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = nrf_drv_ppi_channel_alloc(&m_ppi_channel1);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
|
||||
err_code = nrf_drv_ppi_channel_assign(m_ppi_channel1, nrf_drv_pwm_event_address_get(&m_pwm, NRF_PWM_EVENT_PWMPERIODEND), nrf_drv_timer_task_address_get(&m_timer_lf_reader, NRF_TIMER_TASK_COUNT));
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Enable both configured PPI channels
|
||||
err_code = nrf_drv_ppi_channel_enable(m_ppi_channel1);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
|
||||
|
||||
// LF采集下降沿中断,默认将gpio下拉,触发方式为下降沿触发
|
||||
nrf_drv_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
|
||||
err_code = nrf_drv_gpiote_in_init(LF_OA_OUT, &in_config, lf_125khz_gpio_handler);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
nrf_drv_gpiote_in_event_enable(LF_OA_OUT, true);
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user