Update repo
This commit is contained in:
1 parent
749dab5721
commit
ce65a0f59a
14950 files changed
+4408250
-1
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex16_daisy_handshake_lead"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex16_daisy_handshake_lead.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex16_daisy_handshake_node"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex16_daisy_handshake_node.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex1_loopback_cpucontrol"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex1_loopback_cpucontrol.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex2_loopback_clacontrol"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../../../device_support/f2838x/common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../../../device_support/f2838x/headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/headers/source/f2838x_globalvariabledefs.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex2_loopback_clacontrol.c" targetDirectory="" />
|
||||
<file action="copy" path="../fsi_ex2_loopback_clacontrol_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../fsi_ex2_loopback_clacontrol_cla_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex3_loopback_dmacontrol"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
;if ${GUI_SUPPORT} == 1 "${BuildDirectory}/syscfg/gui_setup.bat"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --define=generic_ram_lnk --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs -ldevice_cmd.cmd.genlibs --define=generic_ram_lnk" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} --define=_FLASH --define=generic_flash_lnk -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs -ldevice_cmd.cmd.genlibs --define=generic_flash_lnk" />
|
||||
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="CLB_DEBUG" value="0" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<buildVariable name="GUI_SUPPORT" value="0" scope="project" />
|
||||
<file action="copy" path="../fsi_ex3_loopback_dmacontrol.c" targetDirectory="" />
|
||||
<file action="copy" path="../fsi_ex3_loopback_dmacontrol.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex4_loopback_epwmtrigger"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex4_loopback_epwmtrigger.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex5_periodic_frame"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex5_periodic_frame.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex6_spi_main_tx"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --vcu_support=vcrc --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --vcu_support=vcrc --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex6_spi_main_tx.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex7_spi_remote_rx"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --vcu_support=vcrc --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --vcu_support=vcrc --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex7_spi_remote_rx.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex8_ext_p2pconnection_rx"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex8_ext_p2pconnection_rx.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex8_ext_p2pconnection_tx"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex8_ext_p2pconnection_tx.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fsi_ex9_star_broadcast"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../fsi_ex9_star_broadcast.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,946 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex16_daisy_handshake_lead.c
|
||||
//
|
||||
// TITLE: FSI daisy chain topology, lead device example
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> FSI daisy chain topology, lead device example </h1>
|
||||
//! fsi_ex16_daisy_handshake_lead is for the lead device in the daisy-chain
|
||||
//! loop, fsi_ex16_daisy_handshake_node for the other N-1 devices(N>=2).
|
||||
//!
|
||||
//! In the code, there are different settings provided:
|
||||
//! [#define FSI_DMA_ENABLE 0] represents FSI communication using CPU control.
|
||||
//! [#define FSI_DMA_ENABLE 1] represents FSI communication using DMA control,
|
||||
//! enabling FSIRX to trigger a DMA event and move the RX FSI data to the
|
||||
//! TX FSI buffer
|
||||
//!
|
||||
//! In a real scenario two separate devices may power up in arbitrary order and
|
||||
//! there is a need to establish a clean communication link which ensures that
|
||||
//! receiver side is flushed to properly interpret the start of a new valid
|
||||
//! frame.
|
||||
//!
|
||||
//! The node devices in the daisy chain topology respond to the handshake
|
||||
//! sequence and forwards the information to the next device in the chain.
|
||||
//!
|
||||
//! After above synchronization steps, FSI Rx can be configured as per use case
|
||||
//! i.e. nWords, lane width, enabling events, etc and start the infinite
|
||||
//! transfers. More details on establishing the communication link can be found
|
||||
//! in the device TRM.
|
||||
//!
|
||||
//! User can edit some of configuration parameters as per use case, similar to
|
||||
//! other examples.
|
||||
//!
|
||||
//! \b nWords - Number of words per transfer may be from 1 -16
|
||||
//! \b nLanes - Choice to select single or double lane for frame transfers
|
||||
//! \b txUserData - User data to be sent with Data frame
|
||||
//! \b txDataFrameTag - Frame tag used for Data transfers
|
||||
//! \b txPingFrameTag - Frame tag used for Ping transfers
|
||||
//! \b txPingTimeRefCntr - Tx Ping timer reference counter
|
||||
//! \b rxWdTimeoutRefCntr - Rx Watchdog timeout reference counter
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For the FSI daisy-chain topology external connections are required to
|
||||
//! be made between the devices in the chain. Each devices FSI TX pins need to
|
||||
//! be connected to the FSI RX pins of the next device in the chain (or ring).
|
||||
//! See below for external connections to include and GPIOs used:
|
||||
//!
|
||||
//! External Connections Required:
|
||||
//! - FSIRX_CLK to FSITX_CLK
|
||||
//! - FSIRX_RX0 to FSITX_TX0
|
||||
//! - FSIRX_RX1 to FSITX_TX1
|
||||
//!
|
||||
//! ControlCard FSI Header GPIOs:
|
||||
//! - GPIO_27 -> FSITXA_CLK
|
||||
//! - GPIO_26 -> FSITXA_TX0
|
||||
//! - GPIO_25 -> FSITXA_TX1
|
||||
//! - GPIO_9 -> FSIRXA_CLK
|
||||
//! - GPIO_8 -> FSIRXA_RX0
|
||||
//! - GPIO_10 -> FSIRXA_RX1
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frames received back
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
#define FSI_DMA_ENABLE 1
|
||||
#define TX_DMA_TRIGGER_ENABLE 0
|
||||
|
||||
#define PRESCALER_VAL FSI_PRESCALE_50MHZ
|
||||
|
||||
#define FSI_DELAY_LINE_CALIBRATION_ENABLE 0
|
||||
|
||||
#define DMA_TRANSFER_SIZE_IN_BURSTS 1U
|
||||
#define DMA_WRAP_SIZE_IN_BURSTS 1U
|
||||
#define TOTAL_WORDS_IN_TRANSFER (DMA_TRANSFER_SIZE_IN_BURSTS * nWords)
|
||||
|
||||
// GS0 RAM to store Tx frame data which DMA will read
|
||||
#define GS0_START_ADDR 0xD100
|
||||
// GS1 RAM to store Tx frame tag and Userdata
|
||||
#define GS1_START_ADDR 0xE000
|
||||
// GS2 RAM to save received Rx frame data
|
||||
#define GS2_START_ADDR 0xF000
|
||||
// GS3 RAM to save received Rx frame tag and Userdata
|
||||
#define GS3_START_ADDR 0x10000
|
||||
|
||||
//
|
||||
// FSI Tx/Rx Frame tag User Data register address, used by DMA channel to
|
||||
// write(and trigger transfer) read userdata respectively
|
||||
//
|
||||
#define FSI_TX_FRAME_TAG_UDATA_REGADDR (FSITXA_BASE + FSI_O_TX_FRAME_TAG_UDATA)
|
||||
#define FSI_RX_FRAME_TAG_UDATA_REGADDR (FSIRXA_BASE + FSI_O_RX_FRAME_TAG_UDATA)
|
||||
|
||||
#define DATA_FRAME_TEST_IO 16
|
||||
#define DATA_FRAME_TEST_IO_CONF GPIO_16_GPIO16
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1 -16
|
||||
//
|
||||
uint16_t nWords = 8;
|
||||
|
||||
// Transfer can be happen over single or double lane
|
||||
FSI_DataWidth nLanes = FSI_DATA_WIDTH_1_LANE;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10, txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// User data to be sent with Data frame(for CPU control)
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
// Tx Ping timer and Rx Watchdog reference counter values
|
||||
uint32_t txPingTimeRefCntr = 0x1000000, rxWdTimeoutRefCntr = 0x1400000;
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
uint16_t rxBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
uint32_t txTimeOutCntr = 0x100000, rxTimeOutCntr = 0x100000;
|
||||
uint32_t dataFrameCntr = 0, dataFrameCntr_ui32 = 0;
|
||||
|
||||
uint32_t dmaIntr1 = 0, dmaIntr2 = 0;
|
||||
volatile uint16_t i = 0, *txTempData16 = 0, *rxTempData16 = 0;
|
||||
uint32_t dmaTxIntCnt = 0, dmaRxIntCnt = 0;
|
||||
uint32_t error = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void initFSI(void);
|
||||
void prepareTxBufData(void);
|
||||
void testGPIO(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
__interrupt void fsitxdma_isr(void);
|
||||
__interrupt void fsirxdma_isr(void);
|
||||
void fsitx_dma_config();
|
||||
void fsirx_dma_config();
|
||||
void InitFrameTagAndData();
|
||||
void UpdateTxframeData();
|
||||
void handshake_lead(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
testGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Initialize basic settings for FSI
|
||||
//
|
||||
initFSI();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
#if FSI_DMA_ENABLE==1
|
||||
|
||||
//
|
||||
// DMA Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file.
|
||||
//
|
||||
Interrupt_register(INT_DMA_CH2, &fsitxdma_isr);
|
||||
Interrupt_register(INT_DMA_CH4, &fsirxdma_isr);
|
||||
|
||||
//
|
||||
// Enable DMA interrupts
|
||||
//
|
||||
Interrupt_enable(INT_DMA_CH2);
|
||||
Interrupt_enable(INT_DMA_CH4);
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Enable normal data receive events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_PING_FRAME);
|
||||
|
||||
//
|
||||
// Begin handshake -
|
||||
// Wait till interrupt is received on FSIRX INT1 line, verify it's for FRAME
|
||||
// DONE event for PING Frame reception
|
||||
//
|
||||
handshake_lead();
|
||||
|
||||
#if FSI_DELAY_LINE_CALIBRATION_ENABLE
|
||||
|
||||
// TODO - Implement FSI RX delay line calibration here
|
||||
// to compensate for channel-to-channel skew.
|
||||
// See Application Report SPRACJ9 and respective
|
||||
// software examples within C2000ware.
|
||||
|
||||
#endif
|
||||
|
||||
// Setting for requested nWords and nLanes with transfers
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
FSI_setTxSoftwareFrameSize(FSITXA_BASE, nWords);
|
||||
FSI_setTxDataWidth(FSITXA_BASE, nLanes);
|
||||
// RX setting part
|
||||
FSI_setRxSoftwareFrameSize(FSIRXA_BASE, nWords);
|
||||
FSI_setRxDataWidth(FSIRXA_BASE, nLanes);
|
||||
|
||||
|
||||
//
|
||||
// Enable transmit/receive error events to be sent over INT2 line
|
||||
// Overrun and Underrun conditions in Rx are not enabled as buffer pointers
|
||||
// are always overwritten to first location for sending data frames.
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_CRC_ERR |
|
||||
FSI_RX_EVT_EOF_ERR |
|
||||
FSI_RX_EVT_TYPE_ERR);
|
||||
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_PING_FRAME);
|
||||
DEVICE_DELAY_US(10);
|
||||
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
|
||||
DEVICE_DELAY_US(1000); // Delay needed for Node setup time
|
||||
|
||||
#if FSI_DMA_ENABLE==0
|
||||
|
||||
FSI_setTxUserDefinedData(FSITXA_BASE, txUserData);
|
||||
FSI_setTxFrameTag(FSITXA_BASE, txDataFrameTag);
|
||||
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_DATA_FRAME);
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Initialize the dma channels for both tx and rx buffers
|
||||
//
|
||||
DMA_initController();
|
||||
|
||||
fsirx_dma_config();
|
||||
fsitx_dma_config();
|
||||
|
||||
FSI_setTxStartMode(FSITXA_BASE, FSI_TX_START_FRAME_CTRL_OR_UDATA_TAG);
|
||||
|
||||
#if TX_DMA_TRIGGER_ENABLE == 1
|
||||
// Enable DMA event on FSI Tx
|
||||
FSI_enableTxDMAEvent(FSITXA_BASE);
|
||||
#endif
|
||||
|
||||
// Enable DMA event on FSI Rx
|
||||
FSI_enableRxDMAEvent(FSIRXA_BASE);
|
||||
|
||||
InitFrameTagAndData();
|
||||
|
||||
// Start TX /RX channels
|
||||
|
||||
DMA_startChannel(DMA_CH1_BASE);
|
||||
DMA_startChannel(DMA_CH2_BASE);
|
||||
|
||||
DMA_startChannel(DMA_CH3_BASE);
|
||||
DMA_startChannel(DMA_CH4_BASE);
|
||||
|
||||
// use software to trigger the first transfer
|
||||
DMA_forceTrigger(DMA_CH1_BASE);
|
||||
DMA_forceTrigger(DMA_CH2_BASE);
|
||||
#endif
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
#if FSI_DMA_ENABLE==0
|
||||
|
||||
// Now, start transmitting data frames
|
||||
|
||||
// Fill TX array with new data
|
||||
prepareTxBufData();
|
||||
|
||||
// Write data into Tx buffer
|
||||
// Start the first transfer
|
||||
FSI_writeTxBuffer(FSITXA_BASE, txBufData, nWords, 0U);
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Wait for TX frame done event
|
||||
//
|
||||
while(fsiTxInt1Received != 1U);
|
||||
|
||||
//
|
||||
// Wait for RX data frame received event
|
||||
//
|
||||
while(fsiRxInt1Received != 1U);
|
||||
|
||||
if(error == 0)
|
||||
{
|
||||
fsiTxInt1Received = 0U;
|
||||
fsiRxInt1Received = 0U;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Error occurred during communications
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
#else
|
||||
//
|
||||
// Wait for both TX and RX channels to complete a transfer
|
||||
//
|
||||
while(dmaIntr1 == 0U); // TX Int flag
|
||||
dmaIntr1 = 0;
|
||||
|
||||
while(dmaIntr2 == 0U); // RX Int flag
|
||||
dmaIntr2 = 0;
|
||||
|
||||
if(error != 0)
|
||||
{
|
||||
DMA_disableInterrupt(DMA_CH2_BASE);
|
||||
DMA_disableInterrupt(DMA_CH4_BASE);
|
||||
|
||||
// Error occurred during communications
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void handshake_lead(void)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Send the flush sequence
|
||||
//
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Send a ping frame with frame tag 0000b
|
||||
//
|
||||
FSI_setTxFrameTag(FSITXA_BASE, FSI_FRAME_TAG0);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_PING);
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
while(fsiRxInt1Received != 1U && rxTimeOutCntr != 0U)
|
||||
{
|
||||
DEVICE_DELAY_US(1);
|
||||
rxTimeOutCntr--;
|
||||
}
|
||||
|
||||
if(rxTimeOutCntr == 0)
|
||||
{
|
||||
rxTimeOutCntr = 0x100000;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(rxEventSts, (FSI_RX_EVT_PING_FRAME | FSI_RX_EVT_FRAME_DONE));
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_PING, FSI_FRAME_TAG0);
|
||||
|
||||
//
|
||||
// If received frame type and tag matches, exit this loop and proceed
|
||||
// to next step by sending flush sequence, otherwise clear error and
|
||||
// interrupt flag and continue looping.
|
||||
//
|
||||
if(error == 0)
|
||||
{
|
||||
fsiRxInt1Received = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
fsiRxInt1Received = 0;
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Send a ping frame with frame tag 0001b
|
||||
//
|
||||
FSI_setTxFrameTag(FSITXA_BASE, FSI_FRAME_TAG1);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_PING);
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
while(fsiRxInt1Received != 1U && rxTimeOutCntr != 0U)
|
||||
{
|
||||
DEVICE_DELAY_US(1);
|
||||
rxTimeOutCntr--;
|
||||
}
|
||||
|
||||
if(rxTimeOutCntr == 0)
|
||||
{
|
||||
rxTimeOutCntr = 0x100000;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(rxEventSts, (FSI_RX_EVT_PING_FRAME | FSI_RX_EVT_FRAME_DONE));
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_PING, FSI_FRAME_TAG1);
|
||||
|
||||
//
|
||||
// If received frame type and tag matches, exit this loop and proceed
|
||||
// to next step by sending flush sequence, otherwise clear error and
|
||||
// interrupt flag and continue looping.
|
||||
//
|
||||
if(error == 0)
|
||||
{
|
||||
fsiRxInt1Received = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
fsiRxInt1Received = 0;
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// initFSI - Initializes FSI Tx/Rx and also sends FLUSH sequence.
|
||||
//
|
||||
void initFSI(void)
|
||||
{
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
//
|
||||
// NOTE: External loopback, Modify GPIO settings as per setup
|
||||
//
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TXCLK);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX0);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RXCLKA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX0A);
|
||||
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX1A);
|
||||
}
|
||||
|
||||
//
|
||||
// Set RX GPIO to be asynchronous
|
||||
// (pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX1A, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX0A, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RXCLKA, GPIO_QUAL_ASYNC);
|
||||
|
||||
// Could add logic to calculate PRESCALER_VAL based on user input FSI CLK
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
FSI_performRxInitialization(FSIRXA_BASE);
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// prepareTxBufData - Update array which is used as source to Tx data buffer
|
||||
//
|
||||
void prepareTxBufData(void)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t value = txBufData[nWords-1];
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
txBufData[i] = value + i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
// Set FSI TX circular buffer pointer back to beginning
|
||||
FSI_setTxBufferPtr(FSITXA_BASE, 0U);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
if((rxEventSts & FSI_RX_EVT_DATA_FRAME) != 0)
|
||||
{
|
||||
//
|
||||
// Verify TX data is same as RX data
|
||||
//
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_NWORD_DATA, txDataFrameTag);
|
||||
compare16(FSI_getRxUserDefinedData(FSIRXA_BASE), txUserData);
|
||||
compareBufData(0, 0, nWords);
|
||||
|
||||
dataFrameCntr++;
|
||||
|
||||
if(dataFrameCntr >= 0xFFFFFFFF)
|
||||
{
|
||||
dataFrameCntr_ui32++;
|
||||
dataFrameCntr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
|
||||
// Set FSI RX circular buffer pointer back to beginning
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//11.24
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t rxDataArray[16];
|
||||
|
||||
FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, rxBufIndex);
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxDataArray[i] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
void testGPIO(void)
|
||||
{
|
||||
GPIO_setDirectionMode(DATA_FRAME_TEST_IO,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(DATA_FRAME_TEST_IO,GPIO_QUAL_ASYNC);
|
||||
GPIO_setPinConfig(DATA_FRAME_TEST_IO_CONF);
|
||||
|
||||
GPIO_writePin(DATA_FRAME_TEST_IO,1);
|
||||
}
|
||||
|
||||
//
|
||||
// fsitx_dma_config - Sets up DMA channels(Ch1 and Ch2) for FSI Tx operation
|
||||
//
|
||||
void fsitx_dma_config()
|
||||
{
|
||||
//
|
||||
// GS0 RAM to store Tx frame data which DMA will read
|
||||
// for the data buffers
|
||||
//
|
||||
DMA_configAddresses(DMA_CH1_BASE, txBufAddr, (uint16_t *)GS0_START_ADDR);
|
||||
DMA_configBurst(DMA_CH1_BASE, nWords, 1, 1);
|
||||
DMA_configTransfer(DMA_CH1_BASE, DMA_TRANSFER_SIZE_IN_BURSTS, 0, 0);
|
||||
DMA_configWrap(DMA_CH1_BASE, DMA_WRAP_SIZE_IN_BURSTS, 0,
|
||||
DMA_WRAP_SIZE_IN_BURSTS, 0);
|
||||
|
||||
#if TX_DMA_TRIGGER_ENABLE == 1
|
||||
DMA_configMode(DMA_CH1_BASE, DMA_TRIGGER_FSITXA, DMA_CFG_ONESHOT_DISABLE|
|
||||
DMA_CFG_CONTINUOUS_ENABLE | DMA_CFG_SIZE_16BIT);
|
||||
#else
|
||||
DMA_configMode(DMA_CH1_BASE, DMA_TRIGGER_SOFTWARE, DMA_CFG_ONESHOT_DISABLE|
|
||||
DMA_CFG_CONTINUOUS_ENABLE | DMA_CFG_SIZE_16BIT);
|
||||
#endif
|
||||
|
||||
DMA_disableInterrupt(DMA_CH1_BASE);
|
||||
DMA_enableTrigger(DMA_CH1_BASE);
|
||||
|
||||
//
|
||||
// For the tag and userdata fields
|
||||
//
|
||||
DMA_configAddresses(DMA_CH2_BASE, (uint16_t *)FSI_TX_FRAME_TAG_UDATA_REGADDR,
|
||||
(uint16_t *)GS1_START_ADDR);
|
||||
DMA_configBurst(DMA_CH2_BASE, 1, 0, 0);
|
||||
DMA_configTransfer(DMA_CH2_BASE, DMA_TRANSFER_SIZE_IN_BURSTS, 0, 0);
|
||||
DMA_configWrap(DMA_CH2_BASE, DMA_WRAP_SIZE_IN_BURSTS, 0,
|
||||
DMA_WRAP_SIZE_IN_BURSTS, 0);
|
||||
|
||||
#if TX_DMA_TRIGGER_ENABLE == 1
|
||||
DMA_configMode(DMA_CH2_BASE, DMA_TRIGGER_FSITXA, DMA_CFG_ONESHOT_DISABLE|
|
||||
DMA_CFG_CONTINUOUS_ENABLE | DMA_CFG_SIZE_16BIT);
|
||||
#else
|
||||
DMA_configMode(DMA_CH2_BASE, DMA_TRIGGER_SOFTWARE, DMA_CFG_ONESHOT_DISABLE|
|
||||
DMA_CFG_CONTINUOUS_ENABLE | DMA_CFG_SIZE_16BIT);
|
||||
#endif
|
||||
|
||||
DMA_setInterruptMode(DMA_CH2_BASE, DMA_INT_AT_END);
|
||||
DMA_enableInterrupt(DMA_CH2_BASE);
|
||||
|
||||
DMA_enableTrigger(DMA_CH2_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// fsirx_dma_config - Sets up DMA channels(Ch3 and Ch4) for FSI Rx operation
|
||||
//
|
||||
void fsirx_dma_config()
|
||||
{
|
||||
//
|
||||
// GS2 RAM to save received Rx frame data
|
||||
//
|
||||
DMA_configAddresses(DMA_CH3_BASE, (uint16_t *)GS2_START_ADDR, rxBufAddr);
|
||||
DMA_configBurst(DMA_CH3_BASE, nWords, 1, 1);
|
||||
DMA_configTransfer(DMA_CH3_BASE, DMA_TRANSFER_SIZE_IN_BURSTS, 0, 0);
|
||||
DMA_configWrap(DMA_CH3_BASE, DMA_WRAP_SIZE_IN_BURSTS, 0,
|
||||
DMA_WRAP_SIZE_IN_BURSTS, 0);
|
||||
DMA_configMode(DMA_CH3_BASE, DMA_TRIGGER_FSIRXA, DMA_CFG_ONESHOT_DISABLE|
|
||||
DMA_CFG_CONTINUOUS_ENABLE |DMA_CFG_SIZE_16BIT);
|
||||
|
||||
DMA_disableInterrupt(DMA_CH3_BASE);
|
||||
DMA_enableTrigger(DMA_CH3_BASE);
|
||||
|
||||
//
|
||||
// For the tag and userdata fields
|
||||
//
|
||||
DMA_configAddresses(DMA_CH4_BASE,(uint16_t *)GS3_START_ADDR,
|
||||
(uint16_t *)FSI_RX_FRAME_TAG_UDATA_REGADDR);
|
||||
DMA_configBurst(DMA_CH4_BASE, 1, 0, 0);
|
||||
DMA_configTransfer(DMA_CH4_BASE, DMA_TRANSFER_SIZE_IN_BURSTS, 0, 0);
|
||||
DMA_configWrap(DMA_CH4_BASE, DMA_WRAP_SIZE_IN_BURSTS, 0,
|
||||
DMA_WRAP_SIZE_IN_BURSTS, 0);
|
||||
DMA_configMode(DMA_CH4_BASE, DMA_TRIGGER_FSIRXA, DMA_CFG_ONESHOT_DISABLE |
|
||||
DMA_CFG_CONTINUOUS_ENABLE | DMA_CFG_SIZE_16BIT);
|
||||
|
||||
DMA_setInterruptMode(DMA_CH4_BASE, DMA_INT_AT_END);
|
||||
DMA_enableInterrupt(DMA_CH4_BASE);
|
||||
DMA_enableTrigger(DMA_CH4_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// InitFrameTagAndData - Initializes GS0/GS1 memories to populate tag and data
|
||||
// for frame transfers
|
||||
//
|
||||
void InitFrameTagAndData(void)
|
||||
{
|
||||
unsigned int i;
|
||||
uint16_t *temp;
|
||||
|
||||
temp = (uint16_t *)GS0_START_ADDR;
|
||||
for(i = 0; i < TOTAL_WORDS_IN_TRANSFER; i++)
|
||||
{
|
||||
*temp = i;
|
||||
temp++;
|
||||
}
|
||||
|
||||
temp = (uint16_t *)GS1_START_ADDR;
|
||||
for(i = FSI_FRAME_TAG0; i < FSI_FRAME_TAG15; i++)
|
||||
{
|
||||
//
|
||||
//tag and user data
|
||||
//
|
||||
*temp = ((0x0 + i) | ((unsigned long)(0x0 + i) << 8));
|
||||
temp++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// UpdateTxframeData - Updates GS0 memory with new data for frame transfer
|
||||
//
|
||||
void UpdateTxframeData(void)
|
||||
{
|
||||
unsigned int i;
|
||||
uint16_t *temp;
|
||||
|
||||
temp = (uint16_t *)GS0_START_ADDR;
|
||||
for(i = 0; i < TOTAL_WORDS_IN_TRANSFER; i++)
|
||||
{
|
||||
*temp = *temp + 1;
|
||||
temp++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// fsitxdma_isr - FSI TX DMA ISR
|
||||
//
|
||||
interrupt void fsitxdma_isr(void)
|
||||
{
|
||||
GPIO_writePin(DATA_FRAME_TEST_IO,0);
|
||||
|
||||
dmaTxIntCnt++; // Increment DMA TX interrupt counter
|
||||
|
||||
dmaIntr1 = 1;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
|
||||
}
|
||||
|
||||
//
|
||||
// fsirxdma_isr - FSI RX DMA ISR
|
||||
//
|
||||
interrupt void fsirxdma_isr(void)
|
||||
{
|
||||
GPIO_writePin(DATA_FRAME_TEST_IO,1);
|
||||
|
||||
// Set FSI RX circular buffer pointer back to beginning
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
|
||||
dmaRxIntCnt++; // Increment DMA RX interrupt counter
|
||||
|
||||
#if TX_DMA_TRIGGER_ENABLE == 0
|
||||
|
||||
//
|
||||
// Verify TX data is same as RX data
|
||||
//
|
||||
txTempData16 = (uint16_t *)(GS0_START_ADDR);
|
||||
rxTempData16 = (uint16_t *)(GS2_START_ADDR);
|
||||
|
||||
for(i = 0; i < TOTAL_WORDS_IN_TRANSFER; i++)
|
||||
{
|
||||
compare16(*txTempData16,*rxTempData16);
|
||||
txTempData16++;
|
||||
rxTempData16++;
|
||||
}
|
||||
|
||||
dataFrameCntr++;
|
||||
|
||||
if(dataFrameCntr >= 0xFFFFFFFF)
|
||||
{
|
||||
dataFrameCntr_ui32++;
|
||||
dataFrameCntr = 0;
|
||||
}
|
||||
|
||||
UpdateTxframeData(); // Update TX Frame data (GS0 memory)
|
||||
|
||||
// Trigger TX DMA channels 1 & 2
|
||||
DMA_forceTrigger(DMA_CH1_BASE);
|
||||
DMA_forceTrigger(DMA_CH2_BASE);
|
||||
|
||||
#endif
|
||||
|
||||
dmaIntr2 = 1;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
|
||||
}
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,754 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex16_daisy_handshake_node.c
|
||||
//
|
||||
// TITLE: FSI daisy chain topology, node device example
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> FSI daisy chain topology, node device example </h1>
|
||||
//! fsi_ex16_daisy_handshake_lead is for the lead device in the daisy-chain
|
||||
//! loop, fsi_ex16_daisy_handshake_node for the other N-1 devices(N>=2).
|
||||
//!
|
||||
//! In the code, there are different settings provided:
|
||||
//! [#define FSI_DMA_ENABLE 0] represents FSI communication using CPU control.
|
||||
//! [#define FSI_DMA_ENABLE 1] represents FSI communication using DMA control,
|
||||
//! enabling FSIRX to trigger a DMA event and move the RX FSI data to the
|
||||
//! TX FSI buffer
|
||||
//!
|
||||
//! In a real scenario two separate devices may power up in arbitrary order and
|
||||
//! there is a need to establish a clean communication link which ensures that
|
||||
//! receiver side is flushed to properly interpret the start of a new valid
|
||||
//! frame.
|
||||
//!
|
||||
//! The node devices in the daisy chain topology respond to the handshake
|
||||
//! sequence and forwards the information to the next device in the chain.
|
||||
//!
|
||||
//! After above synchronization steps, FSI Rx can be configured as per use case
|
||||
//! i.e. nWords, lane width, enabling events, etc and start the infinite
|
||||
//! transfers. More details on establishing the communication link can be found
|
||||
//! in the device TRM.
|
||||
//!
|
||||
//! User can edit some of configuration parameters as per use case, similar to
|
||||
//! other examples.
|
||||
//!
|
||||
//! \b nWords - Number of words per transfer may be from 1 -16
|
||||
//! \b nLanes - Choice to select single or double lane for frame transfers
|
||||
//! \b txUserData - User data to be sent with Data frame
|
||||
//! \b txDataFrameTag - Frame tag used for Data transfers
|
||||
//! \b txPingFrameTag - Frame tag used for Ping transfers
|
||||
//! \b txPingTimeRefCntr - Tx Ping timer reference counter
|
||||
//! \b rxWdTimeoutRefCntr - Rx Watchdog timeout reference counter
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For the FSI daisy-chain topology external connections are required to
|
||||
//! be made between the devices in the chain. Each devices FSI TX pins need to
|
||||
//! be connected to the FSI RX pins of the next device in the chain (or ring).
|
||||
//! See below for external connections to include and GPIOs used:
|
||||
//!
|
||||
//! External Connections Required:
|
||||
//! - FSIRX_CLK to FSITX_CLK
|
||||
//! - FSIRX_RX0 to FSITX_TX0
|
||||
//! - FSIRX_RX1 to FSITX_TX1
|
||||
//!
|
||||
//! ControlCard FSI Header GPIOs:
|
||||
//! - GPIO_27 -> FSITXA_CLK
|
||||
//! - GPIO_26 -> FSITXA_TX0
|
||||
//! - GPIO_25 -> FSITXA_TX1
|
||||
//! - GPIO_9 -> FSIRXA_CLK
|
||||
//! - GPIO_8 -> FSIRXA_RX0
|
||||
//! - GPIO_10 -> FSIRXA_RX1
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frames received back
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
#define FSI_DMA_ENABLE 1
|
||||
|
||||
#define FSI_DELAY_LINE_CALIBRATION_ENABLE 0
|
||||
|
||||
#define PRESCALER_VAL FSI_PRESCALE_50MHZ
|
||||
|
||||
#define DMA_TRANSFER_SIZE_IN_BURSTS 1U
|
||||
#define DMA_WRAP_SIZE_IN_BURSTS 1U
|
||||
#define TOTAL_WORDS_IN_TRANSFER (DMA_TRANSFER_SIZE_IN_BURSTS * nWords)
|
||||
|
||||
#define DATA_FRAME_TEST_IO 16
|
||||
#define DATA_FRAME_TEST_IO_CONF GPIO_16_GPIO16
|
||||
|
||||
#define TX_TIME_OUT_CNTR 0x1000000
|
||||
#define RX_TIME_OUT_CNTR 0x1000000
|
||||
|
||||
// GS0 RAM to store Tx frame data which DMA will read
|
||||
#define GS0_START_ADDR 0xD100
|
||||
// GS1 RAM to store Tx frame tag and Userdata
|
||||
#define GS1_START_ADDR 0xE000
|
||||
// GS2 RAM to save received Rx frame data
|
||||
#define GS2_START_ADDR 0xF000
|
||||
// GS3 RAM to save received Rx frame tag and Userdata
|
||||
#define GS3_START_ADDR 0x10000
|
||||
|
||||
//
|
||||
// FSI Tx/Rx Frame tag User Data register address, used by DMA channel to
|
||||
// write(and trigger transfer) read userdata respectively
|
||||
//
|
||||
#define FSI_TX_FRAME_TAG_UDATA_REGADDR (FSITXA_BASE + FSI_O_TX_FRAME_TAG_UDATA)
|
||||
#define FSI_RX_FRAME_TAG_UDATA_REGADDR (FSIRXA_BASE + FSI_O_RX_FRAME_TAG_UDATA)
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1 -16
|
||||
uint16_t nWords = 8;
|
||||
|
||||
// Transfer can be happen over single or double lane
|
||||
FSI_DataWidth nLanes = FSI_DATA_WIDTH_1_LANE;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10;
|
||||
|
||||
// User data to be sent with Data frame(for CPU control)
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
// Tx Ping timer and Rx Watchdog reference counter values
|
||||
uint32_t txPingTimeRefCntr = TX_TIME_OUT_CNTR, rxWdTimeoutRefCntr = 0x1400000;
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
uint16_t rxBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
uint32_t txTimeOutCntr = TX_TIME_OUT_CNTR, rxTimeOutCntr = RX_TIME_OUT_CNTR;
|
||||
uint32_t dataFrameCntr = 0, dataFrameCntr_ui32 = 0;
|
||||
|
||||
uint32_t dmaIntr1 = 0, dmaIntr2 = 0;
|
||||
volatile uint16_t i = 0, *txTempData16 = 0, *rxTempData16 = 0;
|
||||
|
||||
uint32_t error = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void initFSI(void);
|
||||
void testGPIO(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
__interrupt void fsirxdma_isr(void);
|
||||
void fsirx_dma_config();
|
||||
void InitFrameTagAndData();
|
||||
void handshake_node(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
testGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Initialize basic settings for FSI
|
||||
//
|
||||
initFSI();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
#if FSI_DMA_ENABLE ==1
|
||||
|
||||
//
|
||||
// DMA Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file.
|
||||
//
|
||||
Interrupt_register(INT_DMA_CH4, &fsirxdma_isr);
|
||||
|
||||
//
|
||||
// Enable DMA interrupts
|
||||
//
|
||||
Interrupt_enable(INT_DMA_CH4);
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_PING_FRAME);
|
||||
|
||||
// Wait till interrupt is received on FSIRX INT1 line, verify it's for FRAME
|
||||
// DONE event for PING Frame reception
|
||||
//
|
||||
handshake_node();
|
||||
|
||||
#if FSI_DELAY_LINE_CALIBRATION_ENABLE
|
||||
|
||||
// TODO - Implement FSI RX delay line calibration here
|
||||
// to compensate for channel-to-channel skew.
|
||||
// See Application Report SPRACJ9 and respective
|
||||
// software examples within C2000ware.
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Setting for requested nWords and nLanes with transfers
|
||||
//
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
FSI_setTxSoftwareFrameSize(FSITXA_BASE, nWords);
|
||||
FSI_setTxDataWidth(FSITXA_BASE, nLanes);
|
||||
// RX setting part
|
||||
FSI_setRxSoftwareFrameSize(FSIRXA_BASE, nWords);
|
||||
FSI_setRxDataWidth(FSIRXA_BASE, nLanes);
|
||||
|
||||
//
|
||||
// Enable transmit/receive error events to be sent over INT2 line
|
||||
// Overrun and Underrun conditions in Rx are not enabled as buffer pointers
|
||||
// are always overwritten to first location for sending data frames.
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_CRC_ERR |
|
||||
FSI_RX_EVT_EOF_ERR |
|
||||
FSI_RX_EVT_TYPE_ERR);
|
||||
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_PING_FRAME);
|
||||
DEVICE_DELAY_US(10);
|
||||
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
|
||||
#if FSI_DMA_ENABLE==0
|
||||
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_DATA_FRAME);
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Initialize the dma channels for both tx and rx buffers
|
||||
//
|
||||
DMA_initController();
|
||||
|
||||
InitFrameTagAndData();
|
||||
|
||||
fsirx_dma_config();
|
||||
|
||||
FSI_setTxStartMode(FSITXA_BASE, FSI_TX_START_FRAME_CTRL_OR_UDATA_TAG);
|
||||
|
||||
// Enable DMA event on FSI Rx
|
||||
FSI_enableRxDMAEvent(FSIRXA_BASE);
|
||||
|
||||
// Start RX channels
|
||||
DMA_startChannel(DMA_CH3_BASE);
|
||||
DMA_startChannel(DMA_CH4_BASE);
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Now, start transmitting data frames
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
|
||||
#if FSI_DMA_ENABLE==0
|
||||
|
||||
//
|
||||
// Wait for RX data frame received event
|
||||
//
|
||||
while(fsiRxInt1Received != 1U);
|
||||
|
||||
while(fsiTxInt1Received != 1U);
|
||||
|
||||
fsiRxInt1Received = 0U;
|
||||
fsiTxInt1Received = 0U;
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Wait for RX channels to complete a transfer
|
||||
//
|
||||
while(dmaIntr2 == 0U); // RX Int flag
|
||||
dmaIntr2 = 0;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void handshake_node(void)
|
||||
{
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(fsiRxInt1Received != 1);
|
||||
compare16(rxEventSts, (FSI_RX_EVT_PING_FRAME | FSI_RX_EVT_FRAME_DONE));
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_PING, FSI_FRAME_TAG0);
|
||||
//
|
||||
// If received frame type and tag matches, exit this loop and proceed to
|
||||
// next step by sending flush sequence, otherwise clear error and
|
||||
// interrupt flag and continue looping.
|
||||
//
|
||||
if(error == 0)
|
||||
{
|
||||
fsiRxInt1Received = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
fsiRxInt1Received = 0;
|
||||
error = 0;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Send the flush sequence
|
||||
//
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Send a ping frame with frame tag 0000b
|
||||
//
|
||||
FSI_setTxFrameTag(FSITXA_BASE, FSI_FRAME_TAG0);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_PING);
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
while(fsiRxInt1Received != 1U && rxTimeOutCntr != 0U)
|
||||
{
|
||||
DEVICE_DELAY_US(1);
|
||||
rxTimeOutCntr--;
|
||||
}
|
||||
|
||||
if(rxTimeOutCntr == 0)
|
||||
{
|
||||
rxTimeOutCntr = RX_TIME_OUT_CNTR;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(rxEventSts, (FSI_RX_EVT_PING_FRAME | FSI_RX_EVT_FRAME_DONE));
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_PING, FSI_FRAME_TAG1);
|
||||
//
|
||||
// If received frame type and tag matches, exit this loop and proceed
|
||||
// to next step by sending flush sequence, otherwise clear error and
|
||||
// interrupt flag and continue looping.
|
||||
//
|
||||
if(error == 0)
|
||||
{
|
||||
fsiRxInt1Received = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
fsiRxInt1Received = 0;
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Send a ping frame with frame tag 0001b
|
||||
//
|
||||
FSI_setTxFrameTag(FSITXA_BASE, FSI_FRAME_TAG1);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_PING);
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
DEVICE_DELAY_US(10);
|
||||
}
|
||||
|
||||
//
|
||||
// initFSI - Initializes FSI Tx/Rx and also sends FLUSH sequence.
|
||||
//
|
||||
void initFSI(void)
|
||||
{
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
//
|
||||
// NOTE: External loopback, Modify GPIO settings as per setup
|
||||
//
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TXCLK);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX0);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RXCLKA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX0A);
|
||||
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX1A);
|
||||
}
|
||||
|
||||
//
|
||||
// Set RX GPIO to be asynchronous
|
||||
// (pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX1A, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX0A, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RXCLKA, GPIO_QUAL_ASYNC);
|
||||
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
FSI_performRxInitialization(FSIRXA_BASE);
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
// Set FSI TX buffer pointer to beginning
|
||||
FSI_setTxBufferPtr(FSITXA_BASE, 0U);
|
||||
|
||||
// Clear the interrupt flag and issue ACK
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
if((rxEventSts & FSI_RX_EVT_DATA_FRAME) != 0)
|
||||
{
|
||||
dataFrameCntr++;
|
||||
|
||||
if(dataFrameCntr >= 0xFFFFFFFF)
|
||||
{
|
||||
dataFrameCntr_ui32++;
|
||||
dataFrameCntr = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Move received User Data, Frame Tag, and Data to TX buffer/registers
|
||||
//
|
||||
FSI_setTxUserDefinedData(FSITXA_BASE, FSI_getRxUserDefinedData(FSIRXA_BASE));
|
||||
FSI_setTxFrameTag(FSITXA_BASE, (FSI_FrameTag)FSI_getRxFrameTag(FSIRXA_BASE));
|
||||
|
||||
FSI_writeTxBuffer(FSITXA_BASE, rxBufAddr, nWords, 0U); // Put read data into TX buffer
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
}
|
||||
fsiRxInt1Received = 1U;
|
||||
|
||||
// Set FSI RX buffer pointer to beginning
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t rxDataArray[16];
|
||||
|
||||
FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, rxBufIndex);
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxDataArray[i] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
void testGPIO(void)
|
||||
{
|
||||
GPIO_setDirectionMode(DATA_FRAME_TEST_IO,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(DATA_FRAME_TEST_IO,GPIO_QUAL_ASYNC);
|
||||
GPIO_setPinConfig(DATA_FRAME_TEST_IO_CONF);
|
||||
|
||||
GPIO_writePin(DATA_FRAME_TEST_IO,1);
|
||||
}
|
||||
|
||||
//
|
||||
// InitFrameTagAndData - Initializes GS0/GS1 memories to populate tag and data
|
||||
// for frame transfers
|
||||
//
|
||||
void InitFrameTagAndData(void)
|
||||
{
|
||||
unsigned int i;
|
||||
uint16_t *temp;
|
||||
|
||||
temp = (uint16_t *)GS1_START_ADDR;
|
||||
for(i = FSI_FRAME_TAG0; i < FSI_FRAME_TAG15; i++)
|
||||
{
|
||||
//
|
||||
//tag and user data
|
||||
//
|
||||
*temp = ((0x0 + i) | ((unsigned long)(0x0 + i) << 8));
|
||||
temp++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsirx_dma_config - Sets up DMA channels(Ch3 and Ch4) for FSI Rx operation
|
||||
//
|
||||
void fsirx_dma_config()
|
||||
{
|
||||
//
|
||||
// Move RX FSI data into TX buffer
|
||||
//
|
||||
DMA_configAddresses(DMA_CH3_BASE, txBufAddr, rxBufAddr);
|
||||
DMA_configBurst(DMA_CH3_BASE, nWords, 1, 1);
|
||||
DMA_configTransfer(DMA_CH3_BASE, DMA_TRANSFER_SIZE_IN_BURSTS, 0, 0);
|
||||
DMA_configWrap(DMA_CH3_BASE, DMA_WRAP_SIZE_IN_BURSTS, 0,
|
||||
DMA_WRAP_SIZE_IN_BURSTS, 0);
|
||||
|
||||
DMA_configMode(DMA_CH3_BASE, DMA_TRIGGER_FSIRXA, DMA_CFG_ONESHOT_DISABLE|
|
||||
DMA_CFG_CONTINUOUS_ENABLE|DMA_CFG_SIZE_16BIT);
|
||||
|
||||
DMA_disableInterrupt(DMA_CH3_BASE);
|
||||
DMA_enableTrigger(DMA_CH3_BASE);
|
||||
|
||||
//
|
||||
// Move Tag and User Data into TX Registers
|
||||
//
|
||||
DMA_configAddresses(DMA_CH4_BASE,(uint16_t *)FSI_TX_FRAME_TAG_UDATA_REGADDR,
|
||||
(uint16_t *)GS1_START_ADDR);
|
||||
DMA_configBurst(DMA_CH4_BASE, 1, 0, 0);
|
||||
DMA_configTransfer(DMA_CH4_BASE, DMA_TRANSFER_SIZE_IN_BURSTS, 0, 0);
|
||||
DMA_configWrap(DMA_CH4_BASE, DMA_WRAP_SIZE_IN_BURSTS, 0,
|
||||
DMA_WRAP_SIZE_IN_BURSTS, 0);
|
||||
DMA_configMode(DMA_CH4_BASE, DMA_TRIGGER_FSIRXA, DMA_CFG_ONESHOT_DISABLE |
|
||||
DMA_CFG_CONTINUOUS_ENABLE | DMA_CFG_SIZE_16BIT);
|
||||
|
||||
DMA_setInterruptMode(DMA_CH4_BASE, DMA_INT_AT_END);
|
||||
DMA_enableInterrupt(DMA_CH4_BASE);
|
||||
|
||||
DMA_enableTrigger(DMA_CH4_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// fsirxdma_isr - FSI RX DMA ISR
|
||||
//
|
||||
interrupt void fsirxdma_isr(void)
|
||||
{
|
||||
// Set FSI TX/RX circular buffer pointers back to beginning
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
|
||||
GPIO_togglePin(DATA_FRAME_TEST_IO);
|
||||
|
||||
dataFrameCntr++;
|
||||
|
||||
if(dataFrameCntr >= 0xFFFFFFFF)
|
||||
{
|
||||
dataFrameCntr_ui32++;
|
||||
dataFrameCntr = 0;
|
||||
}
|
||||
|
||||
dmaIntr2 = 1;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,617 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex1_loopback_cpucontrol.c
|
||||
//
|
||||
// TITLE: CPU controlled data frame transfers with internal or external
|
||||
// loopback
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>FSI Loopback:CPU Control</h1>
|
||||
//!
|
||||
//! Example sets up infinite data frame transfers where trigger happens through
|
||||
//! \b CPU. Automatic(Hw triggered) Ping frame transmission is also setup along
|
||||
//! with data.
|
||||
//!
|
||||
//! User can edit some of configuration parameters as per usecase. These are as
|
||||
//! below. Default values can be referred in code where these globals are defined
|
||||
//!
|
||||
//! - \b nWords - Number of words per transfer may be from 1 -16
|
||||
//! - \b nLanes - Choice to select single or double lane for frame transfers
|
||||
//! - \b fsiClock - FSI Clock used for transfers
|
||||
//! - \b txUserData - User data to be sent with Data frame
|
||||
//! - \b txDataFrameTag - Frame tag used for Data transfers
|
||||
//! - \b txPingFrameTag - Frame tag used for Ping transfers
|
||||
//! - \b txPingTimeRefCntr - Tx Ping timer reference counter
|
||||
//! - \b rxWdTimeoutRefCntr - Rx Watchdog timeout reference counter
|
||||
//!
|
||||
//! For any errors during transfers i.e. \b error events such as Frame Overrun,
|
||||
//! Underrun, Watchdog timeout and CRC/EOF/TYPE errors, execution will stop
|
||||
//! immediately and status variables can be looked into for more details.
|
||||
//! Execution will also stop for any mismatch between received data and sent
|
||||
//! ones and also if transfers takes unusually long time(detected through
|
||||
//! software counters - txTimeOutCntr and rxTimeOutCntr)
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For FSI internal loopback (EXTERNAL_FSI_ENABLE == 0), no external
|
||||
//! connections needed
|
||||
//!
|
||||
//! For FSI external loopback (EXTERNAL_FSI_ENABLE == 1), external
|
||||
//! connections are required. The FSI TX pins should be connected to the
|
||||
//! FSI RX pins of the same device. See below for external connections to
|
||||
//! include and GPIOs used:
|
||||
//!
|
||||
//! External Connections Required between FSI TX and RX of the same device:
|
||||
//! - FSIRX_CLK to FSITX_CLK
|
||||
//! - FSIRX_RX0 to FSITX_TX0
|
||||
//! - FSIRX_RX1 to FSITX_TX1
|
||||
//!
|
||||
//! ControlCard FSI Header GPIOs:
|
||||
//! - GPIO_27 -> FSITXA_CLK
|
||||
//! - GPIO_26 -> FSITXA_TX0
|
||||
//! - GPIO_25 -> FSITXA_TX1
|
||||
//! - GPIO_9 -> FSIRXA_CLK
|
||||
//! - GPIO_8 -> FSIRXA_RX0
|
||||
//! - GPIO_10 -> FSIRXA_RX1
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frame transfered
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
#define PRESCALER_VAL FSI_PRESCALE_50MHZ
|
||||
|
||||
//
|
||||
// Define to enable external FSI configuration
|
||||
//
|
||||
// 0 = internal loopback enabled
|
||||
// 1 = internal loopback disabled, FSI GPIOs configured,
|
||||
// external connections required
|
||||
//
|
||||
#define EXTERNAL_FSI_ENABLE 0
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1 -16
|
||||
uint16_t nWords = 6;
|
||||
|
||||
// Transfer can be happen over single or double lane
|
||||
FSI_DataWidth nLanes = FSI_DATA_WIDTH_1_LANE;
|
||||
|
||||
// FSI Clock used for transfer
|
||||
uint32_t fsiClock = 50000000;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10, txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// User data to be sent with Data frame
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
// Tx Ping timer and Rx Watchdog reference counter values
|
||||
uint32_t txPingTimeRefCntr = 0x10000, rxWdTimeoutRefCntr = 0x14000;
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
uint32_t txTimeOutCntr = 0x100000, rxTimeOutCntr = 0x100000;
|
||||
uint32_t dataFrameCntr = 0;
|
||||
|
||||
uint32_t error = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void initFSI(void);
|
||||
void prepareTxBufData(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Initialize basic settings for FSI
|
||||
//
|
||||
initFSI();
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// First setup Ping transfer and then Data
|
||||
//
|
||||
|
||||
//
|
||||
// Performing a reset on PING WD counter before its usage is recommended
|
||||
// Done on both FSI Tx/Rx sides
|
||||
//
|
||||
FSI_resetTxModule(FSITXA_BASE, FSI_TX_PING_TIMEOUT_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearTxModuleReset(FSITXA_BASE, FSI_TX_PING_TIMEOUT_CNT_RESET);
|
||||
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_PING_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_PING_WD_CNT_RESET);
|
||||
|
||||
//
|
||||
// Enable Rx Ping Watchdog timeout event on INT2 line
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_PING_WD_TIMEOUT);
|
||||
|
||||
//
|
||||
// Now enable PING WD timer in both FSI Tx/Rx sides
|
||||
// Keeping reference counter for Rx little wide to ensure its not too sharp
|
||||
// to generate a WD timeout
|
||||
//
|
||||
FSI_enableTxPingTimer(FSITXA_BASE, txPingTimeRefCntr, txPingFrameTag);
|
||||
FSI_enableRxPingWatchdog(FSIRXA_BASE, rxWdTimeoutRefCntr);
|
||||
|
||||
//
|
||||
// Automatic Ping transmission is setup, now configure for data transfers
|
||||
//
|
||||
|
||||
//
|
||||
// Setting for requested nWords and nLanes with transfers
|
||||
//
|
||||
FSI_setTxSoftwareFrameSize(FSITXA_BASE, nWords);
|
||||
FSI_setRxSoftwareFrameSize(FSIRXA_BASE, nWords);
|
||||
FSI_setTxDataWidth(FSITXA_BASE, nLanes);
|
||||
FSI_setRxDataWidth(FSIRXA_BASE, nLanes);
|
||||
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_DATA_FRAME );
|
||||
|
||||
//
|
||||
// Enable transmit/receive error events to be sent over INT2 line
|
||||
// Overrun and Underrun conditions in Rx are not enabled as buffer pointers
|
||||
// are always overwritten to first location for sending data frames.
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_CRC_ERR |
|
||||
FSI_RX_EVT_EOF_ERR |
|
||||
FSI_RX_EVT_TYPE_ERR);
|
||||
|
||||
FSI_setTxUserDefinedData(FSITXA_BASE, txUserData);
|
||||
FSI_setTxFrameTag(FSITXA_BASE, txDataFrameTag);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
|
||||
if(isRxFrameWdEnable)
|
||||
{
|
||||
//
|
||||
// Performing a reset on frame WD before its usage is recommended
|
||||
//
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2,
|
||||
FSI_RX_EVT_FRAME_WD_TIMEOUT);
|
||||
FSI_enableRxFrameWatchdog(FSIRXA_BASE, rxFrameWdRefCntr);
|
||||
}
|
||||
|
||||
//
|
||||
// Now, start transmitting data frames
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Write data into Tx buffer and set other Frame specific fields
|
||||
//
|
||||
prepareTxBufData();
|
||||
FSI_writeTxBuffer(FSITXA_BASE, txBufData, nWords, 0U);
|
||||
|
||||
//
|
||||
// Start Transfer
|
||||
//
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Wait till frame done event is received by both Tx/Rx modules
|
||||
//
|
||||
while((fsiTxInt1Received != 1U) && (txTimeOutCntr != 0U))
|
||||
{
|
||||
txTimeOutCntr--;
|
||||
}
|
||||
|
||||
while((fsiRxInt1Received != 1U) && (rxTimeOutCntr != 0U))
|
||||
{
|
||||
rxTimeOutCntr--;
|
||||
}
|
||||
|
||||
if((txTimeOutCntr == 0) || (rxTimeOutCntr == 0))
|
||||
{
|
||||
//
|
||||
// Timeout for one of expected Tx/Rx evetns, so break execution here
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//
|
||||
// Re-initialize flags and buffer pointer before next transmission
|
||||
//
|
||||
fsiTxInt1Received = 0U;
|
||||
fsiRxInt1Received = 0U;
|
||||
txTimeOutCntr = 0x100000U;
|
||||
rxTimeOutCntr = 0x100000U;
|
||||
FSI_setTxBufferPtr(FSITXA_BASE, 0U);
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Coming out of infinite while loop means timeout occurred for one of Tx
|
||||
// or Rx transmit/receive events. Debug further to root-cause
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// initFSI - Initializes FSI Tx/Rx for loopback and also sends FLUSH
|
||||
// sequence.
|
||||
//
|
||||
void initFSI(void)
|
||||
{
|
||||
#if EXTERNAL_FSI_ENABLE == 0
|
||||
|
||||
//
|
||||
// Set internalLoopback mode
|
||||
//
|
||||
FSI_enableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Configure for External Loopback
|
||||
//
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TXCLK);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX0);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RXCLKA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX0A);
|
||||
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX1A);
|
||||
}
|
||||
|
||||
//
|
||||
// Set RX GPIO to be asynchronous
|
||||
// (pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX0A, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RXCLKA, GPIO_QUAL_ASYNC);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX1A, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Initialize Tx/Rx, reset sequence, clear events
|
||||
//
|
||||
|
||||
// TODO- Add logic to calculate PRESCALER_VAL based on user input FSI CLK
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
FSI_performRxInitialization(FSIRXA_BASE);
|
||||
|
||||
//
|
||||
// Flush Sequence before and after releasing Rx core reset, ensures flushing
|
||||
// of Rx data/clock lines and prepares it for reception
|
||||
//
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Assigning base addresses of Tx/Rx data buffer to globals
|
||||
//
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// prepareTxBufData - Update array which is used as source to Tx data buffer
|
||||
//
|
||||
void prepareTxBufData(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
txBufData[i] = txBufData[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
dataFrameCntr++;
|
||||
|
||||
//
|
||||
// Verify Frame attributes and data
|
||||
//
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_NWORD_DATA, txDataFrameTag);
|
||||
compare16(FSI_getRxUserDefinedData(FSIRXA_BASE), txUserData);
|
||||
compareBufData(0, 0, nWords);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
//
|
||||
// Stop execution if errors encountered in frame verification
|
||||
//
|
||||
if(error != 0)
|
||||
{
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t rxDataArray[16];
|
||||
|
||||
FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, rxBufIndex);
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxDataArray[i] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,647 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex2_loopback_clacontrol.c
|
||||
//
|
||||
// TITLE: FSI data transfer control(triggered) through CLA
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> FSI Loopback CLA control </h1>
|
||||
//!
|
||||
//! Example sets up infinite data frame transfers where trigger happens through
|
||||
//! \b CLA. Automatic(Hw triggered) Ping frame transmission is also setup along
|
||||
//! with data.
|
||||
//! This example is similar to fsi_ex1_loopback_cpucontrol and only different in
|
||||
//! in the sense that data frame transfer are trigged from a CLA task. Using
|
||||
//! CLA will release some of load from CPU and help it in providing time for
|
||||
//! other tasks.
|
||||
//!
|
||||
//! User can edit some of configuration parameters as per usecase. These are as
|
||||
//! below. Default values can be referred in code where these globals are defined
|
||||
//!
|
||||
//! - \b nWords - Number of words per transfer may be from 1 -16
|
||||
//! - \b nLanes - Choice to select single or double lane for frame transfers
|
||||
//! - \b fsiClock - FSI Clock used for transfers
|
||||
//! - \b txUserData - User data to be sent with Data frame
|
||||
//! - \b txDataFrameTag - Frame tag used for Data transfers
|
||||
//! - \b txPingFrameTag - Frame tag used for Ping transfers
|
||||
//! - \b txPingTimeRefCntr - Tx Ping timer reference counter
|
||||
//! - \b rxWdTimeoutRefCntr - Rx Watchdog timeout reference counter
|
||||
//!
|
||||
//! For any errors during transfers i.e. \b error events such as Frame Overrun,
|
||||
//! Underrun, Watchdog timeout and CRC/EOF/TYPE errors, execution will stop
|
||||
//! immediately and status variables can be looked into for more details.
|
||||
//! Execution will also stop for any mismatch between received data and sent
|
||||
//! ones and also if transfers takes unusually long time(detected through
|
||||
//! software counters - txTimeOutCntr and rxTimeOutCntr)
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For FSI internal loopback (EXTERNAL_FSI_ENABLE == 0), no external
|
||||
//! connections needed
|
||||
//!
|
||||
//! For FSI external loopback (EXTERNAL_FSI_ENABLE == 1), external
|
||||
//! connections are required. The FSI TX pins should be connected to the
|
||||
//! respective FSI RX pins of the same device. See below for external
|
||||
//! connections to include and GPIOs used:
|
||||
//!
|
||||
//! External Connections Required between FSI TX and RX of the same device:
|
||||
//! - FSIRX_CLK to FSITX_CLK
|
||||
//! - FSIRX_RX0 to FSITX_TX0
|
||||
//! - FSIRX_RX1 to FSITX_TX1
|
||||
//!
|
||||
//! ControlCard FSI Header GPIOs:
|
||||
//! - GPIO_27 -> FSITXA_CLK
|
||||
//! - GPIO_26 -> FSITXA_TX0
|
||||
//! - GPIO_25 -> FSITXA_TX1
|
||||
//! - GPIO_9 -> FSIRXA_CLK
|
||||
//! - GPIO_8 -> FSIRXA_RX0
|
||||
//! - GPIO_10 -> FSIRXA_RX1
|
||||
//!
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frame transfered
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "fsi_ex2_loopback_clacontrol_cla_shared.h"
|
||||
|
||||
|
||||
#define PRESCALER_VAL FSI_PRESCALE_50MHZ
|
||||
|
||||
//
|
||||
// Define to enable external FSI configuration
|
||||
//
|
||||
// 0 = internal loopback enabled
|
||||
// 1 = internal loopback disabled, FSI GPIOs configured,
|
||||
// external connections required
|
||||
//
|
||||
#define EXTERNAL_FSI_ENABLE 0
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1 -16
|
||||
uint16_t nWords = 6;
|
||||
|
||||
// Transfer can be happen over single or double lane
|
||||
FSI_DataWidth nLanes = FSI_DATA_WIDTH_1_LANE;
|
||||
|
||||
// FSI Clock used for transfer
|
||||
uint32_t fsiClock = 50000000;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10, txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// User data to be sent with Data frame
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
// Tx Ping timer and Rx Watchdog reference counter values
|
||||
uint32_t txPingTimeRefCntr = 0x100000, rxWdTimeoutRefCntr = 0x140000;
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
volatile uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
|
||||
#pragma DATA_SECTION(fsiTxInt1Received, "CLADataLS1")
|
||||
volatile uint32_t fsiTxInt1Received = 0;
|
||||
|
||||
#pragma DATA_SECTION(fsiRxInt1Received, "CLADataLS1")
|
||||
volatile uint32_t fsiRxInt1Received = 0;
|
||||
|
||||
volatile uint32_t fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt2Received = 0;
|
||||
|
||||
uint32_t dataFrameCntr = 0;
|
||||
|
||||
uint32_t error = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void initFSI(void);
|
||||
void prepareTxBufData(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
void initCLA();
|
||||
|
||||
//
|
||||
// Linker Defined variables
|
||||
//
|
||||
extern uint32_t Cla1funcsRunStart, Cla1funcsLoadStart, Cla1funcsLoadSize;
|
||||
extern uint32_t Cla1ConstRunStart, Cla1ConstLoadStart, Cla1ConstLoadSize;
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Initialize basic settings for FSI
|
||||
//
|
||||
initFSI();
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// First setup Ping transfer and then Data
|
||||
//
|
||||
|
||||
//
|
||||
// Performing a reset on PING WD counter before its usage is recommended
|
||||
// Done on both FSI Tx/Rx sides
|
||||
//
|
||||
FSI_resetTxModule(FSITXA_BASE, FSI_TX_PING_TIMEOUT_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearTxModuleReset(FSITXA_BASE, FSI_TX_PING_TIMEOUT_CNT_RESET);
|
||||
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_PING_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_PING_WD_CNT_RESET);
|
||||
|
||||
//
|
||||
// Enable Rx Ping Watchdog timeout event on INT2 line
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_PING_WD_TIMEOUT);
|
||||
|
||||
//
|
||||
// Now enable PING WD timer in both FSI Tx/Rx sides
|
||||
// Keeping reference counter for Rx little wide to ensure its not too sharp
|
||||
// to generate a WD timeout
|
||||
//
|
||||
FSI_enableTxPingTimer(FSITXA_BASE, txPingTimeRefCntr, txPingFrameTag);
|
||||
FSI_enableRxPingWatchdog(FSIRXA_BASE, rxWdTimeoutRefCntr);
|
||||
|
||||
if(isRxFrameWdEnable)
|
||||
{
|
||||
//
|
||||
// Performing a reset on frame WD before its usage is recommended
|
||||
//
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2,
|
||||
FSI_RX_EVT_FRAME_WD_TIMEOUT);
|
||||
FSI_enableRxFrameWatchdog(FSIRXA_BASE, rxFrameWdRefCntr);
|
||||
}
|
||||
|
||||
//
|
||||
// Automatic Ping transmission is setup, now configure for data transfers
|
||||
// First, configure CLA first
|
||||
//
|
||||
initCLA();
|
||||
|
||||
//
|
||||
// Setting for requested nWords and nLanes with transfers
|
||||
//
|
||||
FSI_setTxSoftwareFrameSize(FSITXA_BASE, nWords);
|
||||
FSI_setRxSoftwareFrameSize(FSIRXA_BASE, nWords);
|
||||
FSI_setTxDataWidth(FSITXA_BASE, nLanes);
|
||||
FSI_setRxDataWidth(FSIRXA_BASE, nLanes);
|
||||
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_DATA_FRAME );
|
||||
|
||||
//
|
||||
// Enable transmit/receive error events to be sent over INT2 line
|
||||
// Overrun and Underrun conditions in Rx are not enabled as buffer pointers
|
||||
// are always overwritten to first location for sending data frames.
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_FRAME_WD_TIMEOUT |
|
||||
FSI_RX_EVT_CRC_ERR |
|
||||
FSI_RX_EVT_EOF_ERR |
|
||||
FSI_RX_EVT_TYPE_ERR);
|
||||
|
||||
FSI_setTxUserDefinedData(FSITXA_BASE, txUserData);
|
||||
FSI_setTxFrameTag(FSITXA_BASE, txDataFrameTag);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
|
||||
prepareTxBufData();
|
||||
FSI_writeTxBuffer(FSITXA_BASE, txBufData, nWords, 0U);
|
||||
|
||||
//
|
||||
// Enable background CLA task and force it to run
|
||||
//
|
||||
CLA_enableBackgroundTask(CLA1_BASE);
|
||||
CLA_startBackgroundTask(CLA1_BASE);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// initFSI - Initializes FSI Tx/Rx with internal loopback and also sends FLUSH
|
||||
// sequence.
|
||||
//
|
||||
void initFSI(void)
|
||||
{
|
||||
#if EXTERNAL_FSI_ENABLE == 0
|
||||
|
||||
//
|
||||
// Set internalLoopback mode
|
||||
//
|
||||
FSI_enableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Configure for External Loopback
|
||||
//
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TXCLK);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX0);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RXCLKA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX0A);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX1A);
|
||||
}
|
||||
|
||||
//
|
||||
// Set RX GPIO to be asynchronous
|
||||
// (pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX0A, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RXCLKA, GPIO_QUAL_ASYNC);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX1A, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Initialize Tx/Rx, reset sequence, clear events
|
||||
//
|
||||
|
||||
// TODO- Add logic to calculate PRESCALER_VAL based on user input FSI CLK
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
FSI_performRxInitialization(FSIRXA_BASE);
|
||||
|
||||
//
|
||||
// Flush Sequence before and after releasing Rx core reset, ensures flushing
|
||||
// of Rx data/clock lines and prepares it for reception
|
||||
//
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Assigning base addresses of Tx/Rx data buffer to globals
|
||||
//
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// prepareTxBufData - Update array which is used as source to Tx data buffer
|
||||
//
|
||||
void prepareTxBufData(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
txBufData[i] = txBufData[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
fsiTxInt1Received = 1U;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
dataFrameCntr++;
|
||||
|
||||
//
|
||||
// Verify Frame attributes and data
|
||||
//
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_NWORD_DATA, txDataFrameTag);
|
||||
compare16(FSI_getRxUserDefinedData(FSIRXA_BASE), txUserData);
|
||||
compareBufData(0, 0, nWords);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
//
|
||||
// Stop execution if errors encountered in frame verification
|
||||
//
|
||||
if(error != 0)
|
||||
{
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
prepareTxBufData();
|
||||
FSI_setTxBufferPtr(FSITXA_BASE, 0U);
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
FSI_writeTxBuffer(FSITXA_BASE, txBufData, nWords, 0U);
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t rxDataArray[16];
|
||||
|
||||
FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, rxBufIndex);
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxDataArray[i] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// initCLA - Configures CLA
|
||||
//
|
||||
void initCLA( void )
|
||||
{
|
||||
//
|
||||
// Copy the program and constants from FLASH to RAM before configuring
|
||||
// the CLA
|
||||
//
|
||||
#if defined(_FLASH)
|
||||
memcpy((uint32_t *)&Cla1funcsRunStart, (uint32_t *)&Cla1funcsLoadStart,
|
||||
(uint32_t)&Cla1funcsLoadSize );
|
||||
memcpy((uint32_t *)&Cla1ConstRunStart, (uint32_t *)&Cla1ConstLoadStart,
|
||||
(uint32_t)&Cla1ConstLoadSize );
|
||||
#endif //defined(_FLASH)
|
||||
|
||||
//
|
||||
// CLA Program will reside in RAMLS0 and data in RAMLS1
|
||||
//
|
||||
MemCfg_setCLAMemType(MEMCFG_SECT_LS5, MEMCFG_CLA_MEM_PROGRAM);
|
||||
MemCfg_setCLAMemType(MEMCFG_SECT_LS0, MEMCFG_CLA_MEM_DATA);
|
||||
MemCfg_setCLAMemType(MEMCFG_SECT_LS1, MEMCFG_CLA_MEM_DATA);
|
||||
MemCfg_setLSRAMControllerSel(MEMCFG_SECT_LS5, MEMCFG_LSRAMCONTROLLER_CPU_CLA1);
|
||||
MemCfg_setLSRAMControllerSel(MEMCFG_SECT_LS0, MEMCFG_LSRAMCONTROLLER_CPU_CLA1);
|
||||
MemCfg_setLSRAMControllerSel(MEMCFG_SECT_LS1, MEMCFG_LSRAMCONTROLLER_CPU_CLA1);
|
||||
|
||||
//
|
||||
// Suppressing #770-D conversion from pointer to smaller integer
|
||||
// The CLA address range is 16 bits so the addresses passed to the MVECT
|
||||
// registers will be in the lower 64KW address space. Turn the warning
|
||||
// back on after the MVECTs are assigned addresses
|
||||
//
|
||||
#pragma diag_suppress=770
|
||||
|
||||
//
|
||||
// Assign the background task, CLA task 8 will be made as background one
|
||||
// Also, disable hardware trigger and enable software trigger for same
|
||||
// and 8
|
||||
//
|
||||
CLA_mapBackgroundTaskVector(CLA1_BASE, (uint16_t)&Cla1Task8);
|
||||
#pragma diag_warning=770
|
||||
|
||||
CLA_disableHardwareTrigger(CLA1_BASE);
|
||||
CLA_setTriggerSource(CLA_TASK_8, CLA_TRIGGER_SOFTWARE);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,174 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex2_loopback_clacontrol_cla.cla
|
||||
//
|
||||
// TITLE: CLA code to control FSI data frame transfers
|
||||
//
|
||||
// Task 8 made as background task to keep on triggering FSI data transfers
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include <stdint.h>
|
||||
#include "f2838x_device.h"
|
||||
#include "fsi_ex2_loopback_clacontrol_cla_shared.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 1 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task1 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 2 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 3 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 4 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 5 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 6 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 7 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 8 - Infinite loop to trigger FSI data transfers iteratively
|
||||
//
|
||||
// Description: Before triggering next data transfer, execution waits to see if
|
||||
// a flag is set(to notify the previous data is transmitted/received)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt("background"))) void Cla1Task8()
|
||||
{
|
||||
//
|
||||
// Now, start transmitting data frames
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Trigger Data Frame Transfer
|
||||
//
|
||||
FsiTxaRegs.TX_FRAME_CTRL.bit.START = 1;
|
||||
|
||||
//
|
||||
// Wait till frame done event is received by both Tx/Rx modules
|
||||
//
|
||||
while(fsiTxInt1Received != 1U);
|
||||
while(fsiRxInt1Received != 1U);
|
||||
|
||||
//
|
||||
// Re-initialize flags and buffer pointer before next transmission
|
||||
//
|
||||
fsiTxInt1Received = 0U;
|
||||
fsiRxInt1Received = 0U;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex2_loopback_clacontrol_cla_shared.h
|
||||
//
|
||||
// TITLE: CLA code to control FSI data frame transfers
|
||||
//
|
||||
// This header file contains defines, variables and prototypes that are shared
|
||||
// among the C28x and the CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _FSI_EX2_LOOPBACK_CLACONTROL_CLA_SHARED_H_
|
||||
#define _FSI_EX2_LOOPBACK_CLACONTROL_CLA_SHARED_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
|
||||
extern volatile uint32_t fsiTxInt1Received;
|
||||
extern volatile uint32_t fsiRxInt1Received;
|
||||
extern uint32_t txTimeOutCntr, rxTimeOutCntr;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
|
||||
//Task 2 (C) Variables
|
||||
|
||||
//Task 3 (C) Variables
|
||||
|
||||
//Task 4 (C) Variables
|
||||
|
||||
//Task 5 (C) Variables
|
||||
|
||||
//Task 6 (C) Variables
|
||||
|
||||
//Task 7 (C) Variables
|
||||
|
||||
//Task 8 (C) Variables
|
||||
|
||||
//Common (C) Variables
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
//CLA C Tasks defined in fsi_ex2_loopback_clacontrol_cla.cla
|
||||
__attribute__((interrupt)) void Cla1Task1();
|
||||
__attribute__((interrupt)) void Cla1Task2();
|
||||
__attribute__((interrupt)) void Cla1Task3();
|
||||
__attribute__((interrupt)) void Cla1Task4();
|
||||
__attribute__((interrupt)) void Cla1Task5();
|
||||
__attribute__((interrupt)) void Cla1Task6();
|
||||
__attribute__((interrupt)) void Cla1Task7();
|
||||
__attribute__((interrupt)) void Cla1Task8();
|
||||
#if defined(__TMS320C28XX__)
|
||||
__attribute__((interrupt)) void Cla1Task8();
|
||||
#else
|
||||
__attribute__((interrupt("background"))) void Cla1Task8();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
#endif //_FSI_EX2_LOOPBACK_CLACONTROL_CLA_SHARED_H_
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,360 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex3_loopback_dmacontrol.c
|
||||
//
|
||||
// TITLE: DMA controlled data frame transfers with internal loopback
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>FSI DMA frame transfers:DMA Control</h1>
|
||||
//!
|
||||
//! Example sets up infinite data frame transfers where DMA trigger happens
|
||||
//! once through CPU and then DMA takes control to transfer data iteratively.
|
||||
//! This example demonstrates the FSI feature about triggering DMA events which
|
||||
//! in turn can copy data and trigger next transfer.
|
||||
//!
|
||||
//! Two DMA channels are setup for FSI Tx operation and two for Rx.
|
||||
//! Four areas in GSx memories are also setup as source and sink for data and
|
||||
//! tag values of frame under transmission.
|
||||
//!
|
||||
//! Automatic(Hw triggered) Ping frame transmission is also setup along
|
||||
//! with data.
|
||||
//!
|
||||
//! If there are any comparison failures during transfers or any error
|
||||
//! event occurs, execution will stop.
|
||||
//!
|
||||
//! User Configurations:
|
||||
//! If "Software Frame Size" is modified in FSI TX or FSI RX Sysconfig, change:
|
||||
//! DMA CH0 "Destination Wrap Size"
|
||||
//! DMA CH0 "Burst Size"
|
||||
//! DMA CH2 "Source Wrap Size"
|
||||
//! DMA CH2 "Burst Size"
|
||||
//! FSI TX/RX "Software Frame Size"
|
||||
//!
|
||||
//! \note: This example project has support for migration across our C2000
|
||||
//! device families. If you are wanting to build this project from launchpad
|
||||
//! or controlCARD, please specify in the .syscfg file the board you're using.
|
||||
//! At any time you can select another device to migrate this example.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! For FSI internal loopback (default setting), no external
|
||||
//! connections needed
|
||||
//!
|
||||
//! For FSI external loopback (disable "Loopback Mode" in FSI RX Sysconfig),
|
||||
//! external connections are required. Refer to SysConfig for external
|
||||
//! connections (GPIO pin numbers) specific to each device.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b countDMAtransfers Number of Data frame transfered
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define TOTAL_WORDS_IN_TRANSFER (myDMA0_TRANSFERSIZE * myFSIRX0_nWords)
|
||||
|
||||
//
|
||||
// GSRAM data buffers
|
||||
//
|
||||
uint16_t gs0Data[0x800];
|
||||
uint16_t gs1Data[0x800];
|
||||
uint16_t gs2Data[0x800];
|
||||
uint16_t gs3Data[0x800];
|
||||
|
||||
//
|
||||
// FSI Tx/Rx Frame tag User Data register address, used by DMA channels to
|
||||
// write (and trigger transfer) and read User data respectively
|
||||
//
|
||||
const void *txFrameTagAddr = (const void *)(myFSITX0_BASE +
|
||||
FSI_O_TX_FRAME_TAG_UDATA);
|
||||
const void *rxFrameTagAddr = (const void *)(myFSIRX0_BASE +
|
||||
FSI_O_RX_FRAME_TAG_UDATA);
|
||||
|
||||
//
|
||||
// Map the TX frame data buffer to DMA accessible global shared memory.
|
||||
//
|
||||
#pragma DATA_SECTION(gs0Data, "ramgs0");
|
||||
|
||||
//
|
||||
// Map the TX data frame tag and User data buffer to DMA accessible global
|
||||
// shared memory.
|
||||
//
|
||||
#pragma DATA_SECTION(gs1Data, "ramgs1");
|
||||
//
|
||||
// Map the RX frame data buffer to DMA accessible global shared memory.
|
||||
//
|
||||
#pragma DATA_SECTION(gs2Data, "ramgs2");
|
||||
//
|
||||
// Map the RX frame tag and User data buffer to DMA accessible global
|
||||
// shared memory.
|
||||
//
|
||||
#pragma DATA_SECTION(gs3Data, "ramgs3");
|
||||
//
|
||||
// Set up pointers to GSRAM buffers
|
||||
//
|
||||
const void *gs0Addr = (const void *)gs0Data;
|
||||
const void *gs1Addr = (const void *)gs1Data;
|
||||
const void *gs2Addr = (const void *)gs2Data;
|
||||
const void *gs3Addr = (const void *)gs3Data;
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per use case
|
||||
//
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
// If changed to false: take out FSI_RX_EVT_FRAME_WD_TIMEOUT interrupt setting
|
||||
// in FSIRX Sysconfig
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
const void *txBufAddr = 0, *rxBufAddr = 0;
|
||||
uint16_t txBufData[16] = {0};
|
||||
uint32_t error = 0;
|
||||
uint32_t dmaIntr1 = 0, dmaIntr2 = 0;
|
||||
uint32_t countDMAtransfers = 0U;
|
||||
volatile uint16_t i = 0, *txTempData16 = 0, *rxTempData16 = 0;
|
||||
uint32_t dmaTxIntCnt = 0, dmaRxIntCnt = 0; //TODO, may remove it, just for DEBUG
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
__interrupt void fsitxdma_isr(void);
|
||||
__interrupt void fsirxdma_isr(void);
|
||||
|
||||
//
|
||||
// InitFrameTagAndData - Initializes GS0/GS1 memories to populate tag and data
|
||||
// for frame transfers
|
||||
//
|
||||
void InitFrameTagAndData(void)
|
||||
{
|
||||
unsigned int i;
|
||||
uint16_t *temp;
|
||||
|
||||
temp = (uint16_t *)gs0Addr;
|
||||
for(i = 0; i < TOTAL_WORDS_IN_TRANSFER; i++)
|
||||
{
|
||||
*temp = i;
|
||||
temp++;
|
||||
}
|
||||
|
||||
temp = (uint16_t *)gs1Addr;
|
||||
for(i = FSI_FRAME_TAG0; i < FSI_FRAME_TAG15; i++)
|
||||
{
|
||||
//
|
||||
//tag and user data
|
||||
//
|
||||
*temp = ((0x0 + i) | ((unsigned long)(0x0 + i) << 8));
|
||||
temp++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Assigning base addresses of Tx/Rx data buffer to globals
|
||||
//
|
||||
txBufAddr = (const void *)(myFSITX0_BASE + FSI_O_TX_BUF_BASE(0));
|
||||
rxBufAddr = (const void *)(myFSIRX0_BASE + FSI_O_RX_BUF_BASE(0));
|
||||
|
||||
//
|
||||
// Call Sysconfig configured code.
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Flush Sequence before and after releasing Rx core reset, ensures flushing
|
||||
// of Rx data/clock lines and prepares it for reception.
|
||||
//
|
||||
FSI_resetRxModule(myFSIRX0_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(myFSITX0_BASE, myFSITX0_PRESCALER_VAL);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(myFSIRX0_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(myFSITX0_BASE, myFSITX0_PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM).
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
if(isRxFrameWdEnable)
|
||||
{
|
||||
//
|
||||
// Performing a reset on frame WD before its usage is recommended.
|
||||
//
|
||||
FSI_resetRxModule(myFSIRX0_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(myFSIRX0_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
FSI_enableRxFrameWatchdog(myFSIRX0_BASE, rxFrameWdRefCntr);
|
||||
}
|
||||
|
||||
FSI_enableTxDMAEvent(myFSITX0_BASE);
|
||||
FSI_enableRxDMAEvent(myFSIRX0_BASE);
|
||||
|
||||
InitFrameTagAndData();
|
||||
|
||||
//
|
||||
// Start RX channels
|
||||
//
|
||||
DMA_startChannel(DMA_CH3_BASE);
|
||||
DMA_startChannel(DMA_CH4_BASE);
|
||||
|
||||
DMA_startChannel(DMA_CH1_BASE);
|
||||
DMA_forceTrigger(DMA_CH1_BASE);
|
||||
DMA_startChannel(DMA_CH2_BASE);
|
||||
DMA_forceTrigger(DMA_CH2_BASE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Wait for both TX and RX channels to complete a transfer
|
||||
//
|
||||
while(dmaIntr1 == 0U);
|
||||
dmaIntr1 = 0;
|
||||
|
||||
while(dmaIntr2 == 0U);
|
||||
dmaIntr2 = 0;
|
||||
|
||||
//
|
||||
// Starting location is after one word as extra write to marker
|
||||
// location will lead to 1st comparison fail.
|
||||
//
|
||||
txTempData16 = ((uint16_t *)gs0Addr) + 1;
|
||||
rxTempData16 = ((uint16_t *)gs2Addr) + 1;
|
||||
|
||||
//
|
||||
// verify transfers
|
||||
//
|
||||
for(i = 1; i < TOTAL_WORDS_IN_TRANSFER; i++)
|
||||
{
|
||||
compare16(*txTempData16,*rxTempData16);
|
||||
txTempData16++;
|
||||
rxTempData16++;
|
||||
}
|
||||
|
||||
countDMAtransfers++;
|
||||
//
|
||||
// Just changing the 1st entry in Tx buffer Source GS0 location as a
|
||||
// marker for observing change in received data in memory view of
|
||||
// debugger with each transfer
|
||||
//
|
||||
*((uint16_t *)gs0Addr) = (uint16_t )countDMAtransfers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// fsitxdma_isr - FSI Tx DMA ISR
|
||||
//
|
||||
interrupt void fsitxdma_isr(void)
|
||||
{
|
||||
dmaIntr1 = 1;
|
||||
dmaTxIntCnt++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
|
||||
}
|
||||
|
||||
//
|
||||
// fsirxdma_isr - FSI Rx DMA ISR
|
||||
//
|
||||
interrupt void fsirxdma_isr(void)
|
||||
{
|
||||
dmaIntr2 = 1;
|
||||
dmaRxIntCnt++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
|
||||
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
|
||||
* @cliArgs --device "F2838x" --package "337bga" --part "F2838x_337bga" --context "CPU1" --product "C2000WARE@5.02.00.00"
|
||||
* @versions {"tool":"1.0.0+dev"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const device_support = scripting.addModule("/driverlib/device_support.js");
|
||||
const dma = scripting.addModule("/driverlib/dma.js", {}, false);
|
||||
const dma1 = dma.addInstance();
|
||||
const dma2 = dma.addInstance();
|
||||
const dma3 = dma.addInstance();
|
||||
const dma4 = dma.addInstance();
|
||||
const fsirx = scripting.addModule("/driverlib/fsirx.js", {}, false);
|
||||
const fsirx1 = fsirx.addInstance();
|
||||
const fsitx = scripting.addModule("/driverlib/fsitx.js", {}, false);
|
||||
const fsitx1 = fsitx.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
const sysctl = scripting.addModule("/driverlib/sysctl.js");
|
||||
const CMD = scripting.addModule("/utilities/cmd_tool/cmd_syscfg/source/CMD");
|
||||
const CMD1 = CMD.addInstance();
|
||||
const CMD2 = CMD.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
dma1.$name = "myDMA0";
|
||||
dma1.enableTriggers = true;
|
||||
dma1.triggerSource = "DMA_TRIGGER_FSITXA";
|
||||
dma1.continuousModeConfig = "DMA_CFG_CONTINUOUS_ENABLE";
|
||||
dma1.burstSize = 4;
|
||||
dma1.transferSize = 512;
|
||||
dma1.srcAddressInputMode = "VARIABLE";
|
||||
dma1.srcBurstStep = 1;
|
||||
dma1.srcTransferStep = 1;
|
||||
dma1.srcAddressVariable = "gs0Addr";
|
||||
dma1.srcWrapSize = 512;
|
||||
dma1.destAddressInputMode = "VARIABLE";
|
||||
dma1.destBurstStep = 1;
|
||||
dma1.destAddressVariable = "txBufAddr";
|
||||
dma1.destTransferStep = 1;
|
||||
dma1.destWrapSize = 4;
|
||||
|
||||
dma2.$name = "myDMA1";
|
||||
dma2.dmaBase = "DMA_CH2_BASE";
|
||||
dma2.enableTriggers = true;
|
||||
dma2.triggerSource = "DMA_TRIGGER_FSITXA";
|
||||
dma2.useInterrupts = true;
|
||||
dma2.registerInterrupts = true;
|
||||
dma2.enableInterrupts = true;
|
||||
dma2.interruptMode = "DMA_INT_AT_END";
|
||||
dma2.continuousModeConfig = "DMA_CFG_CONTINUOUS_ENABLE";
|
||||
dma2.transferSize = 512;
|
||||
dma2.srcAddressInputMode = "VARIABLE";
|
||||
dma2.destAddressInputMode = "VARIABLE";
|
||||
dma2.srcAddressVariable = "gs1Addr";
|
||||
dma2.srcTransferStep = 1;
|
||||
dma2.srcWrapSize = 16;
|
||||
dma2.destAddressVariable = "txFrameTagAddr";
|
||||
dma2.destWrapSize = 16;
|
||||
dma2.dmaInt.interruptHandler = "fsitxdma_isr";
|
||||
dma2.dmaInt.enableInterrupt = true;
|
||||
|
||||
dma3.$name = "myDMA2";
|
||||
dma3.dmaBase = "DMA_CH3_BASE";
|
||||
dma3.enableTriggers = true;
|
||||
dma3.triggerSource = "DMA_TRIGGER_FSIRXA";
|
||||
dma3.continuousModeConfig = "DMA_CFG_CONTINUOUS_ENABLE";
|
||||
dma3.burstSize = 4;
|
||||
dma3.transferSize = 512;
|
||||
dma3.srcAddressInputMode = "VARIABLE";
|
||||
dma3.destAddressInputMode = "VARIABLE";
|
||||
dma3.srcAddressVariable = "rxBufAddr";
|
||||
dma3.srcBurstStep = 1;
|
||||
dma3.srcTransferStep = 1;
|
||||
dma3.srcWrapSize = 4;
|
||||
dma3.destAddressVariable = "gs2Addr";
|
||||
dma3.destBurstStep = 1;
|
||||
dma3.destTransferStep = 1;
|
||||
dma3.destWrapSize = 512;
|
||||
|
||||
dma4.$name = "myDMA3";
|
||||
dma4.dmaBase = "DMA_CH4_BASE";
|
||||
dma4.enableTriggers = true;
|
||||
dma4.triggerSource = "DMA_TRIGGER_FSIRXA";
|
||||
dma4.useInterrupts = true;
|
||||
dma4.registerInterrupts = true;
|
||||
dma4.enableInterrupts = true;
|
||||
dma4.interruptMode = "DMA_INT_AT_END";
|
||||
dma4.continuousModeConfig = "DMA_CFG_CONTINUOUS_ENABLE";
|
||||
dma4.transferSize = 512;
|
||||
dma4.srcAddressInputMode = "VARIABLE";
|
||||
dma4.destAddressInputMode = "VARIABLE";
|
||||
dma4.srcAddressVariable = "rxFrameTagAddr";
|
||||
dma4.srcWrapSize = 16;
|
||||
dma4.destAddressVariable = "gs3Addr";
|
||||
dma4.destTransferStep = 1;
|
||||
dma4.destWrapSize = 16;
|
||||
dma4.dmaInt.interruptHandler = "fsirxdma_isr";
|
||||
dma4.dmaInt.enableInterrupt = true;
|
||||
|
||||
fsirx1.$name = "myFSIRX0";
|
||||
fsirx1.softwareFrameSize = "4";
|
||||
fsirx1.enableLoopback = true;
|
||||
fsirx1.enableInterrupt = true;
|
||||
fsirx1.useInterrupts = ["FSI_INT2"];
|
||||
fsirx1.enabledINT2Interrupts = ["FSI_RX_EVT_CRC_ERR","FSI_RX_EVT_EOF_ERR","FSI_RX_EVT_FRAME_WD_TIMEOUT","FSI_RX_EVT_PING_WD_TIMEOUT","FSI_RX_EVT_TYPE_ERR"];
|
||||
fsirx1.pingTimeout = true;
|
||||
fsirx1.timeoutDelay = 20971520;
|
||||
fsirx1.fsirx.fsirx_d0Pin.$assign = "GPIO8";
|
||||
fsirx1.fsirx.fsirx_d1Pin.$assign = "GPIO10";
|
||||
fsirx1.fsirx.fsirx_clkPin.$assign = "GPIO9";
|
||||
|
||||
|
||||
fsitx1.$name = "myFSITX0";
|
||||
fsitx1.clkPres = 2;
|
||||
|
||||
fsitx1.softwareFrameSize = "4";
|
||||
fsitx1.startOfTransmissionMode = "FSI_TX_START_FRAME_CTRL_OR_UDATA_TAG";
|
||||
fsitx1.frameType = "FSI_FRAME_TYPE_NWORD_DATA";
|
||||
fsitx1.frameTag = "FSI_FRAME_TAG15";
|
||||
fsitx1.pingTimeout = true;
|
||||
fsitx1.timeoutDelay = 16777216;
|
||||
fsitx1.fsitx.fsitx_d0Pin.$assign = "GPIO26";
|
||||
fsitx1.fsitx.fsitx_d1Pin.$assign = "GPIO25";
|
||||
fsitx1.fsitx.fsitx_clkPin.$assign = "GPIO27";
|
||||
|
||||
|
||||
CMD1.$name = "generic_ram_lnk";
|
||||
CMD2.$name = "generic_flash_lnk";
|
||||
|
||||
CMD1.sectionMemory_text = ["RAMLS0","RAMLS1","RAMLS2","RAMLS3","RAMLS4"];
|
||||
CMD1.sectionMemory_ramfunc = ["RAMM0"];
|
||||
CMD1.sectionMemory_cinit = ["RAMM0"];
|
||||
CMD1.sectionMemory_stack = ["RAMM1"];
|
||||
CMD1.sectionMemory_init_array = ["RAMM0"];
|
||||
CMD1.sectionMemory_bss = ["RAMLS5"];
|
||||
CMD1.sectionMemory_const = ["RAMLS5"];
|
||||
CMD1.sectionMemory_data = ["RAMLS5"];
|
||||
CMD1.sectionMemory_switch = ["RAMM0"];
|
||||
CMD1.sectionMemory_sysmem = ["RAMLS5"];
|
||||
|
||||
|
||||
CMD1.userSection.create(4);
|
||||
|
||||
CMD1.userSection[0].$name = "userSection0";
|
||||
CMD1.userSection[0].sectionName = "ramgs0";
|
||||
CMD1.userSection[0].sectionMemory = ["RAMGS0"];
|
||||
CMD1.userSection[0].sectionType = "NOINIT";
|
||||
|
||||
CMD1.userSection[1].$name = "userSection2";
|
||||
CMD1.userSection[1].sectionName = "ramgs1";
|
||||
CMD1.userSection[1].sectionMemory = ["RAMGS1"];
|
||||
CMD1.userSection[1].sectionType = "NOINIT";
|
||||
CMD1.userSection[2].$name = "userSection3";
|
||||
CMD1.userSection[2].sectionName = "ramgs2";
|
||||
CMD1.userSection[2].sectionMemory = ["RAMGS2"];
|
||||
CMD1.userSection[2].sectionType = "NOINIT";
|
||||
CMD1.userSection[3].$name = "userSection4";
|
||||
CMD1.userSection[3].sectionName = "ramgs3";
|
||||
CMD1.userSection[3].sectionMemory = ["RAMGS3"];
|
||||
CMD1.userSection[3].sectionType = "NOINIT";
|
||||
|
||||
CMD2.sectionAlignEnable_ramfunc = true;
|
||||
CMD2.sectionAlignEnable_text = true;
|
||||
CMD2.sectionAlignEnable_binit = true;
|
||||
CMD2.sectionAlignEnable_cinit = true;
|
||||
CMD2.sectionAlignEnable_switch = true;
|
||||
CMD2.sectionAlignEnable_init_array = true;
|
||||
CMD2.sectionAlignEnable_const = true;
|
||||
CMD2.sectionAlignEnable_ovly = true;
|
||||
CMD2.sectionMemory_codestart = "0x080000";
|
||||
CMD2.sectionMemory_stack = ["RAMM1"];
|
||||
CMD2.sectionMemory_bss = ["RAMLS5"];
|
||||
CMD2.sectionMemory_data = ["RAMLS5"];
|
||||
CMD2.sectionMemory_sysmem = ["RAMLS5"];
|
||||
CMD2.sectionMemory_ramfunc = ["FLASH3"];
|
||||
CMD2.sectionMemory_text = ["FLASH1","FLASH2","FLASH3","FLASH4"];
|
||||
CMD2.sectionMemory_binit = ["FLASH4"];
|
||||
CMD2.sectionMemory_cinit = ["FLASH4"];
|
||||
CMD2.sectionMemory_switch = ["FLASH1"];
|
||||
CMD2.sectionMemory_init_array = ["FLASH1"];
|
||||
CMD2.sectionMemory_const = ["FLASH5"];
|
||||
CMD2.sectionMemory_ovly = ["FLASH6"];
|
||||
CMD2.sectionRunFromDifferentAddr_ramfunc = true;
|
||||
CMD2.sectionRun_ramfunc = ["RAMLS0"];
|
||||
CMD2.sectionBinit_ramfunc = false;
|
||||
|
||||
|
||||
CMD2.userSection.create(4);
|
||||
|
||||
CMD2.userSection[0].$name = "userSection1";
|
||||
CMD2.userSection[0].sectionName = "ramgs0";
|
||||
CMD2.userSection[0].sectionMemory = ["RAMGS0"];
|
||||
CMD2.userSection[0].sectionType = "NOINIT";
|
||||
|
||||
CMD2.userSection[1].$name = "userSection5";
|
||||
CMD2.userSection[1].sectionName = "ramgs1";
|
||||
CMD2.userSection[1].sectionMemory = ["RAMGS1"];
|
||||
CMD2.userSection[1].sectionType = "NOINIT";
|
||||
CMD2.userSection[2].$name = "userSection6";
|
||||
CMD2.userSection[2].sectionName = "ramgs2";
|
||||
CMD2.userSection[2].sectionMemory = ["RAMGS2"];
|
||||
CMD2.userSection[2].sectionType = "NOINIT";
|
||||
CMD2.userSection[3].$name = "userSection7";
|
||||
CMD2.userSection[3].sectionName = "ramgs3";
|
||||
CMD2.userSection[3].sectionMemory = ["RAMGS3"];
|
||||
CMD2.userSection[3].sectionType = "NOINIT";
|
||||
@@ -0,0 +1,693 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex4_loopback_epwmtrigger.c
|
||||
//
|
||||
// TITLE: FSI data frame transfer triggered by ePWM SOC
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>FSI data transfer by external trigger</h1>
|
||||
//!
|
||||
//! FSI frame transfer can be triggered by external sources. It can connect up
|
||||
//! to 32 trigger sources but as of now, only 16 ePWMx-SOCy(x-1:8, y-A:B) are
|
||||
//! supported. FSI supports external trigger for both PING and DATA frame
|
||||
//! transfers and in this example we demonstrate how to setup infinite DATA
|
||||
//! transfers using selectable ePWM-SOC as a trigger source.
|
||||
//! The TB counter for ePWM operation is in up/down count mode for this example.
|
||||
//!
|
||||
//! Automatic(Hw triggered) Ping frame transmission is also setup along
|
||||
//! with data.
|
||||
//!
|
||||
//! If there are any comparison failures during transfers or any of error
|
||||
//! event occurs, execution will stop.
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For FSI internal loopback (EXTERNAL_FSI_ENABLE == 0), no external
|
||||
//! connections needed
|
||||
//!
|
||||
//! For FSI external loopback (EXTERNAL_FSI_ENABLE == 1), external
|
||||
//! connections are required. The FSI TX pins should be connected to the
|
||||
//! respective FSI RX pins of the same device. See below for external
|
||||
//! connections to include and GPIOs used:
|
||||
//!
|
||||
//! External Connections Required between FSI TX and RX of the same device:
|
||||
//! - FSIRX_CLK to FSITX_CLK
|
||||
//! - FSIRX_RX0 to FSITX_TX0
|
||||
//! - FSIRX_RX1 to FSITX_TX1
|
||||
//!
|
||||
//! ControlCard FSI Header GPIOs:
|
||||
//! - GPIO_27 -> FSITXA_CLK
|
||||
//! - GPIO_26 -> FSITXA_TX0
|
||||
//! - GPIO_25 -> FSITXA_TX1
|
||||
//! - GPIO_9 -> FSIRXA_CLK
|
||||
//! - GPIO_8 -> FSIRXA_RX0
|
||||
//! - GPIO_10 -> FSIRXA_RX1
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frame transfered
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Defines: User can modify these values as desired
|
||||
//
|
||||
#define PRESCALER_VAL FSI_PRESCALE_50MHZ
|
||||
|
||||
//
|
||||
// Define to enable external FSI configuration
|
||||
//
|
||||
// 0 = internal loopback enabled
|
||||
// 1 = internal loopback disabled, FSI GPIOs configured,
|
||||
// external connections required
|
||||
//
|
||||
#define EXTERNAL_FSI_ENABLE 0
|
||||
|
||||
#define EPWM_TIMER_TBPRD 2000U
|
||||
#define EPWM_CMPA_VALUE 1950U
|
||||
#define EPWM_CMPB_VALUE 1950U
|
||||
|
||||
//
|
||||
// Globals and Typedefs
|
||||
//
|
||||
|
||||
// User can choose any of 16 ePWM SOC event triggers
|
||||
FSI_ExtFrameTriggerSrc ePWMTrigSel = FSI_EXT_TRIGSRC_EPWM1_SOCB;
|
||||
|
||||
// ePWM base addresses to operate on selected module and also Sysctl Clock to
|
||||
// enable/disable them.
|
||||
// Need to change base address as per EPWM trigger selection in \b ePWMTrigSel
|
||||
uint32_t ePWMBaseAddr = EPWM1_BASE;
|
||||
SysCtl_PeripheralPCLOCKCR epwmSysCtlClock = SYSCTL_PERIPH_CLK_EPWM1;
|
||||
|
||||
// Number of words per transfer may be from 1 -16
|
||||
uint16_t nWords = 9;
|
||||
|
||||
// Transfer can be happen over single or double lane
|
||||
FSI_DataWidth nLanes = FSI_DATA_WIDTH_1_LANE;
|
||||
|
||||
// FSI Clock used for transfer
|
||||
uint32_t fsiClock = 50000000;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag, txPingFrameTag;
|
||||
|
||||
// User data to be sent with Data frame
|
||||
uint16_t txUserData = 0U;
|
||||
|
||||
// Tx Ping timer and Rx Watchdog reference counter values
|
||||
uint32_t txPingTimeRefCntr = 0x100000, rxWdTimeoutRefCntr = 0x140000;
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
uint32_t txTimeOutCntr = 0x100000, rxTimeOutCntr = 0x100000;
|
||||
uint32_t dataFrameCntr = 0;
|
||||
uint32_t error = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void initFSI(void);
|
||||
void prepareTxBufData(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
void ConfigPWM();
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Initialize basic settings for FSI
|
||||
//
|
||||
initFSI();
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// First setup Ping transfer and then Data
|
||||
//
|
||||
|
||||
//
|
||||
// Performing a reset on PING WD counter before its usage is recommended
|
||||
// Done on both FSI Tx/Rx sides
|
||||
//
|
||||
FSI_resetTxModule(FSITXA_BASE, FSI_TX_PING_TIMEOUT_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearTxModuleReset(FSITXA_BASE, FSI_TX_PING_TIMEOUT_CNT_RESET);
|
||||
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_PING_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_PING_WD_CNT_RESET);
|
||||
|
||||
//
|
||||
// Enable Rx Ping Watchdog timeout event on INT2 line
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_PING_WD_TIMEOUT);
|
||||
|
||||
//
|
||||
// Now enable PING WD timer in both FSI Tx/Rx sides
|
||||
// Keeping reference counter for Rx little wide to ensure its not too sharp
|
||||
// to generate a WD timeout
|
||||
//
|
||||
FSI_enableTxPingTimer(FSITXA_BASE, txPingTimeRefCntr, txPingFrameTag);
|
||||
FSI_enableRxPingWatchdog(FSIRXA_BASE, rxWdTimeoutRefCntr);
|
||||
|
||||
//
|
||||
// Automatic Ping transmission is setup, now configure for data transfers
|
||||
//
|
||||
|
||||
//
|
||||
// Setting for requested nWords and nLanes with transfers
|
||||
//
|
||||
FSI_setTxSoftwareFrameSize(FSITXA_BASE, nWords);
|
||||
FSI_setRxSoftwareFrameSize(FSIRXA_BASE, nWords);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
FSI_setTxDataWidth(FSITXA_BASE, nLanes);
|
||||
FSI_setRxDataWidth(FSIRXA_BASE, nLanes);
|
||||
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_DATA_FRAME );
|
||||
|
||||
//
|
||||
// Enable transmit/receive error events to be sent over INT2 line
|
||||
// Overrun and Underrun conditions in Rx are not enabled as buffer pointers
|
||||
// are always overwritten to first location for sending data frames.
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_CRC_ERR |
|
||||
FSI_RX_EVT_EOF_ERR |
|
||||
FSI_RX_EVT_TYPE_ERR);
|
||||
|
||||
if(isRxFrameWdEnable)
|
||||
{
|
||||
//
|
||||
// Performing a reset on frame WD before its usage is recommended
|
||||
//
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2,
|
||||
FSI_RX_EVT_FRAME_WD_TIMEOUT);
|
||||
FSI_enableRxFrameWatchdog(FSIRXA_BASE, rxFrameWdRefCntr);
|
||||
}
|
||||
|
||||
//
|
||||
// Configure the ePWM, requested by user as external trigger source for
|
||||
// FSI frame transfers. Setting data frame tag to reflect selected EPWM
|
||||
// trigger. Some arithmetic to ensure tag remains in range 0x0 - 0xF.
|
||||
//
|
||||
txDataFrameTag = (FSI_FrameTag)(ePWMTrigSel - FSI_EXT_TRIGSRC_EPWM1_SOCA);
|
||||
ConfigPWM();
|
||||
|
||||
//
|
||||
// Set up some FSI frame fields and external trigger source based on
|
||||
// selected ePWM
|
||||
//
|
||||
FSI_setTxFrameTag(FSITXA_BASE, txDataFrameTag);
|
||||
FSI_setTxStartMode(FSITXA_BASE, FSI_TX_START_EXT_TRIG );
|
||||
FSI_setTxExtFrameTrigger(FSITXA_BASE, ePWMTrigSel );
|
||||
|
||||
//
|
||||
// Now, start transmitting data frames
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Enable peripheral clk for ePWM
|
||||
//
|
||||
SysCtl_enablePeripheral(epwmSysCtlClock);
|
||||
|
||||
//
|
||||
// Setup a GPIO pin, not for operation but for debug/probe purpose
|
||||
//
|
||||
GPIO_setPinConfig(GPIO_1_EPWM1B);
|
||||
|
||||
//
|
||||
// Write data into Tx buffer and set other Frame specific fields
|
||||
//
|
||||
prepareTxBufData();
|
||||
FSI_writeTxBuffer(FSITXA_BASE, txBufData, nWords, 0U);
|
||||
txUserData += 1;
|
||||
FSI_setTxUserDefinedData(FSITXA_BASE, (txUserData & 0xFF));
|
||||
|
||||
//
|
||||
// Start ePWM to trigger FSI data frames transfer upon SOC event
|
||||
//
|
||||
EPWM_setEmulationMode(ePWMBaseAddr, EPWM_EMULATION_FREE_RUN);
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Wait till frame done event is received by both Tx/Rx modules
|
||||
//
|
||||
while(fsiTxInt1Received != 1U);
|
||||
fsiTxInt1Received = 0;
|
||||
while(fsiRxInt1Received != 1U);
|
||||
fsiRxInt1Received = 0;
|
||||
|
||||
//
|
||||
// Disable peripheral clk for ePWM and Sync
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
SysCtl_disablePeripheral(epwmSysCtlClock);
|
||||
|
||||
//
|
||||
// Verify Frame attributes and data
|
||||
//
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_NWORD_DATA, txDataFrameTag);
|
||||
compare16(FSI_getRxUserDefinedData(FSIRXA_BASE), (txUserData & 0xFF));
|
||||
compareBufData(0, 0, nWords);
|
||||
|
||||
FSI_setTxBufferPtr(FSITXA_BASE, 0U);
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
|
||||
if(error)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Coming out of infinite while loop means data comparison test failed.
|
||||
// Debug further to root-cause
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// initFSI - Initializes FSI Tx/Rx with internal loopback and also sends FLUSH
|
||||
// sequence.
|
||||
//
|
||||
void initFSI(void)
|
||||
{
|
||||
#if EXTERNAL_FSI_ENABLE == 0
|
||||
|
||||
//
|
||||
// Set internalLoopback mode
|
||||
//
|
||||
FSI_enableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Configure for External Loopback
|
||||
//
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TXCLK);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX0);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RXCLKA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX0A);
|
||||
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX1A);
|
||||
}
|
||||
|
||||
//
|
||||
// Set RX GPIO to be asynchronous
|
||||
// (pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX0A, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RXCLKA, GPIO_QUAL_ASYNC);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX1A, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Initialize Tx/Rx, reset sequence, clear events
|
||||
//
|
||||
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
FSI_performRxInitialization(FSIRXA_BASE);
|
||||
|
||||
//
|
||||
// Flush Sequence before and after releasing Rx core reset, ensures flushing
|
||||
// of Rx data/clock lines and prepares it for reception
|
||||
//
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Assigning base addresses of Tx/Rx data buffer to globals
|
||||
//
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// prepareTxBufData - Update array which is used as source to Tx data buffer
|
||||
//
|
||||
void prepareTxBufData(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
txBufData[i] = txBufData[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
dataFrameCntr++;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t rxDataArray[16];
|
||||
|
||||
FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, rxBufIndex);
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxDataArray[i] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
txBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigPWM - Configures requested ePWM
|
||||
// TB counter is in up/down count mode for this example
|
||||
//
|
||||
void ConfigPWM()
|
||||
{
|
||||
//
|
||||
// Set-up TBCLK
|
||||
//
|
||||
EPWM_setTimeBasePeriod(ePWMBaseAddr, EPWM_TIMER_TBPRD);
|
||||
EPWM_setPhaseShift(ePWMBaseAddr, 0U);
|
||||
EPWM_setTimeBaseCounter(ePWMBaseAddr, 0U);
|
||||
|
||||
//
|
||||
// Set Compare values
|
||||
//
|
||||
EPWM_setCounterCompareValue(ePWMBaseAddr,
|
||||
EPWM_COUNTER_COMPARE_A,
|
||||
EPWM_CMPA_VALUE);
|
||||
|
||||
EPWM_setCounterCompareValue(ePWMBaseAddr,
|
||||
EPWM_COUNTER_COMPARE_B,
|
||||
EPWM_CMPB_VALUE);
|
||||
|
||||
EPWM_setTimeBaseCounterMode(ePWMBaseAddr, EPWM_COUNTER_MODE_UP_DOWN);
|
||||
EPWM_disablePhaseShiftLoad(ePWMBaseAddr);
|
||||
EPWM_setClockPrescaler(ePWMBaseAddr,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
|
||||
//
|
||||
// Set up shadowing
|
||||
//
|
||||
EPWM_setCounterCompareShadowLoadMode(ePWMBaseAddr,
|
||||
EPWM_COUNTER_COMPARE_A,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
EPWM_setCounterCompareShadowLoadMode(ePWMBaseAddr,
|
||||
EPWM_COUNTER_COMPARE_B,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPWM_setActionQualifierAction(ePWMBaseAddr,
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(ePWMBaseAddr,
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
|
||||
EPWM_setActionQualifierAction(ePWMBaseAddr,
|
||||
EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_HIGH,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
|
||||
EPWM_setActionQualifierAction(ePWMBaseAddr,
|
||||
EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB);
|
||||
|
||||
//
|
||||
// Setup ePWM SOC trigger
|
||||
//
|
||||
EPWM_setADCTriggerEventPrescale(ePWMBaseAddr, EPWM_SOC_A, 1);
|
||||
EPWM_setADCTriggerEventPrescale(ePWMBaseAddr, EPWM_SOC_B, 1);
|
||||
EPWM_enableADCTrigger(ePWMBaseAddr,EPWM_SOC_A);
|
||||
EPWM_enableADCTrigger(ePWMBaseAddr,EPWM_SOC_B);
|
||||
EPWM_setADCTriggerSource(ePWMBaseAddr,EPWM_SOC_A,EPWM_SOC_TBCTR_PERIOD);
|
||||
EPWM_setADCTriggerSource(ePWMBaseAddr,EPWM_SOC_B,EPWM_SOC_TBCTR_PERIOD);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,644 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex5_periodic_frame.c
|
||||
//
|
||||
// TITLE: FSI data frame transfers upon CPU Timer event
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>FSI data transfers upon CPU Timer event</h1>
|
||||
//!
|
||||
//! Example sets up infinite data frame transfers where trigger comes from ISR
|
||||
//! handling the periodic CPU Timer event. Automatic(Hw triggered) Ping frame
|
||||
//! transmission is also setup along with data.
|
||||
//!
|
||||
//! CPU Timer0 is chosen for setting up periodic timer events. User can choose
|
||||
//! any other Timer-1/Timer-2 as well.
|
||||
//!
|
||||
//! Automatic(Hw triggered) Ping frame transmission is also setup along
|
||||
//! with data.
|
||||
//!
|
||||
//! If there are any comparison failures during transfers or any of error
|
||||
//! event occurs, execution will stop.
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For FSI internal loopback (EXTERNAL_FSI_ENABLE == 0), no external
|
||||
//! connections needed
|
||||
//!
|
||||
//! For FSI external loopback (EXTERNAL_FSI_ENABLE == 1), external
|
||||
//! connections are required. The FSI TX pins should be connected to the
|
||||
//! respective FSI RX pins of the same device. See below for external
|
||||
//! connections to include and GPIOs used:
|
||||
//!
|
||||
//! External Connections Required between FSI TX and RX of the same device:
|
||||
//! - FSIRX_CLK to FSITX_CLK
|
||||
//! - FSIRX_RX0 to FSITX_TX0
|
||||
//! - FSIRX_RX1 to FSITX_TX1
|
||||
//!
|
||||
//! ControlCard FSI Header GPIOs:
|
||||
//! - GPIO_27 -> FSITXA_CLK
|
||||
//! - GPIO_26 -> FSITXA_TX0
|
||||
//! - GPIO_25 -> FSITXA_TX1
|
||||
//! - GPIO_9 -> FSIRXA_CLK
|
||||
//! - GPIO_8 -> FSIRXA_RX0
|
||||
//! - GPIO_10 -> FSIRXA_RX1
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frame transfered
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
// Period(in us) with which CPU Timer-0 will send events
|
||||
#define TIMER_PERIOD_US 1000U
|
||||
|
||||
#define PRESCALER_VAL FSI_PRESCALE_50MHZ
|
||||
|
||||
//
|
||||
// Define to enable external FSI configuration
|
||||
//
|
||||
// 0 = internal loopback enabled
|
||||
// 1 = internal loopback disabled, FSI GPIOs configured,
|
||||
// external connections required
|
||||
//
|
||||
#define EXTERNAL_FSI_ENABLE 0
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1 -16
|
||||
uint16_t nWords = 13;
|
||||
|
||||
// Transfer can be happen over single or double lane
|
||||
FSI_DataWidth nLanes = FSI_DATA_WIDTH_1_LANE;
|
||||
|
||||
// FSI Clock used for transfer
|
||||
uint32_t fsiClock = 50000000;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10, txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// User data to be sent with Data frame
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
// Tx Ping timer and Rx Watchdog reference counter values
|
||||
uint32_t txPingTimeRefCntr = 0x100000, rxWdTimeoutRefCntr = 0x140000;
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
uint32_t txTimeOutCntr = 0x100000, rxTimeOutCntr = 0x100000;
|
||||
uint32_t dataFrameCntr = 0;
|
||||
int cpuTimer0IntCount;
|
||||
|
||||
uint32_t error = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void initFSI(void);
|
||||
void configTimer0(void);
|
||||
|
||||
void prepareTxBufData(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
__interrupt void cpuTimer0ISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
Interrupt_register(INT_TIMER0, &cpuTimer0ISR);
|
||||
|
||||
//
|
||||
// Initialize basic settings for FSI
|
||||
//
|
||||
initFSI();
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// First setup Ping transfer and then Data
|
||||
//
|
||||
|
||||
//
|
||||
// Performing a reset on PING WD counter before its usage is recommended
|
||||
// Done on both FSI Tx/Rx sides
|
||||
//
|
||||
FSI_resetTxModule(FSITXA_BASE, FSI_TX_PING_TIMEOUT_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearTxModuleReset(FSITXA_BASE, FSI_TX_PING_TIMEOUT_CNT_RESET);
|
||||
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_PING_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_PING_WD_CNT_RESET);
|
||||
|
||||
//
|
||||
// Enable Rx Ping Watchdog timeout event on INT2 line
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_PING_WD_TIMEOUT);
|
||||
|
||||
//
|
||||
// Now enable PING WD timer in both FSI Tx/Rx sides
|
||||
// Keeping reference counter for Rx little wide to ensure its not too sharp
|
||||
// to generate a WD timeout
|
||||
//
|
||||
FSI_enableTxPingTimer(FSITXA_BASE, txPingTimeRefCntr, txPingFrameTag);
|
||||
FSI_enableRxPingWatchdog(FSIRXA_BASE, rxWdTimeoutRefCntr);
|
||||
|
||||
//
|
||||
// Automatic Ping transmission is setup, now configure for data transfers
|
||||
//
|
||||
|
||||
//
|
||||
// Setting for requested nWords and nLanes with transfers
|
||||
//
|
||||
FSI_setTxSoftwareFrameSize(FSITXA_BASE, nWords);
|
||||
FSI_setRxSoftwareFrameSize(FSIRXA_BASE, nWords);
|
||||
FSI_setTxDataWidth(FSITXA_BASE, nLanes);
|
||||
FSI_setRxDataWidth(FSIRXA_BASE, nLanes);
|
||||
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_DATA_FRAME );
|
||||
|
||||
//
|
||||
// Enable transmit/receive error events to be sent over INT2 line
|
||||
// Overrun and Underrun conditions in Rx are not enabled as buffer pointers
|
||||
// are always overwritten to first location for sending data frames.
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_CRC_ERR |
|
||||
FSI_RX_EVT_EOF_ERR |
|
||||
FSI_RX_EVT_TYPE_ERR);
|
||||
|
||||
if(isRxFrameWdEnable)
|
||||
{
|
||||
//
|
||||
// Performing a reset on frame WD before its usage is recommended
|
||||
//
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_FRAME_WD_CNT_RESET);
|
||||
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2,
|
||||
FSI_RX_EVT_FRAME_WD_TIMEOUT);
|
||||
FSI_enableRxFrameWatchdog(FSIRXA_BASE, rxFrameWdRefCntr);
|
||||
}
|
||||
|
||||
FSI_setTxFrameTag(FSITXA_BASE, txDataFrameTag);
|
||||
FSI_setTxUserDefinedData(FSITXA_BASE, txUserData);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
|
||||
//
|
||||
// Configure and start CPU-Timer 0, Timer-0 is taken as a clock event
|
||||
// source, Timer-1 or Timer-2 can also be used as example.
|
||||
//
|
||||
configTimer0();
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Now, start processing transferred data frames. Trigger for transfers will
|
||||
// be provided inside CPU Timer Event ISR
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Write data into Tx buffer and set other Frame specific fields
|
||||
//
|
||||
prepareTxBufData();
|
||||
FSI_writeTxBuffer(FSITXA_BASE, txBufData, nWords, 0U);
|
||||
|
||||
//frame transmission is done at tx side
|
||||
while(fsiTxInt1Received != 1U);
|
||||
fsiTxInt1Received = 0;
|
||||
|
||||
//frame receiving is done at rx_side
|
||||
while (fsiRxInt1Received != 1U);
|
||||
fsiRxInt1Received = 0;
|
||||
|
||||
//
|
||||
// Verify Frame attributes and data
|
||||
//
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_NWORD_DATA, txDataFrameTag);
|
||||
compare16(FSI_getRxUserDefinedData(FSIRXA_BASE), (txUserData & 0xFF));
|
||||
compareBufData(0, 0, nWords);
|
||||
|
||||
FSI_setTxBufferPtr(FSITXA_BASE, 0U);
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
|
||||
// In case of comparison failures, break execution
|
||||
if(error)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Coming out of infinite while loop means data comparison test failed.
|
||||
// Debug further to root-cause
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// initFSI - Initializes FSI Tx/Rx with internal loopback and also sends FLUSH
|
||||
// sequence.
|
||||
//
|
||||
void initFSI(void)
|
||||
{
|
||||
#if EXTERNAL_FSI_ENABLE == 0
|
||||
|
||||
//
|
||||
// Set internalLoopback mode
|
||||
//
|
||||
FSI_enableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Configure for External Loopback
|
||||
//
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TXCLK);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX0);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RXCLKA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX0A);
|
||||
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX1A);
|
||||
}
|
||||
|
||||
//
|
||||
// Set RX GPIO to be asynchronous
|
||||
// (pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX0A, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RXCLKA, GPIO_QUAL_ASYNC);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX1A, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Initialize Tx/Rx, reset sequence, clear events
|
||||
//
|
||||
|
||||
//
|
||||
// Perform FSI Tx and Rx initialization
|
||||
//
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
FSI_performRxInitialization(FSIRXA_BASE);
|
||||
|
||||
//
|
||||
// Flush Sequence before and after releasing Rx core reset, ensures flushing
|
||||
// of Rx data/clock lines and prepares it for reception
|
||||
//
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
DEVICE_DELAY_US(1);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Assigning base addresses of Tx/Rx data buffer to globals
|
||||
//
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// configTimer0 - Sets up Timer-0 sequence.
|
||||
//
|
||||
void configTimer0(void)
|
||||
{
|
||||
uint32_t temp;
|
||||
float freq = DEVICE_SYSCLK_FREQ;
|
||||
|
||||
//
|
||||
// Initialize timer period:
|
||||
//
|
||||
temp = (long) (freq / 1000000 * TIMER_PERIOD_US);
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE, temp - 1);
|
||||
|
||||
//
|
||||
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
|
||||
//
|
||||
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
|
||||
|
||||
//
|
||||
// Initializes timer control register. The timer is stopped, reloaded,
|
||||
// and emulation mode is setup
|
||||
//
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
|
||||
CPUTimer_setEmulationMode(CPUTIMER0_BASE,
|
||||
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
|
||||
|
||||
//
|
||||
// Enable interrupt and reset counter
|
||||
//
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
cpuTimer0IntCount = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// prepareTxBufData - Update array which is used as source to Tx data buffer
|
||||
//
|
||||
void prepareTxBufData(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
txBufData[i] = txBufData[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// cpuTimer0ISR - Counter for CpuTimer0
|
||||
//
|
||||
interrupt void
|
||||
cpuTimer0ISR(void)
|
||||
{
|
||||
cpuTimer0IntCount++;
|
||||
|
||||
//
|
||||
// Start Transfer
|
||||
//
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 1
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
dataFrameCntr++;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t rxDataArray[16];
|
||||
|
||||
FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, rxBufIndex);
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxDataArray[i] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,646 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex6_spi_main_tx.c
|
||||
//
|
||||
// TITLE: FSI(Main Tx) and SPI(Remote Rx) communication
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>FSI and SPI communication(fsi_ex6_spi_main_tx) </h1>
|
||||
//!
|
||||
//! FSI supports SPI compatibility mode to talk to the devices not having FSI
|
||||
//! but SPI module. Example sets up infinite data frame transfers where FSI acts
|
||||
//! like main Tx and SPI as remote Rx.
|
||||
//! API to decode FSI frame received at SPI end is implemented and checks are
|
||||
//! made to ensure received details(frame tag/type, userdata, data) match with
|
||||
//! transfered frame.
|
||||
//!
|
||||
//! If there are any comparison failures during transfers or any of error
|
||||
//! event occurs, execution will stop.
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For FSI <-> SPI communication, make below connections in GPIO settings
|
||||
//!
|
||||
//! - GPIO_2 -> GPIO_18 :: To connect FSITX_CLK with SPICLKA
|
||||
//! - GPIO_0 -> GPIO_16 :: To connect FSITX_TX0 with SPIPICOA
|
||||
//! - GPIO_1 -> GPIO_19 :: To connect FSITX_TX1 with SPIPTEA
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frame transfered
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
// Period(in us) with which CPU Timer-0 will send events
|
||||
#define TIMER_PERIOD_US 1000U
|
||||
|
||||
#define PRESCALER_VAL 25U
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1 -16
|
||||
uint16_t nWords = 13;
|
||||
|
||||
// FSI Clock used for transfer
|
||||
uint32_t fsiClock = 50000000;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10, txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// User data to be sent with Data frame
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
|
||||
uint32_t dataFrameCntr = 0;
|
||||
uint32_t error = 0, idx = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FSI_FrameType type;
|
||||
uint16_t userdata;
|
||||
uint16_t *data;
|
||||
uint16_t data_len;
|
||||
uint16_t crcbyte;
|
||||
FSI_FrameTag tag;
|
||||
} SPI_FSIFrameInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t frameLen;
|
||||
uint16_t spiDataBuf[18];
|
||||
} SPI_FSIBuiltFrame;
|
||||
|
||||
uint16_t spiTempBuf[18];
|
||||
SPI_FSIFrameInfo spiFrameInfo;
|
||||
SPI_FSIBuiltFrame spiBuiltFrame;
|
||||
|
||||
unsigned long resultcrccalculated = 0;
|
||||
int inpdata[50];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void configTimer0(void);
|
||||
|
||||
void prepareTxBufData(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
|
||||
void configureSPI(void);
|
||||
void decodeFSIFrameReceivedinSPI(SPI_FSIFrameInfo *frameInfo,
|
||||
SPI_FSIBuiltFrame *txFrame);
|
||||
unsigned long crc8(unsigned long address, unsigned int no_locations);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Perform FSI Tx Initialization
|
||||
//
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Configure GPIOs for FSI Tx and SPIA
|
||||
//
|
||||
GPIO_setPinConfig(GPIO_2_FSITXA_CLK);
|
||||
GPIO_setPinConfig(GPIO_0_FSITXA_D0);
|
||||
GPIO_setPinConfig(GPIO_1_FSITXA_D1);
|
||||
|
||||
GPIO_setPinConfig(GPIO_18_SPIA_CLK);
|
||||
GPIO_setPinConfig(GPIO_19_SPIA_STEN);
|
||||
GPIO_setPinConfig(GPIO_17_SPIA_SOMI);
|
||||
GPIO_setPinConfig(GPIO_16_SPIA_SIMO);
|
||||
|
||||
//
|
||||
// Set GP16, 17, 18, 19 to be asynchronous(pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
GPIO_setQualificationMode(16, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(17, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(18, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(19, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Configure SPI module for Rx operation
|
||||
//
|
||||
configureSPI();
|
||||
|
||||
//
|
||||
// Assigning base addresses of Tx/Rx data buffer to globals
|
||||
//
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)spiFrameInfo.data;
|
||||
|
||||
//
|
||||
// enable SPI mode on the FSIRX
|
||||
//
|
||||
FSI_enableTxSPIMode(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Configure for data transfers
|
||||
//
|
||||
|
||||
//
|
||||
// Setting for requested nWords and nLanes with transfers
|
||||
//
|
||||
FSI_setTxSoftwareFrameSize(FSITXA_BASE, nWords);
|
||||
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
|
||||
FSI_setTxFrameTag(FSITXA_BASE, txDataFrameTag);
|
||||
FSI_setTxUserDefinedData(FSITXA_BASE, txUserData);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
|
||||
//
|
||||
// Now, start sending data frames from FSI Tx and receive + verify at SPI
|
||||
// end. Come out of loop if there is any mismatch between transmit and
|
||||
// receive data.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Write data into Tx buffer and set other Frame specific fields
|
||||
//
|
||||
prepareTxBufData();
|
||||
FSI_writeTxBuffer(FSITXA_BASE, txBufData, nWords, 0U);
|
||||
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Wait for FSI Tx to finish transmit operation
|
||||
// Also, check that the Transmit frame done interrupt was the source
|
||||
//
|
||||
while(fsiTxInt1Received != 1U);
|
||||
fsiTxInt1Received = 0;
|
||||
compare16(txEventSts, FSI_TX_EVT_FRAME_DONE);
|
||||
|
||||
idx = 0;
|
||||
|
||||
//
|
||||
// Read the SPIRX buffer until empty
|
||||
// Then save the number of words received and decode the data frame
|
||||
//
|
||||
while(SPI_getRxFIFOStatus(SPIA_BASE)>0)
|
||||
{
|
||||
spiBuiltFrame.spiDataBuf[idx] = SPI_readDataBlockingFIFO(SPIA_BASE);
|
||||
idx++;
|
||||
}
|
||||
|
||||
spiBuiltFrame.frameLen = idx;
|
||||
decodeFSIFrameReceivedinSPI(&spiFrameInfo,&spiBuiltFrame);
|
||||
|
||||
//
|
||||
// Verify Frame attributes and data
|
||||
//
|
||||
compare16(spiFrameInfo.type, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
compare16(spiFrameInfo.tag, txDataFrameTag);
|
||||
compare16(spiFrameInfo.userdata, txUserData);
|
||||
compareBufData(0U, 0U, spiFrameInfo.data_len);
|
||||
|
||||
//
|
||||
// In case of comparison failures, break execution
|
||||
// Else, increment received data frame counter and reset FSI Tx buffer
|
||||
// for next transfer
|
||||
//
|
||||
if(error)
|
||||
break;
|
||||
|
||||
dataFrameCntr++;
|
||||
FSI_setTxBufferPtr(FSITXA_BASE, 0U);
|
||||
}
|
||||
|
||||
//
|
||||
// Coming out of infinite while loop means data comparison test failed.
|
||||
// Debug further to root-cause
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// prepareTxBufData - Update array which is used as source to Tx data buffer
|
||||
//
|
||||
void prepareTxBufData(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
txBufData[i] = txBufData[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
dataFrameCntr++;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxBufAddr[rxBufIndex] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
rxBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Decode the received FSI frame
|
||||
//
|
||||
void decodeFSIFrameReceivedinSPI(SPI_FSIFrameInfo *frameInfo,
|
||||
SPI_FSIBuiltFrame *txFrame)
|
||||
{
|
||||
uint16_t temp = 0;
|
||||
uint16_t i = 0;
|
||||
uint16_t j = 0;
|
||||
uint16_t dataframe;
|
||||
uint16_t crc_val = 0;
|
||||
|
||||
//
|
||||
// Maximum num of words considered - 16 + udata
|
||||
//
|
||||
uint16_t crc_tempArray[17];
|
||||
|
||||
//
|
||||
// Get the frame type from first word and set the number of words in the
|
||||
// received frame, based on the frame type
|
||||
//
|
||||
temp = txFrame->spiDataBuf[i];
|
||||
frameInfo->type = (FSI_FrameType)((temp>>8) & 0x000F);
|
||||
|
||||
switch (frameInfo->type)
|
||||
{
|
||||
case FSI_FRAME_TYPE_NWORD_DATA:
|
||||
frameInfo->data_len = txFrame->frameLen - 2;
|
||||
dataframe = 1;
|
||||
break;
|
||||
case FSI_FRAME_TYPE_1WORD_DATA:
|
||||
frameInfo->data_len = 1;
|
||||
dataframe = 1;
|
||||
break;
|
||||
case FSI_FRAME_TYPE_2WORD_DATA:
|
||||
frameInfo->data_len = 2;
|
||||
dataframe = 1;
|
||||
break;
|
||||
case FSI_FRAME_TYPE_4WORD_DATA:
|
||||
frameInfo->data_len = 4;
|
||||
dataframe = 1;
|
||||
break;
|
||||
case FSI_FRAME_TYPE_6WORD_DATA:
|
||||
frameInfo->data_len = 6;
|
||||
dataframe = 1;
|
||||
break;
|
||||
case FSI_FRAME_TYPE_ERROR:
|
||||
case FSI_FRAME_TYPE_PING:
|
||||
frameInfo->data_len = 0;
|
||||
frameInfo->userdata = 0;
|
||||
dataframe = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// For data frames, get it calculated CRC value.
|
||||
// Fetch userdata and data from frame and use SW CRC function to calculate
|
||||
// CRC value
|
||||
//
|
||||
if(dataframe)
|
||||
{
|
||||
frameInfo->userdata = ((uint16_t)txFrame->spiDataBuf[i] & 0x00FF);
|
||||
|
||||
for(i = 1; i <= frameInfo->data_len; i++)
|
||||
{
|
||||
frameInfo->data[i-1] = txFrame->spiDataBuf[i];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the data and userdata into another buffer for the crc calculation
|
||||
//
|
||||
crc_tempArray[0] = (frameInfo->userdata <<8) & 0xFF00;
|
||||
for(j = 1; j <= frameInfo->data_len; j++)
|
||||
{
|
||||
crc_tempArray[j] = txFrame->spiDataBuf[j-1];
|
||||
}
|
||||
|
||||
crc_val = crc8((uint32_t)(&crc_tempArray[0]), frameInfo->data_len +1);
|
||||
frameInfo->crcbyte = crc_val & 0x000F;
|
||||
}
|
||||
|
||||
//
|
||||
// Complete the frame decoding the tag
|
||||
// Drop the last 4 bits since its just the end of frame
|
||||
//
|
||||
frameInfo->tag = (FSI_FrameTag)((txFrame->spiDataBuf[i] >> 4) & 0x000F);
|
||||
}
|
||||
|
||||
//
|
||||
// configureSPI - Configure SPI for Rx remote operation
|
||||
//
|
||||
void configureSPI(void)
|
||||
{
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_SPIA);
|
||||
|
||||
SPI_disableModule(SPIA_BASE);
|
||||
|
||||
//
|
||||
// SPI configuration. Use a 500kHz SPICLK and 16-bit word size.
|
||||
//
|
||||
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
|
||||
SPI_MODE_PERIPHERAL, 500000, 16);
|
||||
|
||||
SPI_enableFIFO(SPIA_BASE);
|
||||
SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_STOP_AFTER_TRANSMIT);
|
||||
|
||||
SPI_enableModule(SPIA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// crc8 - This function calculates crc8 i.e.polynomial with highest degree 8
|
||||
// It returns 32 bit crc and assumes that, at each location data is
|
||||
// written as "16" bit and i/p to the function is "starting address
|
||||
// location and no.of locations for which crc8 has to be calculated"
|
||||
//
|
||||
unsigned long crc8(unsigned long address, unsigned int no_locations)
|
||||
{
|
||||
int count;
|
||||
unsigned long address1 = address;
|
||||
|
||||
//
|
||||
// Clear CRC
|
||||
//
|
||||
asm(" VCRCCLR ");
|
||||
|
||||
for(count = 0; count < no_locations; count++){
|
||||
inpdata[count] = HWREGH(address1);
|
||||
address1++;
|
||||
}
|
||||
|
||||
//
|
||||
// Pointer to the beginning of data section - vcu_data_init - source pointer
|
||||
//
|
||||
asm(" MOVL XAR6,#inpdata ");
|
||||
|
||||
//
|
||||
// Pointer for destination
|
||||
//
|
||||
asm(" MOV DP,#resultcrccalculated ");
|
||||
|
||||
for(count = 1; count <= no_locations; count++)
|
||||
{
|
||||
//
|
||||
// CRC calculation : VCU instructions
|
||||
//
|
||||
asm(" VNOP ");
|
||||
asm(" VCRC8L_1 *XAR6 "); //calculates crc on lower byte of 16 bit
|
||||
asm(" VCRC8H_1 *XAR6++ "); //calculates crc on higher byte of 16 bit
|
||||
asm(" VNOP ");
|
||||
asm(" VNOP ");
|
||||
}
|
||||
|
||||
asm(" VMOV32 @resultcrccalculated, VCRC ");
|
||||
return(resultcrccalculated);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,646 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex7_spi_remote_rx.c
|
||||
//
|
||||
// TITLE: FSI(Remote Rx) and SPI(Main Tx) communication
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>FSI and SPI communication(fsi_ex7_spi_remote_rx) </h1>
|
||||
//!
|
||||
//! FSI supports SPI compatibility mode to talk to the devices not having FSI
|
||||
//! but SPI module. Example sets up infinite data frame transfers where FSI acts
|
||||
//! like remote Rx and SPI as main Rx.
|
||||
//! API to build the FSI frame at SPI end before transfer is implemented in SW
|
||||
//! and checks are made to ensure received details(frame tag/type, userdata,
|
||||
//! data) on FSI Rx match with transferred data.
|
||||
//!
|
||||
//! If there are any comparison failures during transfers or any of error
|
||||
//! event occurs, execution will stop.
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For FSI(Rx) <-> SPI(Tx) communication, make connections in GPIO settings
|
||||
//!
|
||||
//! There is no requirement for a chip select signal to be used when connected
|
||||
//! to the FSIRX. This is because the FSIRX will respond to any incoming clock
|
||||
//! edge.
|
||||
//!
|
||||
//! - GPIO_13 -> GPIO_18 :: To connect FSIRXCLKA with SPICLKA
|
||||
//! - GPIO_12 -> GPIO_16 :: To connect FSIRXD0A with SPIPICOA
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frame transfered
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
// Period(in us) with which CPU Timer-0 will send events
|
||||
#define TIMER_PERIOD_US 1000U
|
||||
|
||||
#define PRESCALER_VAL 25U
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1 -16
|
||||
uint16_t nWords = 13;
|
||||
|
||||
// FSI Clock used for transfer
|
||||
uint32_t fsiClock = 50000000;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10, txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// User data to be sent with Data frame
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
|
||||
uint32_t dataFrameCntr = 0;
|
||||
uint32_t error = 0, idx = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FSI_FrameType type;
|
||||
uint16_t userdata;
|
||||
uint16_t *data;
|
||||
uint16_t data_len;
|
||||
uint16_t crcbyte;
|
||||
FSI_FrameTag tag;
|
||||
} SPI_FSIFrameInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t frameLen;
|
||||
uint16_t spiDataBuf[18];
|
||||
} SPI_FSIBuiltFrame;
|
||||
|
||||
uint16_t spiTempBuf[18];
|
||||
SPI_FSIFrameInfo spiFrameInfo;
|
||||
SPI_FSIBuiltFrame spiBuiltFrame;
|
||||
|
||||
unsigned long resultcrccalculated = 0;
|
||||
int inpdata[50];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void configTimer0(void);
|
||||
|
||||
void prepareTxBufData(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
|
||||
void configureSPI(void);
|
||||
void sendFlushSeqFromSPI(void);
|
||||
void buildFSIFrameForSPI(SPI_FSIFrameInfo *frameInfo,
|
||||
SPI_FSIBuiltFrame *txFrame);
|
||||
|
||||
unsigned long crc8(unsigned long address, unsigned int no_locations);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Disable Internal Loopback in FSI Rx and keep it under main Core reset
|
||||
// till all GPIO settings are made, also clear any Rx events.
|
||||
//
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
FSI_resetRxModule(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
|
||||
//
|
||||
// NOTE: External loopback, Modify GPIO settings as per setup
|
||||
//
|
||||
GPIO_setPinConfig(GPIO_13_FSIRXA_CLK);
|
||||
GPIO_setPinConfig(GPIO_12_FSIRXA_D0);
|
||||
|
||||
GPIO_setPinConfig(GPIO_18_SPIA_CLK);
|
||||
GPIO_setPinConfig(GPIO_16_SPIA_SIMO);
|
||||
|
||||
//
|
||||
// Set GP12,13 to be asynchronous(pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
GPIO_setQualificationMode(12, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(13, GPIO_QUAL_ASYNC);
|
||||
|
||||
//
|
||||
// Configure SPI module for main Tx operation
|
||||
//
|
||||
configureSPI();
|
||||
|
||||
//
|
||||
// Enable SPI mode on the FSI Rx and take it out of reset. Also, send Flush
|
||||
// sequence from SPI to synchronize with FSI Rx
|
||||
//
|
||||
FSI_enableRxSPIMode(FSIRXA_BASE);
|
||||
FSI_clearRxModuleReset(FSIRXA_BASE, FSI_RX_MAIN_CORE_RESET);
|
||||
DEVICE_DELAY_US(10);
|
||||
sendFlushSeqFromSPI();
|
||||
|
||||
//
|
||||
// Assigning base addresses of Tx/Rx data buffer to globals
|
||||
//
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
txBufAddr = (uint16_t *)txBufData;
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Configure for data transfers
|
||||
//
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line and Error
|
||||
// events on INT2 from FSI Rx
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_DATA_FRAME |
|
||||
FSI_RX_EVT_FRAME_DONE);
|
||||
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_CRC_ERR |
|
||||
FSI_RX_EVT_EOF_ERR |
|
||||
FSI_RX_EVT_FRAME_OVERRUN |
|
||||
FSI_RX_EVT_TYPE_ERR);
|
||||
//
|
||||
// Setting for requested nWords with transfers
|
||||
//
|
||||
FSI_setRxSoftwareFrameSize(FSIRXA_BASE, nWords);
|
||||
|
||||
//
|
||||
// Fill the Frame Info fields for SPI main
|
||||
//
|
||||
spiFrameInfo.tag = txDataFrameTag;
|
||||
spiFrameInfo.data = &txBufData[0];
|
||||
spiFrameInfo.data_len = nWords;
|
||||
spiFrameInfo.type = FSI_FRAME_TYPE_NWORD_DATA;
|
||||
spiFrameInfo.userdata = txUserData;
|
||||
|
||||
//
|
||||
// Now, start transfers from SPI end after building a data frame.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Update Tx data and build frame for transfer
|
||||
//
|
||||
prepareTxBufData();
|
||||
buildFSIFrameForSPI(&spiFrameInfo, &spiBuiltFrame);
|
||||
|
||||
//
|
||||
// Now sending word(16 bit) by word from SPI for full frame
|
||||
//
|
||||
for(idx = 0; idx < spiBuiltFrame.frameLen; idx++)
|
||||
{
|
||||
SPI_writeDataBlockingFIFO(SPIA_BASE, spiBuiltFrame.spiDataBuf[idx]);
|
||||
}
|
||||
|
||||
//
|
||||
// Wait till FSI Rx completely receives a frame.
|
||||
//
|
||||
while (fsiRxInt1Received != 1U);
|
||||
fsiRxInt1Received = 0;
|
||||
|
||||
//
|
||||
// Verify Frame attributes and data
|
||||
//
|
||||
compare16(rxEventSts, (FSI_RX_EVT_DATA_FRAME | FSI_RX_EVT_FRAME_DONE));
|
||||
|
||||
compare16(FSI_getRxFrameType(FSIRXA_BASE), FSI_FRAME_TYPE_NWORD_DATA);
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), txDataFrameTag);
|
||||
compare16(FSI_getRxUserDefinedData(FSIRXA_BASE), txUserData);
|
||||
compareBufData(0U, 0U, nWords);
|
||||
|
||||
//
|
||||
// In case of comparison failures, break execution
|
||||
// Else, increment received data frame counter and reset FSI Rx buffer
|
||||
// for next transfer
|
||||
//
|
||||
if(error)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
dataFrameCntr++;
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
}
|
||||
|
||||
//
|
||||
// Coming out of infinite while loop means data comparison test failed.
|
||||
// Debug further to root-cause
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// prepareTxBufData - Update array which is used as source to Tx data buffer
|
||||
//
|
||||
void prepareTxBufData(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
txBufData[i] = txBufData[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxBufAddr[rxBufIndex] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
rxBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// buildFSIFrameForSPI - builds the data frame for SPI which FSI Rx can
|
||||
// understand
|
||||
//
|
||||
void buildFSIFrameForSPI(SPI_FSIFrameInfo *frameInfo,
|
||||
SPI_FSIBuiltFrame *txFrame)
|
||||
{
|
||||
uint16_t i = 0;
|
||||
uint16_t j = 0;
|
||||
// maximum 16 + udata
|
||||
uint16_t crc_tempArray[17];
|
||||
uint16_t crc_val = 0;
|
||||
|
||||
//
|
||||
// First put the SOF (1001'b) in the upper 4 bits
|
||||
// Frame Type field in the next 4 bits
|
||||
// User data in the lower 8 bits
|
||||
//
|
||||
i = 0;
|
||||
|
||||
txFrame->spiDataBuf[i] = 0x9000 | ((frameInfo->type <<8)& 0x0F00);
|
||||
|
||||
switch (frameInfo->type)
|
||||
{
|
||||
case FSI_FRAME_TYPE_NWORD_DATA:
|
||||
case FSI_FRAME_TYPE_1WORD_DATA:
|
||||
case FSI_FRAME_TYPE_2WORD_DATA:
|
||||
case FSI_FRAME_TYPE_4WORD_DATA:
|
||||
case FSI_FRAME_TYPE_6WORD_DATA:
|
||||
//
|
||||
// Data frame has been chosen. So add user data, set the frame
|
||||
// length and fill the data to be transmitted. Also, create the CRC
|
||||
// value on data + userdata to be sent across
|
||||
//
|
||||
txFrame->spiDataBuf[i] |=(frameInfo->userdata & 0x00FF);
|
||||
txFrame->frameLen= frameInfo->data_len + 2;
|
||||
|
||||
for(i = 1; i <= frameInfo->data_len; i++)
|
||||
{
|
||||
txFrame->spiDataBuf[i] = frameInfo->data[i-1];
|
||||
}
|
||||
|
||||
crc_tempArray[0] = (frameInfo->userdata <<8) & 0xFF00;
|
||||
for(j = 1; j <= frameInfo->data_len;j++)
|
||||
{
|
||||
crc_tempArray[j] = frameInfo->data[j-1];
|
||||
}
|
||||
|
||||
crc_val = crc8((uint32_t)(&crc_tempArray[0]), frameInfo->data_len +1);
|
||||
frameInfo->crcbyte = crc_val & 0x00FF;
|
||||
|
||||
//
|
||||
// Add the CRC (lower 8), Frame Tag (next 4), and EOF (upper4)
|
||||
//
|
||||
txFrame->spiDataBuf[i] = (crc_val <<8)&0xFF00;
|
||||
break;
|
||||
case FSI_FRAME_TYPE_ERROR:
|
||||
case FSI_FRAME_TYPE_PING:
|
||||
//
|
||||
// There is nothing else to add
|
||||
// set the data length of the SPI array to be 1 word.
|
||||
//
|
||||
txFrame->frameLen = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Complete the frame by adding the tag and EOF fields
|
||||
//
|
||||
txFrame->spiDataBuf[i] |= ((frameInfo->tag <<4) & 0x00F0) | 0x0006;
|
||||
}
|
||||
|
||||
//
|
||||
// configureSPI - Configures the SPI for main Tx operation
|
||||
//
|
||||
void configureSPI(void)
|
||||
{
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_SPIA);
|
||||
SPI_disableModule(SPIA_BASE);
|
||||
|
||||
SPI_setConfig(SPIA_BASE, SysCtl_getLowSpeedClock(20000000),
|
||||
SPI_PROT_POL0PHA0, SPI_MODE_CONTROLLER, 5000000, 16);
|
||||
|
||||
SPI_enableFIFO(SPIA_BASE);
|
||||
SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_FREE_RUN);
|
||||
|
||||
SPI_enableModule(SPIA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// sendFlushSeqFromSPI - Send Flush sequence from SPI to FSI Rx
|
||||
//
|
||||
void sendFlushSeqFromSPI(void)
|
||||
{
|
||||
SPI_writeDataBlockingFIFO(SPIA_BASE,0xFFFF);
|
||||
}
|
||||
|
||||
//
|
||||
// crc8 - This function calculates crc8 i.e. polynomial with highest degree 8
|
||||
// It returns 32 bit CRC and assumes that, at each location data is
|
||||
// written as "16" bit and i/p to the function is "starting address
|
||||
// location and no.of locations for which crc8 has to be calculated"
|
||||
//
|
||||
unsigned long crc8(unsigned long address, unsigned int no_locations)
|
||||
{
|
||||
int count;
|
||||
unsigned long address1 = address;
|
||||
|
||||
//
|
||||
// Clear CRC
|
||||
//
|
||||
asm(" VCRCCLR ");
|
||||
|
||||
for(count = 0; count < no_locations; count++){
|
||||
inpdata[count] = HWREGH(address1);
|
||||
address1++;
|
||||
}
|
||||
|
||||
//
|
||||
// Pointer to the beginning of data section - vcu_data_init - source pointer
|
||||
//
|
||||
asm(" MOVL XAR6,#inpdata ");
|
||||
|
||||
//
|
||||
// Pointer for destination
|
||||
//
|
||||
asm(" MOV DP,#resultcrccalculated ");
|
||||
|
||||
for(count = 1; count <= no_locations; count++)
|
||||
{
|
||||
//
|
||||
// CRC calculation : VCU instructions
|
||||
//
|
||||
asm(" VNOP ");
|
||||
asm(" VCRC8L_1 *XAR6 "); //calculates CRC on lower byte of 16 bit
|
||||
asm(" VCRC8H_1 *XAR6++ "); //calculates CRC on higher byte of 16 bit
|
||||
asm(" VNOP ");
|
||||
asm(" VNOP ");
|
||||
}
|
||||
|
||||
asm(" VMOV32 @resultcrccalculated, VCRC ");
|
||||
return(resultcrccalculated);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,559 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex8_ext_p2pconnection_rx.c
|
||||
//
|
||||
// TITLE: FSI Receive in Point to Point Connection
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>FSI P2Point Connection:Rx Side</h1>
|
||||
//!
|
||||
//! Example sets up FSI receiving device in a point to point connection
|
||||
//! to the FSI transmitting device. Example code to set up FSI transmit device
|
||||
//! is implemented in a separate file.
|
||||
//!
|
||||
//! In a real scenario two separate devices may power up in arbitrary order and
|
||||
//! there is a need to establish a clean communication link which ensures that
|
||||
//! receiver side is flushed to properly interpret the start of a new valid
|
||||
//! frame.
|
||||
//!
|
||||
//! There is no true concept of a main or a remote node in the FSI protocol,
|
||||
//! but to simplify the data flow and connection we can consider transmitting
|
||||
//! device as main and receiving side as remote. Transmitting side will be
|
||||
//! driver of initialization sequence.
|
||||
//!
|
||||
//! Handshake mechanism which must take place before actual data transmission
|
||||
//! can be usecase specific; points described below can be taken as an example
|
||||
//! on how to implement the handshake from receiving side -
|
||||
//!
|
||||
//! - Setup the receiver interrupts to detect PING type frame reception
|
||||
//! - Begin the first PING loop
|
||||
//! + Wait for receiver interrupt
|
||||
//! + If the FSI Rx has received a PING frame with \b FSI_FRAME_TAG0, come
|
||||
//! out of loop. Otherwise iterate the loop again.
|
||||
//! - Begin the second PING loop
|
||||
//! + Send the Flush sequence
|
||||
//! + Send the PING frame with tag \bFSI_FRAME_TAG1
|
||||
//! + Wait for receiver interrupt
|
||||
//! + If the FSI Rx has received a PING frame with \b FSI_FRAME_TAG1, come
|
||||
//! out of loop. Otherwise iterate the loop again.
|
||||
//! - Now, the receiver side has received the acknowledged PING frame(tag1), so
|
||||
//! it is ready for normal operation further.
|
||||
//!
|
||||
//! After above synchronization steps, FSI Rx can be configured as per usecase
|
||||
//! i.e. nWords, lane width, enabling events etc and start the infinite
|
||||
//! transfers. More details on establishing the communication link can be found
|
||||
//! in device TRM.
|
||||
//!
|
||||
//! User can edit some of configuration parameters as per usecase, similar to
|
||||
//! other examples.
|
||||
//!
|
||||
//! \b nWords - Number of words per transfer may be from 1 -16
|
||||
//! \b nLanes - Choice to select single or double lane for frame transfers
|
||||
//! \b fsiClock - FSI Clock used for transfers
|
||||
//! \b txUserData - User data to be sent with Data frame
|
||||
//! \b txDataFrameTag - Frame tag used for Data transfers
|
||||
//! \b txPingFrameTag - Frame tag used for Ping transfers
|
||||
//! \b txPingTimeRefCntr - Tx Ping timer reference counter
|
||||
//! \b rxWdTimeoutRefCntr - Rx Watchdog timeout reference counter
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For FSI external P2P connection, external connections are required
|
||||
//! to be made between two devices. Device 1's FSI TX and RX pins need to
|
||||
//! be connected to device 2's FSI RX and TX pins respectively. See below
|
||||
//! for external connections to make and GPIOs used:
|
||||
//!
|
||||
//! External connections required between independent RX and TX devices:
|
||||
//! - FSIRX_CLK to FSITX_CLK
|
||||
//! - FSIRX_RX0 to FSITX_TX0
|
||||
//! - FSIRX_RX1 to FSITX_TX1
|
||||
//!
|
||||
//! ControlCard FSI Header GPIOs:
|
||||
//! - GPIO_27 -> FSITXA_CLK
|
||||
//! - GPIO_26 -> FSITXA_TX0
|
||||
//! - GPIO_25 -> FSITXA_TX1
|
||||
//! - GPIO_9 -> FSIRXA_CLK
|
||||
//! - GPIO_8 -> FSIRXA_RX0
|
||||
//! - GPIO_10 -> FSIRXA_RX1
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frame received
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
#define PRESCALER_VAL FSI_PRESCALE_50MHZ
|
||||
|
||||
#define FSI_DELAY_LINE_CALIBRATION_ENABLE 0
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1 -16
|
||||
uint16_t nWords = 6;
|
||||
|
||||
// Transfer can be happen over single or double lane
|
||||
FSI_DataWidth nLanes = FSI_DATA_WIDTH_1_LANE;
|
||||
|
||||
// FSI Clock used for transfer
|
||||
uint32_t fsiClock = 50000000;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10, txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// User data to be sent with Data frame
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
// Tx Ping timer and Rx Watchdog reference counter values
|
||||
uint32_t txPingTimeRefCntr = 0x10000, rxWdTimeoutRefCntr = 0x14000;
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
uint32_t txTimeOutCntr = 0x100000, rxTimeOutCntr = 0x100000;
|
||||
uint32_t dataFrameCntr = 0;
|
||||
|
||||
uint32_t error = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void initFSI(void);
|
||||
void prepareTxBufData(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Initialize basic settings for FSI
|
||||
//
|
||||
initFSI();
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_PING_FRAME);
|
||||
|
||||
//
|
||||
// Wait till interrupt is received on FSIRX INT1 line, verify it's for FRAME
|
||||
// DONE event for PING Frame reception
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
while(fsiRxInt1Received != 1);
|
||||
compare16(rxEventSts, (FSI_RX_EVT_PING_FRAME | FSI_RX_EVT_FRAME_DONE));
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_PING, FSI_FRAME_TAG0);
|
||||
|
||||
//
|
||||
// If received frame type and tag matches, exit this loop and proceed to
|
||||
// next step by sending flush sequence, otherwise clear error and
|
||||
// interrupt flag and continue looping.
|
||||
//
|
||||
if(error == 0)
|
||||
{
|
||||
fsiRxInt1Received = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
fsiRxInt1Received = 0;
|
||||
error = 0;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Send the flush sequence
|
||||
//
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Send a ping frame with frame tag 0001b
|
||||
//
|
||||
FSI_setTxFrameTag(FSITXA_BASE, FSI_FRAME_TAG1);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_PING);
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
while(fsiRxInt1Received != 1U && rxTimeOutCntr != 0U)
|
||||
{
|
||||
DEVICE_DELAY_US(1);
|
||||
rxTimeOutCntr--;
|
||||
}
|
||||
|
||||
if(rxTimeOutCntr == 0)
|
||||
{
|
||||
rxTimeOutCntr = 0x100000;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(rxEventSts, (FSI_RX_EVT_PING_FRAME | FSI_RX_EVT_FRAME_DONE));
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_PING, FSI_FRAME_TAG1);
|
||||
//
|
||||
// If received frame type and tag matches, exit this loop and proceed
|
||||
// to next step by sending flush sequence, otherwise clear error and
|
||||
// interrupt flag and continue looping.
|
||||
//
|
||||
if(error == 0)
|
||||
{
|
||||
fsiRxInt1Received = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
fsiRxInt1Received = 0;
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if FSI_DELAY_LINE_CALIBRATION_ENABLE
|
||||
|
||||
// TODO - Implement FSI RX delay line calibration here
|
||||
// to compensate for channel-to-channel skew.
|
||||
// See Application Report SPRACJ9 and respective
|
||||
// software examples within C2000ware.
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Enable transmit/receive error events to be sent over INT2 line
|
||||
// Overrun and Underrun conditions in Rx are not enabled as buffer pointers
|
||||
// are always overwritten to first location for sending data frames.
|
||||
//
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVT_CRC_ERR |
|
||||
FSI_RX_EVT_EOF_ERR |
|
||||
FSI_RX_EVT_TYPE_ERR);
|
||||
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_PING_FRAME);
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_DATA_FRAME);
|
||||
|
||||
DEVICE_DELAY_US(10);
|
||||
|
||||
FSI_setRxSoftwareFrameSize(FSIRXA_BASE, nWords);
|
||||
FSI_setRxDataWidth(FSIRXA_BASE, nLanes);
|
||||
|
||||
//
|
||||
// Now, start transmitting data frames
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
while(fsiRxInt1Received != 1U);
|
||||
|
||||
//
|
||||
// Re-initialize flags and buffer pointer before next transmission
|
||||
//
|
||||
fsiRxInt1Received = 0U;
|
||||
FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// initFSI - Initializes FSI Tx/Rx and also sends FLUSH sequence.
|
||||
//
|
||||
void initFSI(void)
|
||||
{
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
//
|
||||
// NOTE: External loopback, Modify GPIO settings as per setup
|
||||
//
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TXCLK);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX0);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RXCLKA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX0A);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX1A);
|
||||
}
|
||||
|
||||
//
|
||||
// Set RX GPIO to be asynchronous
|
||||
// (pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX0A, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RXCLKA, GPIO_QUAL_ASYNC);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX1A, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
FSI_performRxInitialization(FSIRXA_BASE);
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
|
||||
//
|
||||
// Increment number of data frames received
|
||||
//
|
||||
if((rxEventSts & FSI_RX_EVT_DATA_FRAME) != 0)
|
||||
{
|
||||
dataFrameCntr++;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t rxDataArray[16];
|
||||
|
||||
FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, rxBufIndex);
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxDataArray[i] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,551 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: fsi_ex8_ext_p2pconnection_tx.c
|
||||
//
|
||||
// TITLE: FSI Transmit in Point to Point Connection
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>FSI P2Point Connection:Tx Side</h1>
|
||||
//!
|
||||
//! Example sets up FSI transmitting device in a point to point connection
|
||||
//! to the FSI receiving device. Example code to set up FSI receiving device is
|
||||
//! implemented in a separate file.
|
||||
//!
|
||||
//! In a real scenario two separate devices may power up in arbitrary order and
|
||||
//! there is a need to establish a clean communication link which ensures that
|
||||
//! receiver side is flushed to properly interpret the start of a new valid
|
||||
//! frame.
|
||||
//!
|
||||
//! There is no true concept of a main or a remote node in the FSI protocol,
|
||||
//! but to simplify the data flow and connection we can consider transmitting
|
||||
//! device as main and receiving side as remote. Transmitting side will be
|
||||
//! driver of initialization sequence.
|
||||
//!
|
||||
//! Handshake mechanism which must take place before actual data transmission
|
||||
//! can be usecase specific; points described below can be taken as an example
|
||||
//! on how to implement the handshake from transmitting side -
|
||||
//!
|
||||
//! - Setup the receiver interrupts to detect PING type frame reception
|
||||
//! - Begin the PING loop
|
||||
//! + Send the Flush sequence
|
||||
//! + Send a PING frame with the frame tag \b FSI_FRAME_TAG0
|
||||
//! + Wait for some time(determined by application)
|
||||
//! + If the FSI Rx has received a PING frame with \b FSI_FRAME_TAG1, come
|
||||
//! out of loop. Otherwise iterate the loop again
|
||||
//! - Send a PING frame with the frame tag FSI_FRAME_TAG1
|
||||
//!
|
||||
//! After above synchronization steps, FSI Tx can be configured as per usecase
|
||||
//! i.e. nWords, lane width, enabling events etc and start the infinite
|
||||
//! transfers. More details on establishing the communication link can be found
|
||||
//! in device TRM.
|
||||
//!
|
||||
//! User can edit some of configuration parameters as per usecase, similar to
|
||||
//! other examples.
|
||||
//!
|
||||
//! \b nWords - Number of words per transfer may be from 1 -16
|
||||
//! \b nLanes - Choice to select single or double lane for frame transfers
|
||||
//! \b fsiClock - FSI Clock used for transfers
|
||||
//! \b txUserData - User data to be sent with Data frame
|
||||
//! \b txDataFrameTag - Frame tag used for Data transfers
|
||||
//! \b txPingFrameTag - Frame tag used for Ping transfers
|
||||
//! \b txPingTimeRefCntr - Tx Ping timer reference counter
|
||||
//! \b rxWdTimeoutRefCntr - Rx Watchdog timeout reference counter
|
||||
//!
|
||||
//!\b External \b Connections \n
|
||||
//! For FSI external P2P connection, external connections are required
|
||||
//! to be made between two devices. Device 1's FSI TX and RX pins need to
|
||||
//! be connected to device 2's FSI RX and TX pins respectively. See below
|
||||
//! for external connections to make and GPIOs used:
|
||||
//!
|
||||
//! External connections required between independent RX and TX devices:
|
||||
//! - FSIRX_CLK to FSITX_CLK
|
||||
//! - FSIRX_RX0 to FSITX_TX0
|
||||
//! - FSIRX_RX1 to FSITX_TX1
|
||||
//!
|
||||
//! ControlCard FSI Header GPIOs:
|
||||
//! - GPIO_27 -> FSITXA_CLK
|
||||
//! - GPIO_26 -> FSITXA_TX0
|
||||
//! - GPIO_25 -> FSITXA_TX1
|
||||
//! - GPIO_9 -> FSIRXA_CLK
|
||||
//! - GPIO_8 -> FSIRXA_RX0
|
||||
//! - GPIO_10 -> FSIRXA_RX1
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b dataFrameCntr Number of Data frame transmitted
|
||||
//! - \b error Non zero for transmit/receive data mismatch
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
#define PRESCALER_VAL FSI_PRESCALE_50MHZ
|
||||
|
||||
#define FSI_DELAY_LINE_CALIBRATION_ENABLE 0
|
||||
|
||||
//
|
||||
// Globals, User can modify these parameters as per usecase
|
||||
//
|
||||
// Number of words per transfer may be from 1-16
|
||||
uint16_t nWords = 6;
|
||||
|
||||
// Transfer can be happen over single or double lane
|
||||
FSI_DataWidth nLanes = FSI_DATA_WIDTH_1_LANE;
|
||||
|
||||
// FSI Clock used for transfer
|
||||
uint32_t fsiClock = 50000000;
|
||||
|
||||
// Frame tag used with Data/Ping transfers
|
||||
FSI_FrameTag txDataFrameTag = FSI_FRAME_TAG10, txPingFrameTag = FSI_FRAME_TAG15;
|
||||
|
||||
// User data to be sent with Data frame
|
||||
uint16_t txUserData = 0x47;
|
||||
|
||||
// Tx Ping timer and Rx Watchdog reference counter values
|
||||
uint32_t txPingTimeRefCntr = 0x10000, rxWdTimeoutRefCntr = 0x14000;
|
||||
|
||||
// Boolean flag to enable/disable Rx Frame Watchdog
|
||||
bool isRxFrameWdEnable = true;
|
||||
|
||||
//
|
||||
// This value can be anything suitable to generate a single interrupt event,
|
||||
// lower values may lead WD to trigger another event even before handler of 1st
|
||||
// one is not completed
|
||||
//
|
||||
uint32_t rxFrameWdRefCntr = 0x1000000;
|
||||
|
||||
//
|
||||
// Globals, these are not config parameters, user are not required to edit them
|
||||
//
|
||||
uint16_t txEventSts = 0, rxEventSts = 0;
|
||||
uint16_t *txBufAddr = 0, *rxBufAddr = 0;
|
||||
|
||||
uint16_t txBufData[16] = {0};
|
||||
volatile uint32_t fsiTxInt1Received = 0,fsiTxInt2Received = 0;
|
||||
volatile uint32_t fsiRxInt1Received = 0,fsiRxInt2Received = 0;
|
||||
uint32_t txTimeOutCntr = 0x100000, rxTimeOutCntr = 0x100000;
|
||||
uint32_t dataFrameCntr = 0;
|
||||
|
||||
uint32_t error = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2);
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords);
|
||||
void disableAllFSIInterrupts(void);
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag);
|
||||
void initFSI(void);
|
||||
void prepareTxBufData(void);
|
||||
__interrupt void fsiTxInt1ISR(void);
|
||||
__interrupt void fsiTxInt2ISR(void);
|
||||
__interrupt void fsiRxInt1ISR(void);
|
||||
__interrupt void fsiRxInt2ISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Total 4; FSI Tx/Rx :: INT1/INT2
|
||||
//
|
||||
Interrupt_register(INT_FSITXA1, &fsiTxInt1ISR);
|
||||
Interrupt_register(INT_FSITXA2, &fsiTxInt2ISR);
|
||||
Interrupt_register(INT_FSIRXA1, &fsiRxInt1ISR);
|
||||
Interrupt_register(INT_FSIRXA2, &fsiRxInt2ISR);
|
||||
|
||||
//
|
||||
// Initialize basic settings for FSI
|
||||
//
|
||||
initFSI();
|
||||
|
||||
//
|
||||
// Enable FSI Tx/Rx interrupts
|
||||
//
|
||||
Interrupt_enable(INT_FSITXA1);
|
||||
Interrupt_enable(INT_FSITXA2);
|
||||
Interrupt_enable(INT_FSIRXA1);
|
||||
Interrupt_enable(INT_FSIRXA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Enable normal data transfer events to be sent over INT1 line
|
||||
//
|
||||
FSI_enableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVT_FRAME_DONE);
|
||||
FSI_enableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVT_PING_FRAME);
|
||||
|
||||
//
|
||||
// Wait till interrupt is received on FSIRX INT1 line, verify it's for FRAME
|
||||
// DONE event for PING Frame reception
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Send the flush sequence
|
||||
//
|
||||
FSI_executeTxFlushSequence(FSITXA_BASE, PRESCALER_VAL);
|
||||
|
||||
//
|
||||
// Send a ping frame with frame tag 0000b
|
||||
//
|
||||
FSI_setTxFrameTag(FSITXA_BASE, FSI_FRAME_TAG0);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_PING);
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
while(fsiRxInt1Received != 1U && rxTimeOutCntr != 0U)
|
||||
{
|
||||
DEVICE_DELAY_US(1);
|
||||
rxTimeOutCntr--;
|
||||
}
|
||||
|
||||
if(rxTimeOutCntr == 0)
|
||||
{
|
||||
rxTimeOutCntr = 0x100000;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(rxEventSts, (FSI_RX_EVT_PING_FRAME | FSI_RX_EVT_FRAME_DONE));
|
||||
checkReceivedFrameTypeTag(FSI_FRAME_TYPE_PING, FSI_FRAME_TAG1);
|
||||
//
|
||||
// If received frame type and tag matches, exit this loop and proceed
|
||||
// to next step by sending flush sequence, otherwise clear error and
|
||||
// interrupt flag and continue looping.
|
||||
//
|
||||
if(error == 0)
|
||||
{
|
||||
fsiRxInt1Received = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
fsiRxInt1Received = 0;
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Send a ping frame with frame tag 0001b
|
||||
//
|
||||
FSI_setTxFrameTag(FSITXA_BASE, FSI_FRAME_TAG1);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_PING);
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
DEVICE_DELAY_US(100);
|
||||
|
||||
#if FSI_DELAY_LINE_CALIBRATION_ENABLE
|
||||
|
||||
// TODO - Implement FSI RX delay line calibration here
|
||||
// to compensate for channel-to-channel skew.
|
||||
// See Application Report SPRACJ9 and respective
|
||||
// software examples within C2000ware.
|
||||
|
||||
#endif
|
||||
|
||||
FSI_setTxSoftwareFrameSize(FSITXA_BASE, nWords);
|
||||
FSI_setTxDataWidth(FSITXA_BASE, nLanes);
|
||||
FSI_setTxUserDefinedData(FSITXA_BASE, txUserData);
|
||||
FSI_setTxFrameTag(FSITXA_BASE, txDataFrameTag);
|
||||
FSI_setTxFrameType(FSITXA_BASE, FSI_FRAME_TYPE_NWORD_DATA);
|
||||
|
||||
//
|
||||
// Now, start transmitting data frames
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Write data into Tx buffer and set other Frame specific fields
|
||||
//
|
||||
prepareTxBufData();
|
||||
FSI_writeTxBuffer(FSITXA_BASE, txBufData, nWords, 0U);
|
||||
while(fsiTxInt1Received != 1U);
|
||||
|
||||
//
|
||||
// Start Transfer
|
||||
//
|
||||
FSI_startTxTransmit(FSITXA_BASE);
|
||||
|
||||
while(fsiTxInt1Received != 1);
|
||||
|
||||
//
|
||||
// Re-initialize flags and buffer pointer before next transmission
|
||||
//
|
||||
fsiTxInt1Received = 0U;
|
||||
dataFrameCntr++;
|
||||
FSI_setTxBufferPtr(FSITXA_BASE, 0U);
|
||||
DEVICE_DELAY_US(10);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// initFSI - Initializes FSI Tx/Rx and also sends FLUSH sequence.
|
||||
//
|
||||
void initFSI(void)
|
||||
{
|
||||
FSI_disableRxInternalLoopback(FSIRXA_BASE);
|
||||
|
||||
//
|
||||
// NOTE: External loopback, Modify GPIO settings as per setup
|
||||
//
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TXCLK);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX0);
|
||||
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RXCLKA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX0A);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_TX1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_FSI_RX1A);
|
||||
}
|
||||
|
||||
//
|
||||
// Set RX GPIO to be asynchronous
|
||||
// (pass through without delay)
|
||||
// Default setting is to have 2 SYS_CLK cycles delay
|
||||
//
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX0A, GPIO_QUAL_ASYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RXCLKA, GPIO_QUAL_ASYNC);
|
||||
if(nLanes == FSI_DATA_WIDTH_2_LANE)
|
||||
{
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_FSI_RX1A, GPIO_QUAL_ASYNC);
|
||||
}
|
||||
|
||||
//
|
||||
// Perform FSI Tx and Rx initialization
|
||||
//
|
||||
FSI_performTxInitialization(FSITXA_BASE, PRESCALER_VAL);
|
||||
FSI_performRxInitialization(FSIRXA_BASE);
|
||||
txBufAddr = (uint16_t *)FSI_getTxBufferAddress(FSITXA_BASE);
|
||||
rxBufAddr = (uint16_t *)FSI_getRxBufferAddress(FSIRXA_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// prepareTxBufData - Update array which is used as source to Tx data buffer
|
||||
//
|
||||
void prepareTxBufData(void)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
txBufData[i] = txBufData[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt1ISR - FSI Tx Interrupt on INsT1 line
|
||||
//
|
||||
__interrupt void fsiTxInt1ISR(void)
|
||||
{
|
||||
fsiTxInt1Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiTxInt2ISR - FSI Tx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiTxInt2ISR(void)
|
||||
{
|
||||
fsiTxInt2Received = 1U;
|
||||
|
||||
txEventSts = FSI_getTxEventStatus(FSITXA_BASE);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Actual Error
|
||||
// is captured in txEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt1ISR - FSI Rx Interrupt on INT1 line
|
||||
//
|
||||
__interrupt void fsiRxInt1ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt1Received = 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
}
|
||||
|
||||
//
|
||||
// fsiRxInt2ISR - FSI Rx Interrupt on INT2 line
|
||||
//
|
||||
__interrupt void fsiRxInt2ISR(void)
|
||||
{
|
||||
rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);
|
||||
|
||||
fsiRxInt2Received = fsiRxInt2Received + 1U;
|
||||
|
||||
//
|
||||
// Clear the interrupt flag and issue ACK
|
||||
//
|
||||
FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
|
||||
|
||||
disableAllFSIInterrupts();
|
||||
|
||||
//
|
||||
// INT2 line is set to fire for error events, stop immediately. Error
|
||||
// is captured in rxEventSts for debug
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// disableAllFSIInterrupts - Disables all event interrupts in both FSI Tx/Rx,
|
||||
// also clear them
|
||||
//
|
||||
void disableAllFSIInterrupts(void)
|
||||
{
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT1, FSI_TX_EVTMASK);
|
||||
FSI_disableTxInterrupt(FSITXA_BASE, FSI_INT2, FSI_TX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT1, FSI_RX_EVTMASK);
|
||||
FSI_disableRxInterrupt(FSIRXA_BASE, FSI_INT2, FSI_RX_EVTMASK);
|
||||
|
||||
FSI_clearTxEvents(FSITXA_BASE, FSI_TX_EVTMASK);
|
||||
FSI_clearRxEvents(FSIRXA_BASE, FSI_RX_EVTMASK);
|
||||
}
|
||||
|
||||
//
|
||||
// compare16 - Compares two 16 bit values and increments global error flag by 1
|
||||
// for mismatch
|
||||
//
|
||||
static inline void compare16(uint16_t val1, uint16_t val2)
|
||||
{
|
||||
if(val1 != val2)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// compareBufData - Compares if received data is same as transmitted ones
|
||||
// It doesn't consider wrap-up cases, but, can be enhanced
|
||||
//
|
||||
void compareBufData(uint16_t txBufIndex, uint16_t rxBufIndex, uint16_t nWords)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t rxDataArray[16];
|
||||
|
||||
FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, rxBufIndex);
|
||||
|
||||
for(i = 0; i < nWords; i++)
|
||||
{
|
||||
if(rxDataArray[i] != txBufAddr[txBufIndex])
|
||||
{
|
||||
error++;
|
||||
return;
|
||||
}
|
||||
|
||||
txBufIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// checkReceivedFrameTypeTag - Checks received frame type/tag and updates global
|
||||
// error flag
|
||||
//
|
||||
void checkReceivedFrameTypeTag(FSI_FrameType type, FSI_FrameTag tag)
|
||||
{
|
||||
compare16((uint16_t)FSI_getRxFrameType(FSIRXA_BASE), (uint16_t)type);
|
||||
|
||||
if(type == FSI_FRAME_TYPE_PING)
|
||||
{
|
||||
compare16(FSI_getRxPingTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
compare16(FSI_getRxFrameTag(FSIRXA_BASE), (uint16_t)tag);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user