check as3956 on startup
This commit is contained in:
parent
2049020b92
commit
4c941997b4
@ -65,8 +65,6 @@ int main(int argc, char * argv[])
|
|||||||
usbhid_init();
|
usbhid_init();
|
||||||
printf1(TAG_GEN,"init usb\n");
|
printf1(TAG_GEN,"init usb\n");
|
||||||
|
|
||||||
nfc_init();
|
|
||||||
|
|
||||||
ctaphid_init();
|
ctaphid_init();
|
||||||
printf1(TAG_GEN,"init ctaphid\n");
|
printf1(TAG_GEN,"init ctaphid\n");
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
|
|||||||
{
|
{
|
||||||
uint32_t len = ((req->LC3) | ((uint32_t)req->LC2 << 8) | ((uint32_t)req->LC1 << 16));
|
uint32_t len = ((req->LC3) | ((uint32_t)req->LC2 << 8) | ((uint32_t)req->LC1 << 16));
|
||||||
|
|
||||||
u2f_request_ex((APDU_HEADER *)req, &req[7], len, resp, false);
|
u2f_request_ex((APDU_HEADER *)req, req->payload, len, resp, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t u2f_response_writeback(const uint8_t * buf, uint16_t len)
|
int8_t u2f_response_writeback(const uint8_t * buf, uint16_t len)
|
||||||
|
@ -28,7 +28,7 @@ static void wait_for_rx()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ams_print_device(AMS_DEVICE * dev)
|
void ams_print_device(AMS_DEVICE * dev)
|
||||||
{
|
{
|
||||||
printf1(TAG_NFC, "AMS_DEVICE:\r\n");
|
printf1(TAG_NFC, "AMS_DEVICE:\r\n");
|
||||||
printf1(TAG_NFC, " io_conf: %02x\r\n",dev->regs.io_conf);
|
printf1(TAG_NFC, " io_conf: %02x\r\n",dev->regs.io_conf);
|
||||||
@ -252,7 +252,7 @@ void ams_print_int1(uint8_t int0)
|
|||||||
printf1(tag,"\r\n");
|
printf1(tag,"\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ams_init()
|
bool ams_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
uint8_t block[4];
|
uint8_t block[4];
|
||||||
@ -273,13 +273,19 @@ void ams_init()
|
|||||||
ams_write_command(AMS_CMD_DEFAULT);
|
ams_write_command(AMS_CMD_DEFAULT);
|
||||||
ams_write_command(AMS_CMD_CLEAR_BUFFER);
|
ams_write_command(AMS_CMD_CLEAR_BUFFER);
|
||||||
|
|
||||||
|
// check connection
|
||||||
|
uint8_t productType = ams_read_reg(AMS_REG_PRODUCT_TYPE);
|
||||||
|
if (!productType)
|
||||||
|
{
|
||||||
|
printf1(TAG_NFC,"Have no product type. Connection error.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
printf1(TAG_NFC,"Product type 0x%02x.", productType);
|
||||||
|
|
||||||
// enable tunneling mode and RF configuration
|
// enable tunneling mode and RF configuration
|
||||||
ams_write_reg(AMS_REG_IC_CONF2, AMS_RFCFG_EN | AMS_TUN_MOD);
|
ams_write_reg(AMS_REG_IC_CONF2, AMS_RFCFG_EN | AMS_TUN_MOD);
|
||||||
|
|
||||||
ams_read_eeprom_block(0, block);
|
ams_read_eeprom_block(AMS_CONFIG_UID_ADDR, block);
|
||||||
printf1(TAG_NFC,"UID: "); dump_hex1(TAG_NFC,block,4);
|
|
||||||
|
|
||||||
ams_read_eeprom_block(0, block);
|
|
||||||
printf1(TAG_NFC,"UID: "); dump_hex1(TAG_NFC,block,4);
|
printf1(TAG_NFC,"UID: "); dump_hex1(TAG_NFC,block,4);
|
||||||
|
|
||||||
ams_read_eeprom_block(AMS_CONFIG_BLOCK0_ADDR, block);
|
ams_read_eeprom_block(AMS_CONFIG_BLOCK0_ADDR, block);
|
||||||
@ -337,4 +343,5 @@ void ams_init()
|
|||||||
printf1(TAG_NFC,"conf1: "); dump_hex1(TAG_NFC,block,4);
|
printf1(TAG_NFC,"conf1: "); dump_hex1(TAG_NFC,block,4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
|
// AS3956 interface
|
||||||
|
// https://ams.com/as3956
|
||||||
|
// https://ams.com/documents/20143/36005/AS3956_DS000546_7-00.pdf
|
||||||
|
|
||||||
#ifndef _AMS_H_
|
#ifndef _AMS_H_
|
||||||
#define _AMS_H_
|
#define _AMS_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdint.h>
|
#include <stdbool.h>
|
||||||
#include "stm32l4xx_ll_gpio.h"
|
#include "stm32l4xx_ll_gpio.h"
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +39,7 @@ typedef union
|
|||||||
#define SELECT() LL_GPIO_ResetOutputPin(SOLO_AMS_CS_PORT,SOLO_AMS_CS_PIN)
|
#define SELECT() LL_GPIO_ResetOutputPin(SOLO_AMS_CS_PORT,SOLO_AMS_CS_PIN)
|
||||||
#define UNSELECT() LL_GPIO_SetOutputPin(SOLO_AMS_CS_PORT,SOLO_AMS_CS_PIN)
|
#define UNSELECT() LL_GPIO_SetOutputPin(SOLO_AMS_CS_PORT,SOLO_AMS_CS_PIN)
|
||||||
|
|
||||||
void ams_init();
|
bool ams_init();
|
||||||
|
|
||||||
void ams_read_buffer(uint8_t * data, int len);
|
void ams_read_buffer(uint8_t * data, int len);
|
||||||
void ams_write_buffer(uint8_t * data, int len);
|
void ams_write_buffer(uint8_t * data, int len);
|
||||||
@ -92,7 +96,14 @@ void ams_write_reg(uint8_t addr, uint8_t tx);
|
|||||||
#define AMS_REG_BUF2 0x0c
|
#define AMS_REG_BUF2 0x0c
|
||||||
#define AMS_BUF_LEN_MASK 0x1f
|
#define AMS_BUF_LEN_MASK 0x1f
|
||||||
#define AMS_BUF_INVALID 0x80
|
#define AMS_BUF_INVALID 0x80
|
||||||
|
#define AMS_REG_BUF1 0x0d
|
||||||
|
// ... //
|
||||||
|
#define AMS_REG_PRODUCT_TYPE 0x1c
|
||||||
|
#define AMS_REG_PRODUCT_SUBTYPE 0x1d
|
||||||
|
#define AMS_REG_VERSION_MAJOR 0x1e
|
||||||
|
#define AMS_REG_VERSION_MINOR 0x1f
|
||||||
|
|
||||||
|
#define AMS_CONFIG_UID_ADDR 0x00
|
||||||
#define AMS_CONFIG_BLOCK0_ADDR 0x7e
|
#define AMS_CONFIG_BLOCK0_ADDR 0x7e
|
||||||
#define AMS_CONFIG_BLOCK1_ADDR 0x7f
|
#define AMS_CONFIG_BLOCK1_ADDR 0x7f
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ uint32_t __90_ms = 0;
|
|||||||
uint32_t __device_status = 0;
|
uint32_t __device_status = 0;
|
||||||
uint32_t __last_update = 0;
|
uint32_t __last_update = 0;
|
||||||
extern PCD_HandleTypeDef hpcd;
|
extern PCD_HandleTypeDef hpcd;
|
||||||
|
bool haveNFC = false;
|
||||||
|
|
||||||
#define IS_BUTTON_PRESSED() (0 == (LL_GPIO_ReadInputPort(SOLO_BUTTON_PORT) & SOLO_BUTTON_PIN))
|
#define IS_BUTTON_PRESSED() (0 == (LL_GPIO_ReadInputPort(SOLO_BUTTON_PORT) & SOLO_BUTTON_PIN))
|
||||||
|
|
||||||
@ -118,6 +119,12 @@ void device_init()
|
|||||||
#else
|
#else
|
||||||
flash_option_bytes_init(0);
|
flash_option_bytes_init(0);
|
||||||
#endif
|
#endif
|
||||||
|
printf1(TAG_GEN,"init nfc\n");
|
||||||
|
haveNFC = nfc_init();
|
||||||
|
if (haveNFC)
|
||||||
|
printf1(TAG_GEN,"NFC OK.\n");
|
||||||
|
else
|
||||||
|
printf1(TAG_GEN,"NFC not found.\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf1(TAG_GEN,"hello solo\r\n");
|
printf1(TAG_GEN,"hello solo\r\n");
|
||||||
@ -397,6 +404,7 @@ void device_manage()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef IS_BOOTLOADER
|
#ifndef IS_BOOTLOADER
|
||||||
|
if(haveNFC)
|
||||||
nfc_loop();
|
nfc_loop();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,12 @@ void nfc_state_init()
|
|||||||
NFC_STATE.block_num = 1;
|
NFC_STATE.block_num = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nfc_init()
|
bool nfc_init()
|
||||||
{
|
{
|
||||||
nfc_state_init();
|
nfc_state_init();
|
||||||
ams_init();
|
return ams_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_int0(uint8_t int0)
|
void process_int0(uint8_t int0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
#define _NFC_H_
|
#define _NFC_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include "apdu.h"
|
#include "apdu.h"
|
||||||
|
|
||||||
void nfc_loop();
|
void nfc_loop();
|
||||||
void nfc_init();
|
bool nfc_init();
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user