initial development for NXP NFC I2C IC
This commit is contained in:
parent
58ec4b16c5
commit
111e8a6fe4
@ -226,7 +226,7 @@
|
|||||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
</cconfiguration>
|
</cconfiguration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="com.silabs.ss.framework.ide.project.core.cpp" project.generation="54" projectCommon.boardIds="brd2500a:0.0.0" projectCommon.buildArtifactType="EXE" projectCommon.importModeId="COPY" projectCommon.partId="mcu.arm.efm32.pg1.efm32pg1b200f256gm48" projectCommon.sdkId="com.silabs.sdk.stack.super:1.1.1._310456152"/>
|
<storageModule moduleId="com.silabs.ss.framework.ide.project.core.cpp" project.generation="74" projectCommon.boardIds="brd2500a:0.0.0" projectCommon.buildArtifactType="EXE" projectCommon.importModeId="COPY" projectCommon.partId="mcu.arm.efm32.pg1.efm32pg1b200f256gm48" projectCommon.sdkId="com.silabs.sdk.stack.super:1.1.1._310456152"/>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
<project id="EFM32.com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType.1696568425" name="SLS CDT Project" projectType="com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType"/>
|
<project id="EFM32.com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType.1696568425" name="SLS CDT Project" projectType="com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType"/>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<mode name="DefaultMode">
|
<mode name="DefaultMode">
|
||||||
<property object="ADC0" propertyId="ABPeripheral.included" value="true"/>
|
<property object="ADC0" propertyId="ABPeripheral.included" value="true"/>
|
||||||
<property object="CMU" propertyId="ABPeripheral.included" value="true"/>
|
<property object="CMU" propertyId="ABPeripheral.included" value="true"/>
|
||||||
<property object="CMU" propertyId="clocksettings.hfrcosettings.hfrcofrequency" value="13 MHz"/>
|
<property object="CMU" propertyId="clocksettings.hfrcosettings.hfrcofrequency" value="38 MHz"/>
|
||||||
<property object="CMU" propertyId="clocksettings.lfclocksettings.lfrcorequired" value="Yes"/>
|
<property object="CMU" propertyId="clocksettings.lfclocksettings.lfrcorequired" value="Yes"/>
|
||||||
<property object="CRYOTIMER" propertyId="ABPeripheral.included" value="true"/>
|
<property object="CRYOTIMER" propertyId="ABPeripheral.included" value="true"/>
|
||||||
<property object="CRYOTIMER" propertyId="cryotimer.clocking.eventafterevery" value="1 cycle"/>
|
<property object="CRYOTIMER" propertyId="cryotimer.clocking.eventafterevery" value="1 cycle"/>
|
||||||
@ -61,6 +61,11 @@
|
|||||||
<property object="PD10" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
<property object="PD10" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||||
<property object="PD10" propertyId="ports.settings.pulldirection" value="Pullup"/>
|
<property object="PD10" propertyId="ports.settings.pulldirection" value="Pullup"/>
|
||||||
<property object="PD10" propertyId="ports.settings.pullup" value="Enabled"/>
|
<property object="PD10" propertyId="ports.settings.pullup" value="Enabled"/>
|
||||||
|
<property object="PD15" propertyId="ports.settings.dout" value="1"/>
|
||||||
|
<property object="PD15" propertyId="ports.settings.filter" value="Enabled"/>
|
||||||
|
<property object="PD15" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||||
|
<property object="PD15" propertyId="ports.settings.pulldirection" value="Pullup"/>
|
||||||
|
<property object="PD15" propertyId="ports.settings.pullup" value="Enabled"/>
|
||||||
<property object="PF3" propertyId="ports.settings.pinmode" value="Wired-and pullup filter"/>
|
<property object="PF3" propertyId="ports.settings.pinmode" value="Wired-and pullup filter"/>
|
||||||
<property object="PF4" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
<property object="PF4" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||||
<property object="PF5" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
<property object="PF5" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||||
|
@ -14,13 +14,17 @@
|
|||||||
|
|
||||||
#define USING_DEV_BOARD
|
#define USING_DEV_BOARD
|
||||||
|
|
||||||
#define BRIDGE_TO_WALLET
|
//#define BRIDGE_TO_WALLET
|
||||||
|
|
||||||
//#define DISABLE_CTAPHID_PING
|
//#define DISABLE_CTAPHID_PING
|
||||||
//#define DISABLE_CTAPHID_WINK
|
//#define DISABLE_CTAPHID_WINK
|
||||||
#define DISABLE_CTAPHID_CBOR
|
//#define DISABLE_CTAPHID_CBOR
|
||||||
|
|
||||||
void printing_init();
|
void printing_init();
|
||||||
|
|
||||||
|
#define TEST
|
||||||
|
#define TEST_POWER
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SRC_APP_H_ */
|
#endif /* SRC_APP_H_ */
|
||||||
|
@ -104,7 +104,7 @@ extern void CMU_enter_DefaultMode_from_RESET(void) {
|
|||||||
CMU_HFXOInit(&hfxoInit);
|
CMU_HFXOInit(&hfxoInit);
|
||||||
|
|
||||||
/* Setting system HFRCO frequency */
|
/* Setting system HFRCO frequency */
|
||||||
CMU_HFRCOFreqSet (cmuHFRCOFreq_13M0Hz);
|
CMU_HFRCOFreqSet (cmuHFRCOFreq_38M0Hz);
|
||||||
|
|
||||||
/* Using HFRCO as high frequency clock, HFCLK */
|
/* Using HFRCO as high frequency clock, HFCLK */
|
||||||
CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
|
CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
|
||||||
@ -660,6 +660,9 @@ extern void PORTIO_enter_DefaultMode_from_RESET(void) {
|
|||||||
|
|
||||||
/* Pin PD10 is configured to Push-pull */
|
/* Pin PD10 is configured to Push-pull */
|
||||||
GPIO_PinModeSet(gpioPortD, 10, gpioModePushPull, 1);
|
GPIO_PinModeSet(gpioPortD, 10, gpioModePushPull, 1);
|
||||||
|
|
||||||
|
/* Pin PD15 is configured to Push-pull */
|
||||||
|
GPIO_PinModeSet(gpioPortD, 15, gpioModePushPull, 1);
|
||||||
// [Port D Configuration]$
|
// [Port D Configuration]$
|
||||||
|
|
||||||
// $[Port E Configuration]
|
// $[Port E Configuration]
|
||||||
|
@ -424,6 +424,7 @@ void device_init(void)
|
|||||||
{
|
{
|
||||||
buf[i] = adc_rng();
|
buf[i] = adc_rng();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef IS_BOOTLOADER
|
#ifdef IS_BOOTLOADER
|
||||||
typedef enum
|
typedef enum
|
||||||
|
132
efm32/src/nfc.c
132
efm32/src/nfc.c
@ -18,6 +18,7 @@
|
|||||||
#include "nfc.h"
|
#include "nfc.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
#define NT3H2111_ADDR 0xAA
|
||||||
|
|
||||||
I2C_TransferReturn_TypeDef I2CSPM_Transfer(I2C_TypeDef *i2c, I2C_TransferSeq_TypeDef *seq)
|
I2C_TransferReturn_TypeDef I2CSPM_Transfer(I2C_TypeDef *i2c, I2C_TransferSeq_TypeDef *seq)
|
||||||
{
|
{
|
||||||
@ -35,7 +36,7 @@ I2C_TransferReturn_TypeDef I2CSPM_Transfer(I2C_TypeDef *i2c, I2C_TransferSeq_Typ
|
|||||||
// data must be 16 bytes
|
// data must be 16 bytes
|
||||||
void read_block(uint8_t block, uint8_t * data)
|
void read_block(uint8_t block, uint8_t * data)
|
||||||
{
|
{
|
||||||
uint8_t addr = 0xAA;
|
uint8_t addr = NT3H2111_ADDR;
|
||||||
I2C_TransferSeq_TypeDef seq;
|
I2C_TransferSeq_TypeDef seq;
|
||||||
I2C_TransferReturn_TypeDef ret;
|
I2C_TransferReturn_TypeDef ret;
|
||||||
uint8_t i2c_read_data[16];
|
uint8_t i2c_read_data[16];
|
||||||
@ -59,9 +60,37 @@ void read_block(uint8_t block, uint8_t * data)
|
|||||||
}
|
}
|
||||||
memmove(data, i2c_read_data, 16);
|
memmove(data, i2c_read_data, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// data must be 16 bytes
|
||||||
|
void write_block(uint8_t block, uint8_t * data)
|
||||||
|
{
|
||||||
|
uint8_t addr = NT3H2111_ADDR;
|
||||||
|
I2C_TransferSeq_TypeDef seq;
|
||||||
|
I2C_TransferReturn_TypeDef ret;
|
||||||
|
uint8_t i2c_write_data[1 + 16];
|
||||||
|
|
||||||
|
seq.addr = addr;
|
||||||
|
seq.flags = I2C_FLAG_WRITE;
|
||||||
|
/* Select command to issue */
|
||||||
|
i2c_write_data[0] = block;
|
||||||
|
memmove(i2c_write_data + 1, data, 16);
|
||||||
|
seq.buf[0].data = i2c_write_data;
|
||||||
|
seq.buf[0].len = 17;
|
||||||
|
/* Select location/length of data to be read */
|
||||||
|
seq.buf[1].data = NULL;
|
||||||
|
seq.buf[1].len = 0;
|
||||||
|
|
||||||
|
ret = I2CSPM_Transfer(I2C0, &seq);
|
||||||
|
|
||||||
|
if (ret != i2cTransferDone) {
|
||||||
|
printf("I2C fail %04x\r\n",ret);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void write_reg_flash(uint8_t reg_addr, uint8_t mask,uint8_t data)
|
void write_reg_flash(uint8_t reg_addr, uint8_t mask,uint8_t data)
|
||||||
{
|
{
|
||||||
uint8_t addr = 0xAA;
|
uint8_t addr = NT3H2111_ADDR;
|
||||||
I2C_TransferSeq_TypeDef seq;
|
I2C_TransferSeq_TypeDef seq;
|
||||||
I2C_TransferReturn_TypeDef ret;
|
I2C_TransferReturn_TypeDef ret;
|
||||||
uint8_t i2c_write_data[4];
|
uint8_t i2c_write_data[4];
|
||||||
@ -87,7 +116,7 @@ void write_reg_flash(uint8_t reg_addr, uint8_t mask,uint8_t data)
|
|||||||
}
|
}
|
||||||
void write_reg(uint8_t reg_addr, uint8_t mask,uint8_t data)
|
void write_reg(uint8_t reg_addr, uint8_t mask,uint8_t data)
|
||||||
{
|
{
|
||||||
uint8_t addr = 0xAA;
|
uint8_t addr = NT3H2111_ADDR;
|
||||||
I2C_TransferSeq_TypeDef seq;
|
I2C_TransferSeq_TypeDef seq;
|
||||||
I2C_TransferReturn_TypeDef ret;
|
I2C_TransferReturn_TypeDef ret;
|
||||||
uint8_t i2c_write_data[4];
|
uint8_t i2c_write_data[4];
|
||||||
@ -119,7 +148,7 @@ uint8_t read_reg(uint8_t reg_addr)
|
|||||||
uint8_t write_data[2];
|
uint8_t write_data[2];
|
||||||
uint8_t read_data[1];
|
uint8_t read_data[1];
|
||||||
|
|
||||||
seq.addr = 0xAA;
|
seq.addr = NT3H2111_ADDR;
|
||||||
seq.flags = I2C_FLAG_WRITE_READ;
|
seq.flags = I2C_FLAG_WRITE_READ;
|
||||||
write_data[0] = 0xFE;
|
write_data[0] = 0xFE;
|
||||||
write_data[1] = reg_addr;
|
write_data[1] = reg_addr;
|
||||||
@ -149,30 +178,99 @@ void read_reg_block(uint8_t * data)
|
|||||||
data++;
|
data++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#define NS_REG_ADDR 6
|
||||||
|
typedef enum{
|
||||||
|
RF_FIELD_PRESENT = 0x01,
|
||||||
|
EEPROM_WR_BUSY = 0x02,
|
||||||
|
EEPROM_WR_ERR = 0x04,
|
||||||
|
SRAM_RF_READY = 0x08,
|
||||||
|
SRAM_I2C_READY = 0x10,
|
||||||
|
RF_LOCKED = 0x20,
|
||||||
|
I2C_LOCKED = 0x40,
|
||||||
|
NDEF_DATA_READ = 0x80,
|
||||||
|
} NS_REG_BIT;
|
||||||
|
|
||||||
|
#define RF_FIELD_PRESENT 0x01
|
||||||
|
#define EEPROM_WR_BUSY 0x02
|
||||||
|
#define SRAM_RF_READY 0x02
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t header;
|
||||||
|
uint8_t tlen;
|
||||||
|
uint8_t plen;
|
||||||
|
uint8_t ilen;
|
||||||
|
uint8_t rtype;
|
||||||
|
} NDEF;
|
||||||
|
|
||||||
void nfc_test()
|
void nfc_test()
|
||||||
{
|
{
|
||||||
uint8_t data[16];
|
uint8_t data[16];
|
||||||
|
uint8_t ns_reg;
|
||||||
|
uint8_t last_ns_reg;
|
||||||
|
// magic-number,
|
||||||
|
uint8_t cc[] = {0xE1,0x10,0x08, 0x00};
|
||||||
|
|
||||||
|
uint8_t ndef[32] = "\x03\x11\xD1\x01\x0D\x55\x01adafruit.com";
|
||||||
|
|
||||||
printf("-NFC test-\n");
|
printf("-NFC test-\n");
|
||||||
|
|
||||||
read_block(0x00, data);
|
return;
|
||||||
printf("block 00: "); dump_hex(data,16);
|
//
|
||||||
|
////
|
||||||
|
// read_block(0x00, data);
|
||||||
|
// read_block(0x00, data);
|
||||||
|
// printf("block 00: "); dump_hex(data,16);
|
||||||
|
//
|
||||||
|
// printf("capability container [init]: "); dump_hex(data+12,4);
|
||||||
|
//
|
||||||
|
// data[0] = 0xaa;
|
||||||
|
// memmove(data+12,cc,4);
|
||||||
|
//
|
||||||
|
// write_block(0x00,data);
|
||||||
|
// delay(10);
|
||||||
|
// write_block(0x01,ndef);
|
||||||
|
// delay(10);
|
||||||
|
// write_block(0x02,ndef+16);
|
||||||
|
// delay(10);
|
||||||
|
// printf("wrote block\n");
|
||||||
|
//
|
||||||
|
// read_block(0x00, data);
|
||||||
|
//
|
||||||
|
// printf("capability container [done]: "); dump_hex(data+12,4);
|
||||||
|
//
|
||||||
|
// read_reg_block(data);
|
||||||
|
// printf("regs [init]:"); dump_hex(data,8);
|
||||||
|
|
||||||
read_reg_block(data);
|
// write_reg(0, 0xff, 0x42);
|
||||||
printf("block 3A [init]:"); dump_hex(data,8);
|
// write_reg(2, 0xff, 0x01);
|
||||||
|
//
|
||||||
write_reg(0, 0xff, 0x43);
|
// read_reg_block(data);
|
||||||
write_reg_flash(0, 0xff, 0x43);
|
// printf("block 3A [done]:"); dump_hex(data,8);
|
||||||
write_reg(2, 0xff, 0x01);
|
|
||||||
|
|
||||||
read_reg_block(data);
|
|
||||||
printf("block 3A [done]:"); dump_hex(data,8);
|
|
||||||
//
|
//
|
||||||
// read_block(0x3A, data);
|
// read_block(0x3A, data);
|
||||||
// printf("block 3A [done]:"); dump_hex(data,16);
|
// printf("block 3A [done]:"); dump_hex(data,16);
|
||||||
|
|
||||||
while(1)
|
// while(1)
|
||||||
;
|
// {
|
||||||
|
// delay(250);
|
||||||
|
// read_reg_block(data);
|
||||||
|
// printf("regs:"); dump_hex(data,8);
|
||||||
|
//
|
||||||
|
// ns_reg = read_reg(NS_REG_ADDR);
|
||||||
|
// if (ns_reg & SRAM_I2C_READY)
|
||||||
|
// {
|
||||||
|
// printf("Data in sram\r\n");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// if ((ns_reg & RF_FIELD_PRESENT) && !(last_ns_reg & RF_FIELD_PRESENT))
|
||||||
|
//// {
|
||||||
|
//// printf("RF present\r\n");
|
||||||
|
//// }
|
||||||
|
//// if (!(ns_reg & RF_FIELD_PRESENT) && (last_ns_reg & RF_FIELD_PRESENT))
|
||||||
|
//// {
|
||||||
|
//// printf("RF gone\r\n");
|
||||||
|
//// }
|
||||||
|
// last_ns_reg = ns_reg;
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user