EFC_EcatDriver

This commit is contained in:
seklyuts 2024-06-07 11:11:23 +03:00
parent 3eec0875b0
commit f754bd7630
33 changed files with 17791 additions and 0 deletions

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?ccsproject version="1.0"?>
<projectOptions>
<ccsVariant value="0:Eclipse-based"/>
<ccsVersion value="12.4.0"/>
<deviceVariant value="Cortex M.TMS320F28388D"/>
<deviceFamily value="TMS470"/>
<deviceEndianness value="little"/>
<codegenToolVersion value="20.2.7.LTS"/>
<isElfFormat value="true"/>
<createSlaveProjects value=""/>
<templateProperties value="id=com.ti.common.project.core.emptyProjectWithMainTemplate"/>
<filesToOpen value="main.c"/>
<isTargetManual value="false"/>
<origin value="D:/MotorControlModuleSDFM_TMS320F28388D/malyarenko/EFC_EcatDriver"/>
</projectOptions>

View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.779747171">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.779747171" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="com.ti.ccstudio.binaryparser.CoffParser" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.CoffErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.AsmErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.LinkErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="lib" artifactName="efc_ecat_cm" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.779747171" name="Debug" parent="com.ti.ccstudio.buildDefinitions.TMS470.Debug">
<folderInfo id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.779747171." name="/" resourcePath="">
<toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.libraryDebugToolchain.367416713" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.libraryDebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.librarianDebug.1344322407">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.589415374" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
<listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=Cortex M.TMS320F28388D"/>
<listOptionValue builtIn="false" value="DEVICE_CORE_ID="/>
<listOptionValue builtIn="false" value="DEVICE_ENDIANNESS=little"/>
<listOptionValue builtIn="false" value="OUTPUT_FORMAT=ELF"/>
<listOptionValue builtIn="false" value="CCS_MBS_VERSION=6.1.3"/>
<listOptionValue builtIn="false" value="OUTPUT_TYPE=staticLibrary"/>
<listOptionValue builtIn="false" value="PRODUCTS=c2000ware_software_package:5.0.0.00;"/>
<listOptionValue builtIn="false" value="PRODUCT_MACRO_IMPORTS={&quot;c2000ware_software_package&quot;:[&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INCLUDE_PATH}&quot;,&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_LIBRARY_PATH}&quot;,&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_LIBRARIES}&quot;,&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}&quot;,&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYSCONFIG_MANIFEST}&quot;]}"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.833796757" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="20.2.7.LTS" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.targetPlatformDebug.1115460" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.targetPlatformDebug"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.builderDebug.743774572" keepEnvironmentInBuildfile="false" name="GNU Make" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.builderDebug"/>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.compilerDebug.1988911961" name="Arm Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.compilerDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.SILICON_VERSION.1909397293" name="Target processor version (--silicon_version, -mv)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.SILICON_VERSION" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.SILICON_VERSION.7M4" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.CODE_STATE.2071754359" name="Designate code state, 16-bit (thumb) or 32-bit (--code_state)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.CODE_STATE" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.CODE_STATE.16" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.FLOAT_SUPPORT.1253650549" name="Specify floating point support (--float_support)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.FLOAT_SUPPORT" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.FLOAT_SUPPORT.none" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.GEN_FUNC_SUBSECTIONS.1078250721" name="Place each function in a separate subsection (--gen_func_subsections, -ms)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.GEN_FUNC_SUBSECTIONS" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.GEN_FUNC_SUBSECTIONS.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DEBUGGING_MODEL.1572892809" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DEBUGGING_MODEL" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DEBUGGING_MODEL._none" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WARNING.1185956654" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WARNING" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="225"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DISPLAY_ERROR_NUMBER.660145174" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DISPLAY_ERROR_NUMBER" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WRAP.1639153444" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WRAP" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.INCLUDE_PATH.935863231" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INSTALL_DIR}/device_support/f2838x/common/include"/>
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INSTALL_DIR}/driverlib/f2838x/driverlib_cm"/>
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INSTALL_DIR}/libraries/communications/Ethercat/f2838x/include"/>
<listOptionValue builtIn="false" value="${PROJECT_ROOT}/include"/>
<listOptionValue builtIn="false" value="${PROJECT_ROOT}/device"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.LITTLE_ENDIAN.473231484" name="Little endian code [See 'General' page to edit] (--little_endian, -me)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.LITTLE_ENDIAN" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DEFINE.1960491440" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DEFINE" valueType="definedSymbols"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.C_DIALECT.783059765" name="C Dialect" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.C_DIALECT" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.C_DIALECT.C11" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_LEVEL.288649803" name="Optimization level (--opt_level, -O)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_LEVEL.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_FOR_SPEED.1739341421" name="Speed vs. size trade-offs (--opt_for_speed, -mf)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_FOR_SPEED" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_FOR_SPEED.2" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OTHER_FLAGS.1434539465" name="Other flags" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OTHER_FLAGS" valueType="stringList">
<listOptionValue builtIn="false" value=""/>
</option>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__C_SRCS.65491363" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__C_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__CPP_SRCS.737872717" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__CPP_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__ASM_SRCS.2056613617" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__ASM_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__ASM2_SRCS.274557246" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__ASM2_SRCS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.librarianDebug.1344322407" name="Arm Archiver" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.librarianDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.OUTPUT_FILE.91858401" name="Output file" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.OUTPUT_FILE" useByScannerDiscovery="false" value="efc_ecat_cm.lib" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.VERBOSE.298175100" name="Verbose (v)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.VERBOSE" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.PRINT_GLOBAL_SYMBOLS.202221361" name="Print symbol table contents (s)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.PRINT_GLOBAL_SYMBOLS" value="false" valueType="boolean"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.ti.ccstudio.buildDefinitions.TMS470.Release.165659480">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.TMS470.Release.165659480" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="com.ti.ccstudio.binaryparser.CoffParser" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.CoffErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.AsmErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.LinkErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="lib" artifactName="efc_ecat_cm" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.TMS470.Release.165659480" name="Release" parent="com.ti.ccstudio.buildDefinitions.TMS470.Release">
<folderInfo id="com.ti.ccstudio.buildDefinitions.TMS470.Release.165659480." name="/" resourcePath="">
<toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.ReleaseToolchain.1226097760" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.ReleaseToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.librarianRelease.2062298442">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.849892926" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
<listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=Cortex M.TMS320F28388D"/>
<listOptionValue builtIn="false" value="DEVICE_CORE_ID="/>
<listOptionValue builtIn="false" value="DEVICE_ENDIANNESS=little"/>
<listOptionValue builtIn="false" value="OUTPUT_FORMAT=ELF"/>
<listOptionValue builtIn="false" value="CCS_MBS_VERSION=6.1.3"/>
<listOptionValue builtIn="false" value="OUTPUT_TYPE=staticLibrary"/>
<listOptionValue builtIn="false" value="PRODUCTS=c2000ware_software_package:5.0.0.00;"/>
<listOptionValue builtIn="false" value="PRODUCT_MACRO_IMPORTS={&quot;c2000ware_software_package&quot;:[&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INCLUDE_PATH}&quot;,&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_LIBRARY_PATH}&quot;,&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_LIBRARIES}&quot;,&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}&quot;,&quot;${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYSCONFIG_MANIFEST}&quot;]}"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1369294733" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="20.2.7.LTS" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.targetPlatformRelease.779956611" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.targetPlatformRelease"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.builderRelease.1735718130" keepEnvironmentInBuildfile="false" name="GNU Make" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.builderRelease"/>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.compilerRelease.929526181" name="Arm Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.compilerRelease">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.SILICON_VERSION.730543322" name="Target processor version (--silicon_version, -mv)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.SILICON_VERSION" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.SILICON_VERSION.7M4" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.CODE_STATE.2024874105" name="Designate code state, 16-bit (thumb) or 32-bit (--code_state)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.CODE_STATE" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.CODE_STATE.16" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.FLOAT_SUPPORT.1704554860" name="Specify floating point support (--float_support)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.FLOAT_SUPPORT" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.FLOAT_SUPPORT.none" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.GEN_FUNC_SUBSECTIONS.1006534814" name="Place each function in a separate subsection (--gen_func_subsections, -ms)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.GEN_FUNC_SUBSECTIONS" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.GEN_FUNC_SUBSECTIONS.on" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WARNING.1008443671" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WARNING" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="225"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DISPLAY_ERROR_NUMBER.589679653" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DISPLAY_ERROR_NUMBER" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WRAP.1288084194" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WRAP" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.INCLUDE_PATH.1189118873" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INSTALL_DIR}/device_support/f2838x/common/include"/>
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INSTALL_DIR}/driverlib/f2838x/driverlib_cm"/>
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_INSTALL_DIR}/libraries/communications/Ethercat/f2838x/include"/>
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
<listOptionValue builtIn="false" value="${PROJECT_ROOT}/include"/>
<listOptionValue builtIn="false" value="${PROJECT_ROOT}/device"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.LITTLE_ENDIAN.1104602926" name="Little endian code [See 'General' page to edit] (--little_endian, -me)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.LITTLE_ENDIAN" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DEFINE.1119485452" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.DEFINE" valueType="definedSymbols">
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_FOR_SPEED.1575451921" name="Speed vs. size trade-offs (--opt_for_speed, -mf)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_FOR_SPEED" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.OPT_FOR_SPEED.2" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.C_DIALECT.1225272476" name="C Dialect" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.C_DIALECT" value="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compilerID.C_DIALECT.C11" valueType="enumerated"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__C_SRCS.684624469" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__C_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__CPP_SRCS.710172533" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__CPP_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__ASM_SRCS.1304228572" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__ASM_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__ASM2_SRCS.1951790416" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.compiler.inputType__ASM2_SRCS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.librarianRelease.2062298442" name="Arm Archiver" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.library.librarianRelease">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.OUTPUT_FILE.778339118" name="Output file" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.OUTPUT_FILE" useByScannerDiscovery="false" value="efc_ecat_cm.lib" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.VERBOSE.1366045598" name="Verbose (v)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_20.2.archiverID.VERBOSE" value="true" valueType="boolean"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="device/cm.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="EFC_UsbDriver.com.ti.ccstudio.buildDefinitions.TMS470.ProjectType.1460968617" name="TMS470" projectType="com.ti.ccstudio.buildDefinitions.TMS470.ProjectType"/>
</storageModule>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/EFC_UsbDriver"/>
</configuration>
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/EFC_UsbDriver"/>
</configuration>
</storageModule>
<storageModule moduleId="scannerConfiguration"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

8
Projects/EFC_EcatDriver/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
/Debug/
/Release/
/doc/*
!/doc/.placeholder
/.settings/

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>EFC_EcatDriver</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.ti.ccstudio.core.ccsNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,137 @@
//#############################################################################
//
// FILE: cm.c
//
// TITLE: Communication manager setup for examples.
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2022 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 "cm.h"
//*****************************************************************************
//
// Function to initialize the device. Primarily initializes system control to a
// known state by disabling the watchdog and enabling the clocks to the peripherals.
//
//*****************************************************************************
void CM_init(void)
{
//
// Disable the watchdog
//
SysCtl_disableWatchdog();
#ifdef _FLASH
//
// Copy time critical code and flash setup code to RAM. This includes the
// following functions: InitFlash();
//
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart symbols
// are created by the linker. Refer to the device .cmd file.
//
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
//
// Call Flash Initialization to setup flash waitstates. This function must
// reside in RAM.
//
Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES);
#endif
//
// Turn on all peripherals
//
CM_enableAllPeripherals();
//
// Sets the NVIC vector table offset address.
//
#ifdef _FLASH
Interrupt_setVectorTableOffset((uint32_t)vectorTableFlash);
#else
Interrupt_setVectorTableOffset((uint32_t)vectorTableRAM);
#endif
}
//*****************************************************************************
//
// Function to turn on all peripherals, enabling reads and writes to the
// peripherals' registers.
//
// Note that to reduce power, unused peripherals should be disabled.
//
//*****************************************************************************
void CM_enableAllPeripherals(void)
{
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_UART0);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_SSI0);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_I2C0);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_USB);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_ENET);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_ECAT);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_CAN_A);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_CAN_B);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_MCAN_A);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TIMER0);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TIMER1);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TIMER2);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_UDMA);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_AESIP);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_GCRC);
}
////*****************************************************************************
////
//// Error handling function to be called when an ASSERT is violated
////
////*****************************************************************************
//void __error__(const char *filename, uint32_t line)
//{
// //
// // An ASSERT condition was evaluated as false. You can use the filename and
// // line parameters to determine what went wrong.
// //
// __asm(" bkpt #0");
//}

View File

@ -0,0 +1,112 @@
//#############################################################################
//
// FILE: cm.h
//
// TITLE: Communication manager setup for examples.
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2022 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_cm.h"
//*****************************************************************************
//
// Defines related to clock configuration. This frequency will be the CM clock
// frequency driven by c28x.
//
//*****************************************************************************
#define CM_CLK_FREQ 125000000U
//*****************************************************************************
//
// Macro to call SysCtl_delay() to achieve a delay in microseconds. The macro
// will convert the desired delay in microseconds to the count value expected
// by the function. \b x is the number of microseconds to delay.
// The SysCtl_delay() function takes around 3 cycles per iteration plus 9
// cycles of overhead which needs to be accounted for when converting the
// microseconds delay into the number of delay loop iterations passed to the
// SysCtl_delay() function.
//
// Note that 3 cycles per iteration is valid if SysCtl_delay function resides
// in CxRAM. SxRAM is 2x slower than CxRAM and hence will consume 6 cycles per
// iteration.
//
//*****************************************************************************
#define DEVICE_DELAY_US(x) SysCtl_delay(((((long double)(x)) / (1000000.0L / \
(long double)CM_CLK_FREQ)) - 9.0L) / 3.0L)
//*****************************************************************************
//
// Defines, Globals, and Header Includes related to Flash Support
//
//*****************************************************************************
#ifdef _FLASH
#include <stddef.h>
extern uint16_t RamfuncsLoadStart;
extern uint16_t RamfuncsLoadEnd;
extern uint16_t RamfuncsLoadSize;
extern uint16_t RamfuncsRunStart;
extern uint16_t RamfuncsRunEnd;
extern uint16_t RamfuncsRunSize;
#define DEVICE_FLASH_WAITSTATES 2
#endif
//*****************************************************************************
//
// Defines for pin numbers and other GPIO configuration
//
//*****************************************************************************
//
// LEDs
//
#define DEVICE_GPIO_PIN_LED1 31U // GPIO number for LD2
#define DEVICE_GPIO_PIN_LED2 34U // GPIO number for LD3
//*****************************************************************************
//
// Function Prototypes
//
//*****************************************************************************
extern void CM_init(void);
extern void CM_enableAllPeripherals(void);
extern void __error__(const char *filename, uint32_t line);

View File

@ -0,0 +1,95 @@
//#############################################################################
//
// FILE: driverlib.h
//
// TITLE: C28x Driverlib Header File
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2022 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 DRIVERLIB_H
#define DRIVERLIB_H
#include "inc/hw_memmap.h"
#include "adc.h"
#include "asysctl.h"
#include "bgcrc.h"
#include "can.h"
#include "cla.h"
#include "clb.h"
#include "cmpss.h"
#include "cpu.h"
#include "cputimer.h"
#include "dac.h"
#include "dcc.h"
#include "dcsm.h"
#include "debug.h"
#include "dma.h"
#include "ecap.h"
#include "emif.h"
#include "epwm.h"
#include "eqep.h"
#include "erad.h"
#include "escss.h"
#include "flash.h"
#include "fsi.h"
#include "gpio.h"
#include "hrcap.h"
#include "hrpwm.h"
#include "i2c.h"
#include "interrupt.h"
#include "ipc.h"
#include "mcbsp.h"
#include "memcfg.h"
#include "pin_map.h"
#include "pmbus.h"
#include "sci.h"
#include "sdfm.h"
#include "spi.h"
#include "sysctl.h"
#include "usb.h"
#include "xbar.h"
//
// Include MCAN driverlib header only if bitfield header is not already included
//
#ifndef F2838x_MCAN_H
#include "mcan.h"
#endif
#include "driver_inclusive_terminology_mapping.h"
#endif // end of DRIVERLIB_H definition

View File

View File

@ -0,0 +1,159 @@
/*
* efc_ecat.h
*
* Created on: 20 Nov 2023
* Author: titov
*/
#ifndef INCLUDE_EFC_ECAT_H_
#define INCLUDE_EFC_ECAT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include "../src/ssc/applInterface.h"
/**
* @defgroup Api API
*
* @{
*/
/**
* @defgroup Common Общий API
*
* @{
*/
/**
* @brief Инициализация EtherCat драйвера
*
* Вызов функции инициализации должен предшествовать всем оставльным функциям драйвера
*
* @return @c true при успешной инициализации; иначе @c false
*/
bool efc_ecat_init(void);
/**
* @brief Денициализация EtherCat драйвера
*
* После вызова драйвера обращения к его функциям запрещено
*
* @return @c void
*/
void efc_ecat_fini(void);
/**
* @brief Обработчик циклических задач EtherCat драйвера
*
* Обработчик должен исполняться в низкоприоритетном потоке
*
* @return void
*/
void efc_ecat_loop(void);
/** @} */ /* Common */
/**
* @defgroup EthercatStateMachine Обработка событий машины состояния API
*
* @{
*/
typedef enum ESMS1 {
PreOp = 1,
SafeOp = 2,
Op = 3
} EcatStateMachineStates;
bool efc_ecat_state_pending( EcatStateMachineStates state );
void efc_ecat_state_approve( EcatStateMachineStates state );
typedef void (*efc_ecat_state_pend_handler)( EcatStateMachineStates state );
void efc_ecat_set_state_pend_handler( efc_ecat_state_pend_handler pf );
/** @} */ /* EthercatStateMachine */
typedef void (*efc_ecat_update_sync0_time)( uint32_t time_in_us );
void efc_ecat_set_sync0_time_update_handler( efc_ecat_update_sync0_time pf );
void efc_ecat_set_device_id( uint16_t device_id );
typedef void (*efc_ecat_application_handler)( void );
void efc_ecat_set_application_handler( efc_ecat_application_handler pf );
/**
* @defgroup ProcessDataInterface Обработка данных реального времени
*
* @{
*/
/** @} */ /* ProcessDataInterface */
/**
* @defgroup ServiceDataInterface Обработка сервисных данных
*
* @{
*/
typedef UINT16 Index;
typedef UINT8 SubIndex;
typedef UINT32 Size;
typedef UINT8 CompliteAccess;
typedef UINT16 Data;
typedef UINT8 ResultType;
enum ResultCode {
Done = 0x00, //!<Успешное завершение.
ToggleBitNotChanged = 0x01, /**< Index of "Toggle bit not changed" */
SdoProtocolTimeout = 0x02, /**< Index of "SDO timeout" */
CommandSpecifierUnknown = 0x03, /**< Index of "Command specifier unknown" */
OutOfMemory = 0x04, /**< Index of "Out of memory" */
UnsupportedAccess = 0x05, /**< Index of "Unsupported Access" */
WriteOnlyEntry = 0x06, /**< Index of "Write only entry" */
ReadOnlyEntry = 0x07, /**< Index of "Read only entry" */
ObjectNotExisting = 0x08, /**< Index of "Object not existing" */
ObjectCantBePdoMapped = 0x09, /**< Index of "Object can not be mapped to PDO" */
MappedObjectsExceedPdo = 0x0A, /**< Index of "Mapped Object exceeds PDO" */
ParamIsIncompatible = 0x0B, /**< Index of "Parameter is incompatible" */
InternalDeviceIncompatibility = 0x0C, /**< Index of "Device incompatibility" */
HardwareError = 0x0D, /**< Index of "Hardware error" */
ParamLengthError = 0x0E, /**< Index of "Parameter length error" */
ParamLengthTooLong = 0x0F, /**< Index of "Parameter is too long" */
ParamLengthTooShort = 0x10, /**< Index of "Parameter is too short" */
SubindexNotExisting = 0x11, /**< Index of "Subindex (Entry) not exists" */
ValueExceeded = 0x12, /**< Index of "Value exceeds" */
ValueTooGreat = 0x13, /**< Index of "Value is too great" */
ValueTooSmall = 0x14, /**< Index of "Value is too small" */
ModuleIdListNotMatch = 0x15, /**< Index of "Unequal Module Id list" */
MaxValueIsLessThanMinValue = 0x16, /**< Index of "Value is less than minimum value" */
GeneralError = 0x17, /**< Index of "General error" */
DataCannotBeReadWrite = 0x18, /**< Index of "Data can not be read or written" */
DataCannotBeAccessedWithLocalControl = 0x19, /**< Index of "Data can not be accessed because of local control" */
DataCannotBeReadWriteInCurrentState = 0x1A, /**< Index of "Data can not be read or written in the current state" */
NoObjectDictionaryIsPresent = 0x1B, /**< Index of "Object is not in the object dictionary" */
EntryCantBeWrittenSi0Not0 = 0x1C, /**< Index of "Entry can not be written because Subindex0 is not 0" */
CompleteAccessNotSupported = 0x1D, /**< The object can not be accessed via complete access */
Working = 0xFF /**< Index of application is handling the SDO request */
};
typedef ResultType (* InterfaceRead)( Index index, SubIndex subindex, Size size, Data * data, CompliteAccess complete_access );
typedef ResultType (* InterfaceWrite)( Index index, SubIndex subindex, Size size, Data * data, CompliteAccess complete_access );
/** @} */ /* Api */
#ifdef __cplusplus
}
#endif
#endif /* INCLUDE_EFC_ECAT_H_ */

View File

@ -0,0 +1,705 @@
/*
* ethercat_slave_api.c
*
* Created on: 20 нояб. 2023 г.
* Author: titov
*/
#include <efc_ecat.h>
#include "ssc/ecat_def.h"
#include "ssc/ecatappl.h"
#include "ssc/sdoserv.h"
#include "ssc/objdef.h"
/******************************************************************************
* Object 0x1600 : OutputMapping
******************************************************************************/
/**
* \addtogroup 0x1600 0x1600 | OutputMapping
* @{
* \brief Object 0x1600 (OutputMapping) definition
*/
/**
* \brief Object entry descriptions<br>
* <br>
* SubIndex 0<br>
* SubIndex 1 - map 0x7000 SIO 32bit<br>
* SubIndex 2 - map 0x7001 SIO 8bit<br>
* SubIndex 3 - 8bit padding<br>
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM asEntryDesc0x1600[] = {
{ DEFTYPE_UNSIGNED8 , 0x8 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ }
};
/**
* \brief Object/Entry names
*/
OBJCONST UCHAR OBJMEM aName0x1600[] = "OutputMapping\000"
"SubIndex 001\000"
"SubIndex 002\000"
"SubIndex 003\000"
"SubIndex 004\000"
"SubIndex 005\000"
"SubIndex 006\000"
"SubIndex 007\000"
"SubIndex 008\000"
"SubIndex 009\000"
"SubIndex 010\000"
"SubIndex 011\000"
"SubIndex 012\000"
"SubIndex 013\000"
"SubIndex 014\000"
"SubIndex 015\000"
"SubIndex 016\000\377";
/**
* \brief Object structure
*/
typedef struct OBJ_STRUCT_PACKED_START {
UINT16 u16SubIndex0;
UINT32 aEntries[16];
} OBJ_STRUCT_PACKED_END
TOBJ1600;
/**
* \brief Object variable
*/
TOBJ1600 OutputMapping0x1600;
/** @}*/
/******************************************************************************
* Object 0x1A00 : InputMapping
******************************************************************************/
/**
* \addtogroup 0x1A00 0x1A00 | InputMapping
* @{
* \brief Object 0x1A00 (InputMapping) definition
*/
/**
* \brief Object entry descriptions<br>
* <br>
* SubIndex 0<br>
* SubIndex 1 - map SI 0bit<br>
* SubIndex 2 - 8bit padding<br>
* SubIndex 3 - map 0x6001 SIO 16bit<br>
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM asEntryDesc0x1A00[] = {
{ DEFTYPE_UNSIGNED8 , 0x8 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ },
{ DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ }
};
/**
* \brief Object/Entry names
*/
OBJCONST UCHAR OBJMEM aName0x1A00[] = "InputMapping\000"
"SubIndex 001\000"
"SubIndex 002\000"
"SubIndex 003\000"
"SubIndex 004\000"
"SubIndex 005\000"
"SubIndex 006\000"
"SubIndex 007\000"
"SubIndex 008\000"
"SubIndex 009\000"
"SubIndex 010\000"
"SubIndex 011\000"
"SubIndex 012\000"
"SubIndex 013\000"
"SubIndex 014\000"
"SubIndex 015\000"
"SubIndex 016\000\377";
/**
* \brief Object structure
*/
typedef struct OBJ_STRUCT_PACKED_START {
UINT16 u16SubIndex0;
UINT32 aEntries[16];
} OBJ_STRUCT_PACKED_END
TOBJ1A00;
/**
* \brief Object variable
*/
TOBJ1A00 InputMapping0x1A00;
/** @}*/
/******************************************************************************
* Object 0x1C12 : Obj0x1C12
******************************************************************************/
/**
* \addtogroup 0x1C12 0x1C12 | Obj0x1C12
* @{
* \brief Object 0x1C12 (Obj0x1C12) definition
*/
/**
* \brief Entry descriptions<br>
*
* Subindex 0<br>
* Subindex 1 - n (the same entry description is used)<br>
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM asEntryDesc0x1C12[] = {
{ DEFTYPE_UNSIGNED8 , 0x8 , ACCESS_READ },
{ DEFTYPE_UNSIGNED16 , 0x10 , ACCESS_READ }};
/**
* \brief Object name definition<br>
* For Subindex 1 to n the syntax 'Subindex XXX' is used
*/
OBJCONST UCHAR OBJMEM aName0x1C12[] = "Obj0x1C12\000\377";
/**
* \brief Object structure
*/
typedef struct OBJ_STRUCT_PACKED_START {
UINT16 u16SubIndex0; /**< \brief Subindex 0 */
UINT16 aEntries[1]; /**< \brief Subindex 1 - 1 */
} OBJ_STRUCT_PACKED_END
TOBJ1C12;
/**
* \brief Object variable
*/
TOBJ1C12 sRxPDOassign;
/** @}*/
/******************************************************************************
* Object 0x1C13 : Obj0x1C13
******************************************************************************/
/**
* \addtogroup 0x1C13 0x1C13 | Obj0x1C13
* @{
* \brief Object 0x1C13 (Obj0x1C13) definition
*/
/**
* \brief Entry descriptions<br>
*
* Subindex 0<br>
* Subindex 1 - n (the same entry description is used)<br>
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM asEntryDesc0x1C13[] = {
{ DEFTYPE_UNSIGNED8 , 0x8 , ACCESS_READ },
{ DEFTYPE_UNSIGNED16 , 0x10 , ACCESS_READ }};
/**
* \brief Object name definition<br>
* For Subindex 1 to n the syntax 'Subindex XXX' is used
*/
OBJCONST UCHAR OBJMEM aName0x1C13[] = "Obj0x1C13\000\377";
/**
* \brief Object structure
*/
typedef struct OBJ_STRUCT_PACKED_START {
UINT16 u16SubIndex0; /**< \brief Subindex 0 */
UINT16 aEntries[1]; /**< \brief Subindex 1 - 1 */
} OBJ_STRUCT_PACKED_END
TOBJ1C13;
/**
* \brief Object variable
*/
TOBJ1C13 sTxPDOassign;
/** @}*/
TOBJECT OBJMEM ApplicationObjDic[] = {
/* Object 0x1600 */
{NULL , NULL , 0x1600 , {DEFTYPE_PDOMAPPING , 3 | (OBJCODE_REC << 8)} , asEntryDesc0x1600 , aName0x1600 , &OutputMapping0x1600 , NULL , NULL , 0x0000 },
/* Object 0x1A00 */
{NULL , NULL , 0x1A00 , {DEFTYPE_PDOMAPPING , 3 | (OBJCODE_REC << 8)} , asEntryDesc0x1A00 , aName0x1A00 , &InputMapping0x1A00 , NULL , NULL , 0x0000 },
/* Object 0x1C12 */
{NULL , NULL , 0x1C12 , {DEFTYPE_UNSIGNED16 , 1 | (OBJCODE_ARR << 8)} , asEntryDesc0x1C12 , aName0x1C12 , &sRxPDOassign , NULL , NULL , 0x0000 },
/* Object 0x1C13 */
{NULL , NULL , 0x1C13 , {DEFTYPE_UNSIGNED16 , 1 | (OBJCODE_ARR << 8)} , asEntryDesc0x1C13 , aName0x1C13 , &sTxPDOassign , NULL , NULL , 0x0000 },
{NULL,NULL, 0xFFFF, {0, 0}, NULL, NULL, NULL, NULL}
};
void PDO_Mapping_init(void) {
OutputMapping0x1600.u16SubIndex0 = 16;
for( int i = 0; i < 16; i++)
OutputMapping0x1600.aEntries[i] = 0;
InputMapping0x1A00.u16SubIndex0 = 16;
for( int i = 0; i < 16; i++)
InputMapping0x1A00.aEntries[i] = 0;
sRxPDOassign.u16SubIndex0 = 1;
sRxPDOassign.aEntries[0] = 0x1600;
sTxPDOassign.u16SubIndex0 = 1;
sTxPDOassign.aEntries[0] = 0x1A00;
}
/** @}*/
bool efc_ecat_init( void ) {
PDO_Mapping_init();
HW_Init();
MainInit();
return true;
}
/**
* @brief Денициализация EtherCat драйвера
*
* После вызова драйвера обращения к его функциям запрещено
*
* @return @c void
*/
void efc_ecat_fini( void ) {
HW_Release();
}
/**
* @brief Обработчик циклических задач EtherCat драйвера
*
* Обработчик должен быть зарегистрирован на прерывание от используемого модуля EtherCat
*
* @return void
*/
void efc_ecat_loop( void ) {
MainLoop();
}
//!Подтверждение сброса ошибки от мастера
void APPL_AckErrorInd(UINT16 stateTrans) {}
EcatStateMachineStates efc_ecat_pend_state;
efc_ecat_state_pend_handler efc_ecat_pend_handler;
efc_ecat_update_sync0_time efc_ecat_sync0_time;
uint16_t efc_ecat_device_id;
efc_ecat_application_handler efc_ecat_app_handler;
/*!
* Функция вызывается при переходе состояния из INIT в PREOP,
* когда все общие настройки были проверены для запуска обработчика почтового ящика.
* Эта функция информирует приложение о переходе состояния, приложение может отказаться от перехода состояния,
* возвращая код ошибки AL Status.
*
* Код возврата NOERROR_INWORK можно использовать, если приложение не может немедленно подтвердить переход состояния,
* в этом случае приложению необходимо завершить переход,
* вызвав ECAT_StateChange.
*
*
*/
UINT16 APPL_StartMailboxHandler(void) {
efc_ecat_pend_state = PreOp;
efc_ecat_pend_handler( efc_ecat_pend_state );
//Нужно будет вызвать ECAT_StateChange.
return NOERROR_INWORK;
}
/*!
* Функция вызывается при переходе состояния от PREEOP к INIT, чтобы остановить обработчик почтового ящика.
* Эта функция информирует приложение о переходе состояния, приложение не может отказаться от перехода состояния.
*/
UINT16 APPL_StopMailboxHandler(void) {
return ALSTATUSCODE_NOERROR;
}
/*!
* Функция вызывается при переходе состояния от PREOP к SAFEOP, когда все общие настройки были проверены для запуска обработчика ввода.
* Эта функция информирует приложение о переходе состояния, приложение может отказаться от перехода состояния,
* возвращая код ошибки AL Status.
*
* Код возврата NOERROR_INWORK можно использовать, если приложение не может немедленно подтвердить переход состояния,
* в этом случае приложению необходимо завершить переход, вызвав ECAT_StateChange.
*
* \param pIntMask указатель на маску событий AL,
* которая будет записана в регистр маски событий AL (0x204) при успешном выполнении этой функции.
* В этой функции можно настроить маску события.
*
*/
UINT16 APPL_StartInputHandler( UINT16 * pIntMask ) {
efc_ecat_pend_state = SafeOp;
//Уведомление словаря объектов
//
// Object 0xF030 was not written before
// => update object 0xF010 (Module profile list) and 0xF050 (Detected Module List)
//
// Update 0xF010.0
// Update 0xF050.0
/*Init CiA402 structure if the device is in SM Sync mode
the CiA402 structure will be Initialized after calculation of the Cycle time*/
if(bDcSyncActive == TRUE) {
UINT32 Sync0CycleTime = 0;
HW_EscReadDWord(Sync0CycleTime, ESC_DC_SYNC0_CYCLETIME_OFFSET);
Sync0CycleTime = SWAPDWORD(Sync0CycleTime);
efc_ecat_sync0_time( Sync0CycleTime / 1000 ); //get cycle time in us
}
efc_ecat_pend_handler( efc_ecat_pend_state );
return NOERROR_INWORK;
}
/*!
* Функция вызывается при переходе состояния от SAFEOP к PREEOP, чтобы остановить обработчик ввода.
* Эта функция информирует приложение о переходе состояния, приложение не может отказаться от перехода состояния.
*/
UINT16 APPL_StopInputHandler(void) {
return ALSTATUSCODE_NOERROR;
}
UINT16 APPL_StartOutputHandler(void) {
efc_ecat_pend_state = Op;
efc_ecat_pend_handler( efc_ecat_pend_state );
return NOERROR_INWORK;
}
UINT16 APPL_StopOutputHandler(void) {
return ALSTATUSCODE_NOERROR;
}
typedef struct Part_t {
void * original;
uint16_t offset;
uint16_t size;
} MatchingElement;
//MappingMap
uint16_t recieve_elements_map_num = 0;
const uint16_t recieve_elements_map_size = 16;
MatchingElement recieve_elements_map[16];
uint16_t transmit_elements_map_num = 0;
const uint16_t transmit_elements_map_size = 16;
MatchingElement transmit_elements_map[16];
/*!
* Вычислить размеры данных процесса на основе фактического SM-PDO-Assign и сопоставления PDO.
*/
UINT16 APPL_GenerateMapping( UINT16 * pInputSize, UINT16 * pOutputSize ) {
UINT16 result = ALSTATUSCODE_NOERROR;
UINT16 InputSize = 0;
UINT16 OutputSize = 0;
UINT16 PDOAssignEntryCnt = 0;
OBJCONST TOBJECT OBJMEM * pPDO = NULL;
UINT16 PDOSubindex0 = 0;
UINT32 *pPDOEntry = NULL;
UINT16 PDOEntryCnt = 0;
//Расчет размера TPDO, RPDO.
/*Scan object 0x1C12 RXPDO assign*/
for( PDOAssignEntryCnt = 0; PDOAssignEntryCnt < sRxPDOassign.u16SubIndex0; PDOAssignEntryCnt++ ) {
//PDO Mapping Object
pPDO = OBJ_GetObjectHandle(sRxPDOassign.aEntries[PDOAssignEntryCnt]);
if(pPDO != NULL) {
PDOSubindex0 = *((UINT16 *)pPDO->pVarPtr);
for(PDOEntryCnt = 0; PDOEntryCnt < PDOSubindex0; PDOEntryCnt++) {
pPDOEntry = (UINT32 *)(((UINT16 *)pPDO->pVarPtr) + (OBJ_GetEntryOffset((PDOEntryCnt+1),pPDO)>>4)); //goto PDO entry
// we increment the expected output size depending on the mapped Entry
uint16_t PdoObjectId = (UINT16) ((*pPDOEntry) >> 16);
uint16_t PdoObjectSubId = (UINT16) (((*pPDOEntry) >> 8) & 0xFF);
uint16_t PdoObjectSize = (UINT16) ((*pPDOEntry) & 0xFF);
if( PdoObjectId ) {
OBJCONST TOBJECT OBJMEM * object = OBJ_GetObjectHandle( PdoObjectId );
uint8_t * PdoObjectData = (UINT16 *)object->pVarPtr + (OBJ_GetEntryOffset((PdoObjectSubId),pPDO)>>4);
recieve_elements_map[recieve_elements_map_num].original = PdoObjectData;
recieve_elements_map[recieve_elements_map_num].size = (PdoObjectSize + 7) >> 3; //TODO: Вопрос, что будет если объект будет некоторого малого количества бит??
recieve_elements_map[recieve_elements_map_num].offset = (OutputSize + 7) >> 3;
recieve_elements_map_num++;
}
OutputSize += PdoObjectSize;
}
}
else
{
/*assigned PDO was not found in object dictionary. return invalid mapping*/
OutputSize = 0;
result = ALSTATUSCODE_INVALIDOUTPUTMAPPING;
break;
}
}
//Из битов в октеты
OutputSize = (OutputSize + 7) >> 3;
if(result == 0)
{
/*Scan Object 0x1C13 TXPDO assign*/
for(PDOAssignEntryCnt = 0; PDOAssignEntryCnt < sTxPDOassign.u16SubIndex0; PDOAssignEntryCnt++)
{
pPDO = OBJ_GetObjectHandle(sTxPDOassign.aEntries[PDOAssignEntryCnt]);
if(pPDO != NULL)
{
PDOSubindex0 = *((UINT16 *)pPDO->pVarPtr);
for(PDOEntryCnt = 0; PDOEntryCnt < PDOSubindex0; PDOEntryCnt++)
{
pPDOEntry = (UINT32 *)(((UINT16 *)pPDO->pVarPtr) + (OBJ_GetEntryOffset((PDOEntryCnt+1),pPDO)>>4)); //goto PDO entry
// we increment the expected output size depending on the mapped Entry
uint16_t PdoObjectId = (UINT16) ((*pPDOEntry) >> 16);
uint16_t PdoObjectSubId = (UINT16) (((*pPDOEntry) >> 8) & 0xFF);
uint16_t PdoObjectSize = (UINT16) ((*pPDOEntry) & 0xFF);
OBJCONST TOBJECT OBJMEM * object = OBJ_GetObjectHandle( PdoObjectId );
if( PdoObjectId ) {
uint8_t * PdoObjectData = (UINT16 *)object->pVarPtr + (OBJ_GetEntryOffset((PdoObjectSubId),pPDO)>>4);
transmit_elements_map[recieve_elements_map_num].original = PdoObjectData;
transmit_elements_map[recieve_elements_map_num].size = (PdoObjectSize + 7) >> 3; //TODO: Вопрос, что будет если объект будет некоторого малого количества бит??
transmit_elements_map[recieve_elements_map_num].offset = (InputSize + 7) >> 3;
transmit_elements_map_num++;
}
InputSize += PdoObjectSize;
}
}
else
{
/*assigned PDO was not found in object dictionary. return invalid mapping*/
InputSize = 0;
result = ALSTATUSCODE_INVALIDINPUTMAPPING;
break;
}
}
}
InputSize = (InputSize + 7) >> 3;
*pInputSize = InputSize;
*pOutputSize = OutputSize;
return result;
}
/*!
* Обновить значение TXPDO буффера (исходящего из устройства).
*/
void APPL_InputMapping( UINT16 * pData ) {
uint8_t * write_data = (UINT8 *)pData;
//Обновление TXPDO.
for( uint16_t el = 0; el < transmit_elements_map_num; el++ ) {
memcpy( transmit_elements_map[el].original, write_data + transmit_elements_map[el].offset, transmit_elements_map[el].size );
}
}
/*!
* Обновить значение RXPDO буффера (входящее в устройства).
*/
void APPL_OutputMapping( UINT16 * pData ) {
const uint8_t * read_data = (UINT8 *)pData;
//Обновление RXPDO.
for( uint16_t el = 0; el < recieve_elements_map_num; el++ ) {
memcpy( read_data + recieve_elements_map[el].offset, recieve_elements_map[el].original, recieve_elements_map[el].size );
}
}
/*!
* Синхронизация приложения с циклом EtherCat.
* Функция вызывается из прерывания синхронизации, или главного цикла.
*/
void APPL_Application(void) {
efc_ecat_app_handler();
}
UINT16 APPL_GetDeviceID(void) {
return efc_ecat_device_id;
}
bool efc_ecat_state_pending( EcatStateMachineStates state ) {
return efc_ecat_pend_state = state;
}
void efc_ecat_state_approve( EcatStateMachineStates state ) {
if( !efc_ecat_state_pending(state) )
return;
switch(state) {
case PreOp: {
ECAT_StateChange(INIT_2_PREOP, ALSTATUSCODE_NOERROR);
} break;
case SafeOp: {
ECAT_StateChange(PREOP_2_SAFEOP, ALSTATUSCODE_NOERROR);
} break;
case Op: {
ECAT_StateChange(SAFEOP_2_OP, ALSTATUSCODE_NOERROR);
} break;
}
}
typedef void (*efc_ecat_state_pend_handler)( EcatStateMachineStates state );
void efc_ecat_set_state_pend_handler( efc_ecat_state_pend_handler pf ) {
efc_ecat_pend_handler = pf;
}
/** @} */ /* EthercatStateMachineAPI */
typedef void (*efc_ecat_update_sync0_time)( uint32_t time_in_us );
void efc_ecat_set_sync0_time_update_handler( efc_ecat_update_sync0_time pf ) {
efc_ecat_sync0_time = pf;
}
typedef uint16_t (*efc_ecat_get_device_id_handler)( void );
void efc_ecat_set_device_id( uint16_t device_id ) {
efc_ecat_device_id = device_id;
}
typedef void (*efc_ecat_application_handler)( void );
void efc_ecat_set_application_handler( efc_ecat_application_handler pf ) {
efc_ecat_app_handler = pf;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,149 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
\addtogroup EcatAppl EtherCAT application
@{
*/
/**
\file applInterface.h
\author EthercatSSC@beckhoff.com
\brief Definition of the application interface functions
\version 5.13
<br>Changes to version V5.12:<br>
V5.13 COE4: update default entry name handling in case of 16Bit characters, add CoE Read/write indication functions<br>
<br>Changes to version V5.11:<br>
V5.12 APPL1: add optional application function called from the main loop (after mbx and esm are executed)<br>
V5.12 EEPROM3: implement a store EEPROM timeout handler<br>
V5.12 EOE1: move icmp sample to the sampleappl,add EoE application interface functions<br>
V5.12 FOE1: update new interface,move the FoE sample to sampleappl,add FoE application callback functions<br>
<br>Changes to version - :<br>
V5.10.1 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#ifndef _APPL_INTERFACE_H_
#define _APPL_INTERFACE_H_
#include "ecat_def.h"
#include <stdlib.h>
#include <string.h>
#include "esc.h"
#include "ecatslv.h"
#include "objdef.h"
#include "ecatappl.h"
/*ET9300 Project Handler :(#if DIAGNOSIS_SUPPORTED) lines 49 to 51 deleted*/
/*ET9300 Project Handler :(#if EOE_SUPPORTED) lines 54 to 56 deleted*/
/*ET9300 Project Handler :(#if FOE_SUPPORTED) lines 58 to 60 deleted*/
#endif /*#ifndef _APPL_INTERFACE_H_*/
#if defined(_APPL_INTERFACE_) && (_APPL_INTERFACE_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
/*-----------------------------------------------------------------------------------------
------
------ Function pointer which are used to call optional functions from the application
------
-----------------------------------------------------------------------------------------*/
/*ET9300 Project Handler :(#if ESC_EEPROM_EMULATION) lines 76 to 122 deleted*/
/*ET9300 Project Handler :(#if EOE_SUPPORTED) lines 125 to 152 deleted*/
/*ET9300 Project Handler :(#if FOE_SUPPORTED) lines 155 to 274 deleted*/
/* ECATCHANGE_START(V5.13) COE4*/
/////////////////////////////////////////////////////////////////////////////////////////
/**
\param Index Index of the object to be read
\param Subindex Subindex of the object entry to be read
\param CompleteAccess Indicates if the object is read with complete access
\brief The function is called before an object/entry is read
*////////////////////////////////////////////////////////////////////////////////////////
PROTO void(*pAPPL_CoeReadInd)(UINT16 Index, UINT8 Subindex, BOOL CompleteAccess);
/////////////////////////////////////////////////////////////////////////////////////////
/**
\param Index Index of the object which was written
\param Subindex Subindex of the object entry which was written
\param CompleteAccess Indicates if the object was written with complete access
\brief The function is called after an object/entry was successfully written
*////////////////////////////////////////////////////////////////////////////////////////
PROTO void(*pAPPL_CoeWriteInd)(UINT16 Index, UINT8 Subindex, BOOL CompleteAccess);
/* ECATCHANGE_END(V5.13) COE4*/
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief This function is called by the SSC from the main loop
\brief The function pointer is reset in MainInit() so it shall be set afterwards
*////////////////////////////////////////////////////////////////////////////////////////
PROTO void(*pAPPL_MainLoop)();
/*-----------------------------------------------------------------------------------------
------
------ Functions provided by the SSC to be called from the application
------
-----------------------------------------------------------------------------------------*/
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0 if successful or greater 0 in case of an error
\brief Initialize the generic slave stack.
\brief This function should be called after the platform including operating system and
\brief ESC is ready to use.
*////////////////////////////////////////////////////////////////////////////////////////
PROTO UINT16 MainInit(void);
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief This function handles the low priority function like EtherCAT state machine
\brief handling, mailbox protocols and if no synchronization is enabled also the
\brief application.
\brief This function shall be called cyclically from the application.
*////////////////////////////////////////////////////////////////////////////////////////
PROTO void MainLoop(void);
/////////////////////////////////////////////////////////////////////////////////////////
/**
\param alStatus requested AL Status
\param alStatusCode requested AL Status Code
\brief This function shall be called by the application to trigger state transition in case
\brief of an application error or to complete a pending transition.
\brief If the function was called due to an error it shall be again if the error is gone.
\brief NOTE: state requests to a higher state than the current state are not allowed.
*////////////////////////////////////////////////////////////////////////////////////////
PROTO void ECAT_StateChange(UINT8 alStatus, UINT16 alStatusCode);
/*ET9300 Project Handler :(#if EOE_SUPPORTED) lines 348 to 361 deleted*/
#undef PROTO

View File

@ -0,0 +1,907 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
\addtogroup CoE CAN Application Profile over EtherCAT
@{
*/
/**
\file coeappl.c
\author EthercatSSC@beckhoff.com
\brief Implementation
This file contains an example for CoE services and the CoE object dictionary
\version 5.13
<br>Changes to version V5.12:<br>
V5.13 CIA402 3: change define "CIA402_DEVICE" to "CiA402_SAMPLE_APPLICATION"<br>
V5.13 COE1: handling objects with 255 entries<br>
V5.13 COE10: change 0x10F1.1 access from "rw" to "ro"<br>
V5.13 COE2: handle Backup entries with the code VAR<br>
V5.13 COE6: add 0x10F0.2 (Backup parameter changed)<br>
V5.13 COE7: define 0x1C3x.13 Shift Time too short, just define variable because expected in DC mode but shift mode is not supported by the SSC<br>
<br>Changes to version V5.11:<br>
V5.12 COE1: load backup value after the complete OD was initialized<br>
V5.12 COE4: add time stamp object (0x10F8) and update diagnosis handling<br>
V5.12 COE8: fix invalid size calculation to init backup entries<br>
V5.12 ECAT1: update SM Parameter measurement (based on the system time), enhancement for input only devices and no mailbox support, use only 16Bit pointer in process data length caluclation<br>
V5.12 ECAT5: update Sync error counter/flag handling,check enum memory alignment depending on the processor,in case of a polled timer disable ESC interrupts during DC_CheckWatchdog<br>
<br>Changes to version V5.10:<br>
V5.11 COE1: update invalid end entry in the object dictionaries (error with some compilers)<br>
V5.11 COE3: change 0x10F3.2 (Sync Error limit) from UINT32 to UINT16 (according to the ETG.1020)<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
V5.11 ECAT4: enhance SM/Sync monitoring for input/output only slaves<br>
<br>Changes to version V5.01:<br>
V5.10 COE1: Define one entry description for all 0x1C3x objects and change data type of SI11,12,13 to UINT16 (according ETG.1020)<br>
V5.10 COE2: Change return value of Get ObjectSize to UINT32<br>
Change object size to UINT32<br>
V5.10 ECAT13: Update Synchronization handling (FreeRun,SM Sync, Sync0, Sync1)<br>
Compare DC UINT configuration (by ESC Config data) vs. DC activation register settings<br>
Update 0x1C3x entries<br>
<br>Changes to version V5.0:<br>
V5.01 APPL3: Include library demo application<br>
V5.01 COE1: Remove alignment entry (SI33) from objects 0x1C32/0x1C33<br>
V5.01 EL9800 1: Read/Write functions for setting object 0x8020 moved to el9800appl.c<br>
V5.01 EL9800 2: Add TxPdo Parameter object 0x1802<br>
V5.01 SDO6: Update SDO response interface handling. (used if the object access function returns "ABORTIDX_WORKING" and SDO_RES_INTERFACE is active)<br>
<br>Changes to version V4.40:<br>
V5.0 TEST1: Add test application. See Application Note ET9300 for more details.<br>
V5.0 COE1: Add reserved Subindex7 to object 0x1C32 and 0x1C33.<br>
V5.0 COE4: Create object dictionary on device startup.<br>
V5.0 COE6: Update entry descriptions for object with the code ARRAY.<br>
V5.0 ECAT2: Reference to application specific object dictionary is set to "ApplicationObjDic".<br>
<br>Changes to version V4.30:<br>
V4.40 COE 6: change dynamic object dictionary handling<br>
V4.40 CiA402 2: enable freerun Sync Mode for CiA402 Device (The motion controller application will only be triggered if DC Synchronisation is disabled)<br>
V4.40 COE5: move identification and synchronisation object values to ecat_def.h<br>
V4.40 DIAG1: Add diagnosis object 0x10F3<br>
V4.40 OBJ3: Update the global object dictionary pointer if a new list head is added<br>
V4.40 COE4: Prevent access NULL pointer<br>
V4.40 SYNC1: Initialize 0x1C3x objects<br>
V4.40 HW1: Add (adapt) objects for FC1100 support<br>
<br>Changes to version V4.20:<br>
V4.30 OBJ 3: Handle object dictionary in double link list<br>
V4.30 OBJ 2: General EtherCAT device objects are moved from chnappl.h to coeappl.c<br>
V4.30 SYNC: set 0x1C32:05; 0x1C33:05 (minCyleTime) to MIN_PD_CYCLE_TIME
(should be set dynamic if required)<br>
V4.30 PDO: rename PDO specific function calls
(PDO specific functions are moved to ecatappl.c)<br>
V4.20 PIC24: Add EL9800_4 (PIC24) required source code<br>
V4.11 ECAT 1: C166: MinDelayTime renamed in CalcAndCopyTime<br>
<br>Changes to version V4.07:<br>
V4.10 ECAT 1: To save and restore arrays in the object directory.<br>
The code to get the size of an array entry was changed.<br>
V4.10 COE 1: The SM-Parameter were extended<br>
<br>Changes to version V4.06:<br>
V4.07 COEAPPL 1: The PDO numbers were adapted according top the modular device profile,<br>
the PDO numbers increment now with every module (in chnappl.h)<br>
V4.07 COEAPPL 2: The example is working for the NIOS with the evaluation board DBC2C20 V1.2<br>
which is available by Altera<br>
V4.07 ECAT 1: The sources for SPI and MCI were merged (in ecat_def.h<br>
set the switch MCI_HW to 1 when using the MCI,<br>
set the switch SPI_HW to 1 when using the SPI<br>
<br>Changes to version V4.03:<br>
V4.04 SDO 1: The SDO interface was changed in that way that a SDO response<br>
could be sent by the application to a later time. In that case<br>
the functions OBJ_Read and OBJ_Write shall return the value<br>
ABORTIDX_WORKING. To send the SDO response the new function SDOS_SdoRes<br>
has to be called by the application. While waiting for the call<br>
of SDOS_SdoRes the SDO interface will answer to another SDO request<br>
with the error MBXERR_SERVICEINWORK in the mailbox protocol.<br>
In this example the reading and writing of object 0x8020 is delayed,<br>
the function SDOS_SdoRes will be called from COE_Main.<br>
<br>Changes to version V4.00:<br>
V4.01 COEAPPL 1: The object dictionary and the mapping functions are now defined<br>
in chnappl.h (chnappl.inc made problems with some developing tools)<br>
<br>Changes to version V3.20:<br>
V4.00 COEAPPL 1: The object dictionary and the mapping functions are now defined<br>
in chnappl.c and were adapted to the modular device profile<br>
V4.00 COEAPPL 2: The handling of backup parameters was included according to<br>
the EtherCAT Guidelines and Protocol Enhancements Specification<br>
V4.00 COEAPPL 3: The handling of the TxPDO Toggle was included according to<br>
the EtherCAT Guidelines and Protocol Enhancements Specification<br>
V4.00 COEAPPL 4: The handling of the TxPDO State was included according to<br>
the EtherCAT Guidelines and Protocol Enhancements Specification<br>
V4.00 ECAT 1: The handling of the Sync Manager Parameter was included according to<br>
the EtherCAT Guidelines and Protocol Enhancements Specification
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "ecat_def.h"
#include "ecatslv.h"
#define _COEAPPL_ 1
#include "coeappl.h"
#undef _COEAPPL_
/*remove definition of _COEAPPL_ (#ifdef is used in coeappl.h)*/
#define _OBJD_
/*ET9300 Project Handler :(#if DIAGNOSIS_SUPPORTED && !TEST_APPLICATION) lines 130 to 133 deleted*/
/*Add Application specific Objects*/
/*ECATCHANGE_START(V5.13) CIA402 3*/
/*ET9300 Project Handler :(#if CiA402_SAMPLE_APPLICATION #elif EL9800_APPLICATION #elif SAMPLE_APPLICATION #elif TEST_APPLICATION #elif SAMPLE_APPLICATION_INTERFACE) lines 138 to 149 deleted*/
extern TOBJECT OBJMEM ApplicationObjDic[];
#undef _OBJD_
/*-----------------------------------------------------------------------------------------
------
------ Backup Parameter
------
-----------------------------------------------------------------------------------------*/
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 161 to 168 deleted*/
/*-----------------------------------------------------------------------------------------
------
------ Generic EtherCAT device object
------
-----------------------------------------------------------------------------------------*/
/*---------------------------------------------
- 0x1000
-----------------------------------------------*/
/**
* \brief 0x1000 (Device type) variable to handle the object data
*/
UINT32 u32Devicetype = (DEVICE_PROFILE_TYPE);
/**
* \brief 0x1000 (Device type) entry description
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM sEntryDesc0x1000 = {DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ};
/**
* \brief 0x1000 (Device type) object name
*/
OBJCONST UCHAR OBJMEM aName0x1000[] = "Device type";
/*---------------------------------------------
- 0x1001
-----------------------------------------------*/
/**
* \brief 0x1001 (Error Register) variable to handle the object data
*/
UINT16 u16ErrorRegister = 0x0;
/**
* \brief 0x1001 (Error Register) entry description
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM sEntryDesc0x1001 = {DEFTYPE_UNSIGNED8, 0x08, ACCESS_READ};
/**
* \brief 0x1001 (Error Register) object name
*/
OBJCONST UCHAR OBJMEM aName0x1001[] = "Error register";
/*---------------------------------------------
- 0x1008
-----------------------------------------------*/
/**
* \brief 0x1008 (Device name) variable to handle the object data
*/
CHAR acDevicename[] = DEVICE_NAME;
/**
* \brief 0x1008 (Device name) entry description
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM sEntryDesc0x1008 = {DEFTYPE_VISIBLESTRING, BYTE2BIT(DEVICE_NAME_LEN), ACCESS_READ};
/**
* \brief 0x1008 (Device name) object name
*/
OBJCONST UCHAR OBJMEM aName0x1008[] = "Device name";
/*---------------------------------------------
- 0x1009
-----------------------------------------------*/
/**
* \brief 0x1009 (Hardware version) variable to handle the object data
*/
CHAR acHardwareversion[] = DEVICE_HW_VERSION;
/**
* \brief 0x1009 (Hardware version) entry description
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM sEntryDesc0x1009 = {DEFTYPE_VISIBLESTRING,BYTE2BIT(DEVICE_HW_VERSION_LEN), ACCESS_READ};
/**
* \brief 0x1009 (Hardware version) object name
*/
OBJCONST UCHAR OBJMEM aName0x1009[] = "Manufacturer Hardware version";
/*---------------------------------------------
- 0x100A
-----------------------------------------------*/
/**
* \brief 0x100A (Software version) variable to handle the object data
*/
CHAR acSoftwareversion[] = DEVICE_SW_VERSION;
/**
* \brief 0x100A (Software version) entry description
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM sEntryDesc0x100A = {DEFTYPE_VISIBLESTRING,BYTE2BIT(DEVICE_SW_VERSION_LEN), ACCESS_READ};
/**
* \brief 0x100A (Software version) object name
*/
OBJCONST UCHAR OBJMEM aName0x100A[] = "Manufacturer Software version";
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 271 to 397 deleted*/
/*---------------------------------------------
- 0x1018
-----------------------------------------------*/
/**
* \brief 0x1018 (Identity) variable to handle the object data
*/
TOBJ1018 sIdentity = {4, (VENDOR_ID), (PRODUCT_CODE), (REVISION_NUMBER), (SERIAL_NUMBER)};
/**
* \brief 0x1018 (Identity) entry descriptions
*
* Subindex 000
* SubIndex 001: Vendor ID
* SubIndex 002: Product code
* SubIndex 003: Revision
* SubIndex 004: Serial number
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM asEntryDesc0x1018[] = {
{DEFTYPE_UNSIGNED8, 0x8, ACCESS_READ },
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ},
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ},
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ},
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ}};
/**
* \brief 0x1018 (Identity) object and entry names
*/
OBJCONST UCHAR OBJMEM aName0x1018[] = "Identity Object\000Vendor ID\000Product Code\000Revision Number\000Serial Number\000\377";
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 431 to 456 deleted*/
/*---------------------------------------------
- 0x10F1
-----------------------------------------------*/
/**
* \brief 0x10F1 (Error settings) entry description
* Subindex 000
* SubIndex 001: Local Error Reaction
* SubIndex 002: Sync Error Counter Limit
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM asEntryDesc0x10F1[] = {
{DEFTYPE_UNSIGNED8, 0x8, ACCESS_READ },
/*ECATCHANGE_START(V5.13) COE10*/
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ},
/*ECATCHANGE_END(V5.13) COE10*/
{DEFTYPE_UNSIGNED16, 0x10, ACCESS_READWRITE}};
/**
* \brief 0x10F1 (Error settings) object and entry names
*/
OBJCONST UCHAR OBJMEM aName0x10F1[] = "Error Settings\000Local Error Reaction\000Sync Error Counter Limit\000\377";
//object declaration and initialization in objdef.h
/*---------------------------------------------
- 0x10F8 (Timestamp object)
-----------------------------------------------*/
/**
* \brief 0x10F8 (Timestamp object) entry description
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM sEntryDesc0x10F8 = { DEFTYPE_UNSIGNED64, 0x40, ACCESS_READWRITE | OBJACCESS_TXPDOMAPPING } ;
/**
* \brief 0x10F8 (Timestamp object) object name
*/
OBJCONST UCHAR OBJMEM aName0x10F8[] = "Timestamp Object\000\377";
//object declaration and initialization in coeappl.h
/**
\param index index of the requested object.
\param subindex subindex of the requested object.
\param dataSize received data size of the SDO Download
\param pData Pointer to the buffer where the written data can be copied from
\param bCompleteAccess Indicates if a complete write of all subindices of the
object shall be done or not
\return result of the write operation (0 (success) or an abort code (ABORTIDX_.... defined in
sdosrv.h))
\brief This function reads the object 0x10F8
*/
UINT8 Read0x10F8(UINT16 index, UINT8 subindex, UINT32 dataSize, UINT16 MBXMEM * pData, UINT8 bCompleteAccess)
{
if (index != 0x10F8)
{
return ABORTIDX_PARAM_IS_INCOMPATIBLE;
}
if (bCompleteAccess)
{
/* Complete Access is not supported for object 0x10F8 */
return ABORTIDX_UNSUPPORTED_ACCESS;
}
if (subindex > 0)
{
return ABORTIDX_SUBINDEX_NOT_EXISTING;
}
if (dataSize > 8)
{
return ABORTIDX_PARAM_LENGTH_TOO_LONG;
}
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 540 to 542 deleted*/
MEMCPY(pData, &u64Timestamp, dataSize);
return 0;
}
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 550 to 587 deleted*/
/*---------------------------------------------
- 0x1C00
-----------------------------------------------*/
/**
* \brief 0x1C00 (Sync manager type) variable to handle the object data
*
* SI 0 : 4 (4 SyncManagers available)
* SI1 (SM0): Mailbox Out (0x1)
* SI2 (SM1): Mailbox In (0x2)
* SI3 (SM2): Process data Out (0x3)
* SI4 (SM3): Process data In (0x4)
*
*/
/*ECATCHANGE_START(V5.13)*/
TOBJ1C00 sSyncmanagertype = {0x04, {0x0201, 0x0403}};
/*ECATCHANGE_END(V5.13)*/
/**
* \brief 0x1C00 (Sync manager type) entry descriptions
*
* The object is an array so only the first entry is described (which is used for all entries).
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM asEntryDesc0x1C00[] = {
{DEFTYPE_UNSIGNED8, 0x08, ACCESS_READ},
{DEFTYPE_UNSIGNED8, 0x08, ACCESS_READ}};
/**
* \brief 0x1C00 (Sync manager type) object name
*/
OBJCONST UCHAR OBJMEM aName0x1C00[] = "Sync manager type";
/*---------------------------------------------
- 0x1C3x
-----------------------------------------------*/
/**
* \brief 0x1C3x (SyncManager parameter) entry description
*
* The entry descriptions are used for 0x1C32 and 0x1C33
*/
OBJCONST TSDOINFOENTRYDESC OBJMEM asEntryDesc0x1C3x[] = {
{DEFTYPE_UNSIGNED8, 0x8, ACCESS_READ }, /* Subindex 000 */
/*ET9300 Project Handler :(#if !AL_EVENT_ENABLED && !DC_SUPPORTED) lines 635 to 637 deleted*/
{DEFTYPE_UNSIGNED16, 0x10, (ACCESS_READ | ACCESS_WRITE_PREOP)}, /* SubIndex 001: Synchronization Type */
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ}, /* SubIndex 002: Cycle Time */
{0x0000, 0x20, 0}, /* SubIndex 003: Shift Time (not supported)*/
{DEFTYPE_UNSIGNED16, 0x10, ACCESS_READ}, /* SubIndex 004: Synchronization Types supported */
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ}, /* SubIndex 005: Minimum Cycle Time */
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ}, /* SubIndex 006: Calc and Copy Time */
{0x0000, 0x20, 0}, /* Subindex 007 Minimum Delay Time (not supported)*/
{DEFTYPE_UNSIGNED16, 0x10, ACCESS_READWRITE}, /* SubIndex 008: Get Cycle Time */
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READ}, /* SubIndex 009: Delay Time */
{DEFTYPE_UNSIGNED32, 0x20, ACCESS_READWRITE}, /* SubIndex 010: Sync0 Cycle Time */
{DEFTYPE_UNSIGNED16, 0x10, ACCESS_READ}, /* SubIndex 011: SM-Event Missed */
{DEFTYPE_UNSIGNED16, 0x10, ACCESS_READ}, /* SubIndex 012: Cycle Time Too Small */
/*ECATCHANGE_START(V5.13) COE7*/
{DEFTYPE_UNSIGNED16, 0x10, ACCESS_READ}, /* SubIndex 013: Shift Too Short Counter*/
/*ECATCHANGE_END(V5.13) COE7*/
{0x0000, 0x10, 0}, /* Subindex 014: RxPDO Toggle Failed (not supported)*/
{0x0000, 0x20, 0}, /* Subindex 015: Minimum Cycle Distance (not supported)*/
{0x0000, 0x20, 0}, /* Subindex 016: Maximum Cycle Distance (not supported)*/
{0x0000, 0x20, 0}, /* Subindex 017: Minimum SM Sync Distance (not supported)*/
{0x0000, 0x20, 0}, /* Subindex 018: Maximum SM Sync Distance (not supported)*/
{0x0000, 0, 0}, /* Subindex 019 doesn't exist */
{0x0000, 0, 0}, /* Subindex 020 doesn't exist */
{0x0000, 0, 0}, /* Subindex 021 doesn't exist */
{0x0000, 0, 0}, /* Subindex 022 doesn't exist */
{0x0000, 0, 0}, /* Subindex 023 doesn't exist */
{0x0000, 0, 0}, /* Subindex 024 doesn't exist */
{0x0000, 0, 0}, /* Subindex 025 doesn't exist */
{0x0000, 0, 0}, /* Subindex 026 doesn't exist */
{0x0000, 0, 0}, /* Subindex 027 doesn't exist */
{0x0000, 0, 0}, /* Subindex 028 doesn't exist */
{0x0000, 0, 0}, /* Subindex 029 doesn't exist */
{0x0000, 0, 0}, /* Subindex 030 doesn't exist */
{0x0000, 0, 0}, /* Subindex 031 doesn't exist */
{DEFTYPE_BOOLEAN, 0x01, ACCESS_READ}}; /* SubIndex 032: Sync error */
/**
* \brief 0x1C32 (SyncManager 2 parameter) object and entry names
*/
OBJCONST UCHAR OBJMEM aName0x1C32[] = "SM output parameter\000Synchronization Type\000Cycle Time\000\000Synchronization Types supported\000Minimum Cycle Time\000Calc and Copy Time\000\000Get Cycle Time\000Delay Time\000Sync0 Cycle Time\000SM-Event Missed\000Cycle Time Too Small\000Shift Time Too Short Counter\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000Sync Error\000\377";
/**
* \brief 0x1C33 (SyncManager 3 parameter) object and entry names
*/
OBJCONST UCHAR OBJMEM aName0x1C33[] = "SM input parameter\000Synchronization Type\000Cycle Time\000\000Synchronization Types supported\000Minimum Cycle Time\000Calc and Copy Time\000\000Get Cycle Time\000Delay Time\000Sync0 Cycle Time\000SM-Event Missed\000Cycle Time Too Small\000Shift Time Too Short Counter\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000Sync Error\000\377";
/******************************************************************************
** Object Dictionary
******************************************************************************/
/**
* \brief Object dictionary pointer
*/
TOBJECT OBJMEM * ObjDicList = NULL;
/**
* \brief List of generic application independent objects
*/
TOBJECT OBJMEM GenObjDic[] = {
/* Object 0x1000 */
{NULL,NULL, 0x1000, {DEFTYPE_UNSIGNED32, 0 | (OBJCODE_VAR << 8)}, &sEntryDesc0x1000, aName0x1000, &u32Devicetype, NULL, NULL, 0x0000 },
/* Object 0x1001 */
{NULL,NULL, 0x1001, {DEFTYPE_UNSIGNED8, 0 | (OBJCODE_VAR << 8)}, &sEntryDesc0x1001, aName0x1001, &u16ErrorRegister, NULL, NULL, 0x0000 },
/* Object 0x1008 */
{NULL,NULL, 0x1008, {DEFTYPE_VISIBLESTRING, 0 | (OBJCODE_VAR << 8)}, &sEntryDesc0x1008, aName0x1008, acDevicename, NULL, NULL, 0x0000 },
/* Object 0x1009 */
{NULL,NULL, 0x1009, {DEFTYPE_VISIBLESTRING, 0 | (OBJCODE_VAR << 8)}, &sEntryDesc0x1009, aName0x1009, acHardwareversion, NULL, NULL, 0x0000 },
/* Object 0x100A */
{NULL,NULL, 0x100A, {DEFTYPE_VISIBLESTRING, 0 | (OBJCODE_VAR << 8)}, &sEntryDesc0x100A, aName0x100A, acSoftwareversion, NULL, NULL, 0x0000 },
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 711 to 716 deleted*/
/* Object 0x1018 */
{NULL,NULL, 0x1018, {DEFTYPE_IDENTITY, 4 | (OBJCODE_REC << 8)}, asEntryDesc0x1018, aName0x1018, &sIdentity, NULL, NULL, 0x0000 },
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 719 to 724 deleted*/
/* Object 0x10F1 */
{NULL,NULL, 0x10F1, {DEFTYPE_RECORD, 2 | (OBJCODE_REC << 8)}, asEntryDesc0x10F1, aName0x10F1, &sErrorSettings, NULL, NULL, 0x0000 },
/* Object 0x10F8 */
{ NULL,NULL, 0x10F8,{ DEFTYPE_UNSIGNED64, 0 | (OBJCODE_VAR << 8) }, &sEntryDesc0x10F8, aName0x10F8, &u64Timestamp, Read0x10F8, NULL , 0x0000 },
/*ET9300 Project Handler :(#if DIAGNOSIS_SUPPORTED) lines 730 to 733 deleted*/
/* Object 0x1C00 */
{NULL,NULL, 0x1C00, {DEFTYPE_UNSIGNED8, 4 | (OBJCODE_ARR << 8)}, asEntryDesc0x1C00, aName0x1C00, &sSyncmanagertype, NULL, NULL, 0x0000 },
/* Object 0x1C32 */
{NULL,NULL, 0x1C32, {DEFTYPE_SMPAR, 32 | (OBJCODE_REC << 8)}, asEntryDesc0x1C3x, aName0x1C32, &sSyncManOutPar, NULL, NULL, 0x0000 },
/* Object 0x1C33 */
{NULL,NULL, 0x1C33, {DEFTYPE_SMPAR, 32 | (OBJCODE_REC << 8)}, asEntryDesc0x1C3x, aName0x1C33, &sSyncManInPar, NULL, NULL, 0x0000 },
/*end of entries*/
{NULL,NULL, 0xFFFF, {0, 0}, NULL, NULL, NULL, NULL, NULL, 0x000}};
/*ET9300 Project Handler :(#if !STATIC_OBJECT_DIC #else) lines 749 to 820 deleted*/
/*-----------------------------------------------------------------------------------------
------
------ Functions
------
-----------------------------------------------------------------------------------------*/
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief returns the pointer to the object dictionary
*////////////////////////////////////////////////////////////////////////////////////////
OBJCONST TOBJECT OBJMEM * COE_GetObjectDictionary(void)
{
return (OBJCONST TOBJECT OBJMEM *) ObjDicList;
}
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 838 to 1048 deleted*/
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief Update the Sync Error Indication
*////////////////////////////////////////////////////////////////////////////////////////
void COE_UpdateSyncErrorStatus(void)
{
if (sSyncManOutPar.u16CycleExceededCounter > 0 || sSyncManOutPar.u16SmEventMissedCounter > sErrorSettings.u16SyncErrorCounterLimit)
/*ET9300 Project Handler :(#if !_PIC18 #else) lines 1059 to 1061 deleted*/
{
sSyncManOutPar.u8SyncError = 1;
}
else
{
sSyncManOutPar.u8SyncError = 0;
}
if (sSyncManInPar.u16CycleExceededCounter > 0 || sSyncManInPar.u16SmEventMissedCounter > sErrorSettings.u16SyncErrorCounterLimit)
/*ET9300 Project Handler :(#if !_PIC18 #else) lines 1075 to 1077 deleted*/
{
sSyncManInPar.u8SyncError = 1;
}
else
{
sSyncManInPar.u8SyncError = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief This function initialize the several objects
*////////////////////////////////////////////////////////////////////////////////////////
void COE_ObjInit(void)
{
/* initialize the Sync Manager Output parameter object 0x1C32 */
sSyncManOutPar.subindex0 = 32;
/*
subindex 1 contains the actual synchronization mode, it could be written
from the master to switch between ECAT FreeRun and ECAT Synchron Mode
if the slave supports both modes,
in DC mode (selected by the DC registers) this value will be overwritten
with SYNCTYPE_DCSYNC0 or SYNCTYPE_DCSYNC1 */
/*default mode is ECAT Synchron Mode */
sSyncManOutPar.u16SyncType = SYNCTYPE_FREERUN;
/* subindex 2 contains the cycle time of the application,
in ECAT FreeRun mode it could be used for a timer interrupt to run the application,
in ECAT Synchron mode it could be written from the master with its local cycle time
that the slave can check if this cycle time is supported,
in DC Mode this value will be overwritten with the DC cycle time register */
sSyncManOutPar.u32CycleTime = 0;
/* the subindex 4 contains the supported synchronization types */
sSyncManOutPar.u16SyncTypesSupported = SYNCTYPE_FREERUNSUPP /* ECAT FreeRun Mode is supported */
#if (PD_OUTPUT_CALC_AND_COPY_TIME == 0) || (PD_INPUT_CALC_AND_COPY_TIME == 0) || (MIN_PD_CYCLE_TIME == 0)
| SYNCTYPE_TIMESVARIABLE /* the execution times depend on the connected modules */
#endif
| SYNCTYPE_SYNCHRONSUPP /* ECAT Synchron Mode is supported */
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 1127 to 1133 deleted*/
;
/* subindex 5 contains the minimum cycle time the slave is able to support,
will be calculated dynamically because it depends on the connected modules
(in this example we will make an online measurement in the ESC Interrupt Routine).
For the sample application this value is set to MIN_PD_CYCLE_TIME */
sSyncManOutPar.u32MinCycleTime = MIN_PD_CYCLE_TIME;
/* only for DC Mode important: subindex 6 contains the minimum delay time the slave
needs after receiving the SM2-event before the SYNC0(SYNC1) can be received without delays
will be calculated dynamically because it depends on the connected modules
(in this example we will make an online measurement in the ESC Interrupt Routine) */
sSyncManOutPar.u32CalcAndCopyTime = (PD_OUTPUT_CALC_AND_COPY_TIME);
/*subindex 8: trigger cycle time measurement*/
sSyncManOutPar.u16GetCycleTime = 0;
/*subindex 9: time from start driving outputs until outputs are valid*/
sSyncManOutPar.u32DelayTime = (PD_OUTPUT_DELAY_TIME);
/*subindex 11: reset the sm missed error counter*/
sSyncManOutPar.u16SmEventMissedCounter = 0;
/*subindex 12: reset the cycle exceed error counter*/
sSyncManOutPar.u16CycleExceededCounter = 0;
/*subindex 32: indicates if a synchronisation error has occurred*/
sSyncManOutPar.u8SyncError = 0;
/* initialize the Sync Manager Input parameter object 0x1C33 */
sSyncManInPar.subindex0 = 32;
/* default mode is ECAT Synchron Mode, if output size > 0 the inputs are updated with the SM2-event */
sSyncManInPar.u16SyncType = SYNCTYPE_FREERUN;
/* subindex 2: same as 0x1C32:02 */
sSyncManInPar.u32CycleTime = sSyncManOutPar.u32CycleTime;
/*ET9300 Project Handler :(#if MAX_PD_OUTPUT_SIZE > 0 #else) lines 1173 to 1175 deleted*/
/* subindex 4: same as 0x1C32:04 */
sSyncManInPar.u16SyncTypesSupported = sSyncManOutPar.u16SyncTypesSupported;
/*ET9300 Project Handler :(#elif MAX_PD_INPUT_SIZE > 0) lines 1180 to 1198 deleted*/
/* subindex 5: same as 0x1C32:05 */
sSyncManInPar.u32MinCycleTime = MIN_PD_CYCLE_TIME;
/* subindex 6: delay read inputs, calculation and copy to SM buffer*/
sSyncManInPar.u32CalcAndCopyTime = (PD_INPUT_CALC_AND_COPY_TIME);
/*subindex 8: trigger cycle time measurement*/
sSyncManInPar.u16GetCycleTime = 0;
/*subindex 9: delay to prepare input latch*/
sSyncManInPar.u32DelayTime = (PD_INPUT_DELAY_TIME);
/*subindex 11: reset the sm missed error counter*/
sSyncManInPar.u16SmEventMissedCounter = 0;
/*subindex 12: reset the cycle exceed error counter*/
sSyncManInPar.u16CycleExceededCounter = 0;
/*subindex 32: incremented if a synchronisation error has occurred*/
sSyncManInPar.u8SyncError = 0;
/*Indicate no user specified Sync mode*/
bSyncSetByUser = FALSE;
{
UINT16 result = COE_ObjDictionaryInit();
if(result != 0)
{
/*clear already linked objects*/
COE_ClearObjDictionary();
}
}
u8PendingSdo = 0;
bStoreCompleteAccess = FALSE;
u16StoreIndex = 0;
u8StoreSubindex = 0;
u32StoreDataSize = 0;
pStoreData = NULL;
pSdoPendFunc = NULL;
pSdoSegData = NULL;
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 1247 to 1259 deleted*/
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 1261 to 1280 deleted*/
}
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0 object successful added to object dictionary
ALSTATUSCODE_XX add object failed
\brief This function adds an object to the object dictionary
*////////////////////////////////////////////////////////////////////////////////////////
UINT16 COE_AddObjectToDic(TOBJECT OBJMEM * pNewObjEntry)
{
if(pNewObjEntry != NULL)
{
if(ObjDicList == NULL)
{
/* Object dictionary is empty */
ObjDicList = pNewObjEntry;
ObjDicList->pNext = NULL;
ObjDicList->pPrev = NULL;
return 0;
}
else if(ObjDicList->Index > pNewObjEntry->Index)
{
/*insert new object dictionary head*/
pNewObjEntry->pPrev = NULL;
pNewObjEntry->pNext = ObjDicList;
ObjDicList->pPrev = pNewObjEntry;
ObjDicList = pNewObjEntry;
return 0;
}
else
{
TOBJECT OBJMEM * pDicEntry = ObjDicList;
while(pDicEntry != NULL)
{
if(pDicEntry->Index == pNewObjEntry->Index)
{
/*object already exists in object dictionary*/
return ALSTATUSCODE_UNSPECIFIEDERROR;
}
else if(pDicEntry->Index > pNewObjEntry->Index)
{
pNewObjEntry->pPrev = pDicEntry->pPrev;
pNewObjEntry->pNext = pDicEntry;
if(pDicEntry->pPrev != NULL)
pDicEntry->pPrev->pNext = pNewObjEntry;
pDicEntry->pPrev = pNewObjEntry;
return 0;
}
else if(pDicEntry->pNext == NULL)
{
/*Last entry reached => add object to list tail*/
pDicEntry->pNext = pNewObjEntry;
pNewObjEntry->pPrev = pDicEntry;
pNewObjEntry->pNext = NULL;
return 0;
}
else
{
/*The new object index is smaller than the current index. Get next object handle.*/
pDicEntry = pDicEntry->pNext;
}
}
}
}
return ALSTATUSCODE_UNSPECIFIEDERROR;
}
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief This function removes an object to the object dictionary
*////////////////////////////////////////////////////////////////////////////////////////
void COE_RemoveDicEntry(UINT16 index)
{
TOBJECT OBJMEM * pDicEntry = ObjDicList;
while(pDicEntry != NULL)
{
if(pDicEntry->Index == index)
{
TOBJECT OBJMEM *pPrevEntry = pDicEntry->pPrev;
TOBJECT OBJMEM *pNextEntry = pDicEntry->pNext;
if(pPrevEntry != NULL)
{
pPrevEntry->pNext = pNextEntry;
}
if(pNextEntry != NULL)
{
pNextEntry->pPrev = pPrevEntry;
}
pDicEntry->pPrev = NULL;
pDicEntry->pNext = NULL;
/*Update Object dictionary pointer if list head was removed*/
if(pDicEntry->Index == ObjDicList->Index)
{
ObjDicList = pNextEntry;
}
return;
}
pDicEntry = pDicEntry->pNext;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief This function clear the object dictionary
*////////////////////////////////////////////////////////////////////////////////////////
void COE_ClearObjDictionary(void)
{
TOBJECT OBJMEM * pObjEntry = (TOBJECT OBJMEM *) ObjDicList;
UINT16 Index = 0;
while(pObjEntry != NULL)
{
Index = pObjEntry->Index;
pObjEntry = pObjEntry->pNext;
COE_RemoveDicEntry(Index);
}
ObjDicList = NULL;
}
UINT16 AddObjectsToObjDictionary(TOBJECT OBJMEM * pObjEntry)
{
UINT16 result = 0;
TOBJECT OBJMEM * pEntry = (TOBJECT OBJMEM *)pObjEntry;
while(pEntry->Index != 0xFFFF)
{
result = COE_AddObjectToDic(pEntry);
if(result != 0)
{
return result;
}
pEntry++;
}
return result;
}
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0 object dictionary created successful
ALSTATUSCODE_XX create object dictionary failed
\brief This function initialize the object dictionary
*////////////////////////////////////////////////////////////////////////////////////////
UINT16 COE_ObjDictionaryInit(void)
{
UINT16 result = 0;
/*Reset object dictionary pointer*/
ObjDicList = NULL;
result = AddObjectsToObjDictionary((TOBJECT OBJMEM *) GenObjDic);
if(result != 0)
{
return result;
}
if(ApplicationObjDic != NULL)
{
result = AddObjectsToObjDictionary((TOBJECT OBJMEM *) ApplicationObjDic);
}
return result;
}
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief is called for background calculations which should not influence the
ECAT_Application in synchronous modes
*////////////////////////////////////////////////////////////////////////////////////////
void COE_Main(void)
{
UINT8 abort = 0;
if(pSdoPendFunc != NULL)
{
abort = pSdoPendFunc(u16StoreIndex,u8StoreSubindex,u32StoreDataSize,pStoreData,bStoreCompleteAccess);
if(abort != ABORTIDX_WORKING)
{
switch(u8PendingSdo)
{
case SDO_PENDING_SEG_WRITE:
if(pSdoSegData)
{
/* the allocated buffer can be released */
FREEMEM( (UINT16 VARMEM *) pSdoSegData );
pSdoSegData = NULL;
}
case SDO_PENDING_WRITE:
/*send SDO Download Response*/
SDOS_SdoRes(abort, 0, NULL);
break;
case SDO_PENDING_SEG_READ:
case SDO_PENDING_READ:
/* send SDO upload response */
SDOS_SdoRes(abort, u32StoreDataSize, pStoreData);
break;
}
u8PendingSdo = 0;
u16StoreIndex = 0;
u8StoreSubindex = 0;
u32StoreDataSize = 0;
pStoreData = NULL;
bStoreCompleteAccess = 0;
pSdoPendFunc = NULL;
}
}
}
/** @} */

View File

@ -0,0 +1,120 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
* \addtogroup CoE CAN Application Profile over EtherCAT
* @{
*/
/**
\file coeappl.h
\author EthercatSSC@beckhoff.com
\version 5.13
<br>Changes to version V5.12:<br>
V5.13 COE6: add 0x10F0.2 (Backup parameter changed)<br>
<br>Changes to version V5.11:<br>
V5.12 COE4: add timestamp object (0x10F8) and update diagnosis handling<br>
V5.12 ECAT5: update Sync error counter/flag handling,check enum memory alignment depending on the processor,in case of a polled timer disable ESC interrupts during DC_CheckWatchdog<br>
<br>Changes to version V5.01:<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
<br>Changes to version - :<br>
V5.01 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "objdef.h"
#include "ecatappl.h"
#ifndef _COEAPPL_H_
#define _COEAPPL_H_
/*-----------------------------------------------------------------------------------------
------
------ Defines and Types
------
-----------------------------------------------------------------------------------------*/
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 44 to 69 deleted*/
/*---------------------------------------------
- 0x1018
-----------------------------------------------*/
/**
* \brief 0x1018 (Identity) object structure
*/
typedef struct OBJ_STRUCT_PACKED_START {
UINT16 u16SubIndex0; /**< \brief SubIndex 0*/
UINT32 u32VendorID; /**< \brief EtherCAT vendor ID */
UINT32 u32Productcode; /**< \brief Product code*/
UINT32 u32Revision; /**< \brief Revision number*/
UINT32 u32Serialnumber; /**< \brief Serial number*/
} OBJ_STRUCT_PACKED_END
TOBJ1018;
/*ET9300 Project Handler :(#if BACKUP_PARAMETER_SUPPORTED) lines 89 to 105 deleted*/
/*---------------------------------------------
- 0x1C00
-----------------------------------------------*/
/**
* \brief 0x1C00 (Sync manager type) object structure
*/
typedef struct OBJ_STRUCT_PACKED_START {
UINT16 u16SubIndex0; /**< \brief SubIndex 0*/
UINT16 aEntries[2]; /**< \brief Entry buffer (one for two SyncManagers)*/
} OBJ_STRUCT_PACKED_END
TOBJ1C00;
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 120 to 122 deleted*/
#endif //_COEAPPL_H_
#if defined(_COEAPPL_) && (_COEAPPL_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
/*-----------------------------------------------------------------------------------------
------
------ Global variables
------
-----------------------------------------------------------------------------------------*/
PROTO UINT64 u64Timestamp
#ifdef _COEAPPL_
= { 0 }
#endif
;
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 146 to 149 deleted*/
/*-----------------------------------------------------------------------------------------
------
------ Global functions
------
-----------------------------------------------------------------------------------------*/
PROTO void COE_UpdateSyncErrorStatus(void);
PROTO void COE_ObjInit(void);
PROTO void COE_Main(void);
PROTO UINT16 COE_ObjDictionaryInit(void);
PROTO UINT16 COE_AddObjectToDic(TOBJECT OBJMEM * pNewObjEntry);
PROTO void COE_RemoveDicEntry(UINT16 index);
PROTO void COE_ClearObjDictionary(void);
PROTO OBJCONST TOBJECT OBJMEM * COE_GetObjectDictionary(void);
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 166 to 168 deleted*/
#undef PROTO
/** @}*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,139 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
\addtogroup EcatAppl EtherCAT application
* @{
*/
/**
\file ecatappl.h
\author EthercatSSC@beckhoff.com
\version 5.12
<br>Changes to version V5.11:<br>
V5.12 EEPROM1: get read size from register 0x502.6<br>
<br>Changes to version V5.10:<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
<br>Changes to version V5.01:<br>
V5.10 ECAT13: Update Synchronisation handling (FreeRun,SM Sync, Sync0, Sync1)<br>
Compare DC UINT configuration (by ESC Config data) vs. DC activation register settings<br>
Update 0x1C3x entries<br>
V5.10 ECAT4: Update alignment macro for 8 to 15 bit alignments (16 and 32 Bit controllers)<br>
Bugfix calculate LED blink frequency<br>
<br>Changes to version - :<br>
V5.01 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Description
------
------ ecatappl.h
------
------ EtherCAT Slave Application
------ ------
-----------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "ecat_def.h"
#ifndef _ECATAPPL_H_
#define _ECATAPPL_H_
/*-----------------------------------------------------------------------------------------
------
------ Defines and Types
------
-----------------------------------------------------------------------------------------*/
/*ET9300 Project Handler :(#if CONTROLLER_16BIT || CONTROLLER_32BIT) lines 58 to 85 deleted*/
#define BOOLEAN(x) UINT8 x:1 /**< \brief Macro to define BOOLEAN object entry*/
#define BIT1(x) UINT8 x:1 /**< \brief Macro to define BIT1 object entry*/
#define BIT2(x) UINT8 x:2 /**< \brief Macro to define BIT2 object entry*/
#define BIT3(x) UINT8 x:3 /**< \brief Macro to define BIT3 object entry*/
#define BIT4(x) UINT8 x:4 /**< \brief Macro to define BIT4 object entry*/
#define BIT5(x) UINT8 x:5 /**< \brief Macro to define BIT5 object entry*/
#define BIT6(x) UINT8 x:6 /**< \brief Macro to define BIT5 object entry*/
#define BIT7(x) UINT8 x:7 /**< \brief Macro to define BIT6 object entry*/
#define BIT8(x) UINT8 x:8 /**< \brief Macro to define BIT7 object entry*/
#define ALIGN0(x)
#define ALIGN1(x) UINT8 x:1; /**< \brief Macro to define ALIGN1 object entry*/
#define ALIGN2(x) UINT8 x:2; /**< \brief Macro to define ALIGN2 object entry*/
#define ALIGN3(x) UINT8 x:3; /**< \brief Macro to define ALIGN3 object entry*/
#define ALIGN4(x) UINT8 x:4; /**< \brief Macro to define ALIGN4 object entry*/
#define ALIGN5(x) UINT8 x:5; /**< \brief Macro to define ALIGN5 object entry*/
#define ALIGN6(x) UINT8 x:6; /**< \brief Macro to define ALIGN6 object entry*/
#define ALIGN7(x) UINT8 x:7; /**< \brief Macro to define ALIGN7 object entry*/
#define ALIGN8(x) UINT8 x:8; /**< \brief Macro to define ALIGN8 object entry*/
/*ET9300 Project Handler :(#if _PIC18) lines 104 to 112 deleted*/
#define ALIGN9(x) UINT16 x:9; /**< \brief Macro to define ALIGN9 object entry*/
#define ALIGN10(x) UINT16 x:10; /**< \brief Macro to define ALIGN10 object entry*/
#define ALIGN11(x) UINT16 x:11; /**< \brief Macro to define ALIGN11 object entry*/
#define ALIGN12(x) UINT16 x:12; /**< \brief Macro to define ALIGN12 object entry*/
#define ALIGN13(x) UINT16 x:13; /**< \brief Macro to define ALIGN13 object entry*/
#define ALIGN14(x) UINT16 x:14; /**< \brief Macro to define ALIGN14 object entry*/
#define ALIGN15(x) UINT16 x:15; /**< \brief Macro to define ALIGN15 object entry*/
#endif //_ECATAPPL_H_
#if defined(_ECATAPPL_) && (_ECATAPPL_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
/*-----------------------------------------------------------------------------------------
------
------ Global Variables
------
-----------------------------------------------------------------------------------------*/
/*ET9300 Project Handler :(#if ESC_EEPROM_EMULATION) lines 138 to 140 deleted*/
PROTO BOOL bEcatWaitForInputUpdate; /**< \brief Wait for input update*/
PROTO BOOL bEtherCATRunLed; /**< \brief Current run LED value*/
PROTO BOOL bEtherCATErrorLed; /**< \brief Current error LED value*/
PROTO BOOL bRunApplication; /**< \brief Indicates if the stack shall be running (if false the Hardware will be released)*/
/*ET9300 Project Handler :(#if ESC_EEPROM_EMULATION) lines 149 to 151 deleted*/
/*-----------------------------------------------------------------------------------------
------
------ Global Functions
------
-----------------------------------------------------------------------------------------*/
PROTO void ECAT_CheckTimer(void);
PROTO void PDI_Isr(void);
PROTO void Sync0_Isr(void);
PROTO void Sync1_Isr(void);
PROTO void ECAT_Application(void);
PROTO void PDO_ResetOutputs(void);
PROTO void PDO_ReadInputs(void);
PROTO void PDO_InputMapping(void);
PROTO void ECAT_SetLedIndication(void);
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 175 to 177 deleted*/
/*ET9300 Project Handler :(#if ESC_EEPROM_ACCESS_SUPPORT) lines 178 to 181 deleted*/
/*ET9300 Project Handler :(#if ESC_EEPROM_EMULATION) lines 183 to 185 deleted*/
#undef PROTO
/** @}*/

View File

@ -0,0 +1,191 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
\addtogroup CoE CAN Application Profile over EtherCAT
@{
*/
/**
\file ecatcoe.c
\author EthercatSSC@beckhoff.com
\brief Implementation
This file contains the CoE mailbox interface
\version 5.13
<br>Changes to version V5.11:<br>
V5.13 COE8: handle failure on continue indication<br>
V5.13 TEST4: memory leak on SDO response receive<br>
<br>Changes to version V5.0:<br>
V5.11 COE4: "change prototype of ""COE_ContinueInd()"" return <> 0 if a failure occurred"<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
V5.11 TEST6: add test object to trigger Slave-to-Slave communication<br>
V5.11 TEST7: add test behaviour to send an emergency on every SDO request (in SafeOP)<br>
<br>Changes to version V4.40:<br>
V5.0 SDO7: "SDOS_SdoInfoInd()" never return pending SDO Info service. Delete "NOERROR_INWORK" handling.<br>
<br>Changes to version V4.08:<br>
V4.40 SDO1: add initial value for "nSdoInfoFragmentsLeft"<br>
V4.40 MBX6: change return value if no mailbox buffer is available<br>
V4.08 MBX 1: If the switch MAILBOX_QUEUE was set, we have to put all SDO Info Responses in the Send Queue
*/
/*---------------------------------------------------------------------------------------
------
------ Includes
------
---------------------------------------------------------------------------------------*/
#include "ecat_def.h"
#include "sdoserv.h"
#define _ECATCOE_ 1
#include "ecatcoe.h"
#undef _ECATCOE_
/*remove definition of _ECATCOE_ (#ifdef is used in ecatcoe.h)*/
/*ET9300 Project Handler :(#if TEST_APPLICATION) lines 52 to 60 deleted*/
/*---------------------------------------------------------------------------------------
------
------ internal Types and Defines
------
---------------------------------------------------------------------------------------*/
#define ECATCOE 0x4300
#define ECATCOEMAX 0x02
/*---------------------------------------------------------------------------------------
------
------ static variables
------
---------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------
------
------ static functions
------
---------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------
------
------ functions
------
---------------------------------------------------------------------------------------*/
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief This function intialize the CoE Interface.
*////////////////////////////////////////////////////////////////////////////////////////
void COE_Init(void)
{
pCoeSendStored = 0;
nSdoInfoFragmentsLeft = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
/**
\param pCoeMbx Pointer to the received mailbox data from the master.
\return result of the operation (0 (success) or mailbox error code (MBXERR_.... defined in
mailbox.h))
\brief This function is called when a CoE (CAN application layer over EtherCAT) service is received from
the master.
*////////////////////////////////////////////////////////////////////////////////////////
UINT8 COE_ServiceInd(TCOEMBX MBXMEM *pCoeMbx)
{
UINT8 result = 0;
switch ((pCoeMbx->CoeHeader & COEHEADER_COESERVICEMASK) >> COEHEADER_COESERVICESHIFT)
{
case COESERVICE_SDOREQUEST:
/* SDO-Request received, call SDOS_SdoInd to process the SDO-Request
if an existing SDO-Stack shall be used, the corresponding function
should be called */
/*ET9300 Project Handler :(#if TEST_APPLICATION && EMERGENCY_SUPPORTED) lines 125 to 152 deleted*/
result = SDOS_SdoInd( (TINITSDOMBX MBXMEM *) pCoeMbx );
break;
case COESERVICE_SDOINFO:
/* SDO-Information Request received, call SDOS_SdoInfoInd to process the SDO-Request */
result = SDOS_SdoInfoInd( (TSDOINFORMATION MBXMEM *) pCoeMbx );
/*NOERROR_INWORK is never returned by SDOS_SdoInfoInd() => delete return code handling*/
break;
case COESERVICE_SDORESPONSE:
/*ET9300 Project Handler :(#if TEST_APPLICATION) lines 164 to 178 deleted*/
case COESERVICE_EMERGENCY:
case COESERVICE_TXPDO:
case COESERVICE_RXPDO:
case COESERVICE_TXPDOREMREQ:
case COESERVICE_RXPDOREMREQ:
/* these CoE services are not supported yet */
result = MBXERR_SERVICENOTSUPPORTED;
break;
default:
result = MBXERR_INVALIDHEADER;
break;
}
return result;
}
/////////////////////////////////////////////////////////////////////////////////////////
/**
\param pMbx Pointer to the free mailbox to sent.
\return result of the operation (0 (success)
\brief This function is called when a CoE service to be sent is stored and can
\brief be put in the send mailbox.
*////////////////////////////////////////////////////////////////////////////////////////
UINT8 COE_ContinueInd(TMBX MBXMEM * pMbx)
{
if (pCoeSendStored)
{
/* send the stored CoE service which could not be sent before */
/*ECATCHANGE_START(V5.13) COE8*/
if (MBX_MailboxSendReq(pCoeSendStored, COE_SERVICE) == 0)
{
pCoeSendStored = 0;
}
/*ECATCHANGE_END(V5.13) COE8*/
}
else
{
/* send the next fragment of the last CoE service (only for SDO-Information possible) */
/* in mailbox queue mode pMbx is always 0, so a mailbox buffer shall be get */
pMbx = (TMBX MBXMEM *) APPL_AllocMailboxBuffer(SIZEOF(TMBX));
/* it shall be checked if a valid pointer was returned */
if (pMbx == NULL)
{
return MBXERR_NOMOREMEMORY;
}
else
{
/* copy the stored SDO-Info-Header in the request */
MBXMEMCPY(pMbx, aSdoInfoHeader, SDO_INFO_HEADER_BYTE_SIZE);
/* call SDOS_SdoInfoInd to generate and send the next fragment */
SDOS_SdoInfoInd( (TSDOINFORMATION MBXMEM *) pMbx );
}
}
return 0;
}
/** @} */

View File

@ -0,0 +1,116 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
* \addtogroup CoE CAN Application Profile over EtherCAT
* @{
*/
/**
\file ecatcoe.h
\author EthercatSSC@beckhoff.com
\version 5.11
<br>Changes to version V5.01:<br>
V5.11 COE4: "change prototype of ""COE_ContinueInd()"" return <> 0 if a failure occurred"<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
<br>Changes to version - :<br>
V5.01 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "mailbox.h"
#ifndef _ECATCOE_H_
#define _ECATCOE_H_
/*-----------------------------------------------------------------------------------------
------
------ Defines and Types
------
-----------------------------------------------------------------------------------------*/
/*---------------------------------------------
- Error codes
-----------------------------------------------*/
#define ERROR_COEINVALIDSERVICE 0x01 /**< \brief Invalid SDO service*/
#define ERROR_COENOTSUPPORTED 0x02 /**< \brief Not supported service*/
/*---------------------------------------------
- COE services
-----------------------------------------------*/
#define COESERVICE_EMERGENCY 0x01 /**< \brief CoE Emergency*/
#define COESERVICE_SDOREQUEST 0x02 /**< \brief CoE SDO request*/
#define COESERVICE_SDORESPONSE 0x03 /**< \brief CoE SDO response*/
#define COESERVICE_TXPDO 0x04 /**< \brief CoE TxPDO*/
#define COESERVICE_RXPDO 0x05 /**< \brief CoE RxPDO*/
#define COESERVICE_TXPDOREMREQ 0x06 /**< \brief CoE TxPDO map request*/
#define COESERVICE_RXPDOREMREQ 0x07 /**< \brief CoE RxPDO map request*/
#define COESERVICE_SDOINFO 0x08 /**< \brief CoE SDO Info*/
/*---------------------------------------------
- COE Structures
-----------------------------------------------*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_FORMAT) lines 64 to 67 deleted*/
#define COEHEADER_COESERVICESHIFT 12 /**< \brief CoE service shift (within CoE header)*/
#define COEHEADER_COESERVICEMASK 0xF000 /**< \brief CoE service mask (within CoE header)*/
#define COE_HEADER_SIZE 2 /**< \brief CoE header size*/
typedef UINT16 TCOEHEADER; /**< \brief CoE header*/
/**
* \brief CoE Mailbox header
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
UINT16 Data[((MAX_MBX_DATA_SIZE)-(COE_HEADER_SIZE)) >> 1]; /**< \brief CoE data*/
}MBX_STRUCT_PACKED_END
TCOEMBX;
#endif //_ECATCOE_H_
#if defined(_ECATCOE_) && (_ECATCOE_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
/*-----------------------------------------------------------------------------------------
------
------ Global Variables
------
-----------------------------------------------------------------------------------------*/
PROTO TMBX MBXMEM * VARMEM pCoeSendStored; /** if the mailbox service could not be sent (or stored),
the CoE service will be stored in this variable
and will be sent automatically from the mailbox handler
(COE_ContinueInd) when the send mailbox will be read
the next time from the master */
/*-----------------------------------------------------------------------------------------
------
------ Global Functions
------
-----------------------------------------------------------------------------------------*/
PROTO void COE_Init(void);
PROTO UINT8 COE_ServiceInd(TCOEMBX MBXMEM *pCoeMbx);
PROTO UINT8 COE_ContinueInd(TMBX MBXMEM * pMbx);
#undef PROTO
/** @}*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,465 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
* \addtogroup ESM EtherCAT State Machine
* @{
*/
/**
\file ecatslv.h
\author EthercatSSC@beckhoff.com
\version 5.13
<br>Changes to version V5.12:<br>
V5.13 EMCY1: update emergency diagcodes for invalid sm configuration<br>
V5.13 ESM1: local error handling update, ECAT_StateChange triggers only transitions from Op->Any or reject/accept a pending transition<br>
<br>Changes to version V5.11:<br>
V5.12 COE4: add timestamp object (0x10F8) and update diagnosis handling<br>
V5.12 ECAT6: remove mailbox SyncManager if no mailbox is supported (SM0 Output, SM1 Input)<br>
<br>Changes to version V5.10:<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
V5.11 ECAT4: enhance SM/Sync monitoring for input/output only slaves<br>
V5.11 ECAT9: add new AL Status Codes (ALSTATUSCODE_FW_SII_NOT_MATCH/0x0006, ALSTATUSCODE_FW_UPDATE_FAILED / 0x0007)<br>
V5.11 ESM7: "add Sync define for 0x22 (""SYNCTYPE_SM2_SYNCHRON""), support value 0x22 for 0x1C33.1 (SM2 sync)"<br>
V5.11 HW1: "move hardware independent functions ""HW_DisableSyncManChannel()"", ""HW_EnableSyncManChannel()"", ""HW_GetSyncMan()"", ""HW_ResetALEventMask()"", ""HW_SetALEventMask()"" to ecatalv.c"<br>
<br>Changes to version V5.01:<br>
V5.10 COE1: Define one entry description for all 0x1C3x objects and change data type of SI11,12,13 to UINT16 (according ETG.1020)<br>
V5.10 ECAT12: Add new AL Status Codes (0x2E,0x52,0x70)<br>
V5.10 ECAT13: Update Synchronisation handling (FreeRun,SM Sync, Sync0, Sync1)<br>
Compare DC UINT configuration (by ESC Config data) vs. DC activation register settings<br>
Update 0x1C3x entries<br>
<br>Changes to version - :<br>
V5.01 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "ecat_def.h"
/*ET9300 Project Handler :(#if EL9800_HW #elif FC1100_HW #elif MCI_HW) lines 47 to 53 deleted*/
#include "esc.h"
#include "f2838x_cm_hw.h"
#ifndef _ECATSLV_H_
#define _ECATSLV_H_
/*-----------------------------------------------------------------------------------------
------
------ Defines and Types
------
-----------------------------------------------------------------------------------------*/
#ifndef OBJGETNEXTSTR
/* the old definition was not working with all compilers */
/* old: #define OBJGETNEXTSTR(p) ( (OBJCONST CHAR OBJMEM * )( ((UINT32) p) + OBJSTRLEN( (OBJCONST CHAR OBJMEM *) p ) + 1 ) ) */
#define OBJGETNEXTSTR(p) ( (OBJCONST CHAR OBJMEM * )( &((p)[OBJSTRLEN( (OBJCONST CHAR OBJMEM *) (p) ) + 1]) ) ) /**< \brief Macro to get next name within the objetc name string*/
#endif
/*ET9300 Project Handler :(#if BIG_ENDIAN_FORMAT) lines 75 to 115 deleted*/
#ifndef LO_BYTE
#define LO_BYTE 0 /**< \brief LowByte within an WORD*/
#endif
#ifndef HI_BYTE
#define HI_BYTE 1 /**< \brief HighByte within an WORD*/
#endif
#ifndef LOLO_BYTE
#define LOLO_BYTE 0 /**< \brief LowLowByte within an DWORD*/
#endif
#ifndef LOHI_BYTE
#define LOHI_BYTE 1 /**< \brief LowHighByte within an DWORD*/
#endif
#ifndef HILO_BYTE
#define HILO_BYTE 2 /**< \brief HighLowByte within an DWORD*/
#endif
#ifndef HIHI_BYTE
#define HIHI_BYTE 3 /**< \brief HighHighByte within an DWORD*/
#endif
#ifndef LO_WORD
#define LO_WORD 0 /**< \brief LowWord within an DWORD*/
#endif
#ifndef HI_WORD
#define HI_WORD 1 /**< \brief HighWord within an DWORD*/
#endif
#ifndef SWAPWORD
#define SWAPWORD(x) (x) /**< \brief Macro to swap a WORD*/
#endif
#ifndef SWAPDWORD
#define SWAPDWORD(x) (x) /**< \brief Macro to swap a DWORD*/
#endif
#ifndef LOBYTE
#define LOBYTE(x) ((x)&0xFF) /**< \brief LowByte mask*/
#endif
#ifndef HIBYTE
#define HIBYTE(x) (((x)&0xFF00)>>8)/**< \brief HighwByte mask*/
#endif
#ifndef LOLOBYTE
#define LOLOBYTE(x) ((x)&0xFF)/**< \brief LowLowByte mask*/
#endif
#ifndef LOHIBYTE
#define LOHIBYTE(x) (((x)&0xFF00)>>8)/**< \brief LowHighByte mask*/
#endif
#ifndef HILOBYTE
#define HILOBYTE(x) (((x)&0xFF0000)>>16)/**< \brief HighLowByte mask*/
#endif
#ifndef HIHIBYTE
#define HIHIBYTE(x) (((x)&0xFF000000)>>24)/**< \brief HighHighByte mask*/
#endif
#ifndef LOWORD
#define LOWORD(x) ((x)&0xFFFF)/**< \brief LowWord mask*/
#endif
#ifndef HIWORD
#define HIWORD(x) (((x)&0xFFFF0000)>>16)/**< \brief HighByte mask*/
#endif
#ifndef BIT2BYTE
#define BIT2BYTE(x) (((x)+7)>>3) /**< \brief Macro to convert Bit size to Byte size (round up)*/
#endif
#ifndef BYTE2BIT
#define BYTE2BIT(x) ((x)<<3) /**< \brief Macro to convert Byte size to Bit size*/
#endif
#ifndef BIT2WORD
#define BIT2WORD(x) (((x)+15)>>4) /**< \brief Macro to convert Bit size to Word size (round up)*/
#endif
#ifndef BYTE2WORD
#define BYTE2WORD(x) (((x)+1)>>1) /**< \brief Macro to convert Bytes size to Word size (round up)*/
#endif
#ifndef ROUNDUPBYTE2WORD
#define ROUNDUPBYTE2WORD(x) ((((x)+1)>>1)<<1) /**< \brief Round up Byte size to even number of Words*/
#endif
/*---------------------------------------------
- State defines
-----------------------------------------------*/
#define STATE_INIT ((UINT8) 0x01) /**< \brief State INIT*/
#define STATE_PREOP ((UINT8) 0x02) /**< \brief State PreOP*/
#define STATE_BOOT ((UINT8) 0x03) /**< \brief State BOOT*/
#define STATE_SAFEOP ((UINT8) 0x04) /**< \brief State SafeOP*/
#define STATE_OP ((UINT8) 0x08) /**< \brief State OP*/
#define STATE_MASK ((UINT8) 0x0F) /**< \brief State mask*/
#define STATE_CHANGE ((UINT8) 0x10) /**< \brief State change (Error indication/acknowledge) mask and value*/
#define STATE_DEVID ((UINT8) 0x20) /**< \brief Request/response Explicit device ID*/
#define STATE_VALID(x) ((((x) & STATE_MASK) == STATE_INIT) || (((x) & STATE_MASK) == STATE_PREOP) || (((x) & STATE_MASK) == STATE_SAFEOP) || (((x) & STATE_MASK) == STATE_OP)) /**< \brief Check if one of the mandatory supported state values are set*/
#define BOOT_2_INIT ((UINT8)((STATE_BOOT) << 4) | (STATE_INIT)) /**< \brief State transition BOOT to INIT*/
#define BOOT_2_PREOP ((UINT8)((STATE_BOOT) << 4) | (STATE_PREOP)) /**< \brief State transition BOOT to INIT*/
#define BOOT_2_SAFEOP ((UINT8)((STATE_BOOT) << 4) | (STATE_SAFEOP)) /**< \brief State transition BOOT to INIT*/
#define BOOT_2_OP ((UINT8)((STATE_BOOT) << 4) | (STATE_OP)) /**< \brief State transition BOOT to INIT*/
#define INIT_2_BOOT ((UINT8)((STATE_INIT) << 4) | (STATE_BOOT)) /**< \brief State transition INIT to BOOT*/
#define PREOP_2_BOOT ((UINT8)((STATE_PREOP) << 4) | (STATE_BOOT)) /**< \brief State transition PREOP to BOOT*/
#define SAFEOP_2_BOOT ((UINT8)((STATE_SAFEOP) << 4) | (STATE_BOOT)) /**< \brief State transition SAFEOP to BOOT*/
#define OP_2_BOOT ((UINT8)((STATE_OP) << 4) | (STATE_BOOT)) /**< \brief State transition OP to BOOT*/
#define INIT_2_INIT ((UINT8)((STATE_INIT) << 4) | (STATE_INIT)) /**< \brief State transition INIT to INIT*/
#define INIT_2_PREOP ((UINT8)((STATE_INIT) << 4) | (STATE_PREOP)) /**< \brief State transition INIT to PREOP*/
#define INIT_2_SAFEOP ((UINT8)((STATE_INIT) << 4) | (STATE_SAFEOP)) /**< \brief State transition INIT to SAFEOP*/
#define INIT_2_OP ((UINT8)((STATE_INIT) << 4) | (STATE_OP)) /**< \brief State transition INIT to OP*/
#define PREOP_2_INIT ((UINT8)((STATE_PREOP) << 4) | (STATE_INIT)) /**< \brief State transition PREOP to INIT*/
#define PREOP_2_PREOP ((UINT8)((STATE_PREOP) << 4) | (STATE_PREOP)) /**< \brief State transition PREOP to PREOP*/
#define PREOP_2_SAFEOP ((UINT8)((STATE_PREOP) << 4) | (STATE_SAFEOP)) /**< \brief State transition PREOP to SAFEOP*/
#define PREOP_2_OP ((UINT8)((STATE_PREOP) << 4) | (STATE_OP)) /**< \brief State transition PREOP to OP*/
#define SAFEOP_2_INIT ((UINT8)((STATE_SAFEOP) << 4) | (STATE_INIT)) /**< \brief State transition SAFEOP to INIT*/
#define SAFEOP_2_PREOP ((UINT8)((STATE_SAFEOP) << 4) | (STATE_PREOP)) /**< \brief State transition SAFEOP to PREOP*/
#define SAFEOP_2_SAFEOP ((UINT8)((STATE_SAFEOP) << 4) | (STATE_SAFEOP)) /**< \brief State transition SAFEOP to SAFEOP*/
#define SAFEOP_2_OP ((UINT8)((STATE_SAFEOP) << 4) |( STATE_OP)) /**< \brief State transition SAFEOP to OP*/
#define OP_2_INIT ((UINT8)((STATE_OP) << 4) | (STATE_INIT)) /**< \brief State transition OP to INIT*/
#define OP_2_PREOP ((UINT8)((STATE_OP) << 4) | (STATE_PREOP)) /**< \brief State transition OP to PREOP*/
#define OP_2_SAFEOP ((UINT8)((STATE_OP) << 4) | (STATE_SAFEOP)) /**< \brief State transition OP to SAFEOP*/
#define OP_2_OP ((UINT8)((STATE_OP) << 4) | (STATE_OP)) /**< \brief State transition OP to OP*/
/*-------------------------------------------------------------------------------------------------------------------------
ESM transition error codes
*/
/*ECATCHANGE_START(V5.13) EMCY1*/
#define SYNCMANCHSIZE 0x00 /**< \brief Emergency and Diagnosis code for an invalid SyncManager size*/
#define SYNCMANCHADDRESS 0x01 /**< \brief Emergency and Diagnosis code for an invalid SyncManager address*/
#define SYNCMANCHSETTINGS 0x02 /**< \brief Emergency and Diagnosis code for an invalid SyncManager settings*/
#define ERROR_SYNCMANCH(code, channel) ((code)+((channel)<<2)) /**< \brief Macro to add SyncManager channel*/
/*ECATCHANGE_END(V5.13) EMCY1*/
#define ERROR_SYNCMANCHADDRESS(channel) ((SYNCMANCHADDRESS)+((channel)<<2)) /**< \brief Macro to add SyncManager channel*/
#define ERROR_SYNCMANCHSIZE(channel) ((SYNCMANCHSIZE)+((channel)<<2)) /**< \brief Macro to add SyncManager channel*/
#define ERROR_SYNCMANCHSETTINGS(channel) ((SYNCMANCHSETTINGS)+((channel)<<2)) /**< \brief Macro to add SyncManager channel*/
#define ERROR_SYNCTYPES 0x80 /**< \brief Emergency and Diagnosis code for an invalid Sync types*/
#define ERROR_DCSYNCCONTROL 0x81 /**< \brief Emergency and Diagnosis code for an invalid DC Sync control*/
#define ERROR_DCSYNC0CYCLETIME 0x82 /**< \brief Emergency and Diagnosis code for an invalid Sync0 cycle time*/
#define ERROR_DCSYNC1CYCLETIME 0x83 /**< \brief Emergency and Diagnosis code for an invalid Sync1 cycle time*/
#define ERROR_DCCYCLEPARAMETER 0x84 /**< \brief Emergency and Diagnosis code for an invalid Cycle parameter*/
#define ERROR_DCLATCHCONTROL 0x85 /**< \brief Emergency and Diagnosis code for an invalid Latch control*/
#define ERROR_INVALIDSTATE 0xF0 /**< \brief Emergency and Diagnosis code for an invalid State*/
#define ERROR_NOMEMORY 0xF1 /**< \brief Emergency and Diagnosis code for no memory*/
#define ERROR_OBJECTDICTIONARY 0xF2 /**< \brief Emergency and Diagnosis code for generic object dictionary error*/
#define ERROR_NOSYNCMANACCESS 0xF3 /**< \brief Emergency and Diagnosis code for no SyncManager access*/
#define ERROR_NOOFRXPDOS 0xF4 /**< \brief Emergency and Diagnosis code for no RxPDOs*/
#define ERROR_NOOFTXPDOS 0xF5 /**< \brief Emergency and Diagnosis code for no TxPDOs*/
#define ERROR_STATECHANGE 0xF6 /**< \brief Emergency and Diagnosis code state change error*/
#define NOERROR_NOSTATECHANGE 0xFE /**< \brief Indicates no state change*/
#define NOERROR_INWORK 0xFF /**< \brief Indication for no error but operation is pending*/
#define EMCY_SM_ERRORCODE 0xA000 /**< \brief Emergency and Diagnosis code for an SyncManager error*/
#define EMCY_SM_DEVICESPECIFIC 0xFF00 /**< \brief Emergency and Diagnosis code for a device specific error*/
/*---------------------------------------------
- AL Status Codes
-----------------------------------------------*/
#define ALSTATUSCODE_NOERROR 0x0000 /**< \brief No error*/
#define ALSTATUSCODE_UNSPECIFIEDERROR 0x0001 /**< \brief Unspecified error*/
#define ALSTATUSCODE_NOMEMORY 0x0002 /**< \brief No Memory*/
#define ALSTATUSCODE_INVALID_REVISION 0x0004 /**< \brief Output/Input mapping is not valid for this hardware or software revision (0x1018:03)*/
#define ALSTATUSCODE_FW_SII_NOT_MATCH 0x0006 /**< \brief Firmware and EEPROM do not match. Slave needs BOOT-INIT transition*/
#define ALSTATUSCODE_FW_UPDATE_FAILED 0x0007 /**< \brief Firmware update not successful. Old firmware still running*/
#define ALSTATUSCODE_INVALIDALCONTROL 0x0011 /**< \brief Invalid requested state change*/
#define ALSTATUSCODE_UNKNOWNALCONTROL 0x0012 /**< \brief Unknown requested state*/
#define ALSTATUSCODE_BOOTNOTSUPP 0x0013 /**< \brief Bootstrap not supported*/
#define ALSTATUSCODE_NOVALIDFIRMWARE 0x0014 /**< \brief No valid firmware*/
#define ALSTATUSCODE_INVALIDMBXCFGINBOOT 0x0015 /**< \brief Invalid mailbox configuration (BOOT state)*/
#define ALSTATUSCODE_INVALIDMBXCFGINPREOP 0x0016 /**< \brief Invalid mailbox configuration (PreOP state)*/
#define ALSTATUSCODE_INVALIDSMCFG 0x0017 /**< \brief Invalid sync manager configuration*/
#define ALSTATUSCODE_NOVALIDINPUTS 0x0018 /**< \brief No valid inputs available*/
#define ALSTATUSCODE_NOVALIDOUTPUTS 0x0019 /**< \brief No valid outputs*/
#define ALSTATUSCODE_SYNCERROR 0x001A /**< \brief Synchronization error*/
#define ALSTATUSCODE_SMWATCHDOG 0x001B /**< \brief Sync manager watchdog*/
#define ALSTATUSCODE_SYNCTYPESNOTCOMPATIBLE 0x001C /**< \brief Invalid Sync Manager Types*/
#define ALSTATUSCODE_INVALIDSMOUTCFG 0x001D /**< \brief Invalid Output Configuration*/
#define ALSTATUSCODE_INVALIDSMINCFG 0x001E /**< \brief Invalid Input Configuration*/
#define ALSTATUSCODE_INVALIDWDCFG 0x001F /**< \brief Invalid Watchdog Configuration*/
#define ALSTATUSCODE_WAITFORCOLDSTART 0x0020 /**< \brief Slave needs cold start*/
#define ALSTATUSCODE_WAITFORINIT 0x0021 /**< \brief Slave needs INIT*/
#define ALSTATUSCODE_WAITFORPREOP 0x0022 /**< \brief Slave needs PREOP*/
#define ALSTATUSCODE_WAITFORSAFEOP 0x0023 /**< \brief Slave needs SAFEOP*/
#define ALSTATUSCODE_INVALIDINPUTMAPPING 0x0024 /**< \brief Invalid Input Mapping*/
#define ALSTATUSCODE_INVALIDOUTPUTMAPPING 0x0025 /**< \brief Invalid Output Mapping*/
#define ALSTATUSCODE_INCONSISTENTSETTINGS 0x0026 /**< \brief Inconsistent Settings*/
#define ALSTATUSCODE_FREERUNNOTSUPPORTED 0x0027 /**< \brief FreeRun not supported*/
#define ALSTATUSCODE_SYNCHRONNOTSUPPORTED 0x0028 /**< \brief SyncMode not supported*/
#define ALSTATUSCODE_FREERUNNEEDS3BUFFERMODE 0x0029 /**< \brief FreeRun needs 3Buffer Mode*/
#define ALSTATUSCODE_BACKGROUNDWATCHDOG 0x002A /**< \brief Background Watchdog*/
#define ALSTATUSCODE_NOVALIDINPUTSANDOUTPUTS 0x002B /**< \brief No Valid Inputs and Outputs*/
#define ALSTATUSCODE_FATALSYNCERROR 0x002C /**< \brief Fatal Sync Error*/
#define ALSTATUSCODE_NOSYNCERROR 0x002D /**< \brief No Sync Error*/
#define ALSTATUSCODE_CYCLETIMETOOSMALL 0x002E /**< \brief EtherCAT cycle time smaller Minimum Cycle Time supported by slave*/
#define ALSTATUSCODE_DCINVALIDSYNCCFG 0x0030 /**< \brief Invalid DC SYNCH Configuration*/
#define ALSTATUSCODE_DCINVALIDLATCHCFG 0x0031 /**< \brief Invalid DC Latch Configuration*/
#define ALSTATUSCODE_DCPLLSYNCERROR 0x0032 /**< \brief PLL Error*/
#define ALSTATUSCODE_DCSYNCIOERROR 0x0033 /**< \brief DC Sync IO Error*/
#define ALSTATUSCODE_DCSYNCMISSEDERROR 0x0034 /**< \brief DC Sync Timeout Error*/
#define ALSTATUSCODE_DCINVALIDSYNCCYCLETIME 0x0035 /**< \brief DC Invalid Sync Cycle Time*/
#define ALSTATUSCODE_DCSYNC0CYCLETIME 0x0036 /**< \brief DC Sync0 Cycle Time*/
#define ALSTATUSCODE_DCSYNC1CYCLETIME 0x0037 /**< \brief DC Sync1 Cycle Time*/
#define ALSTATUSCODE_MBX_AOE 0x0041 /**< \brief MBX_AOE*/
#define ALSTATUSCODE_MBX_EOE 0x0042 /**< \brief MBX_EOE*/
#define ALSTATUSCODE_MBX_COE 0x0043 /**< \brief MBX_COE*/
#define ALSTATUSCODE_MBX_FOE 0x0044 /**< \brief MBX_FOE*/
#define ALSTATUSCODE_MBX_SOE 0x0045 /**< \brief MBX_SOE*/
#define ALSTATUSCODE_MBX_VOE 0x004F /**< \brief MBX_VOE*/
#define ALSTATUSCODE_EE_NOACCESS 0x0050 /**< \brief EEPROM no access*/
#define ALSTATUSCODE_EE_ERROR 0x0051 /**< \brief EEPROM Error*/
#define ALSTATUSCODE_EXT_HARDWARE_NOT_READY 0x0052 /**< \brief External hardware not ready. This AL Status Code should be used if the EtherCAT-Slave refused the state transition due to an external connection to another device or signal is missing*/
#define ALSTATUSCODE_DEVICE_IDENT_VALUE_UPDATED 0x0061 /**< \brief In legacy identification mode (dip switch mapped to register 0x12) this error is returned if the EEPROM ID value does not match to dipswitch value*/
#define ALSTATUSCODE_MODULE_ID_LIST_NOT_MATCH 0x0070 /**< \brief Detected Module Ident List (0xF030) and Configured Module Ident List (0xF050) does not match*/
#define ALSTATUSCODE_SUPPLY_VOLTAGE_TOO_LOW 0x0080 /**< \brief The slave supply voltage is too low*/
#define ALSTATUSCODE_SUPPLY_VOLTAGE_TOO_HIGH 0x0081 /**< \brief The slave supply voltage is too high*/
#define ALSTATUSCODE_TEMPERATURE_TOO_LOW 0x0082 /**< \brief The slave temperature is too low*/
#define ALSTATUSCODE_TEMPERATURE_TOO_HIGH 0x0083 /**< \brief The slave temperature is too high*/
/*---------------------------------------------
- Configured Sync Type (0x1C32.1 / 0x1C33.1)
-----------------------------------------------*/
#define SYNCTYPE_FREERUN 0x0000 /**< \brief Sync type FreeRun*/
#define SYNCTYPE_SM_SYNCHRON 0x0001 /**< \brief SyncManager synchron (synchron to the corresponding SM, 0x1C32.1 -> SM2 ; 0x1C33.1 -> SM3) */
#define SYNCTYPE_SM2_SYNCHRON 0x0022 /**< \brief SyncManager2 synchron (only used for 0x1C33.1)*/
#define SYNCTYPE_DCSYNC0 0x0002 /**< \brief Sync type Sync0 synchron*/
#define SYNCTYPE_DCSYNC1 0x0003 /**< \brief Sync type Sync1 synchron*/
/*---------------------------------------------
- AL Event masks
-----------------------------------------------*/
#define AL_CONTROL_EVENT ((UINT16) 0x01) /**< \brief AL Control event*/
#define SYNC0_EVENT ((UINT16) 0x04) /**< \brief Sync0 event*/
#define SYNC1_EVENT ((UINT16) 0x08) /**< \brief Sync1 event*/
#define SM_CHANGE_EVENT ((UINT16) 0x10) /**< \brief SyncManager changed event*/
#define EEPROM_CMD_PENDING ((UINT16) 0x20) /**< \brief EEPROM command pending*/
#define MAILBOX_WRITE_EVENT ((UINT16) 0x0100) /**< \brief MBoxOut write event*/
#define MAILBOX_READ_EVENT ((UINT16) 0x0200) /**< \brief MBoxIn read event*/
#define PROCESS_OUTPUT_EVENT ((UINT16) 0x0400) /**< \brief Output process data write event*/
#define PROCESS_INPUT_EVENT ((UINT16) 0x0800) /**< \brief Input process data read event*/
/*ET9300 Project Handler :(#if MAILBOX_SUPPORTED #else) lines 380 to 383 deleted*/
#define MAILBOX_WRITE 0 /**< \brief SyncManager ID for MBoxOut (master to slave)*/
#define MAILBOX_READ 1 /**< \brief SyncManager ID for MBoxIn (slave to master)*/
#define PROCESS_DATA_OUT 2 /**< \brief SyncManager ID for output process data (master to slave)*/
#define PROCESS_DATA_IN 3 /**< \brief SyncManager ID for input process data (slave to master)*/
/*ET9300 Project Handler :(#if MAILBOX_SUPPORTED #else) lines 390 to 393 deleted*/
/*---------------------------------------------
- Codes for LED
bit 7: invert flag
bit 6: toggle (if toggle == 1 and number of flashes == 0 => infinite toggle)
bit 5: fast toggle flag (50ms cycle)
bit 4-0: number of flashes
-----------------------------------------------*/
#define LED_OFF 0x00 /**< \brief LED off*/
#define LED_FLICKERING 0x60 /**< \brief LED flickering*/
#define LED_BLINKING 0x40 /**< \brief LED blinking*/
#define LED_SINGLEFLASH 0x41 /**< \brief LED single flash*/
#define LED_DOUBLEFLASH 0x42 /**< \brief LED double flash*/
#define LED_INVERT_DOUBLEFLASH 0xC2 /**< \brief LED invert double flash*/
#define LED_ON 0x01 /**< \brief LED on*/
/*ET9300 Project Handler :(#elif ESC_SUPPORT_ECAT_LED) lines 414 to 422 deleted*/
#define MEMORY_START_ADDRESS 0x1000 /**< \brief ESC DPRAM start address*/
#ifndef DC_SYNC_ACTIVE
#define DC_SYNC_ACTIVE ESC_DC_SYNC0_ACTIVE_MASK /**< \brief Expected activated Sync signals by the master*/
#endif
#ifndef DC_EVENT_MASK
#define DC_EVENT_MASK PROCESS_OUTPUT_EVENT /**< \brief AL Event mask (value of register 0x204) in case of DC synchronisation*/
/*ET9300 Project Handler :(#if MAX_PD_OUTPUT_SIZE > 0 #else) lines 434 to 436 deleted*/
#endif
#endif //_ECATSLV_H_
#if defined(_ECATSLV_) && (_ECATSLV_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
/*-----------------------------------------------------------------------------------------
------
------ Global Variables
------
-----------------------------------------------------------------------------------------*/
/*ET9300 Project Handler :(#if BOOTSTRAPMODE_SUPPORTED) lines 452 to 454 deleted*/
PROTO BOOL bEcatOutputUpdateRunning; /**< \brief Indicates the OP state, will be set in StartOutputHandler
and reset in StopOutputHandler*/
PROTO BOOL bEcatInputUpdateRunning; /**< \brief Indicates the SAFEOP or OP state, will be set in StartInputHandler
and reset in Stop InputHandler*/
PROTO BOOL bEcatFirstOutputsReceived; /**< \brief Indicates if outputs were received (SM2-event)
or inputs were read (SM3-event, if the output size is 0),
has to be set by the application and reset in StopOutputHandler*/
PROTO BOOL bWdTrigger; /**< \brief Indicates that the SM2 WD trigger bit (0x814 bit6) is set.*/
PROTO BOOL bDcSyncActive; /**< \brief Indicates that the Distributed Clocks synchronization is active,*/
PROTO INT16 EsmTimeoutCounter; /**< \brief Counter used to detect an ESM timeout.
-1 indicates a deactivated counter and 0 is expired*/
#define MAX_SM_EVENT_MISSED 4 /**< \brief threshold of max missed counter value (0x1C32.11 / 0x1C33.11)*/
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 476 to 498 deleted*/
/*ET9300 Project Handler :(#if !COE_SUPPORTED) lines 500 to 502 deleted*/
PROTO BOOL bEscIntEnabled; /**< \brief Indicates that the ESC interrupt is enabled (SM2/3 or SYNC0/1-event),
will be set in StartInputHandler and reset in StopInputHandler*/
PROTO BOOL b3BufferMode; /**< \brief Indicates that inputs and outputs are running in 3-Buffer-Mode*/
/*ECATCHANGE_START(V5.13) ESM1*/
PROTO UINT16 u16LocalErrorCode; /**< \brief Reason for local error*/
PROTO UINT8 u8LocalErrorState; /**< \brief State of the current local error (lower state could be set by the master)*/
/*ECATCHANGE_END(V5.13) ESM1*/
PROTO BOOL bApplEsmPending; /**< \brief Indicates if the local application ESM function need to be called from Al_ConntrolRes (is true if NOERR_INWORK is returned by generic ESM function)*/
PROTO BOOL bEcatWaitForAlControlRes; /**< \brief Contains the information that the state machine waits for an acknowledge
for the last AL_ControlInd from the application/generic stack*/
PROTO UINT16 nEcatStateTrans; /**< \brief Current state transition*/
PROTO UINT8 u8EcatErrorLed; /**< \brief Current value of the error LED*/
PROTO UINT8 u8EcatRunLed; /**< \brief Current value of the run LED*/
PROTO UINT16 nPdInputSize; /**< \brief Contains the input size (SM3 size)/SM2 if no outputs are supported, has to be written by the application*/
PROTO UINT16 nPdOutputSize; /**< \brief Contains the output size (SM2 size), has to be written by the application*/
PROTO UINT8 nMaxSyncMan; /**< \brief Contains the maximum number of Sync Manager channels, will be initialized in ECAT_Main*/
PROTO UINT16 nMaxEscAddress; /**< \brief Max supported address by the ESC (register(0x1000) + size of the supported DPRAM in Byte)*/
PROTO UINT8 nAlStatus; /**< \brief Contains the actual AL Status, will be written in AL_ControlInd*/
/*ET9300 Project Handler :(#if EXPLICIT_DEVICE_ID) lines 536 to 538 deleted*/
PROTO UINT16 EcatWdValue; /**< \brief Contains the value of the watchdog in ms, will be written in StartInputHandler.
In case that the ESC watchdog feature is used this variable just indicates if the watchdog is enabled or disabled*/
/*ET9300 Project Handler :(#if !ESC_SM_WD_SUPPORTED) lines 542 to 546 deleted*/
PROTO UINT16 nEscAddrOutputData; /**< \brief Contains the SM address for the output process data*/
PROTO UINT16 nEscAddrInputData; /**< \brief Contains the SM address for the input process data*/
/*-----------------------------------------------------------------------------------------
------
------ Global Functions
------
-----------------------------------------------------------------------------------------*/
PROTO void EnableSyncManChannel(UINT8 channel);
PROTO void DisableSyncManChannel(UINT8 channel);
PROTO TSYNCMAN ESCMEM *GetSyncMan(UINT8 channel);
PROTO void SetALStatus(UINT8 alStatus, UINT16 alStatusCode);
PROTO void AL_ControlInd(UINT8 alControl, UINT16 alStatusCode);
/*ET9300 Project Handler :(#if !ESC_SM_WD_SUPPORTED) lines 565 to 569 deleted*/
/*ET9300 Project Handler :(#if DC_SUPPORTED) lines 570 to 572 deleted*/
PROTO void CheckIfEcatError(void);
PROTO void ECAT_Init(void);
PROTO void ECAT_Main(void);
#undef PROTO
/** @}*/

View File

@ -0,0 +1,204 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
* \addtogroup ESCRegister ESC Register
* @{
*/
/**
\file esc.h
\author EthercatSSC@beckhoff.com
\brief EtherCAT Slave Controller related defines and Types
\version 5.10
<br>Changes to version V5.01:<br>
V5.10 ESC1: Update address register offset for 32Bit ESC access<br>
V5.10 ESC2: Check if defined SM settings do not exceed the available DPRAM range (in error case AL Status 0x14 is returned)<br>
V5.10 ESC3: Handle DC cControl register values in case of 32Bit ESC access (a Sync activation mask need to defined/used)<br>
<br>Changes to version - :<br>
V5.01 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "ecat_def.h"
#ifndef _ESC_H_
#define _ESC_H_
/*-----------------------------------------------------------------------------------------
------
------ Defines and Types
------
-----------------------------------------------------------------------------------------*/
#define SIZEOF_SM_REGISTER 8 /**< \brief Each SyncManger has 8Byte Configuration/Status Registers*/
#define MAX_NO_OF_SYNC_MAN 16/**< \brief Maximum Number of SyncManager channels supported by an ESC*/
#define BL_PAGE_SIZE 512
/*---------------------------------------------
- ESC Offsets (Detailed Information about the registers are located in the ESC Datasheets e.g. ET1100 Datasheet http://www.beckhoff.com/english.asp?download/ethercat_development_products.htm?id=71003127100387)
-----------------------------------------------*/
#define ESC_INFO_OFFSET 0x0000 /**< \brief ESC information registers startoffset*/
#define ESC_COMM_INFO_OFFSET 0x0004 /**< \brief Communication information registers startoffset*/
/*ET9300 Project Handler :(#if ESC_32BIT_ACCESS) lines 54 to 59 deleted*/
#define ESC_DPRAM_SIZE_OFFSET 0x0006 /**< \brief Register Description: Size of the supported DPRAM in KB*/
/*ET9300 Project Handler :(#if ESC_16BIT_ACCESS) lines 61 to 65 deleted*/
#define ESC_SM_CHANNELS_OFFSET 0x0005 /**< \brief Register Description: Number of supported SyncManager channels (or entities) of the EtherCAT Slave Controller*/
#define ESC_FEATURES_OFFSET 0x0008 /**< \brief Register indicating ESC features*/
#define ESC_DC_32BIT_MASK 0x00000008 /**< \brief register 0x0008.3 indicates if the DC Unit supports 32Bit/64Bit DC*/
/*ET9300 Project Handler :(#if ESC_32BIT_ACCESS) lines 73 to 75 deleted*/
#define ESC_SLAVE_ADDRESS_OFFSET 0x0010 /**< \brief Register Description: Address used for node addressing (FPxx commands)*/
#define ESC_AL_CONTROL_OFFSET 0x0120 /**< \brief Register Description: Initiate State Transition of the Device State Machine*/
#define ESC_AL_STATUS_OFFSET 0x0130 /**< \brief Register Description: Actual State of the Device State Machine*/
#define ESC_AL_STATUS_CODE_OFFSET 0x0134 /**< \brief Register Description: AL Status Code*/
#define ESC_RUN_LED_OVERRIDE 0x0138 /**< \brief Register Description: Set Ecat Run indication via ESC. (not all ESC types support this feature)*/
#define ESC_ERROR_LED_OVERRIDE 0x0139 /**< \brief Register Description: Set Ecat Error indication via ESC. (not all ESC types support this feature)*/
#define ESC_PDI_CONTROL_OFFSET 0x0140 /**< \brief Register Description: Specifies the process data interface*/
/*ET9300 Project Handler :(#if ESC_32BIT_ACCESS) lines 89 to 91 deleted*/
#define ESC_DEVICE_EMULATION 0x0100 /**< \brief Device emulation bit*/
/*ET9300 Project Handler :(#if ESC_32BIT_ACCESS || ESC_16BIT_ACCESS) lines 95 to 99 deleted*/
#define ESC_PDI_CONFIGURATION 0x0151 /**< \brief Register Description: PDI configuration register (values defined by the ESC configuration data)*/
#define ESC_SYNC0_MAPPED_TO_ALEVENT 0x08 /**< \brief bit indicating if the Sync0 event is mapped to the AL Event register*/
#define ESC_SYNC1_MAPPED_TO_ALEVENT 0x80 /**< \brief bit indicating if the Sync1 event is mapped to the AL Event register*/
#define ESC_AL_EVENTMASK_OFFSET 0x0204 /**< \brief Register Description: AL Event masking of the AL Event Request register Events for mapping to PDI IRQ signal*/
#define ESC_AL_EVENT_OFFSET 0x0220 /**< \brief Register Description: "Mirror" register for ESC events*/
#define ESC_WD_DIVIDER_OFFSET 0x0400 /**< \brief Register Description: Number of 25 MHz tics (minus 2) that represents the basic watchdog increment. (Default value is 100us = 2498)*/
#define ESC_PD_WD_TIME 0x0420 /**< \brief Register Description: Number of basic watchdog increments (Default value with Watchdog divider 100us means 100ms Watchdog)*/
#define ESC_PD_WD_STATE 0x0440 /**< \brief Register Description: Watchdog Status of Process Data (triggered by SyncManagers)*/
/*ET9300 Project Handler :(#if ESC_32BIT_ACCESS) lines 113 to 115 deleted*/
#define ESC_PD_WD_TRIGGER_MASK 0x0001 /**< \brief Trigger state of the process data watchdog*/
#define ESC_EEPROM_CONFIG_OFFSET 0x0500 /**< \brief Register Description: EEPROM Access Configuration*/
/*ET9300 Project Handler :(#if ESC_32BIT_ACCESS) lines 120 to 138 deleted*/
/*EEPROM config and access state bit mask (based on "ESC_EEPROM_CONFIG_OFFSET") - START*/
#define ESC_EEPROM_ASSIGN_TO_PDI_MASK 0x0001 /**< \brief Description (0x500.0): PDI has EEPROM control*/
#define ESC_EEPROM_LOCKED_BY_PDI_MASK 0x0100 /**< \brief Description (0x500.8): PDI locked EEPROM access*/
/*EEPROM config and access state bit mask (based on "ESC_EEPROM_CONFIG_OFFSET") - END*/
#define ESC_EEPROM_CONTROL_OFFSET 0x0502
/* EEPROM command and status bit masks (based on "ESC_EEPROM_CONTROL_OFFSET") - START*/
#define ESC_EEPROM_SUPPORTED_READBYTES_MASK 0x0040 /**< \brief Description (0x502.6): Supported number of EEPROM read bytes: 0-> 4 Bytes; 1 -> 8 Bytes*/
#define ESC_EEPROM_CMD_MASK 0x0700 /**< \brief Description (0x502.8:10): Command bit mask*/
#define ESC_EEPROM_CMD_READ_MASK 0x0100 /**< \brief Description (0x502.8): Currently executed read command*/
#define ESC_EEPROM_CMD_WRITE_MASK 0x0200 /**< \brief Description (0x502.9): Initialize Write Command*/
#define ESC_EEPROM_CMD_RELOAD_MASK 0x0400 /**< \brief Description (0x502.10): Trigger EEPROM reload*/
#define ESC_EEPROM_ERROR_MASK 0x7800 /**< \brief Description : Mask all EEPROM error bits; Checksum error (0x0502.11); EEPROM not loaded (0x0502.12); Missing EEPROM Acknowledge (0x0502.13); Write Error (0x0502.14)*/
#define ESC_EEPROM_ERROR_CRC 0x0800 /**< \brief Description (0x502.11): EEPROM CRC Error*/
#define ESC_EEPROM_ERROR_LOAD 0x1000 /**< \brief Description (0x502.11): EEPROM loading status (0 = OK)*/
#define ESC_EEPROM_ERROR_CMD_ACK 0x2000 /**< \brief Description (0x502.13): EEPROM Acknowledge/Command*/
#define ESC_EEPROM_BUSY_MASK 0x8000 /**< \brief Description (0x502.15): EEPROM Busy*/
/* EEPROM command and status bit masks (based on "ESC_EEPROM_CONTROL_OFFSET") - END*/
#define ESC_EEPROM_ADDRESS_OFFSET 0x0504
#define ESC_EEPROM_DATA_OFFSET 0x0508
#define ESC_SYNCMAN_REG_OFFSET 0x0800 /**< \brief Register Description: Start address of the SyncManager Configuration/Staus registers*/
#define ESC_SYNCMAN_CONTROL_OFFSET 0x0804 /**< \brief Register Description: SyncManager Setting Register*/
#define ESC_SYNCMAN_STATUS_OFFSET 0x0805 /**< \brief Register Description: SyncManager Status Register*/
#define ESC_SYNCMAN_ACTIVE_OFFSET 0x0806 /**< \brief Register Description: SyncManager Activation Register*/
#define ESC_SM_PDICONTROL_OFFSET 0x0807
#define ESC_SYSTEMTIME_OFFSET 0x0910 /**< \brief Register Description: Local copy of the System Time*/
#define ESC_DC_UNIT_CONTROL_OFFSET 0x0980 /**< \brief Register Description: Control registers for Cycle and Sync Unit (can be predefined with the "AssignActivate" Element in the device description, for further information see ETG.2000)*/
/*ET9300 Project Handler :(#if ESC_32BIT_ACCESS #elif ESC_16BIT_ACCESS) lines 179 to 190 deleted*/
#define ESC_DC_SYNC_ACTIVATION_OFFSET 0x0981 /**< \brief Register Description: Sync Configuration*/
#define ESC_DC_SYNC_UNIT_ACTIVE_MASK 0x01 /**< \brief Description (0x981.0): Sync Out Unit is activated*/
#define ESC_DC_SYNC0_ACTIVE_MASK 0x02 /**< \brief Description (0x981.1): Sync0 generation is activated*/
#define ESC_DC_SYNC1_ACTIVE_MASK 0x04 /**< \brief Description (0x981.2): Sync1 generation is activated*/
#define ESC_DC_SYNC_UNIT_AUTO_ACTIVE_MASK 0x08 /**< \brief Description (0x980.11): Sync Out Unit is activated automatic when System time was written*/
#define ESC_DC_SYNC_STATUS 0x098C /**< \brief Register Description: register 0x98E and 0x98F reflecting the status of Sync0 and Sync1*/
#define ESC_DC_SYNC0_CYCLETIME_OFFSET 0x09A0 /**< \brief Register Description: 32Bit Time between two consecutive SYNC0 pulses in ns*/
#define ESC_DC_SYNC1_CYCLETIME_OFFSET 0x09A4 /**< \brief Register Description: 32Bit Time between two consecutive SYNC1 pulses in ns*/
/*ET9300 Project Handler :(#if FC1100_HW) lines 205 to 207 deleted*/
/*---------------------------------------------
- Sync Manager
-----------------------------------------------*/
/** \brief SyncManager register structure*/
typedef struct STRUCT_PACKED_START
{
/*ET9300 Project Handler :(#if ESC_32BIT_ACCESS) lines 217 to 259 deleted*/
UINT16 PhysicalStartAddress; /**< \brief SyncManager address*/
UINT16 Length; /**< \brief SyncManager length*/
/*ET9300 Project Handler :(#if ESC_16BIT_ACCESS) lines 264 to 303 deleted*/
//ESC_8BIT ACCESS
UINT8 Settings[4]; /**< \brief Register values 0x0804 : 0x0807*/
/*Defines to access :
* - SM Control register 0x0804
*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_16BIT) lines 310 to 312 deleted*/
#define SM_SETTING_CONTROL_OFFSET 0 /**< \brief Offset to value of register 0x0804*/
#define SM_SETTING_MODE_MASK 0x02 /**< \brief SyncManager mode mask*/
#define SM_SETTING_MODE_THREE_BUFFER_VALUE 0x00 /**< \brief SyncManager 3Buffer mode value*/
#define SM_SETTING_MODE_ONE_BUFFER_VALUE 0x02 /**< \brief SyncManager 1Buffer mode value*/
#define SM_SETTING_DIRECTION_MASK 0x0C /**< \brief SyncManager direction mask*/
#define SM_SETTING_DIRECTION_READ_VALUE 0x00 /**< \brief SyncManager read direction*/
#define SM_SETTING_DIRECTION_WRITE_VALUE 0x04 /**< \brief SyncManager write direction*/
#define SM_SETTING_WATCHDOG_VALUE 0x40 /**< \brief SyncManager watchdog value*/
/*Defines to access :
* - SM Status register 0x0805
*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_16BIT) lines 326 to 328 deleted*/
#define SM_SETTING_STATUS_OFFSET 1 /**< \brief Offset to value of register 0x0805*/
#define SM_STATUS_MBX_BUFFER_FULL 0x08 /**< \brief Indicates in one buffer mode if buffer was completely written (based on "ESC_SYNCMAN_STATUS_OFFSET")*/
/*Defines to access :
* - SM Active register 0x0806
*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_16BIT) lines 335 to 337 deleted*/
#define SM_SETTING_ACTIVATE_OFFSET 2 /**< \brief Offset to value of register 0x0806*/
#define SM_SETTING_ENABLE_VALUE 0x01 /**< \brief SyncManager enable*/
#define SM_SETTING_REPAET_REQ_MASK 0x02 /**< \brief SyncManager Repeat request*/
#define SM_SETTING_REPEAT_REQ_SHIFT 0 /**< \brief SyncManager Repeat request shift*/
/*Defines to access :
* - SM PDI COntrol register 0x0807
*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_16BIT) lines 347 to 349 deleted*/
#define SM_SETTING_PDICONTROL_OFFSET 3 /**< \brief Offset to value of register 0x0807*/
#define SM_SETTING_PDI_DISABLE 0x01 /**< \brief Bit0 of register 0x0807 (if 1 SM is disabled from PDI)*/
#define SM_SETTING_REPEAT_ACK 0x02 /**< \brief Bit1 of register 0x0807*/
}STRUCT_PACKED_END
TSYNCMAN;
/*ET9300 Project Handler :(#if FC1100_HW) lines 361 to 363 deleted*/
#endif //_ESC_H_
/** @}*/

View File

@ -0,0 +1,24 @@
//###########################################################################
//
// FILE: f2838x_cm_hw.c
//
// TITLE: F2838x CM EtherCAT Hardware API Mapping
//
// This file contains the source for any EtherCAT stack APIs that require
// extended or modified functionality.
//
//###########################################################################
// $TI Release: F2838x EtherCAT Software v2.01.00.00 $
// $Release Date: August 31 2020 $
// $Copyright: Copyright (C) 2020 Texas Instruments Incorporated -
// http://www.ti.com/ ALL RIGHTS RESERVED $
//###########################################################################
//
// Included Files
//
#include "f2838x_cm_hw.h"
//
// End of File
//

View File

@ -0,0 +1,114 @@
//###########################################################################
//
// FILE: f2838x_cm_hw.h
//
// TITLE: F2838x CM EtherCAT Hardware API Mapping
//
// This file maps the F2838x CM HAL APIs to the EtherCAT stack API naming.
//
//###########################################################################
// $TI Release: F2838x EtherCAT Software v2.01.00.00 $
// $Release Date: August 31 2020 $
// $Copyright: Copyright (C) 2020 Texas Instruments Incorporated -
// http://www.ti.com/ ALL RIGHTS RESERVED $
//###########################################################################
#ifndef F2838X_CM_HW_H
#define F2838X_CM_HW_H
//
// Included Files
//
#include <stdint.h>
#include <string.h>
#include "esc.h"
//
// Defines - Mapping HAL APIs to Stack APIS
//
//
// Interrupt APIs
//
#define DISABLE_ESC_INT() _disable_IRQ()
#define ENABLE_ESC_INT() _enable_IRQ()
//
// Timer APIs
//
#define ECAT_TIMER_INC_P_MS ESC_timerIncPerMilliSec()
#define HW_GetTimer() ESC_getTimer()
#define HW_ClearTimer() ESC_clearTimer()
//
// System APIs
//
#define HW_Init() ESC_initHW()
#define HW_Release() ESC_releaseHW()
#define HW_SetLed(RunLed, ErrLed) ESC_setLed(RunLed, ErrLed)
//
// Read and Write APIs
//
#define HW_EscRead(pData, Address, Len) ESC_readBlock(pData, Address, Len)
#define HW_EscReadIsr(pData, Address, Len) ESC_readBlockISR(pData, Address, Len)
#define HW_EscReadDWord(DWordValue, Address) ((DWordValue) = ESC_readDWord(Address))
#define HW_EscReadDWordIsr(DWordValue, Address) ((DWordValue) = ESC_readDWordISR(Address))
#define HW_EscReadWord(WordValue, Address) ((WordValue) = ESC_readWord(Address))
#define HW_EscReadWordIsr(WordValue, Address) ((WordValue) = ESC_readWordISR(Address))
#define HW_EscReadByte(ByteValue, Address) ((ByteValue) = ESC_readByte(Address))
#define HW_EscReadByteIsr(ByteValue, Address) ((ByteValue) = ESC_readByteISR(Address))
#define HW_EscReadMbxMem(pData, Address, Len) ESC_readBlock(pData, Address, Len)
#define HW_EscWrite(pData, Address, Len) ESC_writeBlock(pData, Address, Len)
#define HW_EscWriteIsr(pData, Address, Len) ESC_writeBlockISR(pData, Address, Len)
#define HW_EscWriteDWord(DWordValue, Address) ESC_writeDWord(DWordValue, Address)
#define HW_EscWriteDWordIsr(DWordValue, Address) ESC_writeDWordISR(DWordValue, Address)
#define HW_EscWriteWord(WordValue, Address) ESC_writeWord(WordValue, Address)
#define HW_EscWriteWordIsr(WordValue, Address) ESC_writeWordISR(WordValue, Address)
#define HW_EscWriteByte(ByteValue, Address) ESC_writeByte(ByteValue, Address)
#define HW_EscWriteByteIsr(ByteValue, Address) ESC_writeByteISR(ByteValue, Address)
#define HW_EscWriteMbxMem(pData, Address, Len) ESC_writeBlock(pData, Address, Len)
//
// Application Layer Event APIs
//
#define HW_GetALEventRegister() ESC_readWord(ESC_AL_EVENT_OFFSET)
#define HW_GetALEventRegister_Isr() ESC_readWordISR(ESC_AL_EVENT_OFFSET)
//
// Function Prototypes
//
extern uint16_t ESC_initHW(void);
extern void ESC_releaseHW(void);
extern void ESC_setLed(uint8_t RunLed, uint8_t ErrLed);
extern uint32_t ESC_getTimer(void);
extern void ESC_clearTimer(void);
extern uint32_t ESC_timerIncPerMilliSec(void);
extern void ESC_readBlock(uint8_t *pData, uint16_t Address, uint16_t Len);
extern void ESC_readBlockISR(uint8_t *pData, uint16_t Address, uint16_t Len);
extern uint32_t ESC_readDWord(uint16_t Address);
extern uint32_t ESC_readDWordISR(uint16_t Address);
extern uint16_t ESC_readWord(uint16_t Address);
extern uint16_t ESC_readWordISR(uint16_t Address);
extern uint8_t ESC_readByte(uint16_t Address);
extern uint8_t ESC_readByteISR(uint16_t Address);
extern void ESC_writeBlock(uint8_t *pData, uint16_t Address, uint16_t Len);
extern void ESC_writeBlockISR(uint8_t *pData, uint16_t Address, uint16_t Len);
extern void ESC_writeDWord(uint32_t DWordValue, uint16_t Address);
extern void ESC_writeDWordISR(uint32_t DWordValue, uint16_t Address);
extern void ESC_writeWord(uint16_t WordValue, uint16_t Address);
extern void ESC_writeWordISR(uint16_t WordValue, uint16_t Address);
extern void ESC_writeByte(uint8_t WordValue, uint16_t Address);
extern void ESC_writeByteISR(uint8_t WordValue, uint16_t Address);
#endif // F2838X_CM_HW_H
//
// End of File
//

View File

@ -0,0 +1,37 @@
//###########################################################################
//
// FILE: f2838x_cm_system.c
//
// TITLE: F2838x CM EtherCAT System APIs
//
// This file contains the source for any device system APIs that require
// modification for compatibility with EtherCAT stack usage.
//
//###########################################################################
// $TI Release: F2838x EtherCAT Software v2.01.00.00 $
// $Release Date: August 31 2020 $
// $Copyright: Copyright (C) 2020 Texas Instruments Incorporated -
// http://www.ti.com/ ALL RIGHTS RESERVED $
//###########################################################################
//
// Included Files
//
#include "f2838x_cm_system.h"
//
// F2838XCM_strcpy - String copy wrapper for compatibility with EtherCAT stack
// calls to "strncpy"
//
void F2838XCM_strcpy(void * __restrict dest, const void * __restrict src,
size_t n)
{
//
// Call standard strncpy from string.h
//
strncpy((char *)dest, (const char *)src, (size_t)n);
}
//
// End of File
//

View File

@ -0,0 +1,35 @@
//###########################################################################
//
// FILE: f2838x_cm_system.h
//
// TITLE: F2838x CM EtherCAT System APIs
//
// This file contains the function prototypes for any device system APIs that
// require modification for compatibility with EtherCAT stack usage.
//
//###########################################################################
// $TI Release: F2838x EtherCAT Software v2.01.00.00 $
// $Release Date: August 31 2020 $
// $Copyright: Copyright (C) 2020 Texas Instruments Incorporated -
// http://www.ti.com/ ALL RIGHTS RESERVED $
//###########################################################################
#ifndef F2838X_CM_SYSTEM_H
#define F2838X_CM_SYSTEM_H
//
// Included Files
//
#include <string.h>
//
// Function Prototypes
//
void F2838XCM_strcpy(void * __restrict dest, const void * __restrict src,
size_t n);
#endif // F2838X_CM_SYSTEM_H
//
// End of File
//

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,197 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
* \addtogroup Mailbox Mailbox Functions
* @{
*/
/**
\file mailbox.h
\author EthercatSSC@beckhoff.com
\version 5.12
<br>Changes to version V5.11:<br>
V5.12 ECAT2: big endian changes<br>
V5.12 MBX3: handle incomplete mailbox communication<br>
<br>Changes to version V5.01:<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
V5.11 MBX1: "return value of ""MBX_StartMailboxHandler()"" changed to UINT16"<br>
V5.11 MBX3: set application triggered emergency and EoE data to pending if no mailbox queue is supported and another mailbox request is currently handled, Handle only one mailbox request at a time (in case that MAILBPX_QUEUE is disabled)<br>
<br>Changes to version - :<br>
V5.01 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "ecat_def.h"
#ifndef _MAILBOX_H_
#define _MAILBOX_H_
/*-----------------------------------------------------------------------------------------
------
------ Defines and Types
------
-----------------------------------------------------------------------------------------*/
#define MBX_TYPE_AOE 1 /**< \brief Mailbox type AoE*/
#define MBX_TYPE_EOE 2 /**< \brief Mailbox type EoE*/
#define MBX_TYPE_COE 3 /**< \brief Mailbox type CoE*/
#define MBX_TYPE_FOE 4 /**< \brief Mailbox type FoE*/
#define MBX_TYPE_SOE 5 /**< \brief Mailbox type SoE*/
#define MBX_TYPE_VOE 15 /**< \brief Mailbox type VoE*/
#define EMCY_SERVICE ((UINT8) 0x0001) /**< \brief Emergency service*/
#define COE_SERVICE ((UINT8) 0x0002) /**< \brief CoE service*/
#define SOE_SERVICE ((UINT8) 0x0004) /**< \brief SoE service*/
#define EOE_SERVICE ((UINT8) 0x0008) /**< \brief EoE service*/
#define AOE_SERVICE ((UINT8) 0x0010) /**< \brief AoE service*/
#define VOE_SERVICE ((UINT8) 0x0020) /**< \brief VoE service*/
#define FOE_SERVICE ((UINT8) 0x0040) /**< \brief FoE service*/
#define FRAGMENTS_FOLLOW ((UINT8) 0x0080) /**< \brief Fragments follow service*/
#ifndef ENTER_MBX_CRITICAL
#define ENTER_MBX_CRITICAL /**< \brief Enter mailbox critical section*/
#endif
#ifndef LEAVE_MBX_CRITICAL
#define LEAVE_MBX_CRITICAL /**< \brief Leave mailbox critical section*/
#endif
#ifndef MAX_MBX_QUEUE_SIZE
#define MAX_MBX_QUEUE_SIZE 10 /**< \brief Mailbox queue size*/
#endif
/*---------------------------------------------
- Command Codes for the mailbox type 0
-----------------------------------------------*/
#define MBXSERVICE_MBXERRORCMD 0x01 /**< \brief Mailbox error command*/
/*---------------------------------------------
- Error Codes for a mailbox error response
-----------------------------------------------*/
#define MBXERR_SYNTAX 0x01 /**< \brief Mailbox error "syntax"*/
#define MBXERR_UNSUPPORTEDPROTOCOL 0x02 /**< \brief Mailbox error "unsupported protocol"*/
#define MBXERR_INVALIDCHANNEL 0x03 /**< \brief Mailbox error "invalid channel"*/
#define MBXERR_SERVICENOTSUPPORTED 0x04 /**< \brief Mailbox error "service not supported"*/
#define MBXERR_INVALIDHEADER 0x05 /**< \brief Mailbox error "invalid header"*/
#define MBXERR_SIZETOOSHORT 0x06 /**< \brief Mailbox error "Size too short"*/
#define MBXERR_NOMOREMEMORY 0x07 /**< \brief Mailbox error "No memory"*/
#define MBXERR_INVALIDSIZE 0x08 /**< \brief Mailbox error "Invalid size"*/
#define MBXERR_SERVICEINWORK 0x09 /**< \brief Mailbox error "Service in work"*/
/**
* \brief Mailbox header
*/
typedef struct MBX_STRUCT_PACKED_START
{
UINT16 Length; /**< \brief Length*/
UINT16 Address; /**< \brief Address*/
/*ET9300 Project Handler :(#if MBX_16BIT_ACCESS) lines 103 to 120 deleted*/
UINT8 Flags[2]; /**< \brief Flags*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_16BIT) lines 122 to 125 deleted*/
#define MBX_OFFS_TYPE 1 /**< \brief Protocol type offset*/
#define MBX_OFFS_COUNTER 1 /**< \brief Protocol counter offset*/
#define MBX_MASK_TYPE 0x0F /**< \brief Protocol type mask*/
#define MBX_MASK_COUNTER 0xF0 /**< \brief Protocol counter mask*/
#define MBX_SHIFT_TYPE 0 /**< \brief Protocol type shift*/
#define MBX_SHIFT_COUNTER 4 /**< \brief Protocol counter shift*/
}MBX_STRUCT_PACKED_END
TMBXHEADER;
#define MBX_HEADER_SIZE 6 /**< \brief Mailbox header size*/
#define MAX_MBX_DATA_SIZE (MAX_MBX_SIZE - MBX_HEADER_SIZE) /**< \brief Mailbox data size*/
/**
* \brief Mailbox datagram
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
UINT16 Data[(MAX_MBX_DATA_SIZE >> 1)]; /**< \brief Mailbox data*/
}MBX_STRUCT_PACKED_END
TMBX;
/**
* \brief Mailbox queue
*/
typedef struct
{
UINT16 firstInQueue; /**< \brief First in Queue*/
UINT16 lastInQueue; /**< \brief Last in Queue*/
UINT16 maxQueueSize; /**< \brief Max queue size*/
TMBX MBXMEM * queue[(MAX_MBX_QUEUE_SIZE)+1]; /**< \brief Queue buffer*/
} TMBXQUEUE;
#endif //_MAILBOX_H_
/*-----------------------------------------------------------------------------------------
------
------ Global Variables
------
-----------------------------------------------------------------------------------------*/
#if defined(_MAILBOX_) && (_MAILBOX_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
PROTO BOOL bReceiveMbxIsLocked; /**< \brief Receive mailbox is locked (MBoxOut, default SM0)*/
PROTO BOOL bSendMbxIsFull; /**< \brief Send mailbox is full (MBoxIn, default SM1)*/
PROTO BOOL bMbxRunning; /**< \brief Mailbox running (At least PreOP state)*/
PROTO BOOL bMbxRepeatToggle; /**< \brief Mailbox repeat toggle*/
PROTO UINT16 u16SendMbxSize; /**< \brief Send mailbox size (default SM1)*/
PROTO UINT16 u16ReceiveMbxSize; /**< \brief Receive mailbox size (default SM0)*/
PROTO UINT16 u16EscAddrReceiveMbx; /**< \brief Receive mailbox address (default SM0)*/
PROTO UINT16 u16EscAddrSendMbx; /**< \brief Send mailbox address (default SM1)*/
PROTO UINT8 u8MbxWriteCounter; /**< \brief Write mailbox counter*/
PROTO UINT8 u8MbxReadCounter; /**< \brief Read mailbox counter*/
/*ET9300 Project Handler :(#if !MAILBOX_QUEUE) lines 193 to 195 deleted*/
PROTO UINT8 u8MailboxSendReqStored; /**< \brief Mailbox send request stored*/
PROTO TMBX MBXMEM * psWriteMbx; /**< \brief Pointer to write mailbox buffer*/
PROTO TMBX MBXMEM * psReadMbx; /**< \brief Pointer to read mailbox buffer*/
PROTO TMBX MBXMEM * psRepeatMbx; /**< \brief Pointer to repeat mailbox buffer*/
PROTO TMBX MBXMEM * psStoreMbx; /**< \brief Pointer to store mailbox buffer*/
/*ET9300 Project Handler :(#if !MAILBOX_QUEUE) lines 201 to 203 deleted*/
PROTO TMBXQUEUE MBXMEM sMbxSendQueue; /**< \brief Send mailbox queue*/
PROTO TMBXQUEUE MBXMEM sMbxReceiveQueue; /**< \brief Receive mailbox queue*/
/*-----------------------------------------------------------------------------------------
------
------ Global Functions
------
-----------------------------------------------------------------------------------------*/
PROTO void MBX_Init(void);
PROTO UINT16 MBX_StartMailboxHandler(void);
PROTO void MBX_StopMailboxHandler(void);
PROTO void MBX_MailboxWriteInd(TMBX MBXMEM *pMbx);
PROTO void MBX_MailboxReadInd(void);
PROTO void MBX_MailboxRepeatReq(void);
PROTO UINT8 MBX_MailboxSendReq(TMBX MBXMEM * pMbx, UINT8 flags);
PROTO void MBX_CheckAndCopyMailbox(void);
PROTO UINT8 MBX_CopyToSendMailbox(TMBX MBXMEM *pMbx);
PROTO void MBX_Main(void);
#undef PROTO
/** @}*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,293 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
* \addtogroup CoE CAN Application Profile over EtherCAT
* @{
*/
/**
\file objdef.h
\author EthercatSSC@beckhoff.com
\brief CAN application profile over EtherCAT object dictionary
\version 5.11
<br>Changes to version V5.10:<br>
V5.11 COE2: update synctype supported flag for freerun<br>
V5.11 COE3: change 0x10F3.2 (Sync Error limit) from UINT32 to UINT16 (according to the ETG.1020)<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
<br>Changes to version V5.01:<br>
V5.10 COE1: Define one entry description for all 0x1C3x objects and change data type of SI11,12,13 to UINT16 (according ETG.1020)<br>
V5.10 COE2: Change return value of Get ObjectSize to UINT32<br>
Change object size to UINT32<br>
V5.10 ECAT13: Update Synchronisation handling (FreeRun,SM Sync, Sync0, Sync1)<br>
Compare DC UINT configuration (by ESC Config data) vs. DC activation register settings<br>
Update 0x1C3x entries<br>
V5.10 ECAT8: Update Datatype defines according ETG.1020<br>
<br>Changes to version - :<br>
V5.01 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "sdoserv.h"
#ifndef _OBJDEF_H_
#define _OBJDEF_H_
/*-----------------------------------------------------------------------------------------
------
------ Defines and Types
------
-----------------------------------------------------------------------------------------*/
/*---------------------------------------------
- DataTypes
-----------------------------------------------*/
#define DEFTYPE_NULL 0x0000 /**< \brief Null*/
#define DEFTYPE_BOOLEAN 0x0001 /**< \brief BOOLEAN*/
#define DEFTYPE_INTEGER8 0x0002 /**< \brief INTEGER8*/
#define DEFTYPE_INTEGER16 0x0003 /**< \brief INTEGER16*/
#define DEFTYPE_INTEGER24 0x0010 /**< \brief INTEGER24*/
#define DEFTYPE_INTEGER32 0x0004 /**< \brief INTEGER32*/
#define DEFTYPE_INTEGER40 0x0012 /**< \brief INTEGER40*/
#define DEFTYPE_INTEGER48 0x0013 /**< \brief INTEGER48*/
#define DEFTYPE_INTEGER56 0x0014 /**< \brief INTEGER56*/
#define DEFTYPE_UNSIGNED8 0x0005 /**< \brief UNSIGNED8*/
#define DEFTYPE_UNSIGNED16 0x0006 /**< \brief UNSIGNED16*/
#define DEFTYPE_UNSIGNED24 0x0016 /**< \brief UNSIGNED24*/
#define DEFTYPE_UNSIGNED32 0x0007 /**< \brief UNSIGNED32*/
#define DEFTYPE_REAL32 0x0008 /**< \brief REAL32*/
#define DEFTYPE_VISIBLESTRING 0x0009 /**< \brief VISIBLE_STRING*/
#define DEFTYPE_OCTETSTRING 0x000A /**< \brief OCTET_STRING*/
#define DEFTYPE_UNICODE_STRING 0x000B /**< \brief UNICODE_STRING*/
#define DEFTYPE_TIME_OF_DAY 0x000C /**< \brief TIME_OF_DAY*/
#define DEFTYPE_TIME_DIFFERENCE 0x000D /**< \brief TIME_DIFFERENCE*/
#define DEFTYPE_INTEGER24 0x0010 /**< \brief INTEGER24*/
#define DEFTYPE_REAL64 0x0011 /**< \brief REAL64*/
#define DEFTYPE_INTEGER40 0x0012 /**< \brief INTEGER40*/
#define DEFTYPE_INTEGER48 0x0013 /**< \brief INTEGER48*/
#define DEFTYPE_INTEGER56 0x0014 /**< \brief INTEGER56*/
#define DEFTYPE_INTEGER64 0x0015 /**< \brief INTEGER64*/
#define DEFTYPE_UNSIGNED24 0x0016 /**< \brief UNSIGNED24*/
#define DEFTYPE_UNSIGNED40 0x0018 /**< \brief UNSIGNED40*/
#define DEFTYPE_UNSIGNED48 0x0019 /**< \brief UNSIGNED48*/
#define DEFTYPE_UNSIGNED56 0x001A /**< \brief UNSIGNED56*/
#define DEFTYPE_UNSIGNED64 0x001B /**< \brief UNSIGNED64*/
#define DEFTYPE_GUID 0x001D /**< \brief DEFTYPE_GUID*/
#define DEFTYPE_BYTE 0x001E /**< \brief DEFTYPE_BYTE*/
#define DEFTYPE_WORD 0x001F /**< \brief DEFTYPE_WORD*/
#define DEFTYPE_DWORD 0x0020 /**< \brief DEFTYPE_DWORD*/
#define DEFTYPE_PDOMAPPING 0x0021 /**< \brief PDO_MAPPING*/
#define DEFTYPE_IDENTITY 0x0023 /**< \brief IDENTITY*/
#define DEFTYPE_COMMAND 0x0025 /**< \brief COMMAND_PAR*/
#define DEFTYPE_PDOCOMPAR 0x0027 /**< \brief PDO_PARAMETER*/
#define DEFTYPE_ENUM 0x0028 /**< \brief DEFTYPE_ENUM */
#define DEFTYPE_SMPAR 0x0029 /**< \brief SM_SYNCHRONISATION*/
#define DEFTYPE_RECORD 0x002A /**< \brief DEFTYPE_RECORD */
#define DEFTYPE_BACKUP 0x002B /**< \brief BACKUP_PARAMETER*/
#define DEFTYPE_MDP 0x002C /**< \brief MODULAR_DEVICE_PROFILE*/
#define DEFTYPE_BITARR8 0x002D /**< \brief BITARR8*/
#define DEFTYPE_BITARR16 0x002E /**< \brief BITARR16*/
#define DEFTYPE_BITARR32 0x002F /**< \brief BITARR32*/
#define DEFTYPE_BIT1 0x0030 /**< \brief BIT1*/
#define DEFTYPE_BIT2 0x0031 /**< \brief BIT2*/
#define DEFTYPE_BIT3 0x0032 /**< \brief BIT3*/
#define DEFTYPE_BIT4 0x0033 /**< \brief BIT4*/
#define DEFTYPE_BIT5 0x0034 /**< \brief BIT5*/
#define DEFTYPE_BIT6 0x0035 /**< \brief BIT6*/
#define DEFTYPE_BIT7 0x0036 /**< \brief BIT7*/
#define DEFTYPE_BIT8 0x0037 /**< \brief BIT8*/
#define DEFTYPE_ARRAY_OF_INT 0x0260 /**< \brief DEFTYPE_ARRAY_OF_INT*/
#define DEFTYPE_ARRAY_OF_SINT 0x0261 /**< \brief DEFTYPE_ARRAY_OF_SINT*/
#define DEFTYPE_ARRAY_OF_DINT 0x0262 /**< \brief DEFTYPE_ARRAY_OF_DINT*/
#define DEFTYPE_ARRAY_OF_UDINT 0x0263 /**< \brief DEFTYPE_ARRAY_OF_UDINT*/
#define DEFTYPE_ERRORHANDLING 0x0281 /**< \brief DEFTYPE_ERRORHANDLING*/
#define DEFTYPE_DIAGHISTORY 0x0282 /**< \brief DEFTYPE_DIAGHISTORY*/
#define DEFTYPE_SYNCSTATUS 0x0283 /**< \brief DEFTYPE_SYNCSTATUS*/
#define DEFTYPE_SYNCSETTINGS 0x0284 /**< \brief DEFTYPE_SYNCSETTINGS*/
#define DEFTYPE_FSOEFRAME 0x0285 /**< \brief DEFTYPE_FSOEFRAME*/
#define DEFTYPE_FSOECOMMPAR 0x0286 /**< \brief DEFTYPE_FSOECOMMPAR*/
/*---------------------------------------------
- Flags for supported Synctypes (0x1C32.4 / 0x1C33.4)
-----------------------------------------------*/
#define SYNCTYPE_FREERUNSUPP 0x0001 /**< \brief FreeRun supported*/
#define SYNCTYPE_SYNCHRONSUPP 0x0002 /**< \brief SyncManager synchron supported*/
#define SYNCTYPE_DCSYNC0SUPP 0x0004 /**< \brief Sync0 synchron supported*/
#define SYNCTYPE_DCSYNC1SUPP 0x0008 /**< \brief Sync1 synchron supported*/
#define SYNCTYPE_SUBCYCLESUPP 0x0010 /**< \brief Subordinated Application with fixed Sync0 supported*/
#define SYNCTYPE_LOCALSHIFTSUPP 0x0020 /**< \brief Event shift with local timer supported. Output shift : 0x1C32.4 ; Input shift : 0x1C33.4 (not supported by the default SSC)*/
#define SYNCTYPE_SHIFTBYSYNC1SUPP 0x0040 /**< \brief Event shift with Sync1 event supported. Output shift : 0x1C32.4 ; Input shift : 0x1C33.4*/
#define SYNCTYPE_MEASURE_DELAYSUPP 0x0200 /**< \brief Delay times should be measured (not supported by the default SSC, only the cycle time can be measured (1ms resolution)*/
#define SYNCTYPE_FIXED_DELAYSUPP 0x0400 /**< \brief Delay times are fixed*/
#define SYNCTYPE_TIMESVARIABLE 0x4000 /**< \brief Dynamic Cycle Times supported*/
#define IS_PDO_ASSIGN(x) ((x >= 0x1C10) && (x <= 0x1C2F)) /**< \brief Macro to check if object index is SyncManager assign object*/
#define IS_RX_PDO(x) (((x) >= 0x1600) && ((x) <= 0x17FF)) /**< \brief Macro to check if object index RxPDO mapping object*/
#define IS_TX_PDO(x) (((x) >= 0x1A00) && ((x) <= 0x1BFF)) /**< \brief Macro to check if object index TxPDO mapping object*/
/**
* \brief Object dictionary entry structure
*/
typedef struct OBJ_ENTRY
{
struct OBJ_ENTRY *pPrev; /**< \brief Previous entry(object) in the object dictionary list*/
struct OBJ_ENTRY *pNext; /**< \brief Next entry(object) in the object dictionary list*/
UINT16 Index; /**< \brief Object index*/
TSDOINFOOBJDESC ObjDesc; /**< \brief Object access, type and code*/
OBJCONST TSDOINFOENTRYDESC OBJMEM *pEntryDesc; /**< \brief pointer to object entry descriptions*/
OBJCONST UCHAR OBJMEM *pName; /**< \brief Pointer to object and entry names*/
void MBXMEM *pVarPtr; /**< \brief Pointer to object buffer*/
UINT8 (* Read)( UINT16 Index, UINT8 Subindex, UINT32 Size, UINT16 MBXMEM * pData, UINT8 bCompleteAccess ); /**< \brief Function pointer to read function (if NULL default read function will be used)*/
UINT8 (* Write)( UINT16 Index, UINT8 Subindex, UINT32 Size, UINT16 MBXMEM * pData, UINT8 bCompleteAccess ); /**< \brief Function pointer to write function (if NULL default write function will be used)*/
UINT16 NonVolatileOffset; /**< \brief Offset within the non volatile memory (need to be defined for backup objects)*/
}
TOBJECT;
/**
* Object 0x1C3x (SyncManager Parameter) data structure
*/
typedef struct OBJ_STRUCT_PACKED_START
{
UINT16 subindex0;/**< \brief SubIndex0*/
UINT16 u16SyncType; /**< \brief SunbIndex 001: Sync type*/
UINT32 u32CycleTime;/**< \brief SunbIndex 002: Cycle time */
UINT32 u32Subindex003;/**< \brief SunbIndex 003: Shift time (not supported, variable is only used as a place holder)*/
UINT16 u16SyncTypesSupported;/**< \brief SunbIndex 004: Supported Sync types*/
UINT32 u32MinCycleTime;/**< \brief SunbIndex 005: Min cycle time*/
UINT32 u32CalcAndCopyTime;/**< \brief SunbIndex 006: Calc and Copy time*/
UINT32 u32Si7Reserved;/**< \brief SunbIndex 007: 32Bit Reserved*/
UINT16 u16GetCycleTime;/**< \brief SunbIndex 008: Get cycle time*/
UINT32 u32DelayTime; /**< \brief SunbIndex 009: Delay time*/
UINT32 u32Sync0CycleTime; /**< \brief SunbIndex 010: Sync0 cycle time*/
UINT16 u16SmEventMissedCounter; /**< \brief SunbIndex 011: SyncManager event missed counter*/
UINT16 u16CycleExceededCounter; /**< \brief SunbIndex 012: Cycle exceed counter*/
UINT16 u16ShiftTooShort; /**< \brief SunbIndex 013: Shift too short*/
UINT16 u16Si14Reserved; /**< \brief SubIndex14 not supported*/
UINT32 u32Si15Reserved; /**< \brief SubIndex15 not supported*/
UINT32 u32Si16Reserved; /**< \brief SubIndex16 not supported*/
UINT32 u32Si17Reserved; /**< \brief SubIndex17 not supported*/
UINT32 u32Si18Reserved; /**< \brief SubIndex18 not supported*/
UINT8 u8SyncError; /**< \brief Sync Error*/
}OBJ_STRUCT_PACKED_END
TSYNCMANPAR;
/**
* Cycle diagnosis
*/
typedef struct OBJ_STRUCT_PACKED_START
{
UINT16 syncFailedCounter; /**< \brief Sync Failed Counter*/
}OBJ_STRUCT_PACKED_END
TCYCLEDIAG;
/**
* Object 0x10F1 (Error Settings Object) data structure
*/
typedef struct OBJ_STRUCT_PACKED_START {
UINT16 u16SubIndex0; /**< \brief SubIndex0*/
UINT32 u32LocalErrorReaction; /**< \brief Local error reaction*/
UINT16 u16SyncErrorCounterLimit; /**< \brief Sync error counter limit*/
} OBJ_STRUCT_PACKED_END
TOBJ10F1;
#endif //_OBJDEF_H_
/*-----------------------------------------------------------------------------------------
------
------ Global variables
------
-----------------------------------------------------------------------------------------*/
#if defined(_OBJDEF_) && (_OBJDEF_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
/**
* Indicates if the synchronisation was written by the user on startup (by writing 0x1C3x.1).
* If it was not written the sync mode will be set based on the DC registers 0x980:0x981
*/
PROTO BOOL bSyncSetByUser;
/**
* \brief Cycle diagnosis variable
*/
PROTO TCYCLEDIAG sCycleDiag;
/**
* \brief Object 0x1C32 (SyncManager 2 Parameter) object variable
*/
PROTO TSYNCMANPAR MBXMEM sSyncManOutPar;
/**
* \brief Object 0x1C33 (SyncManager 3 Parameter) object variable
*/
PROTO TSYNCMANPAR MBXMEM sSyncManInPar;
/**
* \brief Object 0x10F1 (Error Settings) object variable
*
* SubIndex0 : 2
* Local error reaction : 1
* Sync error counter limit : MAX_SM_EVENT_MISSED
*/
PROTO TOBJ10F1 sErrorSettings
#if defined(_OBJDEF_) && (_OBJDEF_ == 1)
= {2, 0x01, MAX_SM_EVENT_MISSED}
#endif
;
/**
* \brief Default entry name "SubIndex 000"
*/
PROTO CHAR OBJMEM aSubindexDesc[13]
#if defined(_OBJDEF_) && (_OBJDEF_ == 1)
= { "SubIndex 000" }
#endif
;
/*-----------------------------------------------------------------------------------------
------
------ Global functions
------
-----------------------------------------------------------------------------------------*/
PROTO OBJCONST TOBJECT OBJMEM * OBJ_GetObjectHandle( UINT16 index );
PROTO UINT32 OBJ_GetObjectLength( UINT16 index, UINT8 subindex, OBJCONST TOBJECT OBJMEM * pObjEntry, UINT8 bCompleteAccess);
PROTO UINT16 OBJ_GetNoOfObjects(UINT8 listType);
PROTO UINT16 OBJ_GetObjectList(UINT16 listType, UINT16 *pIndex, UINT16 size, UINT16 MBXMEM *pData,UINT8 *pAbort);
PROTO UINT16 OBJ_GetDesc( UINT16 index, UINT8 subindex, OBJCONST TOBJECT OBJMEM * pObjEntry, UINT16 MBXMEM * pData );
PROTO OBJCONST TSDOINFOENTRYDESC OBJMEM * OBJ_GetEntryDesc(OBJCONST TOBJECT OBJMEM * pObjEntry, UINT8 Subindex);
PROTO OBJCONST TSDOINFOOBJDESC OBJMEM * OBJ_GetObjDesc(OBJCONST TOBJECT OBJMEM * pObjEntry);
PROTO UINT16 OBJ_GetEntryOffset(UINT8 subindex, OBJCONST TOBJECT OBJMEM * pObjEntry);
PROTO UINT8 CheckSyncTypeValue(UINT16 index, UINT16 NewSyncType);
PROTO UINT8 OBJ_Read(UINT16 index, UINT8 subindex, UINT32 objSize, OBJCONST TOBJECT OBJMEM * pObjEntry, UINT16 MBXMEM * pData, UINT8 bCompleteAccess);
PROTO UINT8 OBJ_Write(UINT16 index, UINT8 subindex, UINT32 dataSize, OBJCONST TOBJECT OBJMEM * pObjEntry, UINT16 MBXMEM * pData, UINT8 bCompleteAccess);
PROTO void COE_WriteBackupEntry(UINT8 subindex, OBJCONST TOBJECT OBJMEM * pObjEntry);
#undef PROTO
/** @}*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,649 @@
/*
* This source file is part of the EtherCAT Slave Stack Code licensed by Beckhoff Automation GmbH & Co KG, 33415 Verl, Germany.
* The corresponding license agreement applies. This hint shall not be removed.
* https://www.beckhoff.com/media/downloads/slave-stack-code/ethercat_ssc_license.pdf
*/
/**
* \addtogroup CoE CAN Application Profile over EtherCAT
* @{
*/
/**
\file sdoserv.h
\author EthercatSSC@beckhoff.com
\brief SDO Service definitions
\version 5.12
<br>Changes to version V5.11:<br>
V5.12 ECAT2: big endian changes<br>
V5.12 MBX3: handle incomplete mailbox communication<br>
<br>Changes to version V5.10:<br>
V5.11 ECAT10: change PROTO handling to prevent compiler errors<br>
V5.11 SDO10: add new SDO abort code 0x6010004 (complete access not supported)<br>
<br>Changes to version V5.01:<br>
V5.10 SDO3: Add new SDO Abort Code (0x06090033)<br>
<br>Changes to version - :<br>
V5.01 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#include "ecatcoe.h"
#ifndef _SDOSERV_H_
#define _SDOSERV_H_
/*-----------------------------------------------------------------------------------------
------
------ Defines and Types
------
-----------------------------------------------------------------------------------------*/
/**
* \addtogroup SdoErrorCodes SDO Error Codes
* @{
*/
#define ERROR_SDOINVALIDCOMMAND 0x1101 /**< \brief Invalid SDO command*/
#define ERROR_SDOINVALIDHEADER 0x1102 /**< \brief Invalid SDO header*/
#define ERROR_SDONOTSUPPORTED 0x1103 /**< \brief SDO service not supported*/
/** @}*/
/**
* \addtogroup SdoHeaderData SDO Header and Data
* @{
*/
#define SDOHEADER_SIZEINDICATOR ((UINT8) 0x01) /**< \brief Size Indicator size of data in Data Set Size specified*/
#define SDOHEADER_TRANSFERTYPE ((UINT8) 0x02) /**< \brief Transfer Type<br>1: Expedited<br>0: Normal*/
#define SDOHEADER_DATASETSIZE ((UINT8) 0x0C) /**< \brief Data Set Size (used for Expedited transfer)*/
#define SDOHEADER_COMPLETEACCESS ((UINT8) 0x10) /**< \brief Complete Access indication<br>0: Only specified entry will be transferred<br>1: Whole object (with or without Subindex0) will be transferred)*/
#define SDOHEADER_COMMAND ((UINT8) 0xE0) /**< \brief SDO Command*/
#define SDOHEADERSHIFT_SIZEINDICATOR ((UINT8) 0) /**< \brief Shift for Size Indicator*/
#define SDOHEADERSHIFT_TRANSFERTYPE ((UINT8) 1) /**< \brief Shift for Transfer Type*/
#define SDOHEADERSHIFT_DATASETSIZE ((UINT8) 2) /**< \brief Shift for Data Set Size*/
#define SDOHEADERSHIFT_INDEXACCESS ((UINT8) 4) /**< \brief Shift for Complete Access*/
#define SDOHEADERSHIFT_COMMAND ((UINT8) 5) /**< \brief Shift for SDO Command*/
/** @}*/
/**
* \addtogroup SdoServices SDO Services
* @{
*/
#define SDOSERVICE_INITIATEDOWNLOADREQ ((UINT8) (0x01 << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO download request*/
#define SDOSERVICE_INITIATEDOWNLOADRES ((UINT8) (0x03 << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO download response*/
#define SDOSERVICE_DOWNLOADSEGMENTREQ ((UINT8) (0x00 << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO segmented download request*/
#define SDOSERVICE_DOWNLOADSEGMENTRES ((UINT8) (0x01 << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO segmented download response*/
#define SDOSERVICE_INITIATEUPLOADREQ ((UINT8) (0x02 << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO upload request*/
#define SDOSERVICE_INITIATEUPLOADRES ((UINT8) (0x02 << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO upload response*/
#define SDOSERVICE_UPLOADSEGMENTREQ ((UINT8) (0x03 << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO segmented upload request*/
#define SDOSERVICE_UPLOADSEGMENTRES ((UINT8) (0x00 << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO segmented upload response*/
#define SDOSERVICE_ABORTTRANSFER ((UINT8) (((UINT8) 0x04) << (SDOHEADERSHIFT_COMMAND))) /**< \brief SDO abort*/
/** @}*/
/**
* \addtogroup SdoHeaderData SDO Header and Data
* @{
*/
/**
* Structure to handle the basic SDO header
*/
typedef struct MBX_STRUCT_PACKED_START
{
/*ET9300 Project Handler :(#if MBX_16BIT_ACCESS) lines 101 to 128 deleted*/
UINT8 Sdo[4]; /**< \brief 32Bit SDO header buffer*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_16BIT) lines 130 to 135 deleted*/
#define SDOHEADER_COMMANDOFFSET 0 /**< \brief Memory offset for the command*/
#define SDOHEADER_INDEXLOOFFSET 1 /**< \brief Memory offset for the low Byte of the object index*/
#define SDOHEADER_INDEXHIOFFSET 2 /**< \brief Memory offset for the high Byte of the object index*/
#define SDOHEADER_SUBINDEXOFFSET 3 /**< \brief Memory offset for subindex*/
#define SDOHEADER_COMMANDMASK 0xFF /**< \brief Mask to get the command Byte*/
#define SDOHEADER_INDEXLOSHIFT 0 /**< \brief Shift to get the low Byte of the object index*/
#define SDOHEADER_INDEXHIMASK 0xFF /**< \brief Mask to get the high byte of the object index*/
#define SDOHEADER_SUBINDEXSHIFT 0 /**< \brief Shift to get the subindex*/
}MBX_STRUCT_PACKED_END
TINITSDOHEADER;
#define INITSDO_HEADER_SIZE 4 /**< \brief Size of the SDO header*/
/**
*Complete SDO datagram including mailbox header, CoE header and SDO header
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TINITSDOHEADER SdoHeader; /**< \brief SDO header*/
}MBX_STRUCT_PACKED_END
TINITSDOMBX;
#define MAX_EXPEDITED_DATA 4 /**< \brief Maximum number of Bytes handled via an expedited transfer*/
#define MIN_SEGMENTED_DATA ((UINT16) 7) /**< \brief Minimum number of Bytes required for a segmented transfer*/
#define EXPEDITED_FRAME_SIZE ( COE_HEADER_SIZE + INITSDO_HEADER_SIZE + (MAX_EXPEDITED_DATA) ) /**< \brief Size of an expedited mailbox datagram*/
#define DOWNLOAD_NORM_REQ_SIZE ( COE_HEADER_SIZE + INITSDO_HEADER_SIZE + 4 ) /**< \brief Size of an normal download request*/
/* HBu 06.02.06: names of defines changed */
/* HBu 21.03.06: the SDO_Download-Response has to have always 8 bytes */
#define DOWNLOAD_NORM_RES_SIZE ( COE_HEADER_SIZE + INITSDO_HEADER_SIZE + 4 ) /**< \brief Frame size of an normal download response*/
#define UPLOAD_NORM_RES_SIZE ( COE_HEADER_SIZE + INITSDO_HEADER_SIZE + 4 ) /**< \brief Frame size of an normal upload response*/
#define SEGMENT_NORM_HEADER_SIZE ( COE_HEADER_SIZE + 1 ) /**< \brief Minimum SDO header size*/
#define SEGMENT_NORM_RES_SIZE ( (SEGMENT_NORM_HEADER_SIZE) + (MIN_SEGMENTED_DATA) ) /**< \brief Minimum SDO size*/
#define SEGMENT_MBX_SIZE ( MBX_HEADER_SIZE + (SEGMENT_NORM_HEADER_SIZE) )/**< \brief Minimum mailbox datagram*/
/**
* Segmented SDO header including data
*/
typedef struct MBX_STRUCT_PACKED_START
{
/*ET9300 Project Handler :(#if MBX_16BIT_ACCESS) lines 183 to 209 deleted*/
UINT8 SegHeader; /**< \brief 8Bit header buffer*/
#define SEGHEADER_MASK ((UINT8) 0xFF) /**< \brief SDO header mask*/
#define SEGHEADER_NOMOREFOLLOWS ((UINT8) 0x01) /**< \brief More segments follow flag*/
#define SEGHEADER_SEGDATASIZE ((UINT8) 0x0E) /**< \brief Segmented data size*/
#define SEGHEADER_TOGGLE ((UINT8) 0x10) /**< \brief Toogle flag*/
#define SEGHEADER_COMMAND ((UINT8) 0xE0) /**< \brief Command identifier*/
#define SEGHEADERSHIFT_SEGDATASIZE ((UINT8) 1) /**< \brief Shift for Segmented data size*/
#define SEGHEADERSHIFT_TOGGLE ((UINT8) 4) /**< \brief Shift for toggle flag*/
#define SEGHEADERSHIFT_COMMAND ((UINT8) 5) /**< \brief Shift for command identifier*/
UINT8 Data[(MAX_MBX_DATA_SIZE)-(SEGMENT_NORM_HEADER_SIZE)]; /**< \brief Data buffer*/
}MBX_STRUCT_PACKED_END
TSDOSEGHEADERDATA;
/**
*Expedited download request
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TINITSDOHEADER SdoHeader; /**< \brief SDO header*/
UINT16 Data[(MAX_EXPEDITED_DATA) >> 1]; /**< \brief Data buffer*/
}MBX_STRUCT_PACKED_END
TINITSDODOWNLOADEXPREQMBX;
/**
*Normal download request
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TINITSDOHEADER SdoHeader; /**< \brief SDO header*/
UINT16 CompleteSize[2]; /**< \brief Complete object size*/
UINT16 Data[(((MAX_MBX_DATA_SIZE)-(DOWNLOAD_NORM_REQ_SIZE)) >> 1)]; /**< \brief Data buffer*/
}MBX_STRUCT_PACKED_END
TINITSDODOWNLOADNORMREQMBX;
/**
*Expedited and normal download response:
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TINITSDOHEADER SdoHeader; /**< \brief SDO header*/
}MBX_STRUCT_PACKED_END
TINITSDODOWNLOADRESMBX;
/**
*Segmented download request
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TSDOSEGHEADERDATA SdoHeader; /**< \brief SDO header (data is included in header)*/
}MBX_STRUCT_PACKED_END
TDOWNLOADSDOSEGREQMBX;
/**
*Segmented download response
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
UINT8 SegHeader; /**< \brief SDO header*/
}MBX_STRUCT_PACKED_END
TDOWNLOADSDOSEGRESMBX;
/**
*Expedited and normal upload request
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TINITSDOHEADER SdoHeader; /**< \brief SDO header*/
}MBX_STRUCT_PACKED_END
TINITSDOUPLOADREQMBX;
/**
*Expedited upload response
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TINITSDOHEADER SdoHeader; /**< \brief SDO header*/
UINT16 Data[((MAX_EXPEDITED_DATA) >> 1)]; /**< \brief Data buffer*/
}MBX_STRUCT_PACKED_END
TINITSDOUPLOADEXPRESMBX;
/**
*Normal upload response
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TINITSDOHEADER SdoHeader; /**< \brief SDO header*/
UINT16 CompleteSize[2]; /**< \brief Complete object size*/
UINT16 Data[(((MAX_MBX_DATA_SIZE)-(UPLOAD_NORM_RES_SIZE)) >> 1)]; /**< \brief Data buffer*/
}MBX_STRUCT_PACKED_END
TINITSDOUPLOADNORMRESMBX;
/**
*Segmented upload request
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
UINT8 SegHeader; /**< \brief SDO header*/
}MBX_STRUCT_PACKED_END
TUPLOADSDOSEGREQMBX;
/**
*Segmented upload response
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TSDOSEGHEADERDATA SdoHeader; /**< \brief SDO header (data is included in header)*/
}MBX_STRUCT_PACKED_END
TUPLOADSDOSEGRESMBX;
/**
*Abort request
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TINITSDOHEADER SdoHeader; /**< \brief SDO header*/
UINT32 AbortCode; /**< \brief SDO abort code*/
}MBX_STRUCT_PACKED_END
TABORTSDOTRANSFERREQMBX;
#define ABORT_NORM_RES_SIZE (SIZEOF(TABORTSDOTRANSFERREQMBX) - SIZEOF(TMBXHEADER))/**< \brief Size of the SDO Abort datagram (without the mailbox header)*/
/** @}*/
/**
* \addtogroup SDOAbort SDO Abort Codes
* @{
*/
#define ABORT_NOERROR 0x00000000 /**< \brief No SDO error*/
#define ABORT_TOGGLE_BIT_NOT_CHANGED 0x05030000 /**< \brief Toggle bit not changed*/
#define ABORT_SDO_PROTOCOL_TIMEOUT 0x05040000 /**< \brief SDO timeout*/
#define ABORT_COMMAND_SPECIFIER_UNKNOWN 0x05040001 /**< \brief Command specifier unknown*/
#define ABORT_OUT_OF_MEMORY 0x05040005 /**< \brief Out of memory*/
#define ABORT_UNSUPPORTED_ACCESS 0x06010000 /**< \brief Unsupported Access*/
#define ABORT_WRITE_ONLY_ENTRY 0x06010001 /**< \brief Write only entry*/
#define ABORT_READ_ONLY_ENTRY 0x06010002 /**< \brief Read only entry*/
#define ABORT_ENTRY_CANT_BE_WRITTEN_SI0_NOT_0 0x06010003 /**< \brief Entry can not be written because Subindex0 is not 0*/
#define ABORT_COMPLETE_ACCESS_NOT_SUPPORTED 0x06010004 /**< \brief The object can not be accessed via complete access*/
#define ABORT_OBJECT_NOT_EXISTING 0x06020000 /**< \brief Object not existing*/
#define ABORT_OBJECT_CANT_BE_PDOMAPPED 0x06040041 /**< \brief Object can not be mapped to PDO*/
#define ABORT_MAPPED_OBJECTS_EXCEED_PDO 0x06040042 /**< \brief Mapped Object exceeds PDO*/
#define ABORT_PARAM_IS_INCOMPATIBLE 0x06040043 /**< \brief Parameter is incompatible*/
#define ABORT_INTERNAL_DEVICE_INCOMPATIBILITY 0x06040047 /**< \brief Device incompatibility*/
#define ABORT_HARDWARE_ERROR 0x06060000 /**< \brief Hardware error*/
#define ABORT_PARAM_LENGTH_ERROR 0x06070010 /**< \brief Parameter length error*/
#define ABORT_PARAM_LENGTH_TOO_LONG 0x06070012 /**< \brief Parameter is too long*/
#define ABORT_PARAM_LENGTH_TOO_SHORT 0x06070013 /**< \brief Parameter is too short*/
#define ABORT_SUBINDEX_NOT_EXISTING 0x06090011 /**< \brief Subindex (Entry) not exists*/
#define ABORT_VALUE_EXCEEDED 0x06090030 /**< \brief Value exceeds*/
#define ABORT_VALUE_TOO_GREAT 0x06090031 /**< \brief Value is too great*/
#define ABORT_VALUE_TOO_SMALL 0x06090032 /**< \brief Value is too small*/
#define ABORT_MODULE_ID_LIST_NOT_MATCH 0x06090033 /**< \brief Detected Module Ident List (0xF030) and Configured Module Ident list (0xF050) does not match*/
#define ABORT_MAX_VALUE_IS_LESS_THAN_MIN_VALUE 0x06090036 /**< \brief Value is less than minimum value*/
#define ABORT_GENERAL_ERROR 0x08000000 /**< \brief General error*/
#define ABORT_DATA_CANNOT_BE_READ_OR_STORED 0x08000020 /**< \brief Data can not be read or written*/
#define ABORT_DATA_CANNOT_BE_READ_OR_STORED_BECAUSE_OF_LOCAL_CONTROL 0x08000021 /**< \brief Data can not be accessed because of local control*/
#define ABORT_DATA_CANNOT_BE_READ_OR_STORED_IN_THIS_STATE 0x08000022 /**< \brief Data can not be read or written in the current state*/
#define ABORT_NO_OBJECT_DICTIONARY_IS_PRESENT 0x08000023 /**< \brief Object is not in the object dictionary*/
/**
* \addtogroup SDOAbortIndex SDO Abort Codes Identifier
* @{
* Internal the SDO abort codes are handled in an array.
*/
#define ABORTIDX_TOGGLE_BIT_NOT_CHANGED 0x01 /**< \brief Index of "Toggle bit not changed"*/
#define ABORTIDX_SDO_PROTOCOL_TIMEOUT 0x02 /**< \brief Index of "SDO timeout"*/
#define ABORTIDX_COMMAND_SPECIFIER_UNKNOWN 0x03 /**< \brief Index of "Command specifier unknown"*/
#define ABORTIDX_OUT_OF_MEMORY 0x04 /**< \brief Index of "Out of memory"*/
#define ABORTIDX_UNSUPPORTED_ACCESS 0x05 /**< \brief Index of "Unsupported Access"*/
#define ABORTIDX_WRITE_ONLY_ENTRY 0x06 /**< \brief Index of "Write only entry"*/
#define ABORTIDX_READ_ONLY_ENTRY 0x07 /**< \brief Index of "Read only entry"*/
#define ABORTIDX_OBJECT_NOT_EXISTING 0x08 /**< \brief Index of "Object not existing"*/
#define ABORTIDX_OBJECT_CANT_BE_PDOMAPPED 0x09 /**< \brief Index of "Object can not be mapped to PDO"*/
#define ABORTIDX_MAPPED_OBJECTS_EXCEED_PDO 0x0A /**< \brief Index of "Mapped Object exceeds PDO"*/
#define ABORTIDX_PARAM_IS_INCOMPATIBLE 0x0B /**< \brief Index of "Parameter is incompatible"*/
#define ABORTIDX_INTERNAL_DEVICE_INCOMPATIBILITY 0x0C /**< \brief Index of "Device incompatibility"*/
#define ABORTIDX_HARDWARE_ERROR 0x0D /**< \brief Index of "Hardware error"*/
#define ABORTIDX_PARAM_LENGTH_ERROR 0x0E /**< \brief Index of "Parameter length error"*/
#define ABORTIDX_PARAM_LENGTH_TOO_LONG 0x0F /**< \brief Index of "Parameter is too long"*/
#define ABORTIDX_PARAM_LENGTH_TOO_SHORT 0x10 /**< \brief Index of "Parameter is too short"*/
#define ABORTIDX_SUBINDEX_NOT_EXISTING 0x11 /**< \brief Index of "Subindex (Entry) not exists"*/
#define ABORTIDX_VALUE_EXCEEDED 0x12 /**< \brief Index of "Value exceeds"*/
#define ABORTIDX_VALUE_TOO_GREAT 0x13 /**< \brief Index of "Value is too great"*/
#define ABORTIDX_VALUE_TOO_SMALL 0x14 /**< \brief Index of "Value is too small"*/
#define ABORTIDX_MODULE_ID_LIST_NOT_MATCH 0x15 /**< \brief Index of "Unequal Module Id list"*/
#define ABORTIDX_MAX_VALUE_IS_LESS_THAN_MIN_VALUE 0x16 /**< \brief Index of "Value is less than minimum value"*/
#define ABORTIDX_GENERAL_ERROR 0x17 /**< \brief Index of "General error"*/
#define ABORTIDX_DATA_CANNOT_BE_READ_OR_STORED 0x18 /**< \brief Index of "Data can not be read or written"*/
#define ABORTIDX_DATA_CANNOT_BE_ACCESSED_BECAUSE_OF_LOCAL_CONTROL 0x19 /**< \brief Index of "Data can not be accessed because of local control"*/
#define ABORTIDX_IN_THIS_STATE_DATA_CANNOT_BE_READ_OR_STORED 0x1A /**< \brief Index of "Data can not be read or written in the current state"*/
#define ABORTIDX_NO_OBJECT_DICTIONARY_IS_PRESENT 0x1B /**< \brief Index of "Object is not in the object dictionary"*/
#define ABORTIDX_ENTRY_CANT_BE_WRITTEN_SI0_NOT_0 0x1C /**< \brief Index of "Entry can not be written because Subindex0 is not 0"*/
#define ABORTIDX_COMPLETE_ACCESS_NOT_SUPPORTED 0x1D /**< \brief The object can not be accessed via complete access*/
#define ABORTIDX_WORKING 0xFF /**< \brief Index of application is handling the SDO request*/
/** @}*/
/** @}*/
/**
*\addtogroup SdoServices SDO Services
* @{
*/
#define SDOINFOSERVICE_OBJDICTIONARYLIST_Q 0x01 /**< \brief SDO Info Get object list request*/
#define SDOINFOSERVICE_OBJDICTIONARYLIST_S 0x02 /**< \brief SDO Info Get object list response*/
#define SDOINFOSERVICE_OBJDESCRIPTION_Q 0x03 /**< \brief SDO Info Get object description request*/
#define SDOINFOSERVICE_OBJDESCRIPTION_S 0x04 /**< \brief SDO Info Get object description response*/
#define SDOINFOSERVICE_ENTRYDESCRIPTION_Q 0x05 /**< \brief SDO Info Get entry description request*/
#define SDOINFOSERVICE_ENTRYDESCRIPTION_S 0x06 /**< \brief SDO Info Get entry description request*/
#define SDOINFOSERVICE_ERROR_Q 0x07 /**< \brief SDO Info Error*/
#define SDOINFOSERVICE_INCOMPLETE 0x80 /**< \brief SDO Info Incomplete flag*/
/** @}*/
/**
*\addtogroup SdoHeaderData SDO Header and Data
* @{
*/
/**
* SDO Info Object list
*/
typedef struct MBX_STRUCT_PACKED_START
{
UINT16 ListType; /**< \brief List type variable*/
#define INFO_LIST_TYPE_LENGTH 0 /**< \brief Length of all list types*/
#define INFO_LIST_TYPE_ALL 1 /**< \brief All objects*/
#define INFO_LIST_TYPE_RXPDO 2 /**< \brief Only RxPDO mappable objects*/
#define INFO_LIST_TYPE_TXPDO 3 /**< \brief Only TxPDO mappable objects*/
#define INFO_LIST_TYPE_BACKUP 4 /**< \brief Only backup objects*/
#define INFO_LIST_TYPE_SET 5 /**< \brief Only setting objects*/
#define INFO_LIST_TYPE_MAX 5 /**< \brief Max list identifier*/
}MBX_STRUCT_PACKED_END
TSDOINFOLIST;
/**
* Object description
*/
typedef struct MBX_STRUCT_PACKED_START
{
UINT16 DataType; /**< \brief Object data type*/
UINT16 ObjFlags; /**< \brief Object flags (including object code and max subindex)*/
/*Object Code and MaxSubindex will be set manually in the object dictionary. The value is always created in little endian format*/
#define OBJFLAGS_MAXSUBINDEXMASK 0x00FF /**< \brief Max subindex mask*/
#define OBJFLAGS_MAXSUBINDEXSHIFT 0 /**< \brief Max subindex shift*/
#define OBJFLAGS_OBJCODEMASK 0x0F00 /**< \brief Mask Object code mask*/
#define OBJFLAGS_OBJCODESHIFT 8 /**< \brief Object code shift*/
#define OBJCODE_VAR 0x07 /**< \brief Object code VARIABLE*/
#define OBJCODE_ARR 0x08 /**< \brief Object code ARRAY*/
#define OBJCODE_REC 0x09 /**< \brief Object code RECORD*/
// char Name[]; // rest of mailbox data
}MBX_STRUCT_PACKED_END
TSDOINFOOBJDESC;
#define SDO_INFO_OBJ_DESC_SIZE SIZEOF(TSDOINFOOBJDESC) /**< \brief Object description size*/
/**
* SDO Info object description service data
*/
typedef struct MBX_STRUCT_PACKED_START
{
UINT16 Index; /**< \brief Object index*/
TSDOINFOOBJDESC Res; /**< \brief Description data*/
}MBX_STRUCT_PACKED_END
TSDOINFOOBJ;
#define SDO_INFO_OBJ_DESC_RES_SIZE SIZEOF(TSDOINFOOBJ)/**< \brief Size of the object description service data*/
/**
* SDO Info entry description
*/
typedef struct MBX_STRUCT_PACKED_START
{
UINT16 DataType; /**< \brief Entry data type*/
UINT16 BitLength; /**< \brief Entry bit size*/
UINT16 ObjAccess; /**< \brief Entry access rights*/
/**<
Bit 0: Read Access in Pre-Op
<br>Bit 1: Read Access in Safe-Op
<br>Bit 2: Read Access in Op
<br>Bit 3: Write Access in Pre-Op
<br>Bit 4: Write Access in Safe-Op
<br>Bit 5: Write Access in Op
<br>Bit 6: mappable in RxPDO
<br>Bit 7: mappable in TxPDO
<br>Bit 8: entry will be included in backup
<br>Bit 9: entry will be included in settings*/
#define ACCESS_READWRITE 0x003F /**< \brief Read/write in all states*/
#define ACCESS_READ 0x0007 /**< \brief Read only in all states*/
#define ACCESS_READ_PREOP 0x0001 /**< \brief Read only in PreOP*/
#define ACCESS_READ_SAFEOP 0x0002 /**< \brief Read only in SafeOP*/
#define ACCESS_READ_OP 0x0004 /**< \brief Read only in OP*/
#define ACCESS_WRITE 0x0038 /**< \brief Write only in all states*/
#define ACCESS_WRITE_PREOP 0x0008 /**< \brief Write only in PreOP*/
#define ACCESS_WRITE_SAFEOP 0x0010 /**< \brief Write only in SafeOP*/
#define ACCESS_WRITE_OP 0x0020 /**< \brief Write only in OP*/
#define OBJACCESS_NOPDOMAPPING 0x0000 /**< \brief Not PDO mappable*/
#define OBJACCESS_RXPDOMAPPING 0x0040 /**< \brief Mappable in RxPDOs*/
#define OBJACCESS_TXPDOMAPPING 0x0080 /**< \brief Mappable in TxPDOs*/
#define OBJACCESS_BACKUP 0x0100 /**< \brief Backup entry*/
#define OBJACCESS_SETTINGS 0x0200 /**< \brief Setting Entry*/
#define OBJACCESS_SAFEINPUTS 0x0400 /**< \brief Safe input*/
#define OBJACCESS_SAFEOUTPUTS 0x0800 /**< \brief Safe output*/
#define OBJACCESS_SAFEPARAMETER 0x1000 /**< \brief Safe parameter*/
}MBX_STRUCT_PACKED_END
TSDOINFOENTRYDESC;
/**
* SDO Info entry description service data
*/
typedef struct MBX_STRUCT_PACKED_START
{
UINT16 Index; /**< \brief Index of the parent object*/
UINT16 Info; /**< \brief Info data including the subindex and identifier for the payload data*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_FORMAT) lines 565 to 570 deleted*/
#define ENTRY_MASK_SUBINDEX 0x00FF /**< \brief Subindex mask*/
#define ENTRY_SUBINDEX_SHIFT 0 /**< \brief Subindex shift*/
#define ENTRY_MASK_VALUEINFO 0xFF00 /**< \brief Value info mask*/
#define ENTRY_VALUEINFO_SHIFT 8 /**< \brief Value info shift*/
TSDOINFOENTRYDESC Res; /**< \brief Entry description data*/
}MBX_STRUCT_PACKED_END
TSDOINFOENTRY;
/**
* SDO info Error
*/
typedef struct MBX_STRUCT_PACKED_START
{
UINT32 ErrorCode; /**< \brief SDO Info error code*/
}MBX_STRUCT_PACKED_END
TSDOINFOERROR;
#define SDO_INFO_ERROR_SIZE SIZEOF(TSDOINFOERROR)/**< \brief SDO Info error size*/
/**
*SDO Info header
*/
typedef struct MBX_STRUCT_PACKED_START
{
UINT16 InfoHead; /**< \brief Opcode, Incomplete flag and 8 reserved bits*/
/*ET9300 Project Handler :(#if BIG_ENDIAN_FORMAT) lines 601 to 606 deleted*/
#define INFOHEAD_OPCODE_MASK 0x007F /**< \brief Opcode mask*/
#define INFOHEAD_OPCODE_SHIFT 0 /**< \brief Opcode shift*/
#define INFOHEADER_INCOMPLETE_MASK 0x0080 /**< \brief Incomplete mask*/
#define INFOHEADER_INCOMPLETE_SHIFT 0 /**< \brief Incomplete shift, the incomplete value "SDOINFOSERVICE_INCOMPLETE" is defined as a UINT8 => no shift required*/
UINT16 FragmentsLeft; /**< \brief Number of fragments which will follow*/
union MBX_STRUCT_PACKED_START
{
TSDOINFOLIST List;/**< \brief List data*/
TSDOINFOOBJ Obj;/**< \brief Object Description data*/
TSDOINFOENTRY Entry;/**< \brief Entry description data*/
TSDOINFOERROR Error;/**< \brief Error data*/
UINT16 Data[1];/**< \brief Unspecified data*/
}MBX_STRUCT_PACKED_END
Data;/**< \brief Service data*/
}MBX_STRUCT_PACKED_END
TSDOINFOHEADER;
/**
* SDO Info complete datagram
*/
typedef struct MBX_STRUCT_PACKED_START
{
TMBXHEADER MbxHeader; /**< \brief Mailbox header*/
TCOEHEADER CoeHeader; /**< \brief CoE header*/
TSDOINFOHEADER SdoHeader; /**< \brief SDO Info header and data*/
}MBX_STRUCT_PACKED_END
TSDOINFORMATION;
#define SIZEOF_SDOINFOHEAD 4 /**< \brief SDO Info header size*/
#define SIZEOF_SDOINFO ( (COE_HEADER_SIZE) + (SIZEOF_SDOINFOHEAD )) /**< \brief SDO Info and CoE Size*/
#define SIZEOF_SDOINFOSTRUCT ( (MBX_HEADER_SIZE) + (COE_HEADER_SIZE) + (SIZEOF_SDOINFOHEAD) ) /**< \brief Complete SDO Info datagram size*/
#define SIZEOF_SDOINFOLISTHEAD 2 /**< \brief SDO Info list header size*/
#define SIZEOF_SDOINFOLISTSTRUCT (( COE_HEADER_SIZE) + (SIZEOF_SDOINFOHEAD) + (SIZEOF_SDOINFOLISTHEAD) ) /**< \brief Complete SDO Info list size*/
#define SIZEOF_SDOINFOOBJSTRUCT ( (COE_HEADER_SIZE) + (SIZEOF_SDOINFOHEAD) + (SDO_INFO_OBJ_DESC_RES_SIZE) ) /**< \brief Complete SDO Info object description response size*/
#define SIZEOF_SDOINFOENTRYREQHEAD 4 /**< \brief SDO Info entry description request size*/
#define SIZEOF_SDOINFOENTRYREQSTRUCT ( (COE_HEADER_SIZE) + (SIZEOF_SDOINFOHEAD) + (SIZEOF_SDOINFOENTRYREQHEAD) ) /**< \brief SDO Info entry description request size*/
#define SIZEOF_SDOINFOERRORSTRUCT ( (COE_HEADER_SIZE) + (SIZEOF_SDOINFOHEAD) + (SDO_INFO_ERROR_SIZE) ) /**< \brief SDO Info error size*/
#define SDO_INFO_HEADER_BYTE_SIZE ((SIZEOF_SDOINFOSTRUCT)+(SIZEOF_SDOINFOLISTHEAD)) /**< \brief SDO Info size*/
/** @}*/
/**
* \addtogroup SdoPendingHandler SDO Pending Response
* @{
* If this feature is enabled (SDO_RES_INTERFACE 1) a SDO request may set to pending and is completed afterwards.
* This can be used to forward the read/write request an additional thread, uController.
*/
#define SDO_PENDING_WRITE 0x1 /**< \brief SDO write request is pending*/
#define SDO_PENDING_SEG_WRITE 0x2 /**< \brief SDO segmented write request is pending*/
#define SDO_PENDING_READ 0x3 /**< \brief SDO read request is pending*/
#define SDO_PENDING_SEG_READ 0x4 /**< \brief SDO segmented read request is pending*/
/** @}*/
#endif //_SDOSRV_H_
/*-----------------------------------------------------------------------------------------
------
------ Global Variables
------
-----------------------------------------------------------------------------------------*/
#if defined(_SDOSERV_) && (_SDOSERV_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
/**
* \addtogroup SdoPendingHandler SDO Pending Response
*@{
*/
PROTO UINT8 u8PendingSdo; /**< \brief Identifier for the pending SDO service (see SDO_PENDING_XXX defines)*/
PROTO BOOL bStoreCompleteAccess; /**< \brief Indicates if the pending SDO service is an complete access*/
PROTO UINT8 u8StoreSubindex; /**< \brief Contains the subindex for the pending SDO request*/
PROTO UINT16 u16StoreIndex; /**< \brief Contains the Index for the pending SDO request*/
PROTO UINT32 u32StoreDataSize; /**< \brief Complete data size to be handled*/
PROTO UINT16 MBXMEM *pStoreData; /**< \brief Pointer to the buffer to be handled*/
PROTO UINT8 (* pSdoPendFunc)( UINT16 Index, UINT8 Subindex, UINT32 Size, UINT16 MBXMEM * pData, UINT8 bCompleteAccess ); /**< \brief Function pointer for the SDO pending request handler*/
/** @}*/
PROTO MEM_ADDR VARMEM aSdoInfoHeader[GET_MEM_SIZE(SDO_INFO_HEADER_BYTE_SIZE)]; /**< \brief SDO Info buffer*/
/**
* \addtogroup SegmentedSdo Segmented SDO
* @{
*/
PROTO UINT16 VARMEM * VARMEM pSdoSegData; /**< \brief Pointer to the buffer handling to full object/entry data*/
PROTO UINT16 VARMEM nSdoInfoFragmentsLeft; /**< \brief Number of fragments which need to be transmitted*/
/** @}*/
/*-----------------------------------------------------------------------------------------
------
------ Global Functions
------
-----------------------------------------------------------------------------------------*/
PROTO UINT8 SDOS_SdoInfoInd(TSDOINFORMATION MBXMEM *pSdoInfoInd);
PROTO UINT8 SDOS_SdoInd(TINITSDOMBX MBXMEM *pSdoInd);
PROTO void SDOS_SdoRes(UINT8 abort, UINT32 objLength, UINT16 MBXMEM *pData);
PROTO void SDOS_ClearPendingResponse(void);
#undef PROTO
/** @}*/