From be9bd941c85f68d5ff4f30c3df61bde5f2956ad1 Mon Sep 17 00:00:00 2001 From: Conor Patrick Date: Thu, 7 Feb 2019 19:45:02 -0500 Subject: [PATCH] simplify ams init --- targets/stm32l432/src/ams.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/targets/stm32l432/src/ams.c b/targets/stm32l432/src/ams.c index e218f34..74a24cf 100644 --- a/targets/stm32l432/src/ams.c +++ b/targets/stm32l432/src/ams.c @@ -280,25 +280,22 @@ bool ams_init() // delay(10); SELECT(); - // delay(10); + // delay(1); - ams_write_command(AMS_CMD_DEFAULT); - ams_write_command(AMS_CMD_CLEAR_BUFFER); - - // check connection - uint8_t productType = ams_read_reg(AMS_REG_PRODUCT_TYPE); - if (productType != 0x14) + // Needs to be disabled for passive operation + // if (0) + if (1) { - printf1(TAG_NFC, "Have wrong product type [0x%02x]. AMS3956 connection error.\n", productType); - return false; - } - printf1(TAG_NFC,"AMS3956 product type 0x%02x.\n", productType); - - // enable tunneling mode and RF configuration - ams_write_reg(AMS_REG_IC_CONF2, AMS_RFCFG_EN | AMS_TUN_MOD); + // check connection + uint8_t productType = ams_read_reg(AMS_REG_PRODUCT_TYPE); + if (productType != 0x14) + { + printf1(TAG_NFC, "Have wrong product type [0x%02x]. AMS3956 connection error.\n", productType); + return false; + } + + printf1(TAG_NFC,"AMS3956 product type 0x%02x.\n", productType); - if (1) - { ams_read_eeprom_block(AMS_CONFIG_UID_ADDR, block); printf1(TAG_NFC,"UID: "); dump_hex1(TAG_NFC,block,4); @@ -335,7 +332,12 @@ bool ams_init() if (block[0] != ic_cfg1 || block[1] != ic_cfg2) { + printf1(TAG_NFC,"Writing config block 1\r\n"); + + ams_write_reg(AMS_REG_IC_CONF1,ic_cfg1); + ams_write_reg(AMS_REG_IC_CONF2,ic_cfg2); + // set IC_CFG1 block[0] = ic_cfg1;