Skip to content

Commit 350deb9

Browse files
committed
core upgrade to 3.0.2, support NFC status read
1 parent 6ef315f commit 350deb9

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build/
22
armbuild/
3+
build-arm/
34
cmake-build-*/
45
Inc/git-rev.h

Inc/main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void Error_Handler(void);
5757
/* USER CODE BEGIN EFP */
5858
extern const char *fw_git_version;
5959
void SystemClock_CustomConfig(bool nfc_low_power, bool pll_reconfig);
60+
int check_is_nfc_en(void);
6061
/* USER CODE END EFP */
6162

6263
/* Private defines -----------------------------------------------------------*/

Src/admin_vendor.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,18 @@ int admin_vendor_version(const CAPDU *capdu, RAPDU *rapdu) {
5656
return 0;
5757
}
5858

59-
int admin_vendor_nfc_enable(const CAPDU *capdu, RAPDU *rapdu) {
59+
int admin_vendor_nfc_enable(const CAPDU *capdu, RAPDU *rapdu, bool pin_validated) {
6060
if (P1 != 0x00 && P1 != 0x01) EXCEPT(SW_WRONG_P1P2);
6161
if (P2 != 0x00) EXCEPT(SW_WRONG_P1P2);
6262
if (LC != 0x00) EXCEPT(SW_WRONG_LENGTH);
6363

64+
if (P1 == 0x01 && !pin_validated) EXCEPT(SW_SECURITY_STATUS_NOT_SATISFIED);
65+
if (P1 == 0x00) {
66+
RDATA[0] = check_is_nfc_en();
67+
LL = 1;
68+
return 0;
69+
}
70+
6471
uint32_t magic = P1 * 0x50 + 0x100;
6572
FLASH_OBProgramInitTypeDef cfg = {
6673
.OptionType = OPTIONBYTE_PCROP,

Src/device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
const uint32_t UNTOUCHED_MAX_VAL = 40; /* Suitable for 56K pull-down resistor */
1616
const uint32_t CALI_TIMES = 4;
17-
const uint32_t TOUCH_GAP_TIME = 800; /* Gap period (in ms) between two consecutive touch events */
17+
const uint32_t TOUCH_GAP_TIME = TOUCH_EXPIRE_TIME; /* Gap period (in ms) between two consecutive touch events */
1818
const uint32_t MIN_LONG_TOUCH_TIME = 500;
1919
const uint32_t MIN_TOUCH_TIME = 20;
2020

@@ -153,7 +153,7 @@ void device_periodic_task(void) {
153153
}
154154
break;
155155
case TOUCH_STATE_ASSERT:
156-
if (tick - event_tick > TOUCH_GAP_TIME) {
156+
if (tick - event_tick >= TOUCH_GAP_TIME) {
157157
set_touch_result(TOUCH_NO);
158158
fsm = TOUCH_STATE_DEASSERT;
159159
DBG_MSG("touch deassert, max value measured: %u\r\n", measure_touch);

Src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static void config_usb_mode(void) {
281281
device_loop_enable = 1;
282282
}
283283

284-
static int check_is_nfc_en(void) {
284+
int check_is_nfc_en(void) {
285285
uint32_t *flash_loc = (uint32_t*) 0x1FFF7808U;
286286
uint32_t val = *flash_loc; //FLASH->PCROP1SR;
287287
DBG_MSG("%x\n", val);

0 commit comments

Comments
 (0)