Skip to content

Commit

Permalink
Fix NTAG INCR_CNT command byte order.
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocool3r committed Jul 2, 2024
1 parent 1c14fc0 commit a283795
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions firmware/application/src/rfid/nfctag/hf/nfc_mf0_ntag.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,15 +733,15 @@ static void handle_incr_cnt_command(uint8_t block_num, uint8_t *p_data) {
}

uint8_t *cnt_data = m_tag_information->memory[ctr_page_off + block_num];
uint32_t incr_value = ((uint32_t)p_data[0]) | ((uint32_t)p_data[1] << 8) | ((uint32_t)p_data[2] << 16);
uint32_t cnt = ((uint32_t)cnt_data[0]) | ((uint32_t)cnt_data[1] << 8) | ((uint32_t)cnt_data[2] << 16);
uint32_t incr_value = ((uint32_t)p_data[0] << 16) | ((uint32_t)p_data[1] << 8) | ((uint32_t)p_data[2]);
uint32_t cnt = ((uint32_t)cnt_data[0] << 16) | ((uint32_t)cnt_data[1] << 8) | ((uint32_t)cnt_data[2]);

if ((0xFFFFFF - cnt) < incr_value) cnt = 0xFFFFFF;
else cnt += incr_value;

cnt_data[0] = (uint8_t)(cnt & 0xff);
cnt_data[0] = (uint8_t)(cnt >> 16);
cnt_data[1] = (uint8_t)(cnt >> 8);
cnt_data[2] = (uint8_t)(cnt >> 16);
cnt_data[2] = (uint8_t)(cnt & 0xff);

nfc_tag_14a_tx_nbit(ACK_VALUE, 4);
}
Expand Down

0 comments on commit a283795

Please sign in to comment.