Merge branch 'dev-rakshita-nfc' into stable
commit
cf901f42d3
14
.cproject
14
.cproject
|
|
@ -400,6 +400,7 @@
|
||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.INCLUDE_PATH.1406977247" name="Include paths (-I)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.INCLUDE_PATH" valueType="includePath">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.INCLUDE_PATH.1406977247" name="Include paths (-I)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value="${COM_TI_MSPM0_SDK_INCLUDE_PATH}"/>
|
<listOptionValue builtIn="false" value="${COM_TI_MSPM0_SDK_INCLUDE_PATH}"/>
|
||||||
|
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/ivec_ECU/ivec_ecu_nfc/inc}"/>
|
||||||
<listOptionValue builtIn="false" value="${SYSCONFIG_TOOL_INCLUDE_PATH}"/>
|
<listOptionValue builtIn="false" value="${SYSCONFIG_TOOL_INCLUDE_PATH}"/>
|
||||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Generated Codes}"/>
|
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Generated Codes}"/>
|
||||||
<listOptionValue builtIn="false" value="${PROJECT_ROOT}"/>
|
<listOptionValue builtIn="false" value="${PROJECT_ROOT}"/>
|
||||||
|
|
@ -419,6 +420,10 @@
|
||||||
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/arm-none-eabi/include"/>
|
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/arm-none-eabi/include"/>
|
||||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Core/Include}"/>
|
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Core/Include}"/>
|
||||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Core/Source}"/>
|
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/Core/Source}"/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/mspm0g3507_mcal/ivec_BSW/ivec_bsw_common/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/mspm0g3507_mcal/ivec_BSW/ivec_bsw_nfc/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/mspm0g3507_mcal/ivec_ESDK/ivec_cmplx_gptimer/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/mspm0g3507_mcal/ivec_ESDK/ivec_esdk_nfc_pn532/inc}""/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.OPT_LEVEL.764173782" name="Optimization Level" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.OPT_LEVEL.OPT_FOR_DEBUG" valueType="enumerated"/>
|
<option id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.OPT_LEVEL.764173782" name="Optimization Level" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.OPT_LEVEL.OPT_FOR_DEBUG" valueType="enumerated"/>
|
||||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.FUNCTION_SECTIONS.343631336" name="Place each function into its own section (-ffunction-sections)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.FUNCTION_SECTIONS" value="true" valueType="boolean"/>
|
<option id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.FUNCTION_SECTIONS.343631336" name="Place each function into its own section (-ffunction-sections)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_9.0.compilerID.FUNCTION_SECTIONS" value="true" valueType="boolean"/>
|
||||||
|
|
@ -475,9 +480,7 @@
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry excluding="driverlib|mspm0g3507.cmd|bs_touchAndLcd" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
<entry excluding="driverlib|mspm0g3507.cmd|bs_touchAndLcd" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="driverlib/m0p"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="driverlib"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="driverlib/lib"/>
|
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="driverlib/.meta"/>
|
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
|
@ -692,7 +695,7 @@
|
||||||
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/arm-none-eabi/lib/thumb/v6-m/nofp"/>
|
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/arm-none-eabi/lib/thumb/v6-m/nofp"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.REREAD_LIBS.1439921312" name="Reread libraries; resolve backward references (--reread_libs, -x)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.REREAD_LIBS" value="false" valueType="boolean"/>
|
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.REREAD_LIBS.1439921312" name="Reread libraries; resolve backward references (--reread_libs, -x)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.REREAD_LIBS" value="false" valueType="boolean"/>
|
||||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DIAG_WRAP.1285564209" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DIAG_WRAP._none" valueType="enumerated"/>
|
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DIAG_WRAP.1285564209" name="Wrap diagnostic messages (--diag_wrap) [deprecated]" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DIAG_WRAP._none" valueType="enumerated"/>
|
||||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DISPLAY_ERROR_NUMBER.834742846" name="Emit diagnostic identifier numbers (--display_error_number)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DISPLAY_ERROR_NUMBER" value="false" valueType="boolean"/>
|
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DISPLAY_ERROR_NUMBER.834742846" name="Emit diagnostic identifier numbers (--display_error_number)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.DISPLAY_ERROR_NUMBER" value="false" valueType="boolean"/>
|
||||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.XML_LINK_INFO.1031743849" name="Detailed link information data-base into <file> (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.XML_LINK_INFO" value="" valueType="string"/>
|
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.XML_LINK_INFO.1031743849" name="Detailed link information data-base into <file> (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.XML_LINK_INFO" value="" valueType="string"/>
|
||||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.INITIALIZATION_MODEL.1978227845" name="Initialization model" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.INITIALIZATION_MODEL" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.INITIALIZATION_MODEL._none" valueType="enumerated"/>
|
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.INITIALIZATION_MODEL.1978227845" name="Initialization model" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.INITIALIZATION_MODEL" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.linkerID.INITIALIZATION_MODEL._none" valueType="enumerated"/>
|
||||||
|
|
@ -731,6 +734,9 @@
|
||||||
<project id="empty_LP_MSPM0G3507_nortos_ticlang.com.ti.ccstudio.buildDefinitions.TMS470.ProjectType.711060793" name="TMS470" projectType="com.ti.ccstudio.buildDefinitions.TMS470.ProjectType"/>
|
<project id="empty_LP_MSPM0G3507_nortos_ticlang.com.ti.ccstudio.buildDefinitions.TMS470.ProjectType.711060793" name="TMS470" projectType="com.ti.ccstudio.buildDefinitions.TMS470.ProjectType"/>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||||
|
<configuration configurationName="AAR"/>
|
||||||
|
<configuration configurationName="Test"/>
|
||||||
|
<configuration configurationName="Test__GNU"/>
|
||||||
<configuration configurationName="Debug">
|
<configuration configurationName="Debug">
|
||||||
<resource resourceType="PROJECT" workspacePath="/mspm0g3507_mcal"/>
|
<resource resourceType="PROJECT" workspacePath="/mspm0g3507_mcal"/>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
||||||
2
.project
2
.project
|
|
@ -28,7 +28,7 @@
|
||||||
<link>
|
<link>
|
||||||
<name>driverlib</name>
|
<name>driverlib</name>
|
||||||
<type>2</type>
|
<type>2</type>
|
||||||
<location>C:/ti/mspm0_sdk_2_02_00_05/source/ti/driverlib</location>
|
<location>C:/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib</location>
|
||||||
</link>
|
</link>
|
||||||
</linkedResources>
|
</linkedResources>
|
||||||
<variableList>
|
<variableList>
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,8 @@ encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0gx51x/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0gx51x/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0gx51x/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0gx51x/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l111x/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l111x/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8
|
||||||
|
|
@ -125,6 +127,8 @@ encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0g1x0x_g3x0x/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0gx51x/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0gx51x/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0gx51x/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0gx51x/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l111x/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l111x/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8
|
||||||
|
|
@ -135,6 +139,8 @@ encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0g1x0x_g3x0x/subdir_rules.mk=UTF-
|
||||||
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0gx51x/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0gx51x/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0gx51x/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0gx51x/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l111x/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l111x/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8
|
||||||
|
|
@ -145,6 +151,8 @@ encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0g1x0x_g3x0x/subdir_rules.mk=U
|
||||||
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0gx51x/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0gx51x/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0gx51x/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0gx51x/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l111x/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l111x/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8
|
||||||
|
|
@ -153,14 +161,26 @@ encoding//Test__GNU/driverlib/m0p/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/m0p/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/m0p/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/m0p/sysctl/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/driverlib/m0p/sysctl/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/driverlib/m0p/sysctl/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/driverlib/m0p/sysctl/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/driverlib/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_APP/src/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/ivec_APP/src/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_APP/src/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/ivec_APP/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_BSW/ivec_bsw_common/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_BSW/ivec_bsw_common/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_BSW/ivec_bsw_nfc/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_BSW/ivec_bsw_nfc/src/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_ECU/ivec_ecu_can/src/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_can/src/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_ECU/ivec_ecu_can/src/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_can/src/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_ECU/ivec_ecu_common/src/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_common/src/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_ECU/ivec_ecu_common/src/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_common/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_nfc/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_nfc/src/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_ECU/ivec_ecu_uart/src/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_uart/src/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_ECU/ivec_ecu_uart/src/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/ivec_ECU/ivec_ecu_uart/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ESDK/ivec_cmplx_gptimer/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ESDK/ivec_cmplx_gptimer/src/subdir_vars.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ESDK/ivec_esdk_nfc_pn532/src/subdir_rules.mk=UTF-8
|
||||||
|
encoding//Test__GNU/ivec_ESDK/ivec_esdk_nfc_pn532/src/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_RTE/src/subdir_rules.mk=UTF-8
|
encoding//Test__GNU/ivec_RTE/src/subdir_rules.mk=UTF-8
|
||||||
encoding//Test__GNU/ivec_RTE/src/subdir_vars.mk=UTF-8
|
encoding//Test__GNU/ivec_RTE/src/subdir_vars.mk=UTF-8
|
||||||
encoding//Test__GNU/makefile=UTF-8
|
encoding//Test__GNU/makefile=UTF-8
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
#ifndef IVEC_BSW_COMMON_H
|
||||||
|
#define IVEC_BSW_COMMON_H
|
||||||
|
#include "ivec_ecu_common.h"
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
//common
|
||||||
|
commonBSW_SUCCESS = 0,
|
||||||
|
commonBSW_WAIT,
|
||||||
|
commonBSW_INVALID_PARAM=-7,
|
||||||
|
commonBSW_FAIL = -6,
|
||||||
|
commonBSW_INIT_FAIL = -5,
|
||||||
|
commonBSW_DEINIT_FAIL,
|
||||||
|
commonBSW_CONFIG_FAIL,
|
||||||
|
commonBSW_READ_FAIL,
|
||||||
|
commonBSW_WRITE_FAIL,
|
||||||
|
commonBSW_ALREADY_INIT=-20,
|
||||||
|
commonBSW_ALREADY_DEINIT,
|
||||||
|
commonBSW_NOT_IMPLEMENTED
|
||||||
|
|
||||||
|
|
||||||
|
}IVEC_BswCommonErr_e;
|
||||||
|
|
||||||
|
typedef IVEC_EcuCommonCanFrame_s IVEC_BswCommonCanFrame_s;
|
||||||
|
|
||||||
|
#define IVEC_DELAY_MS(x)
|
||||||
|
|
||||||
|
#define BSW_LOG_ENABLE 0
|
||||||
|
#if BSW_LOG_ENABLE==1
|
||||||
|
#define IVEC_BSW_LOG(LOG_STRING, msg ,...) QL_LOG(QL_LOG_LEVEL_INFO, LOG_STRING, msg, ##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define IVEC_BSW_LOG(LOG_STRING,msg, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define IVEC_BSW_FUNC_ENTRY(LOG_STRING,...) QL_LOG(QL_LOG_LEVEL_INFO, LOG_STRING, "BSW Entry", ##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define IVEC_BSW_FUNC_ENTRY(LOG_STRING, ...)
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
#define IVEC_BSW_FUNC_EXIT(LOG_STRING,...) QL_LOG(QL_LOG_LEVEL_INFO, LOG_STRING, "BSW Exit:%d", ##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define IVEC_BSW_FUNC_EXIT(LOG_STRING, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* IVEC_BSW_COMMON_H */
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef IVEC_BSW_NFC_H
|
||||||
|
#define IVEC_BSW_NFC_H
|
||||||
|
|
||||||
|
#include "ivec_bsw_common.h"
|
||||||
|
#define IVEC_BSW_NFC_MIFRAE_AUTH_A 0x60//imported from pn532 lib
|
||||||
|
#define IVEC_BSW_NFC_MIFRAE_AUTH_B 0x61//imported from pn532 lib
|
||||||
|
|
||||||
|
|
||||||
|
bool bBSW_NfcTest();
|
||||||
|
bool bBSW_NfcInit();
|
||||||
|
bool bBSW_NfcMifareClassicDataRead(uint8_t *pu8Uid,uint8_t u8UidLen,uint32_t u32BlockAddr,uint8_t *pu8Key, uint8_t u8keyType,uint8_t *pu8Data );
|
||||||
|
bool bBSW_NfcConfigure();
|
||||||
|
int i328BSW_NfcScanMIFARE(uint8_t *pu8Uid);
|
||||||
|
int i328BSW_NfcAutoPollMIFARE();
|
||||||
|
#endif /* IVEC_BSW_NFC_H */
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
#include <ivec_BSW/ivec_bsw_nfc/inc/ivec_bsw_nfc.h>
|
||||||
|
#include "ivec_ecu_nfc.h"
|
||||||
|
#include "ivec_cmplx_gptimer.h"
|
||||||
|
#include "pn532.h"
|
||||||
|
#define LOG_STRING "ivec-bsw-nfc"
|
||||||
|
IVEC_EcuNfcConfig_s xNfcConfig = { 0 };
|
||||||
|
static PN532 __gprv_pn532 = { 0 };
|
||||||
|
|
||||||
|
|
||||||
|
int i32Bsw_Pn532Reset(void)
|
||||||
|
{
|
||||||
|
//add gpio
|
||||||
|
vEcu_NfcReset();
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
int i32Bsw_Pn532ReadData(uint8_t* data, uint16_t count)
|
||||||
|
{
|
||||||
|
int i32Ret = xECU_NfcReadData(&xNfcConfig, data, count, 200) == commonECU_SUCCESS ? PN532_STATUS_OK : PN532_ERROR_I2CBUSY;
|
||||||
|
// if(i32Ret==PN532_STATUS_OK)
|
||||||
|
// {
|
||||||
|
// memmove(data,data+1,count);
|
||||||
|
// }
|
||||||
|
return i32Ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i32Bsw_Pn532WriteData(uint8_t* data, uint16_t count)
|
||||||
|
{
|
||||||
|
return xECU_NfcWriteData(&xNfcConfig, data, count) == commonECU_SUCCESS ? PN532_STATUS_OK : PN532_ERROR_I2CBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bBsw_Pn532WaitReady(uint32_t timeout)
|
||||||
|
{
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
int i32Bsw_Pn532Wakeup(void) {
|
||||||
|
|
||||||
|
//add gpio
|
||||||
|
uint8_t wakeup[] = { 0x55, 0x55, 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
IVEC_ECUUartWrite(xNfcConfig.pvChannelHandle, &wakeup[0], sizeof(wakeup));
|
||||||
|
vEcu_NfcReset();
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
void vBsw_Pn532Log(const char* log) {
|
||||||
|
IVEC_BSW_LOG(LOG_STRING, "%s", log);
|
||||||
|
}
|
||||||
|
void vBsw_Pn532Init(PN532* pxPn532) {
|
||||||
|
// init the pn532 functions
|
||||||
|
pxPn532->reset = i32Bsw_Pn532Reset;
|
||||||
|
pxPn532->read_data = i32Bsw_Pn532ReadData;
|
||||||
|
pxPn532->write_data = i32Bsw_Pn532WriteData;
|
||||||
|
pxPn532->wait_ready = bBsw_Pn532WaitReady;
|
||||||
|
pxPn532->wakeup = i32Bsw_Pn532Wakeup;
|
||||||
|
pxPn532->log = vBsw_Pn532Log;
|
||||||
|
|
||||||
|
// hardware wakeup
|
||||||
|
pxPn532->wakeup();
|
||||||
|
}
|
||||||
|
bool bBSW_NfcInit()
|
||||||
|
{
|
||||||
|
xNfcConfig.eNfcChannel = IVEC_ECU_NFC_UART2;
|
||||||
|
if (xECU_NfcInit(&xNfcConfig) != commonECU_SUCCESS)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
vBsw_Pn532Init(&__gprv_pn532);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bBSW_NfcTest()
|
||||||
|
{
|
||||||
|
uint8_t pu8Buff[56] = { 0 };
|
||||||
|
send_wakeup(&__gprv_pn532);
|
||||||
|
return get_firmware(&__gprv_pn532, pu8Buff, 4) == 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i328BSW_NfcScanMIFARE(uint8_t* pu8Uid)
|
||||||
|
{
|
||||||
|
uint8_t l_u8Buff[32] = { 0 };
|
||||||
|
if (xECU_NfcReadData(&xNfcConfig, l_u8Buff, 21, 5) == commonECU_SUCCESS)
|
||||||
|
{
|
||||||
|
if (l_u8Buff[0] != PN532_PREAMBLE && l_u8Buff[1] != PN532_STARTCODE1 && l_u8Buff[2] != PN532_STARTCODE2)
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
// Check length & length checksum match.
|
||||||
|
uint8_t frame_len = l_u8Buff[3];
|
||||||
|
if (((frame_len + l_u8Buff[4]) & 0xFF) != 0) {
|
||||||
|
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
if (frame_len < 14)
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
// Check frame checksum value matches bytes.
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
for (uint8_t i = 0; i < frame_len + 1; i++) {
|
||||||
|
checksum += l_u8Buff[5 + i];
|
||||||
|
}
|
||||||
|
checksum &= 0xFF;
|
||||||
|
if (checksum != 0) {
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
if (l_u8Buff[5] != 0xd5 && l_u8Buff[6] != 0x61 && l_u8Buff[8]!=0x10)//verify auto poll cmd resp
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
uint8_t l_u8NfcIdLen=l_u8Buff[14];
|
||||||
|
if(l_u8NfcIdLen>10)
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
|
||||||
|
// Return frame data.
|
||||||
|
for (uint8_t i = 0; i < l_u8NfcIdLen; i++) {
|
||||||
|
pu8Uid[i] = l_u8Buff[15+ i];
|
||||||
|
}
|
||||||
|
return l_u8NfcIdLen;
|
||||||
|
}
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
int i328BSW_NfcAutoPollMIFARE()
|
||||||
|
{
|
||||||
|
return auto_poll_command(&__gprv_pn532) == PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
bool bBSW_NfcConfigure()//call it after test success
|
||||||
|
{
|
||||||
|
return configure_sam(&__gprv_pn532) == PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
bool bBSW_NfcMifareClassicDataRead(uint8_t* pu8Uid, uint8_t u8UidLen, uint32_t u32BlockAddr, uint8_t* pu8Key, uint8_t u8keyType, uint8_t* pu8Data)
|
||||||
|
{
|
||||||
|
if (UART_MifareClassicAuthenticateBlock(&__gprv_pn532, pu8Uid, u8UidLen, (u32BlockAddr / 4) * 4, u8keyType, pu8Key) == PN532_STATUS_OK)
|
||||||
|
return UART_MifareClassicReadBlock(&__gprv_pn532, pu8Data, u32BlockAddr) == PN532_STATUS_OK;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef IVEC_ECU_NFC_H
|
||||||
|
#define IVEC_ECU_NFC_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "ivec_ecu_common.h"
|
||||||
|
|
||||||
|
#define IVEC_ECU_NFC_I2C_ADDR ( 0x24 )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
IVEC_ECU_NFC_SERIF_I2C = 0,
|
||||||
|
IVEC_ECU_NFC_UART2 = 1,
|
||||||
|
}IVEC_EcuNfcComMode_e;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
IVEC_EcuNfcComMode_e eNfcChannel;
|
||||||
|
void *pvChannelHandle;
|
||||||
|
}IVEC_EcuNfcConfig_s;
|
||||||
|
|
||||||
|
IVEC_EcuCommonErr_e xECU_NfcInit(IVEC_EcuNfcConfig_s *pxNfcConfig);
|
||||||
|
IVEC_EcuCommonErr_e xECU_NfcDeInit(IVEC_EcuNfcConfig_s *pxNfcConfig);
|
||||||
|
void vEcu_NfcReset(void);
|
||||||
|
IVEC_EcuCommonErr_e xECU_NfcWriteData(IVEC_EcuNfcConfig_s *pxNfcConfig, uint8_t *pu8Buffer, uint32_t u32Length);
|
||||||
|
IVEC_EcuCommonErr_e xECU_NfcReadData(IVEC_EcuNfcConfig_s* pxNfcConfig, uint8_t* pu8Buffer, uint32_t u32Length,uint32_t timeout);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* IVEC_ECU_NFC_H */
|
||||||
|
|
@ -0,0 +1,115 @@
|
||||||
|
#include "ivec_ecu_common.h"
|
||||||
|
|
||||||
|
#include "ivec_ecu_nfc.h"
|
||||||
|
#include "ivec_ecu_uart.h"
|
||||||
|
#define LOG_STRING "ivec-ecu-nfc"
|
||||||
|
static IVEC_EcuUartHandle_s __gprv_UartNfcHandle = { 0 };
|
||||||
|
// CAN UART Buffer
|
||||||
|
#define eteCAN_UART_NFC_BUFFER_MAX_SIZE_u32 512
|
||||||
|
volatile uint8_t __gprv_u8NfcUartDataBuffer[eteCAN_UART_NFC_BUFFER_MAX_SIZE_u32]={0};
|
||||||
|
|
||||||
|
void vEcu_NfcReset(void)
|
||||||
|
{
|
||||||
|
// xMCAL_GpioWritePin(135, ivecMCAL_LVL_LOW);
|
||||||
|
// ql_rtos_task_sleep_ms(40);
|
||||||
|
// xMCAL_GpioWritePin(135, ivecMCAL_LVL_HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
|
IVEC_EcuCommonErr_e xECU_NfcInit(IVEC_EcuNfcConfig_s* pxNfcConfig)
|
||||||
|
{
|
||||||
|
IVEC_ECU_FUNC_ENTRY(LOG_STRING);
|
||||||
|
IVEC_McalCommonErr_e l_xFuncStatus = commonMCAL_SUCCESS;
|
||||||
|
if (pxNfcConfig == NULL)
|
||||||
|
{
|
||||||
|
l_xFuncStatus = commonECU_INVALID_PARAM;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (pxNfcConfig->eNfcChannel == IVEC_ECU_NFC_UART2)
|
||||||
|
{
|
||||||
|
__gprv_UartNfcHandle.u8Qbuffer = __gprv_u8NfcUartDataBuffer;
|
||||||
|
__gprv_UartNfcHandle.u16QbufSize = eteCAN_UART_NFC_BUFFER_MAX_SIZE_u32;
|
||||||
|
__gprv_UartNfcHandle.u32BaudRate = IVEC_ECU_UART_BAUD_115200;
|
||||||
|
__gprv_UartNfcHandle.eUartPortNumber = IVEC_ECU_UART_PORT3;
|
||||||
|
xECU_UartInit(&__gprv_UartNfcHandle);
|
||||||
|
pxNfcConfig->pvChannelHandle = &__gprv_UartNfcHandle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_xFuncStatus = commonECU_NOT_IMPLEMENTED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
exit:
|
||||||
|
IVEC_ECU_FUNC_EXIT(LOG_STRING, l_xFuncStatus);
|
||||||
|
return l_xFuncStatus;
|
||||||
|
}
|
||||||
|
IVEC_EcuCommonErr_e xECU_NfcReadData(IVEC_EcuNfcConfig_s* pxNfcConfig, uint8_t* pu8Buffer, uint32_t u32Length,uint32_t timeout)
|
||||||
|
{
|
||||||
|
IVEC_ECU_FUNC_ENTRY(LOG_STRING);
|
||||||
|
IVEC_McalCommonErr_e l_xFuncStatus = commonMCAL_SUCCESS;
|
||||||
|
if (pxNfcConfig == NULL || pu8Buffer == NULL || u32Length == 0)
|
||||||
|
{
|
||||||
|
l_xFuncStatus = commonECU_INVALID_PARAM;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (pxNfcConfig->eNfcChannel == IVEC_ECU_NFC_UART2)
|
||||||
|
{
|
||||||
|
l_xFuncStatus = xECU_UartGetData(pxNfcConfig->pvChannelHandle, pu8Buffer, u32Length, timeout);
|
||||||
|
// l_xFuncStatus = (IVEC_EcuCommonErr_e)xMCAL_I2cReadSlave(&__gprv_xNfcI2cHandle, pu8Buffer, u32Length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_xFuncStatus = commonECU_NOT_IMPLEMENTED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
exit:
|
||||||
|
IVEC_ECU_FUNC_EXIT(LOG_STRING, l_xFuncStatus);
|
||||||
|
return l_xFuncStatus;
|
||||||
|
|
||||||
|
}
|
||||||
|
IVEC_EcuCommonErr_e xECU_NfcWriteData(IVEC_EcuNfcConfig_s* pxNfcConfig, uint8_t* pu8Buffer, uint32_t u32Length)
|
||||||
|
{
|
||||||
|
IVEC_ECU_FUNC_ENTRY(LOG_STRING);
|
||||||
|
IVEC_McalCommonErr_e l_xFuncStatus = commonMCAL_SUCCESS;
|
||||||
|
if (pxNfcConfig == NULL || pu8Buffer == NULL || u32Length == 0)
|
||||||
|
{
|
||||||
|
l_xFuncStatus = commonECU_INVALID_PARAM;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (pxNfcConfig->eNfcChannel == IVEC_ECU_NFC_UART2)
|
||||||
|
{
|
||||||
|
|
||||||
|
l_xFuncStatus = IVEC_ECUUartWrite(pxNfcConfig->pvChannelHandle, pu8Buffer, u32Length);
|
||||||
|
// l_xFuncStatus = (IVEC_EcuCommonErr_e)xMCAL_I2cWriteSlave((McalI2cHandle_s *)pxNfcConfig->pvChannelHandle, pu8Buffer, u32Length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_xFuncStatus = commonECU_NOT_IMPLEMENTED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
exit:
|
||||||
|
IVEC_ECU_FUNC_EXIT(LOG_STRING, l_xFuncStatus);
|
||||||
|
return l_xFuncStatus;
|
||||||
|
}
|
||||||
|
IVEC_EcuCommonErr_e xECU_NfcDeInit(IVEC_EcuNfcConfig_s* pxNfcConfig)
|
||||||
|
{
|
||||||
|
IVEC_ECU_FUNC_ENTRY(LOG_STRING);
|
||||||
|
IVEC_McalCommonErr_e l_xFuncStatus = commonMCAL_SUCCESS;
|
||||||
|
if (pxNfcConfig == NULL)
|
||||||
|
{
|
||||||
|
l_xFuncStatus = commonECU_INVALID_PARAM;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (pxNfcConfig->eNfcChannel == IVEC_ECU_NFC_UART2)
|
||||||
|
{
|
||||||
|
|
||||||
|
// l_xFuncStatus = (IVEC_EcuCommonErr_e)xMCAL_I2cDeInit(&__gprv_xNfcI2cHandle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_xFuncStatus = commonECU_NOT_IMPLEMENTED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
exit:
|
||||||
|
IVEC_ECU_FUNC_EXIT(LOG_STRING, l_xFuncStatus);
|
||||||
|
return l_xFuncStatus;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Copyright (C) 2020 QUECTEL Technologies Limited and/or its affiliates("QUECTEL").
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
set(target ivec_cmplx_gptimer)
|
||||||
|
|
||||||
|
add_library(${target} STATIC)
|
||||||
|
set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${out_app_lib_dir})
|
||||||
|
target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_QUEC)
|
||||||
|
target_include_directories(${target} PUBLIC inc)
|
||||||
|
target_link_libraries(${target} PRIVATE ql_newlib ivec_mcal_common ivec_cmplx_miscellaneous)
|
||||||
|
|
||||||
|
target_sources(${target} PRIVATE
|
||||||
|
src/ivec_cmplx_gptimer.c
|
||||||
|
)
|
||||||
|
|
||||||
|
relative_glob(srcs include/*.h src/*.c inc/*.h)
|
||||||
|
beautify_c_code(${target} ${srcs})
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
/*
|
||||||
|
* Vecmocon Technologies Private Limited [CONFIDENTIAL]
|
||||||
|
* Unpublished Copyright (c) 2019 [Vecmocon Technologies Private Limited], All Rights Reserved.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTICE: All information contained herein is, and remains the property of COMPANY. The intellectual and technical concepts contained
|
||||||
|
* herein are proprietary to COMPANY and may be covered by Indian and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained
|
||||||
|
* from COMPANY. Access to the source code contained herein is hereby forbidden to anyone except current COMPANY employees, managers or contractors who have executed
|
||||||
|
* Confidentiality and Non-disclosure agreements explicitly covering such access.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* The copyright notice above does not evidence any actual or intended publication or disclosure of this source code, which includes
|
||||||
|
* information that is confidential and/or proprietary, and is a trade secret, of COMPANY. ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE,
|
||||||
|
* OR PUBLIC DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE
|
||||||
|
* LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS
|
||||||
|
* TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file gp_timer.h
|
||||||
|
* \author Altamash Abdul Rahim
|
||||||
|
* \brief This file Software timer functionality.
|
||||||
|
*
|
||||||
|
* Changelog:
|
||||||
|
* 09 February 2019: Created.
|
||||||
|
* 28-August-2019: (-) updated variable and function naming convention
|
||||||
|
* (-) add comments for auto-documentation generation tool
|
||||||
|
*/
|
||||||
|
#ifndef __GP_TIMER_H__
|
||||||
|
#define __GP_TIMER_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// time typedef
|
||||||
|
typedef uint32_t tClockTime;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Timer structure. Use Timer_Set() to set the timer.
|
||||||
|
*/
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
struct timer {
|
||||||
|
#else
|
||||||
|
typedef struct {
|
||||||
|
#endif
|
||||||
|
tClockTime start; /// start time
|
||||||
|
tClockTime interval; /// interval for timer
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
} gpTimer_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief This function sets a timer for a specific time.
|
||||||
|
* The function `Timer_Expired()` returns true if
|
||||||
|
* the timer has expired.
|
||||||
|
*
|
||||||
|
* \param[in] t pointer to timer instance
|
||||||
|
* \param[in] interval interval after which the timer expires
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
void Timer_Set(struct timer *t, tClockTime interval);
|
||||||
|
#else
|
||||||
|
void GPT_timerSet(gpTimer_t * t, tClockTime interval);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief [DEPRECATED] This function resets the same interval that was
|
||||||
|
* given to the Timer_Set() function.
|
||||||
|
*
|
||||||
|
* The starting point of the interval is the last timer
|
||||||
|
* value when timer expired. Using this function
|
||||||
|
* makes the timer being stable over time.
|
||||||
|
*
|
||||||
|
* \param[in] t pointer to timer instance
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
void Timer_Reset(struct timer * t);
|
||||||
|
#else
|
||||||
|
void GPT_timerReset(gpTimer_t * t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief This function resets the same interval that was
|
||||||
|
* given to the Timer_Set() function.
|
||||||
|
*
|
||||||
|
* The starting point of the interval is the current time.
|
||||||
|
* For a stable timer over time, it is recommended to use
|
||||||
|
* the Timer_Reset() function.
|
||||||
|
*
|
||||||
|
* \param[in] t pointer to timer instance
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
void Timer_Restart(struct timer * t);
|
||||||
|
#else
|
||||||
|
void GPT_timerRestart(gpTimer_t * t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief This function verifies if a timer has expired.
|
||||||
|
*
|
||||||
|
* \param[in] timer instance
|
||||||
|
* \return uint8_t integer result code (1: expired, 0: not expired)
|
||||||
|
*/
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
uint8_t Timer_Expired(struct timer * timer);
|
||||||
|
#else
|
||||||
|
uint8_t GPT_timerExpired(gpTimer_t * timer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief This function returns the remaining time before the timer expires.
|
||||||
|
*
|
||||||
|
* \param[in] timer instance
|
||||||
|
* \return tClockTimer time remaining
|
||||||
|
*/
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
tClockTime Timer_Remaining(struct timer *t);
|
||||||
|
#else
|
||||||
|
tClockTime GPT_timerRemaining(gpTimer_t * timer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief This function provide a delay for a given amount of time.
|
||||||
|
*
|
||||||
|
* \param[in] delay ticks to delay for
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
void Timer_Delay(uint32_t delay);
|
||||||
|
|
||||||
|
#endif /* __GP_TIMER_H__ */
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Vecmocon Technologies Private Limited [CONFIDENTIAL]
|
||||||
|
* Unpublished Copyright (c) 2019 [Vecmocon Technologies Private Limited], All Rights Reserved.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTICE: All information contained herein is, and remains the property of COMPANY. The intellectual and technical concepts contained
|
||||||
|
* herein are proprietary to COMPANY and may be covered by Indian and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained
|
||||||
|
* from COMPANY. Access to the source code contained herein is hereby forbidden to anyone except current COMPANY employees, managers or contractors who have executed
|
||||||
|
* Confidentiality and Non-disclosure agreements explicitly covering such access.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* The copyright notice above does not evidence any actual or intended publication or disclosure of this source code, which includes
|
||||||
|
* information that is confidential and/or proprietary, and is a trade secret, of COMPANY. ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE,
|
||||||
|
* OR PUBLIC DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE
|
||||||
|
* LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS
|
||||||
|
* TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* \file gp_timer.c
|
||||||
|
*
|
||||||
|
* \author Altamash Abdul Rahim
|
||||||
|
* \brief This file Software timer functionality.
|
||||||
|
*
|
||||||
|
* Change log:
|
||||||
|
* 09-February-2019: Created.
|
||||||
|
* 28-August-2019: (-) updated variable and function naming convention
|
||||||
|
* (-) add comments for auto-documentation generation tool
|
||||||
|
*/
|
||||||
|
#include "ivec_cmplx_gptimer.h"
|
||||||
|
#include "utils.h"
|
||||||
|
//#include "ivec_cmplx_miscellaneous.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
void Timer_Set(struct timer *t, tClockTime interval)
|
||||||
|
#else
|
||||||
|
void GPT_timerSet(gpTimer_t *t, tClockTime interval)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
////NOTNULL_VOID(t);
|
||||||
|
t->interval = interval;
|
||||||
|
t->start = i32MCAL_getTicks();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
/*! \deprecated use `GPT_timerRestart` */
|
||||||
|
void Timer_Reset(struct timer *t)
|
||||||
|
#else
|
||||||
|
void GPT_timerReset(gpTimer_t * t)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
////NOTNULL_VOID(t);
|
||||||
|
t->start += t->interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
void Timer_Restart(struct timer *t)
|
||||||
|
#else
|
||||||
|
void GPT_timerRestart(gpTimer_t * t)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
////NOTNULL_VOID(t);
|
||||||
|
t->start = i32MCAL_getTicks();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
uint8_t Timer_Expired(struct timer *t)
|
||||||
|
#else
|
||||||
|
uint8_t GPT_timerExpired(gpTimer_t *t)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
//NOTNULL(t);
|
||||||
|
tClockTime diff = (i32MCAL_getTicks() - t->start) + 1;
|
||||||
|
return (t->interval < diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
tClockTime Timer_Remaining(struct timer *t)
|
||||||
|
#else
|
||||||
|
tClockTime GPT_timerRemaining(gpTimer_t * t)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
//NOTNULL(t);
|
||||||
|
return (t->start + t->interval) > i32MCAL_getTicks() ? (t->start + t->interval - i32MCAL_getTicks()) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
||||||
|
__attribute__((weak)) void Timer_Delay(uint32_t delay)
|
||||||
|
#else
|
||||||
|
void GPT_timerDelay(uint32_t delay)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
uint32_t nowTick = i32MCAL_getTicks();
|
||||||
|
while((i32MCAL_getTicks() - nowTick) < delay);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Copyright (C) 2020 QUECTEL Technologies Limited and/or its affiliates("QUECTEL").
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
set(target ivec_esdk_nfc_pn532)
|
||||||
|
|
||||||
|
add_library(${target} STATIC)
|
||||||
|
set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${out_app_lib_dir})
|
||||||
|
target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_QUEC)
|
||||||
|
target_include_directories(${target} PUBLIC inc)
|
||||||
|
target_link_libraries(${target} PRIVATE ql_newlib ivec_mcal_common)
|
||||||
|
|
||||||
|
target_sources(${target} PRIVATE
|
||||||
|
src/pn532.c
|
||||||
|
)
|
||||||
|
|
||||||
|
relative_glob(srcs include/*.h src/*.c inc/*.h)
|
||||||
|
beautify_c_code(${target} ${srcs})
|
||||||
|
|
@ -0,0 +1,282 @@
|
||||||
|
/**************************************************************************
|
||||||
|
* @file pn532.h
|
||||||
|
* @author Yehui from Waveshare
|
||||||
|
* @license BSD
|
||||||
|
*
|
||||||
|
* Header file for pn532.c
|
||||||
|
*
|
||||||
|
* Check out the links above for our tutorials and wiring diagrams
|
||||||
|
* These chips use SPI communicate.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PN532_H
|
||||||
|
#define PN532_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PN532_PREAMBLE (0x00)
|
||||||
|
#define PN532_STARTCODE1 (0x00)
|
||||||
|
#define PN532_STARTCODE2 (0xFF)
|
||||||
|
#define PN532_POSTAMBLE (0x00)
|
||||||
|
|
||||||
|
#define PN532_HOSTTOPN532 (0xD4)
|
||||||
|
#define PN532_PN532TOHOST (0xD5)
|
||||||
|
|
||||||
|
// PN532 Commands
|
||||||
|
#define PN532_COMMAND_DIAGNOSE (0x00)
|
||||||
|
#define PN532_COMMAND_GETFIRMWAREVERSION (0x02)
|
||||||
|
#define PN532_COMMAND_GETGENERALSTATUS (0x04)
|
||||||
|
#define PN532_COMMAND_READREGISTER (0x06)
|
||||||
|
#define PN532_COMMAND_WRITEREGISTER (0x08)
|
||||||
|
#define PN532_COMMAND_READGPIO (0x0C)
|
||||||
|
#define PN532_COMMAND_WRITEGPIO (0x0E)
|
||||||
|
#define PN532_COMMAND_SETSERIALBAUDRATE (0x10)
|
||||||
|
#define PN532_COMMAND_SETPARAMETERS (0x12)
|
||||||
|
#define PN532_COMMAND_SAMCONFIGURATION (0x14)
|
||||||
|
#define PN532_COMMAND_POWERDOWN (0x16)
|
||||||
|
#define PN532_COMMAND_RFCONFIGURATION (0x32)
|
||||||
|
#define PN532_COMMAND_RFREGULATIONTEST (0x58)
|
||||||
|
#define PN532_COMMAND_INJUMPFORDEP (0x56)
|
||||||
|
#define PN532_COMMAND_INJUMPFORPSL (0x46)
|
||||||
|
#define PN532_COMMAND_INLISTPASSIVETARGET (0x4A)
|
||||||
|
#define PN532_COMMAND_INATR (0x50)
|
||||||
|
#define PN532_COMMAND_INPSL (0x4E)
|
||||||
|
#define PN532_COMMAND_INDATAEXCHANGE (0x40)
|
||||||
|
#define PN532_COMMAND_INCOMMUNICATETHRU (0x42)
|
||||||
|
#define PN532_COMMAND_INDESELECT (0x44)
|
||||||
|
#define PN532_COMMAND_INRELEASE (0x52)
|
||||||
|
#define PN532_COMMAND_INSELECT (0x54)
|
||||||
|
#define PN532_COMMAND_INAUTOPOLL (0x60)
|
||||||
|
#define PN532_COMMAND_TGINITASTARGET (0x8C)
|
||||||
|
#define PN532_COMMAND_TGSETGENERALBYTES (0x92)
|
||||||
|
#define PN532_COMMAND_TGGETDATA (0x86)
|
||||||
|
#define PN532_COMMAND_TGSETDATA (0x8E)
|
||||||
|
#define PN532_COMMAND_TGSETMETADATA (0x94)
|
||||||
|
#define PN532_COMMAND_TGGETINITIATORCOMMAND (0x88)
|
||||||
|
#define PN532_COMMAND_TGRESPONSETOINITIATOR (0x90)
|
||||||
|
#define PN532_COMMAND_TGGETTARGETSTATUS (0x8A)
|
||||||
|
|
||||||
|
#define PN532_RESPONSE_INDATAEXCHANGE (0x41)
|
||||||
|
#define PN532_RESPONSE_INLISTPASSIVETARGET (0x4B)
|
||||||
|
|
||||||
|
#define PN532_WAKEUP (0x55)
|
||||||
|
|
||||||
|
#define PN532_SPI_STATREAD (0x02)
|
||||||
|
#define PN532_SPI_DATAWRITE (0x01)
|
||||||
|
#define PN532_SPI_DATAREAD (0x03)
|
||||||
|
#define PN532_SPI_READY (0x01)
|
||||||
|
|
||||||
|
#define PN532_I2C_ADDRESS (0x48 >> 1)
|
||||||
|
#define PN532_I2C_READBIT (0x01)
|
||||||
|
#define PN532_I2C_BUSY (0x00)
|
||||||
|
#define PN532_I2C_READY (0x01)
|
||||||
|
#define PN532_I2C_READYTIMEOUT (20)
|
||||||
|
|
||||||
|
#define PN532_MIFARE_ISO14443A (0x00)
|
||||||
|
|
||||||
|
// Mifare Commands
|
||||||
|
#define MIFARE_CMD_AUTH_A (0x60)
|
||||||
|
#define MIFARE_CMD_AUTH_B (0x61)
|
||||||
|
#define MIFARE_CMD_READ (0x30)
|
||||||
|
#define MIFARE_CMD_WRITE (0xA0)
|
||||||
|
#define MIFARE_CMD_TRANSFER (0xB0)
|
||||||
|
#define MIFARE_CMD_DECREMENT (0xC0)
|
||||||
|
#define MIFARE_CMD_INCREMENT (0xC1)
|
||||||
|
#define MIFARE_CMD_STORE (0xC2)
|
||||||
|
#define MIFARE_ULTRALIGHT_CMD_WRITE (0xA2)
|
||||||
|
|
||||||
|
#define MIFARE_UID_MAX_LENGTH MIFARE_UID_TRIPLE_LENGTH
|
||||||
|
#define MIFARE_UID_SINGLE_LENGTH (4)
|
||||||
|
#define MIFARE_UID_DOUBLE_LENGTH (7)
|
||||||
|
#define MIFARE_UID_TRIPLE_LENGTH (10)
|
||||||
|
#define MIFARE_KEY_LENGTH (6)
|
||||||
|
#define MIFARE_BLOCK_LENGTH (16)
|
||||||
|
|
||||||
|
// NTAG2xx Commands
|
||||||
|
#define NTAG2XX_BLOCK_LENGTH (4)
|
||||||
|
|
||||||
|
// Prefixes for NDEF Records (to identify record type)
|
||||||
|
#define NDEF_URIPREFIX_NONE (0x00)
|
||||||
|
#define NDEF_URIPREFIX_HTTP_WWWDOT (0x01)
|
||||||
|
#define NDEF_URIPREFIX_HTTPS_WWWDOT (0x02)
|
||||||
|
#define NDEF_URIPREFIX_HTTP (0x03)
|
||||||
|
#define NDEF_URIPREFIX_HTTPS (0x04)
|
||||||
|
#define NDEF_URIPREFIX_TEL (0x05)
|
||||||
|
#define NDEF_URIPREFIX_MAILTO (0x06)
|
||||||
|
#define NDEF_URIPREFIX_FTP_ANONAT (0x07)
|
||||||
|
#define NDEF_URIPREFIX_FTP_FTPDOT (0x08)
|
||||||
|
#define NDEF_URIPREFIX_FTPS (0x09)
|
||||||
|
#define NDEF_URIPREFIX_SFTP (0x0A)
|
||||||
|
#define NDEF_URIPREFIX_SMB (0x0B)
|
||||||
|
#define NDEF_URIPREFIX_NFS (0x0C)
|
||||||
|
#define NDEF_URIPREFIX_FTP (0x0D)
|
||||||
|
#define NDEF_URIPREFIX_DAV (0x0E)
|
||||||
|
#define NDEF_URIPREFIX_NEWS (0x0F)
|
||||||
|
#define NDEF_URIPREFIX_TELNET (0x10)
|
||||||
|
#define NDEF_URIPREFIX_IMAP (0x11)
|
||||||
|
#define NDEF_URIPREFIX_RTSP (0x12)
|
||||||
|
#define NDEF_URIPREFIX_URN (0x13)
|
||||||
|
#define NDEF_URIPREFIX_POP (0x14)
|
||||||
|
#define NDEF_URIPREFIX_SIP (0x15)
|
||||||
|
#define NDEF_URIPREFIX_SIPS (0x16)
|
||||||
|
#define NDEF_URIPREFIX_TFTP (0x17)
|
||||||
|
#define NDEF_URIPREFIX_BTSPP (0x18)
|
||||||
|
#define NDEF_URIPREFIX_BTL2CAP (0x19)
|
||||||
|
#define NDEF_URIPREFIX_BTGOEP (0x1A)
|
||||||
|
#define NDEF_URIPREFIX_TCPOBEX (0x1B)
|
||||||
|
#define NDEF_URIPREFIX_IRDAOBEX (0x1C)
|
||||||
|
#define NDEF_URIPREFIX_FILE (0x1D)
|
||||||
|
#define NDEF_URIPREFIX_URN_EPC_ID (0x1E)
|
||||||
|
#define NDEF_URIPREFIX_URN_EPC_TAG (0x1F)
|
||||||
|
#define NDEF_URIPREFIX_URN_EPC_PAT (0x20)
|
||||||
|
#define NDEF_URIPREFIX_URN_EPC_RAW (0x21)
|
||||||
|
#define NDEF_URIPREFIX_URN_EPC (0x22)
|
||||||
|
#define NDEF_URIPREFIX_URN_NFC (0x23)
|
||||||
|
|
||||||
|
#define PN532_GPIO_VALIDATIONBIT (0x80)
|
||||||
|
|
||||||
|
/* Official PN532 Errors Definitions */
|
||||||
|
#define PN532_ERROR_NONE (0x00)
|
||||||
|
// Time Out, the target has not answered
|
||||||
|
#define PN532_ERROR_TIMEOUT (0x01)
|
||||||
|
// A CRC error has been detected by the CIU
|
||||||
|
#define PN532_ERROR_CRC (0x02)
|
||||||
|
// A Parity error has been detected by the CIU
|
||||||
|
#define PN532_ERROR_PARITY (0x03)
|
||||||
|
// During an anti-collision/select operation (ISO/IEC14443-3 Type A and
|
||||||
|
// ISO/IEC18092 106 kbps passive mode), an erroneous Bit Count has been
|
||||||
|
// detected
|
||||||
|
#define PN532_ERROR_COLLISION_BITCOUNT (0x04)
|
||||||
|
// Framing error during MIFARE operation
|
||||||
|
#define PN532_ERROR_MIFARE_FRAMING (0x05)
|
||||||
|
// An abnormal bit-collision has been detected during bit wise
|
||||||
|
// anti-collision at 106 kbps
|
||||||
|
#define PN532_ERROR_COLLISION_BITCOLLISION (0x06)
|
||||||
|
// Communication buffer size insufficien
|
||||||
|
#define PN532_ERROR_NOBUFS (0x07)
|
||||||
|
// RF Buffer overflow has been detected by the CI
|
||||||
|
#define PN532_ERROR_RFNOBUFS (0x09)
|
||||||
|
// In active communication mode, the RF field has not been switched on
|
||||||
|
// in time by the counterpart (as defined in NFCIP-1 standard
|
||||||
|
#define PN532_ERROR_ACTIVE_TOOSLOW (0x0a)
|
||||||
|
// RF Protocol error
|
||||||
|
#define PN532_ERROR_RFPROTO (0x0b)
|
||||||
|
// Temperature error: the internal temperature sensor has detected
|
||||||
|
// overheating, and therefore has automatically switched off the
|
||||||
|
// antenna drivers
|
||||||
|
#define PN532_ERROR_TOOHOT (0x0d)
|
||||||
|
// Internal buffer overflow
|
||||||
|
#define PN532_ERROR_INTERNAL_NOBUFS (0x0e)
|
||||||
|
// Invalid parameter (range, format...)
|
||||||
|
#define PN532_ERROR_INVAL (0x10)
|
||||||
|
// DEP Protocol: The PN533 configured in target mode does not support
|
||||||
|
// the command received from the initiator (the command received is not
|
||||||
|
// one of the following: ATR_REQ, WUP_REQ, PSL_REQ, DEP_REQ, DSL_REQ,
|
||||||
|
// RLS_REQ)
|
||||||
|
#define PN532_ERROR_DEP_INVALID_COMMAND (0x12)
|
||||||
|
// DEP Protocol, MIFARE or ISO/IEC14443-4: The data format does not
|
||||||
|
// match to the specification. Depending on the RF protocol used, it
|
||||||
|
// can be: Bad length of RF received frame, Incorrect value of PCB or
|
||||||
|
// PFB, Invalid or unexpected RF received frame, NAD or DID incoherence.
|
||||||
|
#define PN532_ERROR_DEP_BADDATA (0x13)
|
||||||
|
// MIFARE: Authentication error
|
||||||
|
#define PN532_ERROR_MIFARE_AUTH (0x14)
|
||||||
|
// Target or Initiator does not support NFC Secur
|
||||||
|
#define PN532_ERROR_NOSECURE (0x18)
|
||||||
|
// I2C bus line is Busy. A TDA transaction is on going
|
||||||
|
#define PN532_ERROR_I2CBUSY (0x19)
|
||||||
|
// ISO/IEC14443-3: UID Check byte is wrong
|
||||||
|
#define PN532_ERROR_UIDCHECKSUM (0x23)
|
||||||
|
// DEP Protocol: Invalid device state, the system is in a state which
|
||||||
|
// does not allow the operation
|
||||||
|
#define PN532_ERROR_DEPSTATE (0x25)
|
||||||
|
// Operation not allowed in this configuration (host controller
|
||||||
|
// interface)
|
||||||
|
#define PN532_ERROR_HCIINVAL (0x26)
|
||||||
|
// This command is not acceptable due to the current context of the
|
||||||
|
// PN533 (Initiator vs. Target, unknown target number, Target not in the
|
||||||
|
// good state, ...)
|
||||||
|
#define PN532_ERROR_CONTEXT (0x27)
|
||||||
|
// The PN533 configured as target has been released by its initiator
|
||||||
|
#define PN532_ERROR_RELEASED (0x29)
|
||||||
|
// PN533 and ISO/IEC14443-3B only: the ID of the card does not match,
|
||||||
|
// meaning that the expected card has been exchanged with another one.
|
||||||
|
#define PN532_ERROR_CARDSWAPPED (0x2a)
|
||||||
|
// PN533 and ISO/IEC14443-3B only: the card previously activated has
|
||||||
|
// disappeared.
|
||||||
|
#define PN532_ERROR_NOCARD (0x2b)
|
||||||
|
// Mismatch between the NFCID3 initiator and the NFCID3 target in DEP
|
||||||
|
// 212/424 kbps passive.
|
||||||
|
#define PN532_ERROR_MISMATCH (0x2c)
|
||||||
|
// An over-current event has been detected
|
||||||
|
#define PN532_ERROR_OVERCURRENT (0x2d)
|
||||||
|
// NAD missing in DEP frame
|
||||||
|
#define PN532_ERROR_NONAD (0x2e)
|
||||||
|
/* End: Official PN532 Errors Definitions */
|
||||||
|
|
||||||
|
// Other Error Definitions
|
||||||
|
#define PN532_STATUS_ERROR (-1)
|
||||||
|
#define PN532_STATUS_OK (0)
|
||||||
|
|
||||||
|
typedef struct _PN532 {
|
||||||
|
int (*reset)(void);
|
||||||
|
int (*read_data)(uint8_t* data, uint16_t count);
|
||||||
|
int (*write_data)(uint8_t *data, uint16_t count);
|
||||||
|
bool (*wait_ready)(uint32_t timeout);
|
||||||
|
int (*wakeup)(void);
|
||||||
|
void (*log)(const char* log);
|
||||||
|
} PN532;
|
||||||
|
|
||||||
|
|
||||||
|
int PN532_WriteFrame(PN532* pn532, uint8_t* data, uint16_t length);
|
||||||
|
int PN532_ReadFrame(PN532* pn532, uint8_t* buff, uint16_t length);
|
||||||
|
int PN532_CallFunction(PN532* pn532, uint8_t command, uint8_t* response, uint16_t response_length, uint8_t* params, uint16_t params_length, uint32_t timeout);
|
||||||
|
int PN532_GetFirmwareVersion(PN532* pn532, uint8_t* version);
|
||||||
|
int PN532_SamConfiguration(PN532* pn532);
|
||||||
|
int PN532_ReadPassiveTarget(PN532* pn532, uint8_t* response, uint8_t card_baud, uint32_t timeout);
|
||||||
|
int PN532_MifareClassicAuthenticateBlock(PN532* pn532, uint8_t* uid, uint8_t uid_length, uint16_t block_number, uint16_t key_number, uint8_t* key);
|
||||||
|
int PN532_MifareClassicReadBlock(PN532* pn532, uint8_t* response, uint16_t block_number);
|
||||||
|
int PN532_MifareClassicWriteBlock(PN532* pn532, uint8_t* data, uint16_t block_number);
|
||||||
|
int PN532_Ntag2xxReadBlock(PN532* pn532, uint8_t* response, uint16_t block_number);
|
||||||
|
int PN532_Ntag2xxWriteBlock(PN532* pn532, uint8_t* data, uint16_t block_number);
|
||||||
|
int PN532_ReadGpio(PN532* pn532, uint8_t* pins_state);
|
||||||
|
bool PN532_ReadGpioP(PN532* pn532, uint8_t pin_number);
|
||||||
|
bool PN532_ReadGpioI(PN532* pn532, uint8_t pin_number);
|
||||||
|
int PN532_WriteGpio(PN532* pn532, uint8_t* pins_state);
|
||||||
|
int PN532_WriteGpioP(PN532* pn532, uint8_t pin_number, bool pin_state);
|
||||||
|
int get_firmware(PN532* pn532,uint8_t *response_buffer,uint8_t response_len);
|
||||||
|
void send_wakeup(PN532 *pn532);
|
||||||
|
int configure_sam(PN532* pn532);
|
||||||
|
int auto_poll_command(PN532* pn532) ;
|
||||||
|
int UART_MifareClassicAuthenticateBlock(PN532* pn532, uint8_t* uid, uint8_t uid_length, uint16_t block_number, uint16_t key_number, uint8_t* key);
|
||||||
|
int UART_MifareClassicReadBlock(PN532* pn532, uint8_t* response, uint16_t block_number);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PN532_H */
|
||||||
|
|
||||||
|
/* End of file */
|
||||||
|
|
@ -0,0 +1,689 @@
|
||||||
|
/**************************************************************************
|
||||||
|
* @file pn532.c
|
||||||
|
* @author Yehui from Waveshare
|
||||||
|
* @license BSD
|
||||||
|
*
|
||||||
|
* This is a library for the Waveshare PN532 NFC modules
|
||||||
|
*
|
||||||
|
* Check out the links above for our tutorials and wiring diagrams
|
||||||
|
* These chips use SPI communicate.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "pn532.h"
|
||||||
|
|
||||||
|
const uint8_t PN532_ACK[] = { 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00 };
|
||||||
|
const uint8_t PN532_FRAME_START[] = { 0x00, 0x00, 0xFF };
|
||||||
|
|
||||||
|
#define PN532_FRAME_MAX_LENGTH 255
|
||||||
|
#define PN532_DEFAULT_TIMEOUT 1000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Write a frame to the PN532 of at most length bytes in size.
|
||||||
|
* Note that less than length bytes might be returned!
|
||||||
|
* @retval: Returns -1 if there is an error parsing the frame.
|
||||||
|
*/
|
||||||
|
int PN532_WriteFrame(PN532* pn532, uint8_t* data, uint16_t length) {
|
||||||
|
if (length > PN532_FRAME_MAX_LENGTH || length < 1) {
|
||||||
|
return PN532_STATUS_ERROR; // Data must be array of 1 to 255 bytes.
|
||||||
|
}
|
||||||
|
// Build frame to send as:
|
||||||
|
// - Preamble (0x00)
|
||||||
|
// - Start code (0x00, 0xFF)
|
||||||
|
// - Command length (1 byte)
|
||||||
|
// - Command length checksum
|
||||||
|
// - Command bytes
|
||||||
|
// - Checksum
|
||||||
|
// - Postamble (0x00)
|
||||||
|
|
||||||
|
uint8_t frame[PN532_FRAME_MAX_LENGTH + 7];
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
frame[0] = PN532_PREAMBLE;
|
||||||
|
frame[1] = PN532_STARTCODE1;
|
||||||
|
frame[2] = PN532_STARTCODE2;
|
||||||
|
for (uint8_t i = 0; i < 3; i++) {
|
||||||
|
checksum += frame[i];
|
||||||
|
}
|
||||||
|
frame[3] = length & 0xFF;
|
||||||
|
frame[4] = (~length + 1) & 0xFF;
|
||||||
|
for (uint8_t i = 0; i < length; i++) {
|
||||||
|
frame[5 + i] = data[i];
|
||||||
|
checksum += data[i];
|
||||||
|
}
|
||||||
|
frame[length + 5] = ~checksum & 0xFF;
|
||||||
|
frame[length + 6] = PN532_POSTAMBLE;
|
||||||
|
if (pn532->write_data(frame, length + 7) != PN532_STATUS_OK) {
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Read a response frame from the PN532 of at most length bytes in size.
|
||||||
|
* Note that less than length bytes might be returned!
|
||||||
|
* @retval: Returns frame length or -1 if there is an error parsing the frame.
|
||||||
|
*/
|
||||||
|
int PN532_ReadFrame(PN532* pn532, uint8_t* response, uint16_t length) {
|
||||||
|
uint8_t buff[PN532_FRAME_MAX_LENGTH + 7];
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
// Read frame with expected length of data.
|
||||||
|
pn532->read_data(buff, length + 7);
|
||||||
|
// Swallow all the 0x00 values that preceed 0xFF.
|
||||||
|
uint8_t offset = 0;
|
||||||
|
while (buff[offset] == 0x00) {
|
||||||
|
offset += 1;
|
||||||
|
if (offset >= length + 8) {
|
||||||
|
pn532->log("Response frame preamble does not contain 0x00FF!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buff[offset] != 0xFF) {
|
||||||
|
pn532->log("Response frame preamble does not contain 0x00FF!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
offset += 1;
|
||||||
|
if (offset >= length + 8) {
|
||||||
|
pn532->log("Response contains no data!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
// Check length & length checksum match.
|
||||||
|
uint8_t frame_len = buff[offset];
|
||||||
|
if (((frame_len + buff[offset + 1]) & 0xFF) != 0) {
|
||||||
|
pn532->log("Response length checksum did not match length!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
// Check frame checksum value matches bytes.
|
||||||
|
for (uint8_t i = 0; i < frame_len + 1; i++) {
|
||||||
|
checksum += buff[offset + 2 + i];
|
||||||
|
}
|
||||||
|
checksum &= 0xFF;
|
||||||
|
if (checksum != 0) {
|
||||||
|
pn532->log("Response checksum did not match expected checksum");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
// Return frame data.
|
||||||
|
for (uint8_t i = 0; i < frame_len; i++) {
|
||||||
|
response[i] = buff[offset + 2 + i];
|
||||||
|
}
|
||||||
|
return frame_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Send specified command to the PN532 and expect up to response_length.
|
||||||
|
* Will wait up to timeout seconds for a response and read a bytearray into
|
||||||
|
* response buffer.
|
||||||
|
* @param pn532: PN532 handler
|
||||||
|
* @param command: command to send
|
||||||
|
* @param response: buffer returned
|
||||||
|
* @param response_length: expected response length
|
||||||
|
* @param params: can optionally specify an array of bytes to send as parameters
|
||||||
|
* to the function call, or NULL if there is no need to send parameters.
|
||||||
|
* @param params_length: length of the argument params
|
||||||
|
* @param timeout: timout of systick
|
||||||
|
* @retval: Returns the length of response or -1 if error.
|
||||||
|
*/
|
||||||
|
int PN532_CallFunction(
|
||||||
|
PN532* pn532,
|
||||||
|
uint8_t command,
|
||||||
|
uint8_t* response,
|
||||||
|
uint16_t response_length,
|
||||||
|
uint8_t* params,
|
||||||
|
uint16_t params_length,
|
||||||
|
uint32_t timeout
|
||||||
|
) {
|
||||||
|
// Build frame data with command and parameters.
|
||||||
|
uint8_t buff[PN532_FRAME_MAX_LENGTH];
|
||||||
|
buff[0] = PN532_HOSTTOPN532;
|
||||||
|
buff[1] = command & 0xFF;
|
||||||
|
for (uint8_t i = 0; i < params_length; i++) {
|
||||||
|
buff[2 + i] = params[i];
|
||||||
|
}
|
||||||
|
// Send frame and wait for response.
|
||||||
|
if (PN532_WriteFrame(pn532, buff, params_length + 2) != PN532_STATUS_OK) {
|
||||||
|
pn532->wakeup();
|
||||||
|
pn532->log("Trying to wakeup");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
// if (!pn532->wait_ready(timeout)) {
|
||||||
|
// return PN532_STATUS_ERROR;
|
||||||
|
// }
|
||||||
|
// Verify ACK response and wait to be ready for function response.
|
||||||
|
pn532->read_data(buff, sizeof(PN532_ACK));
|
||||||
|
for (uint8_t i = 0; i < sizeof(PN532_ACK); i++) {
|
||||||
|
if (PN532_ACK[i] != buff[i]) {
|
||||||
|
pn532->log("Did not receive expected ACK from PN532!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (!pn532->wait_ready(timeout)) {
|
||||||
|
// return PN532_STATUS_ERROR;
|
||||||
|
// }
|
||||||
|
// Read response bytes.
|
||||||
|
int frame_len = PN532_ReadFrame(pn532, buff, response_length + 2);
|
||||||
|
|
||||||
|
// Check that response is for the called function.
|
||||||
|
if (!((buff[0] == PN532_PN532TOHOST) && (buff[1] == (command + 1)))) {
|
||||||
|
pn532->log("Received unexpected command response!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
// Return response data.
|
||||||
|
for (uint8_t i = 0; i < response_length; i++) {
|
||||||
|
response[i] = buff[i + 2];
|
||||||
|
}
|
||||||
|
// The the number of bytes read
|
||||||
|
return frame_len - 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Call PN532 GetFirmwareVersion function and return a buff with the IC,
|
||||||
|
* Ver, Rev, and Support values.
|
||||||
|
*/
|
||||||
|
int PN532_GetFirmwareVersion(PN532* pn532, uint8_t* version) {
|
||||||
|
// length of version: 4
|
||||||
|
if (PN532_CallFunction(pn532, PN532_COMMAND_GETFIRMWAREVERSION,
|
||||||
|
version, 4, NULL, 0, 500) == PN532_STATUS_ERROR) {
|
||||||
|
pn532->log("Failed to detect the PN532");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Configure the PN532 to read MiFare cards.
|
||||||
|
*/
|
||||||
|
int PN532_SamConfiguration(PN532* pn532) {
|
||||||
|
// Send SAM configuration command with configuration for:
|
||||||
|
// - 0x01, normal mode
|
||||||
|
// - 0x14, timeout 50ms * 20 = 1 second
|
||||||
|
// - 0x01, use IRQ pin
|
||||||
|
// Note that no other verification is necessary as call_function will
|
||||||
|
// check the command was executed as expected.
|
||||||
|
uint8_t params[] = { 0x01, 0x14, 0x01 };
|
||||||
|
PN532_CallFunction(pn532, PN532_COMMAND_SAMCONFIGURATION,
|
||||||
|
NULL, 0, params, sizeof(params), PN532_DEFAULT_TIMEOUT);
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Wait for a MiFare card to be available and return its UID when found.
|
||||||
|
* Will wait up to timeout seconds and return None if no card is found,
|
||||||
|
* otherwise a bytearray with the UID of the found card is returned.
|
||||||
|
* @retval: Length of UID, or -1 if error.
|
||||||
|
*/
|
||||||
|
int PN532_ReadPassiveTarget(
|
||||||
|
PN532* pn532,
|
||||||
|
uint8_t* response,
|
||||||
|
uint8_t card_baud,
|
||||||
|
uint32_t timeout
|
||||||
|
) {
|
||||||
|
// Send passive read command for 1 card. Expect at most a 7 byte UUID.
|
||||||
|
uint8_t params[] = { 0x01, card_baud };
|
||||||
|
uint8_t buff[19];
|
||||||
|
int length = PN532_CallFunction(pn532, PN532_COMMAND_INLISTPASSIVETARGET,
|
||||||
|
buff, sizeof(buff), params, sizeof(params), timeout);
|
||||||
|
if (length < 0) {
|
||||||
|
return PN532_STATUS_ERROR; // No card found
|
||||||
|
}
|
||||||
|
// Check only 1 card with up to a 7 byte UID is present.
|
||||||
|
if (buff[0] != 0x01) {
|
||||||
|
pn532->log("More than one card detected!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
if (buff[5] > 7) {
|
||||||
|
pn532->log("Found card with unexpectedly long UID!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < buff[5]; i++) {
|
||||||
|
response[i] = buff[6 + i];
|
||||||
|
}
|
||||||
|
return buff[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Authenticate specified block number for a MiFare classic card.
|
||||||
|
* @param uid: A byte array with the UID of the card.
|
||||||
|
* @param uid_length: Length of the UID of the card.
|
||||||
|
* @param block_number: The block to authenticate.
|
||||||
|
* @param key_number: The key type (like MIFARE_CMD_AUTH_A or MIFARE_CMD_AUTH_B).
|
||||||
|
* @param key: A byte array with the key data.
|
||||||
|
* @retval: PN532 error code.
|
||||||
|
*/
|
||||||
|
int PN532_MifareClassicAuthenticateBlock(
|
||||||
|
PN532* pn532,
|
||||||
|
uint8_t* uid,
|
||||||
|
uint8_t uid_length,
|
||||||
|
uint16_t block_number,
|
||||||
|
uint16_t key_number,
|
||||||
|
uint8_t* key
|
||||||
|
) {
|
||||||
|
// Build parameters for InDataExchange command to authenticate MiFare card.
|
||||||
|
uint8_t response[1] = { 0xFF };
|
||||||
|
uint8_t params[3 + MIFARE_UID_MAX_LENGTH + MIFARE_KEY_LENGTH];
|
||||||
|
params[0] = 0x01;
|
||||||
|
params[1] = key_number & 0xFF;
|
||||||
|
params[2] = block_number & 0xFF;
|
||||||
|
// params[3:3+keylen] = key
|
||||||
|
for (uint8_t i = 0; i < MIFARE_KEY_LENGTH; i++) {
|
||||||
|
params[3 + i] = key[i];
|
||||||
|
}
|
||||||
|
// params[3+keylen:] = uid
|
||||||
|
for (uint8_t i = 0; i < uid_length; i++) {
|
||||||
|
params[3 + MIFARE_KEY_LENGTH + i] = uid[i];
|
||||||
|
}
|
||||||
|
// Send InDataExchange request
|
||||||
|
PN532_CallFunction(pn532, PN532_COMMAND_INDATAEXCHANGE, response, sizeof(response),
|
||||||
|
params, 3 + MIFARE_KEY_LENGTH + uid_length, PN532_DEFAULT_TIMEOUT);
|
||||||
|
return response[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Read a block of data from the card. Block number should be the block
|
||||||
|
* to read.
|
||||||
|
* @param response: buffer of length 16 returned if the block is successfully read.
|
||||||
|
* @param block_number: specify a block to read.
|
||||||
|
* @retval: PN532 error code.
|
||||||
|
*/
|
||||||
|
int PN532_MifareClassicReadBlock(PN532* pn532, uint8_t* response, uint16_t block_number) {
|
||||||
|
uint8_t params[] = { 0x01, MIFARE_CMD_READ, block_number & 0xFF };
|
||||||
|
uint8_t buff[MIFARE_BLOCK_LENGTH + 1];
|
||||||
|
// Send InDataExchange request to read block of MiFare data.
|
||||||
|
PN532_CallFunction(pn532, PN532_COMMAND_INDATAEXCHANGE, buff, sizeof(buff),
|
||||||
|
params, sizeof(params), PN532_DEFAULT_TIMEOUT);
|
||||||
|
// Check first response is 0x00 to show success.
|
||||||
|
if (buff[0] != PN532_ERROR_NONE) {
|
||||||
|
return buff[0];
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < MIFARE_BLOCK_LENGTH; i++) {
|
||||||
|
response[i] = buff[i + 1];
|
||||||
|
}
|
||||||
|
return buff[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Write a block of data to the card. Block number should be the block
|
||||||
|
* to write and data should be a byte array of length 16 with the data to
|
||||||
|
* write.
|
||||||
|
* @param data: data to write.
|
||||||
|
* @param block_number: specify a block to write.
|
||||||
|
* @retval: PN532 error code.
|
||||||
|
*/
|
||||||
|
int PN532_MifareClassicWriteBlock(PN532* pn532, uint8_t* data, uint16_t block_number) {
|
||||||
|
uint8_t params[MIFARE_BLOCK_LENGTH + 3];
|
||||||
|
uint8_t response[1];
|
||||||
|
params[0] = 0x01; // Max card numbers
|
||||||
|
params[1] = MIFARE_CMD_WRITE;
|
||||||
|
params[2] = block_number & 0xFF;
|
||||||
|
for (uint8_t i = 0; i < MIFARE_BLOCK_LENGTH; i++) {
|
||||||
|
params[3 + i] = data[i];
|
||||||
|
}
|
||||||
|
PN532_CallFunction(pn532, PN532_COMMAND_INDATAEXCHANGE, response,
|
||||||
|
sizeof(response), params, sizeof(params), PN532_DEFAULT_TIMEOUT);
|
||||||
|
return response[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Read a block of data from the card. Block number should be the block
|
||||||
|
* to read.
|
||||||
|
* @param response: buffer of length 4 returned if the block is successfully read.
|
||||||
|
* @param block_number: specify a block to read.
|
||||||
|
* @retval: PN532 error code.
|
||||||
|
*/
|
||||||
|
int PN532_Ntag2xxReadBlock(PN532* pn532, uint8_t* response, uint16_t block_number) {
|
||||||
|
uint8_t params[] = { 0x01, MIFARE_CMD_READ, block_number & 0xFF };
|
||||||
|
// The response length of NTAG2xx is same as Mifare's
|
||||||
|
uint8_t buff[MIFARE_BLOCK_LENGTH + 1];
|
||||||
|
// Send InDataExchange request to read block of MiFare data.
|
||||||
|
PN532_CallFunction(pn532, PN532_COMMAND_INDATAEXCHANGE, buff, sizeof(buff),
|
||||||
|
params, sizeof(params), PN532_DEFAULT_TIMEOUT);
|
||||||
|
// Check first response is 0x00 to show success.
|
||||||
|
if (buff[0] != PN532_ERROR_NONE) {
|
||||||
|
return buff[0];
|
||||||
|
}
|
||||||
|
// Although the response length of NTAG2xx is same as Mifare's,
|
||||||
|
// only the first 4 bytes are available
|
||||||
|
for (uint8_t i = 0; i < NTAG2XX_BLOCK_LENGTH; i++) {
|
||||||
|
response[i] = buff[i + 1];
|
||||||
|
}
|
||||||
|
return buff[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Write a block of data to the card. Block number should be the block
|
||||||
|
* to write and data should be a byte array of length 4 with the data to
|
||||||
|
* write.
|
||||||
|
* @param data: data to write.
|
||||||
|
* @param block_number: specify a block to write.
|
||||||
|
* @retval: PN532 error code.
|
||||||
|
*/
|
||||||
|
int PN532_Ntag2xxWriteBlock(PN532* pn532, uint8_t* data, uint16_t block_number) {
|
||||||
|
uint8_t params[NTAG2XX_BLOCK_LENGTH + 3];
|
||||||
|
uint8_t response[1];
|
||||||
|
params[0] = 0x01; // Max card numbers
|
||||||
|
params[1] = MIFARE_ULTRALIGHT_CMD_WRITE;
|
||||||
|
params[2] = block_number & 0xFF;
|
||||||
|
for (uint8_t i = 0; i < NTAG2XX_BLOCK_LENGTH; i++) {
|
||||||
|
params[3 + i] = data[i];
|
||||||
|
}
|
||||||
|
PN532_CallFunction(pn532, PN532_COMMAND_INDATAEXCHANGE, response,
|
||||||
|
sizeof(response), params, sizeof(params), PN532_DEFAULT_TIMEOUT);
|
||||||
|
return response[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief: Read the GPIO states.
|
||||||
|
* @param pin_state: pin state buffer (3 bytes) returned.
|
||||||
|
* returns 3 bytes containing the pin state where:
|
||||||
|
* P3[0] = P30, P7[0] = 0, I[0] = I0,
|
||||||
|
* P3[1] = P31, P7[1] = P71, I[1] = I1,
|
||||||
|
* P3[2] = P32, P7[2] = P72, I[2] = 0,
|
||||||
|
* P3[3] = P33, P7[3] = 0, I[3] = 0,
|
||||||
|
* P3[4] = P34, P7[4] = 0, I[4] = 0,
|
||||||
|
* P3[5] = P35, P7[5] = 0, I[5] = 0,
|
||||||
|
* P3[6] = 0, P7[6] = 0, I[6] = 0,
|
||||||
|
* P3[7] = 0, P7[7] = 0, I[7] = 0,
|
||||||
|
* @retval: -1 if error
|
||||||
|
*/
|
||||||
|
int PN532_ReadGpio(PN532* pn532, uint8_t* pins_state) {
|
||||||
|
return PN532_CallFunction(pn532, PN532_COMMAND_READGPIO, pins_state, 3,
|
||||||
|
NULL, 0, PN532_DEFAULT_TIMEOUT);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief: Read the GPIO state of specified pins in (P30 ... P35).
|
||||||
|
* @param pin_number: specify the pin to read.
|
||||||
|
* @retval: true if HIGH, false if LOW
|
||||||
|
*/
|
||||||
|
bool PN532_ReadGpioP(PN532* pn532, uint8_t pin_number) {
|
||||||
|
uint8_t pins_state[3];
|
||||||
|
PN532_CallFunction(pn532, PN532_COMMAND_READGPIO, pins_state,
|
||||||
|
sizeof(pins_state), NULL, 0, PN532_DEFAULT_TIMEOUT);
|
||||||
|
if ((pin_number >= 30) && (pin_number <= 37)) {
|
||||||
|
return (pins_state[0] >> (pin_number - 30)) & 1 ? true : false;
|
||||||
|
}
|
||||||
|
if ((pin_number >= 70) && (pin_number <= 77)) {
|
||||||
|
return (pins_state[1] >> (pin_number - 70)) & 1 ? true : false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief: Read the GPIO state of I0 or I1 pin.
|
||||||
|
* @param pin_number: specify the pin to read.
|
||||||
|
* @retval: true if HIGH, false if LOW
|
||||||
|
*/
|
||||||
|
bool PN532_ReadGpioI(PN532* pn532, uint8_t pin_number) {
|
||||||
|
uint8_t pins_state[3];
|
||||||
|
PN532_CallFunction(pn532, PN532_COMMAND_READGPIO, pins_state,
|
||||||
|
sizeof(pins_state), NULL, 0, PN532_DEFAULT_TIMEOUT);
|
||||||
|
if (pin_number <= 7) {
|
||||||
|
return (pins_state[2] >> pin_number) & 1 ? true : false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief: Write the GPIO states.
|
||||||
|
* @param pins_state: pin state buffer (2 bytes) to write.
|
||||||
|
* no need to read pin states before write with the param pin_state
|
||||||
|
* P3 = pin_state[0], P7 = pin_state[1]
|
||||||
|
* bits:
|
||||||
|
* P3[0] = P30, P7[0] = 0,
|
||||||
|
* P3[1] = P31, P7[1] = P71,
|
||||||
|
* P3[2] = P32, P7[2] = P72,
|
||||||
|
* P3[3] = P33, P7[3] = nu,
|
||||||
|
* P3[4] = P34, P7[4] = nu,
|
||||||
|
* P3[5] = P35, P7[5] = nu,
|
||||||
|
* P3[6] = nu, P7[6] = nu,
|
||||||
|
* P3[7] = Val, P7[7] = Val,
|
||||||
|
* For each port that is validated (bit Val = 1), all the bits are applied
|
||||||
|
* simultaneously. It is not possible for example to modify the state of
|
||||||
|
* the port P32 without applying a value to the ports P30, P31, P33, P34
|
||||||
|
* and P35.
|
||||||
|
* @retval: -1 if error
|
||||||
|
*/
|
||||||
|
int PN532_WriteGpio(PN532* pn532, uint8_t* pins_state) {
|
||||||
|
uint8_t params[2];
|
||||||
|
// 0x80, the validation bit.
|
||||||
|
params[0] = 0x80 | pins_state[0];
|
||||||
|
params[1] = 0x80 | pins_state[1];
|
||||||
|
return PN532_CallFunction(pn532, PN532_COMMAND_WRITEGPIO, NULL, 0,
|
||||||
|
params, sizeof(params), PN532_DEFAULT_TIMEOUT);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief: Write the specified pin with given states.
|
||||||
|
* @param pin_number: specify the pin to write.
|
||||||
|
* @param pin_state: specify the pin state. true for HIGH, false for LOW.
|
||||||
|
* @retval: -1 if error
|
||||||
|
*/
|
||||||
|
int PN532_WriteGpioP(PN532* pn532, uint8_t pin_number, bool pin_state) {
|
||||||
|
uint8_t pins_state[2];
|
||||||
|
uint8_t params[2];
|
||||||
|
if (PN532_ReadGpio(pn532, pins_state) == PN532_STATUS_ERROR) {
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
if ((pin_number >= 30) && (pin_number <= 37)) {
|
||||||
|
if (pin_state) {
|
||||||
|
params[0] = 0x80 | pins_state[0] | 1 << (pin_number - 30);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
params[0] = (0x80 | pins_state[0]) & ~(1 << (pin_number - 30));
|
||||||
|
}
|
||||||
|
params[1] = 0x00; // leave p7 unchanged
|
||||||
|
}
|
||||||
|
if ((pin_number >= 70) && (pin_number <= 77)) {
|
||||||
|
if (pin_state) {
|
||||||
|
params[1] = 0x80 | pins_state[1] | 1 << (pin_number - 70);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
params[1] = (0x80 | pins_state[1]) & ~(1 << (pin_number - 70));
|
||||||
|
}
|
||||||
|
params[0] = 0x00; // leave p3 unchanged
|
||||||
|
}
|
||||||
|
return PN532_CallFunction(pn532, PN532_COMMAND_WRITEGPIO, NULL, 0,
|
||||||
|
params, sizeof(params), PN532_DEFAULT_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Command arrays
|
||||||
|
|
||||||
|
uint8_t rf_config_command[] = { 0x00, 0xFF, 0x06, 0xFA, 0xD4, 0x32, 0x05, 0xFF, 0xFF, 0x02, 0xF5, 0x00 };
|
||||||
|
|
||||||
|
uint8_t get_status_command[] = { 0x00, 0xFF, 0x02, 0xFE, 0xD4, 0x04, 0x28, 0x00 };
|
||||||
|
uint8_t in_list_passive_command[] = { 0x00, 0xFF, 0x04, 0xFC, 0xD4, 0x4A, 0x01, 0x00, 0xE1, 0x00 };
|
||||||
|
|
||||||
|
|
||||||
|
// Response buffers
|
||||||
|
//uint8_t response_buffer[32];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Function prototypes
|
||||||
|
int send_command(PN532* pn532, const uint8_t* command, uint8_t length, uint8_t* response, uint16_t response_length,uint8_t send_type);
|
||||||
|
|
||||||
|
// Function implementations
|
||||||
|
int send_command(PN532* pn532, const uint8_t* command, uint8_t length, uint8_t* response, uint16_t response_length,uint8_t send_type) {
|
||||||
|
if (pn532->write_data(command, length) != 0) {
|
||||||
|
pn532->log("Failed to write command data.");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
if(send_type==1)
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
uint8_t buff[64]={0};
|
||||||
|
// if (!pn532->wait_ready(1000)) {
|
||||||
|
// pn532->log("Timeout waiting for PN532 to be ready.");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (pn532->read_data(buff, sizeof(PN532_ACK)) != 0) {
|
||||||
|
pn532->log("Failed to read response data.");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < sizeof(PN532_ACK); i++) {
|
||||||
|
if (PN532_ACK[i] != buff[i]) {
|
||||||
|
pn532->log("Did not receive expected ACK from PN532!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(send_type==2)
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
int frame_len = PN532_ReadFrame(pn532, buff, response_length + 2);
|
||||||
|
|
||||||
|
// Check that response is for the called function.
|
||||||
|
if (!((buff[0] == PN532_PN532TOHOST) )) {
|
||||||
|
pn532->log("Received unexpected command response!");
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
// Return response data.
|
||||||
|
for (uint8_t i = 0; i < response_length; i++) {
|
||||||
|
response[i] = buff[i + 2];
|
||||||
|
}
|
||||||
|
// The the number of bytes read
|
||||||
|
return frame_len - 2;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific command functions
|
||||||
|
void send_wakeup(PN532* pn532) {
|
||||||
|
pn532->log("Sending wakeup command...");
|
||||||
|
uint8_t wakeup[] = { 0x55, 0x55, 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
send_command(pn532, wakeup, sizeof(wakeup), NULL, 0,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_firmware(PN532* pn532,uint8_t *response_buffer,uint8_t response_len) {
|
||||||
|
pn532->log("Sending get firmware command...");
|
||||||
|
|
||||||
|
uint8_t get_firmware_command[] = {0x00, 0x00, 0xFF, 0x02, 0xFE, 0xD4, 0x02, 0x2A, 0x00 };
|
||||||
|
return send_command(pn532, get_firmware_command, sizeof(get_firmware_command), response_buffer, response_len,0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void configure_rf(PN532* pn532) {
|
||||||
|
pn532->log("Sending RF configuration command...");
|
||||||
|
// send_command(pn532, rf_config_command, sizeof(rf_config_command), response_buffer, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
int configure_sam(PN532* pn532) {
|
||||||
|
pn532->log("Sending SAM configuration command...");
|
||||||
|
uint8_t sam_config_command[] = {0x00, 0x00, 0xFF, 0x03, 0xFD, 0xD4, 0x14, 0x01, 0x17, 0x00 };
|
||||||
|
return send_command(pn532, sam_config_command, sizeof(sam_config_command), NULL, 0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_status(PN532* pn532) {
|
||||||
|
pn532->log("Sending get status command...");
|
||||||
|
// send_command(pn532, get_status_command, sizeof(get_status_command), response_buffer, 19);
|
||||||
|
}
|
||||||
|
|
||||||
|
void in_list_passive(PN532* pn532) {
|
||||||
|
pn532->log("Sending in list passive command...");
|
||||||
|
// send_command(pn532, in_list_passive_command, sizeof(in_list_passive_command), response_buffer, 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
int auto_poll_command(PN532* pn532) {
|
||||||
|
pn532->log("Sending auto poll command...");
|
||||||
|
uint8_t auto_poll[] = { 0x00, 0x00, 0xFF, 0x05, 0xFB, 0xD4, 0x60, 0xFF, 0x0F, 0x10, 0xAE, 0x00 };
|
||||||
|
return send_command(pn532, auto_poll, sizeof(auto_poll), NULL, 0,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int UART_MifareClassicAuthenticateBlock(
|
||||||
|
PN532* pn532,
|
||||||
|
uint8_t* uid,
|
||||||
|
uint8_t uid_length,
|
||||||
|
uint16_t block_number,
|
||||||
|
uint16_t key_number,
|
||||||
|
uint8_t* key
|
||||||
|
) {
|
||||||
|
uint8_t length=3+uid_length+MIFARE_KEY_LENGTH+2;
|
||||||
|
uint8_t auth_frame[56]={0};
|
||||||
|
|
||||||
|
auth_frame[0] = PN532_PREAMBLE;
|
||||||
|
auth_frame[1] = PN532_STARTCODE1;
|
||||||
|
auth_frame[2] = PN532_STARTCODE2;
|
||||||
|
|
||||||
|
auth_frame[5] = PN532_HOSTTOPN532;
|
||||||
|
auth_frame[6] = PN532_COMMAND_INDATAEXCHANGE & 0xFF;
|
||||||
|
auth_frame[7] = 0x01;
|
||||||
|
auth_frame[8] = key_number&0xff;//cmd
|
||||||
|
auth_frame[9] = block_number&0xff;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < MIFARE_KEY_LENGTH; i++) {
|
||||||
|
auth_frame[i+10]=key[i];
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < uid_length; i++) {
|
||||||
|
auth_frame[16+i]=uid[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auth_frame[3] = length & 0xFF;
|
||||||
|
auth_frame[4] = (~length+1 ) & 0xFF;
|
||||||
|
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
for (uint8_t i = 0; i < 3; i++) {
|
||||||
|
checksum += auth_frame[i];
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < length; i++) {
|
||||||
|
checksum += auth_frame[5+i];
|
||||||
|
}
|
||||||
|
auth_frame[length+5 ] = ~checksum & 0xFF;
|
||||||
|
auth_frame[length+5 + 1] = PN532_POSTAMBLE;
|
||||||
|
uint8_t l_resp[28]={0xff};
|
||||||
|
send_command(pn532, auth_frame, length+7, l_resp, 1,0);
|
||||||
|
if (l_resp[0] != PN532_ERROR_NONE) {
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
int UART_MifareClassicReadBlock(PN532* pn532, uint8_t* response, uint16_t block_number) {
|
||||||
|
|
||||||
|
uint8_t read_frame[32]={0};
|
||||||
|
uint8_t length=3+2;
|
||||||
|
read_frame[0] = PN532_PREAMBLE;
|
||||||
|
read_frame[1] = PN532_STARTCODE1;
|
||||||
|
read_frame[2] = PN532_STARTCODE2;
|
||||||
|
|
||||||
|
read_frame[5] = PN532_HOSTTOPN532;
|
||||||
|
read_frame[6] = PN532_COMMAND_INDATAEXCHANGE & 0xFF;
|
||||||
|
read_frame[7] = 0x01;
|
||||||
|
read_frame[8] = MIFARE_CMD_READ;//cmd
|
||||||
|
read_frame[9] = block_number&0xff;
|
||||||
|
|
||||||
|
|
||||||
|
read_frame[3] = length & 0xFF;
|
||||||
|
read_frame[4] = (~length+1) & 0xFF;
|
||||||
|
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
for (uint8_t i = 0; i < 3; i++) {
|
||||||
|
checksum += read_frame[i];
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < length; i++) {
|
||||||
|
checksum += read_frame[5+i];
|
||||||
|
}
|
||||||
|
read_frame[length+5 ] = ~checksum & 0xFF;
|
||||||
|
read_frame[length +5+ 1] = PN532_POSTAMBLE;
|
||||||
|
uint8_t l_resp[28]={0xff};
|
||||||
|
send_command(pn532, read_frame, length+7, l_resp, 17,0);
|
||||||
|
if (l_resp[0] != PN532_ERROR_NONE) {
|
||||||
|
return PN532_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < MIFARE_BLOCK_LENGTH; i++) {
|
||||||
|
response[i] = l_resp[i + 1];
|
||||||
|
}
|
||||||
|
return PN532_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
void vRTE_MatlabInit(void);
|
void vRTE_MatlabInit(void);
|
||||||
void vRTE_MatlabRun(void);
|
void vRTE_MatlabRun(void);
|
||||||
void vRTE_AppInit(void);
|
void vRTE_AppInit(void);
|
||||||
void vRTE_AppRunInit(void);
|
void vRTE_AppRun(void);
|
||||||
void vRTE_InitUartCanEcho(void);
|
void vRTE_InitUartCanEcho(void);
|
||||||
void vRTE_ProcessUartData(void);
|
void vRTE_ProcessUartData(void);
|
||||||
void vRTE_ProcessCanData(void);
|
void vRTE_ProcessCanData(void);
|
||||||
|
#define IVEC_RTE_LOG(x, ...)
|
||||||
#endif /* IVEC_RTE_INC_IVEC_RTE_H_ */
|
#endif /* IVEC_RTE_INC_IVEC_RTE_H_ */
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,18 @@
|
||||||
#include "../../Core/Include/ivec_mcal_gpio.h"
|
#include "../../Core/Include/ivec_mcal_gpio.h"
|
||||||
#include "socTouchDisplay.h"
|
#include "socTouchDisplay.h"
|
||||||
#include "../../TM1650_SDK/inc/ivec_TM1650.h"
|
#include "../../TM1650_SDK/inc/ivec_TM1650.h"
|
||||||
|
#include"ivec_bsw_nfc.h"
|
||||||
|
|
||||||
#include "ivec_rte.h"
|
#include "ivec_rte.h"
|
||||||
|
|
||||||
// UART Handles
|
// UART Handles
|
||||||
IVEC_EcuUartHandle_s g_xUartHandle;
|
IVEC_EcuUartHandle_s g_xUartHandle;
|
||||||
IVEC_EcuUartHandle_s g_xUart2Handle;
|
|
||||||
IVEC_EcuCANHandle_s g_xCanHandle;
|
IVEC_EcuCANHandle_s g_xCanHandle;
|
||||||
|
|
||||||
// Configuration Macros
|
// Configuration Macros
|
||||||
#define rteCONFIG_BASIL_BATTERY_SMART_u8 1
|
#define rteCONFIG_BASIL_BATTERY_SMART_u8 1
|
||||||
#define rteCONFIG_BASIL_u8 2
|
#define rteCONFIG_BASIL_u8 2
|
||||||
|
#define rteCONFIG_MOTHER_BOARD_u8 3
|
||||||
|
|
||||||
// UART Configuration
|
// UART Configuration
|
||||||
#define rteUART_PIN_SELECTION_u8 rteCONFIG_BASIL_u8
|
#define rteUART_PIN_SELECTION_u8 rteCONFIG_BASIL_u8
|
||||||
|
|
@ -216,11 +216,12 @@ void vRTE_MatlabRun(void)
|
||||||
|
|
||||||
void vRTE_AppInit(void)
|
void vRTE_AppInit(void)
|
||||||
{
|
{
|
||||||
#if rteUART_PIN_SELECTION_u8 == 1
|
#if rteUART_PIN_SELECTION_u8 == 1
|
||||||
vRTE_MatlabInit();
|
vRTE_MatlabInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vRTE_InitUartCanEcho();
|
vRTE_InitUartCanEcho();
|
||||||
|
vRTE_NfcInit();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Callback function for timer interrupt.
|
* @brief Callback function for timer interrupt.
|
||||||
|
|
@ -238,14 +239,8 @@ void vRTE_InitUartCanEcho(void)
|
||||||
{
|
{
|
||||||
g_xUartHandle.u8Qbuffer = g_prvU8CanUartDataBuffer;
|
g_xUartHandle.u8Qbuffer = g_prvU8CanUartDataBuffer;
|
||||||
g_xUartHandle.u16QbufSize = eteCAN_UART_BUFFER_MAX_SIZE_u32;
|
g_xUartHandle.u16QbufSize = eteCAN_UART_BUFFER_MAX_SIZE_u32;
|
||||||
|
|
||||||
#if (rteUART_PIN_SELECTION_u8 == 1)
|
|
||||||
g_xUartHandle.eUartPortNumber = IVEC_ECU_UART_PORT3;
|
|
||||||
g_xUartHandle.u32BaudRate = IVEC_ECU_UART_BAUD_115200;
|
|
||||||
#elif (rteUART_PIN_SELECTION_u8 == 2)
|
|
||||||
g_xUartHandle.eUartPortNumber = IVEC_ECU_UART_PORT2;
|
g_xUartHandle.eUartPortNumber = IVEC_ECU_UART_PORT2;
|
||||||
g_xUartHandle.u32BaudRate = IVEC_ECU_UART_BAUD_115200;
|
g_xUartHandle.u32BaudRate = IVEC_ECU_UART_BAUD_115200;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
xECU_UartInit(&g_xUartHandle);
|
xECU_UartInit(&g_xUartHandle);
|
||||||
|
|
@ -261,6 +256,11 @@ void vRTE_InitUartCanEcho(void)
|
||||||
}
|
}
|
||||||
xECU_CANInit(&g_xCanHandle);
|
xECU_CANInit(&g_xCanHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vRTE_NfcInit(void)
|
||||||
|
{
|
||||||
|
bBSW_NfcInit();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the application run processes.
|
* @brief Initializes the application run processes.
|
||||||
*
|
*
|
||||||
|
|
@ -269,11 +269,108 @@ void vRTE_InitUartCanEcho(void)
|
||||||
*
|
*
|
||||||
* @returns None
|
* @returns None
|
||||||
*/
|
*/
|
||||||
|
volatile bool g_bConfigured = false;
|
||||||
|
extern uint8_t u8MCAL_StoreMsgFromISRToQueue(uint32_t u32UlId, uint8_t* pu8Data, uint8_t u8Len);
|
||||||
|
void vRTE_UartNfcProcess(void)
|
||||||
|
{
|
||||||
|
static uint32_t a = 0;
|
||||||
|
if (i32MCAL_getTicks() - a > 2000 || g_bConfigured == false)
|
||||||
|
// if(g_bConfigured==false)
|
||||||
|
{
|
||||||
|
a = i32MCAL_getTicks();
|
||||||
|
|
||||||
void vRTE_AppRunInit(void)
|
if (bBSW_NfcTest())
|
||||||
|
{
|
||||||
|
if (g_bConfigured == false)
|
||||||
|
{
|
||||||
|
bBSW_NfcConfigure();//todo: make it one time call
|
||||||
|
g_bConfigured = true;
|
||||||
|
}
|
||||||
|
i328BSW_NfcAutoPollMIFARE();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_bConfigured = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint8_t l_pu8Uid[16] = { 0 };
|
||||||
|
int l_UidLen = i328BSW_NfcScanMIFARE(l_pu8Uid);
|
||||||
|
if (l_UidLen > 0)
|
||||||
|
{
|
||||||
|
a = i32MCAL_getTicks();
|
||||||
|
uint8_t l_pu8Keyb[] = { 0xff,0xff,0xff,0xff,0xff,0xff };
|
||||||
|
uint8_t l_pu8NfcData[32] = { 0 };
|
||||||
|
IVEC_RTE_LOG("Found MIFARE card with UID: %02x %02x %02x %02x ", l_pu8Uid[0], l_pu8Uid[1], l_pu8Uid[2], l_pu8Uid[3]);
|
||||||
|
if (bBSW_NfcMifareClassicDataRead(l_pu8Uid, l_UidLen, 8, l_pu8Keyb, IVEC_BSW_NFC_MIFRAE_AUTH_B, l_pu8NfcData))
|
||||||
|
{
|
||||||
|
IVEC_RTE_LOG("Nfc Read 8");
|
||||||
|
for (int i = 0;i < 16;i++)
|
||||||
|
{
|
||||||
|
IVEC_RTE_LOG("Block 8[%d]->0x%02x", i, l_pu8NfcData[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bBSW_NfcMifareClassicDataRead(l_pu8Uid, l_UidLen, 9, l_pu8Keyb, IVEC_BSW_NFC_MIFRAE_AUTH_B, &l_pu8NfcData[16]))
|
||||||
|
{
|
||||||
|
// g_bConfigured = false;
|
||||||
|
IVEC_RTE_LOG("Nfc Read 9");
|
||||||
|
for (int i = 0;i < 16;i++)
|
||||||
|
{
|
||||||
|
IVEC_RTE_LOG("Block 9[%d]->0x%02x", i, l_pu8NfcData[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//1->4bytesuid
|
||||||
|
//2-4->block8
|
||||||
|
//5-7->block9
|
||||||
|
uint8_t l_u8NfcCanData[8] = { 0 };
|
||||||
|
|
||||||
|
l_u8NfcCanData[0] = 1;
|
||||||
|
for (int i = 0;i < 4;i++)
|
||||||
|
l_u8NfcCanData[i + 1] = l_pu8Uid[i];
|
||||||
|
u8MCAL_StoreMsgFromISRToQueue(0x76969, l_u8NfcCanData, 8);
|
||||||
|
|
||||||
|
l_u8NfcCanData[0] = 2;
|
||||||
|
for (int i = 0;i < 7;i++)
|
||||||
|
l_u8NfcCanData[i + 1] = l_pu8NfcData[i];
|
||||||
|
u8MCAL_StoreMsgFromISRToQueue(0x76969, l_u8NfcCanData, 8);
|
||||||
|
|
||||||
|
l_u8NfcCanData[0] = 3;
|
||||||
|
for (int i = 0;i < 7;i++)
|
||||||
|
l_u8NfcCanData[i + 1] = l_pu8NfcData[7 + i];
|
||||||
|
u8MCAL_StoreMsgFromISRToQueue(0x76969, l_u8NfcCanData, 8);
|
||||||
|
memset(l_u8NfcCanData,0,8);
|
||||||
|
l_u8NfcCanData[0] = 4;
|
||||||
|
for (int i = 0;i < 2;i++)
|
||||||
|
l_u8NfcCanData[i + 1] = l_pu8NfcData[14 + i];
|
||||||
|
u8MCAL_StoreMsgFromISRToQueue(0x76969, l_u8NfcCanData, 8);
|
||||||
|
|
||||||
|
l_u8NfcCanData[0] = 5;
|
||||||
|
for (int i = 0;i < 7;i++)
|
||||||
|
l_u8NfcCanData[i + 1] = l_pu8NfcData[16 + i];
|
||||||
|
u8MCAL_StoreMsgFromISRToQueue(0x76969, l_u8NfcCanData, 8);
|
||||||
|
|
||||||
|
l_u8NfcCanData[0] = 6;
|
||||||
|
for (int i = 0;i < 7;i++)
|
||||||
|
l_u8NfcCanData[i + 1] = l_pu8NfcData[23 + i];
|
||||||
|
u8MCAL_StoreMsgFromISRToQueue(0x76969, l_u8NfcCanData, 8);
|
||||||
|
|
||||||
|
memset(l_u8NfcCanData,0,8);
|
||||||
|
l_u8NfcCanData[0] = 7;
|
||||||
|
for (int i = 0;i < 2;i++)
|
||||||
|
l_u8NfcCanData[i + 1] = l_pu8NfcData[30 + i];
|
||||||
|
u8MCAL_StoreMsgFromISRToQueue(0x76969, l_u8NfcCanData, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
void vRTE_AppRun(void)
|
||||||
{
|
{
|
||||||
vRTE_ProcessUartData();
|
vRTE_ProcessUartData();
|
||||||
vRTE_ProcessCanData();
|
vRTE_ProcessCanData();
|
||||||
|
vRTE_UartNfcProcess();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Callback function for timer interrupt.
|
* @brief Callback function for timer interrupt.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue