Skip to content

Commit

Permalink
First import support HydraNFC Shield v2 (ST RFAL V2.2.0 / 22-May-2020 h…
Browse files Browse the repository at this point in the history
…ttps://www.st.com/en/embedded-software/stsw-st25rfal002.html) with show registers and scan function to read UID of any NFC Tags A/B/V/F
  • Loading branch information
bvernoux committed Jul 7, 2020
1 parent c14e6af commit 3c77512
Show file tree
Hide file tree
Showing 142 changed files with 62,623 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hydrafw</name>
<name>hydrafw_hydranfc_shield_v2</name>
<comment></comment>
<projects>
</projects>
Expand Down
39 changes: 33 additions & 6 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@ MAKEFLAGS += --no-builtin-rules
# Set CPU target (default STM32F4XX)
export STM32F4XX ?= 1

# Set to 1 HYDRAFW_NFC to include HydraNFC extension support
export HYDRAFW_NFC ?= 1
#Set to 1 to include HydraNFC V1 Shield (TRF7970A) extension support
#Set to 2 to include HydraNFC V2 Shield (ST25R3916) extension support
export HYDRAFW_HYDRANFC ?= 2

export HYDRAFW_DEBUG ?= 0
export FW_REVISION := $(shell python build-scripts/hydrafw-revision.py)

HYDRAFW_OPTS =

ifeq ($(HYDRAFW_NFC),1)
ifeq ($(HYDRAFW_HYDRANFC),1)
HYDRAFW_OPTS += -DHYDRANFC
endif

ifeq ($(HYDRAFW_HYDRANFC),2)
HYDRAFW_OPTS += -DHYDRANFC_V2
endif

# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -Os -fomit-frame-pointer -falign-functions=16 -std=gnu89 --specs=nosys.specs
Expand Down Expand Up @@ -143,11 +149,18 @@ ifeq ($(STM32F4XX),1)
include drv/stm32cube/stm32f4xx_hal.mk
endif

ifeq ($(HYDRAFW_NFC),1)
ifeq ($(HYDRAFW_HYDRANFC),1)
include hydranfc/trf7970a/trf7970a.mk
include hydranfc/hydranfc.mk
endif

ifeq ($(HYDRAFW_HYDRANFC),2)
include hydranfc_v2/hydranfc_v2.mk
include hydranfc_v2/hal.mk
include hydranfc_v2/rfal.mk
include hydranfc_v2/lib.mk
endif

# Define linker script file here
ifeq ($(STM32F4XX),1)
LDSCRIPT= $(STARTUPLD)/STM32F405xG.ld
Expand Down Expand Up @@ -175,11 +188,18 @@ ifeq ($(STM32F4XX),1)
CSRC += $(STM32F4XX_HAL_SRC)
endif

ifeq ($(HYDRAFW_NFC),1)
ifeq ($(HYDRAFW_HYDRANFC),1)
CSRC += $(TRFSRC) \
$(HYDRANFCSRC)
endif

ifeq ($(HYDRAFW_HYDRANFC),2)
CSRC += $(HYDRANFC_V2_SRC)
CSRC += $(HYDRANFC_V2_HAL_SRC)
CSRC += $(HYDRANFC_V2_RFAL_SRC)
CSRC += $(HYDRANFC_V2_LIB_SRC)
endif

# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC =
Expand Down Expand Up @@ -222,11 +242,18 @@ ifeq ($(STM32F4XX),1)
INCDIR += $(STM32F4XX_HAL_INC)
endif

ifeq ($(HYDRAFW_NFC),1)
ifeq ($(HYDRAFW_HYDRANFC),1)
INCDIR += $(TRFINC) \
$(HYDRANFCINC)
endif

ifeq ($(HYDRAFW_HYDRANFC),2)
INCDIR += $(HYDRANFC_V2_INC)
INCDIR += $(HYDRANFC_V2_HAL_INC)
INCDIR += $(HYDRANFC_V2_RFAL_INC)
INCDIR += $(HYDRANFC_V2_LIB_INC)
endif

#
# Project, sources and paths
##############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/common/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static struct cmd_map {
{ T_SPI, cmd_mode_init },
{ T_I2C, cmd_mode_init },
{ T_UART, cmd_mode_init },
#ifdef HYDRANFC
#if defined(HYDRANFC) || defined(HYDRANFC_V2)
{ T_NFC, cmd_mode_init },
#endif
{ T_CAN, cmd_mode_init },
Expand Down
41 changes: 29 additions & 12 deletions src/hydrabus/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ t_token_dict tl_dict[] = {
{ T_PERIOD, "period" },
{ T_CONTINUOUS, "continuous" },
{ T_SCAN, "scan" },
#ifdef HYDRANFC
#if defined(HYDRANFC) || defined(HYDRANFC_V2)
{ T_NFC, "nfc" },
{ T_TYPEA, "typea" },
{ T_VICINITY, "vicinity" },
/*
{ T_NFCA, "nfc-a" },
{ T_NFCB, "nfc-b" },
{ T_NFCV, "nfc-v" },
{ T_NFCF, "nfc-f" },
*/
{ T_EMUL_MIFARE, "emul-mifare" },
{ T_EMUL_ISO14443A, "emul-3a" },
{ T_REGISTERS, "registers" },
Expand Down Expand Up @@ -309,7 +313,7 @@ t_token tokens_mode_trigger[] = {
{ }
};

#ifdef HYDRANFC
#if defined(HYDRANFC) || defined(HYDRANFC_V2)

t_token tokens_mode_nfc_show[] = {
{
Expand Down Expand Up @@ -369,20 +373,32 @@ t_token tokens_mode_nfc_sniff[] = {
{ }
};

#define NFC_PARAMETERS \
// For future add selection of NFC A/B/V/F to scan
/*
{\
T_TYPEA,\
.help = "TypeA (ISO14443A => MIFARE...)"\
T_NFCA,\
.help = "NFC-A (ISO14443A => MIFARE...)"\
},\
{\
T_VICINITY,\
.help = "Vicinity (ISO/IEC 15693)"\
T_NFCB,\
.help = "NFC-B (ISO14443B)"\
},\
{\
T_NFCV,\
.help = "NFC-V Vicinity (ISO/IEC 15693)"\
},\
{\
T_NFCF,\
.help = "NFC-F Felica"\
},\
*/

#define NFC_PARAMETERS \
{\
T_SCAN,\
.subtokens = tokens_mode_nfc_scan,\
.help = "Scan"\
},\
/*
{\
T_READ_MF_ULTRALIGHT,\
.arg_type = T_ARG_STRING,\
Expand Down Expand Up @@ -419,6 +435,7 @@ t_token tokens_mode_nfc_sniff[] = {
T_DIRECT_MODE_1,\
.help = "Enter Direct Mode 1 (IO5/PC4=CLK, IO6/PC2=Data)"\
},
*/

t_token tokens_sd[];
t_token tokens_mode_nfc[] = {
Expand All @@ -444,7 +461,7 @@ t_token tokens_nfc[] = {
NFC_PARAMETERS
{ }
};
#endif /* ifdef HYDRANFC */
#endif /* ifdef HYDRANFC or HYDRANFC_V2 */

t_token tokens_parity[] = {
{ T_NONE },
Expand Down Expand Up @@ -2141,7 +2158,7 @@ t_token tl_tokens[] = {
.help = "UART mode",
.help_full = "Configuration: uart [device (1/2)] [speed (value in bauds)] [parity (none/even/odd)] [stop-bits (1/2)]\r\nInteraction: <read/write (value:repeat)>"
},
#ifdef HYDRANFC
#if defined(HYDRANFC) || defined(HYDRANFC_V2)
{
T_NFC,
.subtokens = tokens_nfc,
Expand Down
10 changes: 7 additions & 3 deletions src/hydrabus/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ enum {
T_PERIOD,
T_CONTINUOUS,
T_SCAN,
#ifdef HYDRANFC
#if defined(HYDRANFC) || defined(HYDRANFC_V2)
T_NFC,
T_TYPEA,
T_VICINITY,
/*
T_NFCA,
T_NFCB,
T_NFCV,
T_NFCF,
*/
T_EMUL_MIFARE,
T_EMUL_ISO14443A,
T_REGISTERS,
Expand Down
4 changes: 2 additions & 2 deletions src/hydrabus/hydrabus_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extern const mode_exec_t mode_smartcard_exec;
extern t_token tokens_mode_spi[];
extern t_token tokens_mode_i2c[];
extern t_token tokens_mode_uart[];
#ifdef HYDRANFC
#if defined(HYDRANFC) || defined(HYDRANFC_V2)
extern t_token tokens_mode_nfc[];
#endif
extern t_token tokens_mode_jtag[];
Expand All @@ -76,7 +76,7 @@ static struct {
{ T_SPI, tokens_mode_spi, &mode_spi_exec },
{ T_I2C, tokens_mode_i2c, &mode_i2c_exec },
{ T_UART, tokens_mode_uart, &mode_uart_exec },
#ifdef HYDRANFC
#if defined(HYDRANFC) || defined(HYDRANFC_V2)
{ T_NFC, tokens_mode_nfc, &mode_nfc_exec },
#endif
{ T_JTAG, tokens_mode_jtag, &mode_jtag_exec },
Expand Down
2 changes: 1 addition & 1 deletion src/hydranfc/hydranfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ static void scan(t_hydra_console *con)
{
mode_config_proto_t* proto = &con->mode->proto;

if (proto->config.hydranfc.dev_function == NFC_TYPEA)
if (proto->config.hydranfc.dev_function == NFC_A)
hydranfc_scan_mifare(con);
else if (proto->config.hydranfc.dev_function == NFC_VICINITY)
hydranfc_scan_vicinity(con);
Expand Down
16 changes: 16 additions & 0 deletions src/hydranfc_v2/hal.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# List of all the HydraNFC v2 hal related files.
HYDRANFC_V2_HAL_SRC = hydranfc_v2/hal/src/led.c \
hydranfc_v2/hal/src/logger.c \
hydranfc_v2/hal/src/spi.c \
hydranfc_v2/hal/src/stream_dispatcher.c \
hydranfc_v2/hal/src/timer.c \
hydranfc_v2/hal/src/stm32_usb_device_library_core/src/usbd_core.c \
hydranfc_v2/hal/src/stm32_usb_device_library_core/src/usbd_ctlreq.c \
hydranfc_v2/hal/src/stm32_usb_device_library_core/src/usbd_ioreq.c \
hydranfc_v2/hal/src/stm32_usb_device_library_class_customhid/src/usbd_customhid.c \
hydranfc_v2/hal/src/rfal_analogConfigCustomTbl.c

# Required include directories
HYDRANFC_V2_HAL_INC = ./hydranfc_v2/hal/inc \
./hydranfc_v2/hal/src/stm32_usb_device_library_core/inc \
./hydranfc_v2/hal/src/stm32_usb_device_library_class_customhid/inc
66 changes: 66 additions & 0 deletions src/hydranfc_v2/hal/inc/dispatcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
*
* Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/myliberty
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R3911 firmware
* $Revision: $
* LANGUAGE: ANSI C
*/

/*! \file
*
* \author Ulrich Herrmann
*
* \brief Application dispatcher
*
*/
/*!
*
* Moudle used to dispatch the commands received by the PC application.
*/

#ifndef DISPATCHER_H
#define DISPATCHER_H

/*
******************************************************************************
* INCLUDES
******************************************************************************
*/

/*
******************************************************************************
* GLOBAL FUNCTION PROTOTYPES
******************************************************************************
*/

/*!
*****************************************************************************
* \brief Handle interrupt requests which are targetted for the dispatcher
*
* The GUI may enable interrupts and read out proper results at the time of the
* interrupt.
* This function handles these interrupts and stores the results for a later
* time when the GUI polls it.
*/
extern void dispatcherWorker(void);

#endif /* DISPATCHER_H */

67 changes: 67 additions & 0 deletions src/hydranfc_v2/hal/inc/hydranfc_v2_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
******************************************************************************
* @file hydranfc_v2_common.h
* @author MMY Application Team
* @version $Revision$
* @date $Date$
* @brief Header for main.c module
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
*
* Licensed under MMY-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HYDRANFC_V2_COMMON_H
#define __HYDRANFC_V2_COMMON_H

/* Includes ------------------------------------------------------------------*/
#include "stdint.h"
#include <string.h>
#include "math.h"
//#include "st25_discovery_nfctag.h"
//#include "tagtype5_wrapper.h"

/* Exported types ------------------------------------------------------------*/
//typedef uint8_t boolean;


/* Exported macro ------------------------------------------------------------*/

#undef FAIL
#define FAIL 0

#undef PASS
#define PASS !FAIL

/* Exported constants --------------------------------------------------------*/
#define MAX_NDEF_MEM ((uint32_t)0xC00)
#define NFC_DEVICE_MAX_NDEFMEMORY ((uint32_t)MAX_NDEF_MEM)

#define RESULTOK 0x00
#define ERRORCODE_GENERIC 1
/* Exported functions ------------------------------------------------------- */

typedef enum {
NFCTAG_OK = 0,
NFCTAG_ERROR,
NFCTAG_RESPONSE_ERROR
} NFCTAG_StatusTypeDef;

#endif /* __HYDRANFC_V2_COMMON_H */

/************************ (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
Loading

0 comments on commit 3c77512

Please sign in to comment.