From 0170a152297d494c11ff2e63ed365a08595762a1 Mon Sep 17 00:00:00 2001 From: Hans-Erik Floryd Date: Sun, 20 Jan 2019 15:35:55 +0100 Subject: [PATCH] add sample application for dynamic pdos --- applications/rtl_xmc4_dynpdo/CMakeLists.txt | 14 + applications/rtl_xmc4_dynpdo/config.h | 44 + applications/rtl_xmc4_dynpdo/main.c | 87 + applications/rtl_xmc4_dynpdo/sii_eeprom.bin | Bin 0 -> 256 bytes applications/rtl_xmc4_dynpdo/slave.xml | 1435 +++++++++++++++++ .../rtl_xmc4_dynpdo/slave_objectlist.c | 283 ++++ applications/rtl_xmc4_dynpdo/utypes.h | 78 + cmake/toolchain/rt-kernel-xmc4.cmake | 29 + 8 files changed, 1970 insertions(+) create mode 100644 applications/rtl_xmc4_dynpdo/CMakeLists.txt create mode 100644 applications/rtl_xmc4_dynpdo/config.h create mode 100644 applications/rtl_xmc4_dynpdo/main.c create mode 100644 applications/rtl_xmc4_dynpdo/sii_eeprom.bin create mode 100644 applications/rtl_xmc4_dynpdo/slave.xml create mode 100644 applications/rtl_xmc4_dynpdo/slave_objectlist.c create mode 100644 applications/rtl_xmc4_dynpdo/utypes.h create mode 100644 cmake/toolchain/rt-kernel-xmc4.cmake diff --git a/applications/rtl_xmc4_dynpdo/CMakeLists.txt b/applications/rtl_xmc4_dynpdo/CMakeLists.txt new file mode 100644 index 0000000..988964a --- /dev/null +++ b/applications/rtl_xmc4_dynpdo/CMakeLists.txt @@ -0,0 +1,14 @@ + +add_custom_command ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sii_eeprom.o + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sii_eeprom.bin + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND arm-eabi-objcopy -I binary -O elf32-littlearm -B arm sii_eeprom.bin ${CMAKE_CURRENT_BINARY_DIR}/sii_eeprom.o + ) + +add_executable (demo + slave_objectlist.c + main.c + ${CMAKE_CURRENT_BINARY_DIR}/sii_eeprom.o + ) +target_link_libraries(demo LINK_PUBLIC soes) diff --git a/applications/rtl_xmc4_dynpdo/config.h b/applications/rtl_xmc4_dynpdo/config.h new file mode 100644 index 0000000..2fdf3c1 --- /dev/null +++ b/applications/rtl_xmc4_dynpdo/config.h @@ -0,0 +1,44 @@ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#include + +#define MAX_INPUT_SIZE 128 /* Max processdata size (inputs) */ +#define MAX_OUTPUT_SIZE 128 /* Max processdata size (outputs) */ + +#define MAX_PDO 2 /* Max number of writeable PDOs (RX + TX) */ +#define MAX_PDO_ENTRIES 4 /* Max number of entries in a writeable PDO */ + +#define MAX_SM_ENTRIES 4 /* Max number of PDOs in a SyncManager */ +#define MAX_SM_MAPPINGS 16 /* Max number of mapped objects in a SyncManager */ + +#define MBXSIZE 128 +#define MBXSIZEBOOT 128 +#define MBXBUFFERS 3 + +#define MBX0_sma 0x1000 +#define MBX0_sml MBXSIZE +#define MBX0_sme MBX0_sma+MBX0_sml-1 +#define MBX0_smc 0x26 +#define MBX1_sma MBX0_sma+MBX0_sml +#define MBX1_sml MBXSIZE +#define MBX1_sme MBX1_sma+MBX1_sml-1 +#define MBX1_smc 0x22 + +#define MBX0_sma_b 0x1000 +#define MBX0_sml_b MBXSIZEBOOT +#define MBX0_sme_b MBX0_sma_b+MBX0_sml_b-1 +#define MBX0_smc_b 0x26 +#define MBX1_sma_b MBX0_sma_b+MBX0_sml_b +#define MBX1_sml_b MBXSIZEBOOT +#define MBX1_sme_b MBX1_sma_b+MBX1_sml_b-1 +#define MBX1_smc_b 0x22 + +#define SM2_sma 0x1100 +#define SM2_smc 0x24 +#define SM2_act 1 +#define SM3_sma 0x1180 +#define SM3_smc 0x20 +#define SM3_act 1 + +#endif /* __CONFIG_H__ */ diff --git a/applications/rtl_xmc4_dynpdo/main.c b/applications/rtl_xmc4_dynpdo/main.c new file mode 100644 index 0000000..950bd12 --- /dev/null +++ b/applications/rtl_xmc4_dynpdo/main.c @@ -0,0 +1,87 @@ +/* + * Licensed under the GNU General Public License version 2 with exceptions. See + * LICENSE file in the project root for full license information + */ + +#include +#include "esc.h" +#include "esc_hw.h" +#include "ecat_slv.h" +#include "config.h" +#include "utypes.h" + +/* Global variables used by the stack */ +uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)]; +_MBXcontrol MBXcontrol[MBXBUFFERS]; +_ESCvar ESCvar; +_SMmap SMmap2[MAX_MAPPINGS_SM2]; +_SMmap SMmap3[MAX_MAPPINGS_SM3]; + +/* Application variables */ +_Objects Obj; + +/* Private variables */ +static uint8_t inputs[MAX_INPUT_SIZE] __attribute__((aligned (8))); +static uint8_t outputs[MAX_OUTPUT_SIZE] __attribute__((aligned (8))); + +void cb_get_inputs (void) +{ + Obj.IN1 = 1; + Obj.IN2 = 2; + Obj.IN3 = 3; + Obj.IN4 = 4; +} + +void cb_set_outputs (void) +{ +} + + +/* Setup of DC */ +uint16_t dc_checker (void) +{ + /* Indicate we run DC */ + ESCvar.dcsync = 1; + /* Fetch the sync counter limit SDO10F1*/ + ESCvar.synccounterlimit = Obj.ErrorSettings.SyncErrorCounterLimit; + return 0; +} + +int main (void) +{ + static esc_cfg_t config = + { + .user_arg = NULL, + .use_interrupt = 1, + .watchdog_cnt = INT32_MAX, /* Use HW SM watchdog instead */ + .mbxsize = MBXSIZE, + .mbxsizeboot = MBXSIZEBOOT, + .mbxbuffers = MBXBUFFERS, + .rxpdos_address = outputs, + .rxpdos_mappings = MAX_SM_MAPPINGS, + .txpdos_address = inputs, + .txpdos_mappings = MAX_SM_MAPPINGS, + .mb[0] = {MBX0_sma, MBX0_sml, MBX0_sme, MBX0_smc, 0}, + .mb[1] = {MBX1_sma, MBX1_sml, MBX1_sme, MBX1_smc, 0}, + .mb_boot[0] = {MBX0_sma_b, MBX0_sml_b, MBX0_sme_b, MBX0_smc_b, 0}, + .mb_boot[1] = {MBX1_sma_b, MBX1_sml_b, MBX1_sme_b, MBX1_smc_b, 0}, + .pdosm[0] = {SM2_sma, 0, 0, SM2_smc, SM2_act}, + .pdosm[1] = {SM3_sma, 0, 0, SM3_smc, SM3_act}, + .pre_state_change_hook = NULL, + .post_state_change_hook = NULL, + .application_hook = NULL, + .safeoutput_override = NULL, + .pre_object_download_hook = NULL, + .post_object_download_hook = NULL, + .rxpdo_override = NULL, + .txpdo_override = NULL, + .esc_hw_interrupt_enable = ESC_interrupt_enable, + .esc_hw_interrupt_disable = ESC_interrupt_disable, + .esc_hw_eep_handler = ESC_eep_handler, + .esc_check_dc_handler = dc_checker + }; + + rprintf ("Hello world\n"); + ecat_slv_init (&config); + return 0; +} diff --git a/applications/rtl_xmc4_dynpdo/sii_eeprom.bin b/applications/rtl_xmc4_dynpdo/sii_eeprom.bin new file mode 100644 index 0000000000000000000000000000000000000000..fde43634757dcb94a682ebb4214616c48e7dd9c7 GIT binary patch literal 256 zcmZo*Yh+`9gR>0g!VC;&1mFS)h5!R2gCGzKG%z#(F%Lq9Y!)NXI4%Z$24?Px++-8u z_~M+zvQ!ojn+q&Zl$w)R!63&Vz`(@7$jmCth|?wwkP0Sd22G$^kPFoq7#TsXR04_u TUCp2Z)ZYN46&M&<{-Xc@Y49KW literal 0 HcmV?d00001 diff --git a/applications/rtl_xmc4_dynpdo/slave.xml b/applications/rtl_xmc4_dynpdo/slave.xml new file mode 100644 index 0000000..173194a --- /dev/null +++ b/applications/rtl_xmc4_dynpdo/slave.xml @@ -0,0 +1,1435 @@ + + + + #x1337 + rt-labs + + + + + xmc4 + MyGroup + LeGroup + + + + + xmc43_slave + xmc43relax + xmc4 + + 5001 + 0 + + + + DT1018 + 144 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + Vendor ID + UDINT + 32 + 16 + + ro + + + + 2 + Product Code + UDINT + 32 + 48 + + ro + + + + 3 + Revision Number + UDINT + 32 + 80 + + ro + + + + 4 + Serial Number + UDINT + 32 + 112 + + ro + + + + + DT10F1 + 40 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + Dummy_x01 + USINT + 8 + 16 + + ro + + + + 2 + SyncErrorCounterLimit + UINT + 16 + 24 + + rw + + + + + DT1600 + 112 + + 0 + Max SubIndex + USINT + 8 + 0 + + rw + + + + 1 + OUT1 + UDINT + 32 + 16 + + rw + + + + 2 + OUT2 + UDINT + 32 + 48 + + rw + + + + 3 + OUT3 + UDINT + 32 + 80 + + rw + + + + + DT1A00 + 80 + + 0 + Max SubIndex + USINT + 8 + 0 + + rw + + + + 1 + IN1 + UDINT + 32 + 16 + + rw + + + + 2 + Padding + UDINT + 32 + 48 + + rw + + + + + DT1A01 + 80 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + IN2 + UDINT + 32 + 16 + + ro + + + + 2 + Padding + UDINT + 32 + 48 + + ro + + + + + DT1A02 + 80 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + IN3 + UDINT + 32 + 16 + + ro + + + + 2 + Padding + UDINT + 32 + 48 + + ro + + + + + DT1A03 + 80 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + IN4 + UDINT + 32 + 16 + + ro + + + + 2 + Padding + UDINT + 32 + 48 + + ro + + + + + DT1C00ARR + USINT + 32 + + 1 + 4 + + + + DT1C00 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + Elements + DT1C00ARR + 32 + 16 + + ro + + + + + DT1C12ARR + UINT + 16 + + 1 + 1 + + + + DT1C12 + 32 + + 0 + Max SubIndex + USINT + 8 + 0 + + rw + + + + Elements + DT1C12ARR + 16 + 16 + + rw + + + + + DT1C13ARR + UINT + 64 + + 1 + 4 + + + + DT1C13 + 80 + + 0 + Max SubIndex + USINT + 8 + 0 + + rw + + + + Elements + DT1C13ARR + 64 + 16 + + rw + + + + + DT1C32 + 496 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + SyncType + UINT + 16 + 16 + + ro + + + + 2 + CycleTime + UDINT + 32 + 32 + + ro + + + + 3 + ShiftTime + UDINT + 32 + 64 + + ro + + + + 4 + SyncTypeSupport + UINT + 16 + 96 + + ro + + + + 5 + MinCycleTime + UDINT + 32 + 112 + + ro + + + + 6 + CalcCopyTime + UDINT + 32 + 144 + + ro + + + + 7 + MinDelayTime + UDINT + 32 + 176 + + ro + + + + 8 + GetCycleTime + UINT + 16 + 208 + + ro + + + + 9 + DelayTime + UDINT + 32 + 224 + + ro + + + + 10 + Sync0CycleTime + UDINT + 32 + 256 + + ro + + + + 11 + SMEventMissedCnt + UINT + 16 + 288 + + ro + + + + 12 + CycleTimeTooSmallCnt + UINT + 16 + 304 + + ro + + + + 13 + ShiftTimeTooSmallCnt + UINT + 16 + 320 + + ro + + + + 14 + RxPDOToggleFailed + UINT + 16 + 336 + + ro + + + + 15 + MinCycleDist + UDINT + 32 + 352 + + ro + + + + 16 + MaxCycleDist + UDINT + 32 + 384 + + ro + + + + 17 + MinSMSYNCDist + UDINT + 32 + 416 + + ro + + + + 18 + MaxSMSYNCDist + UDINT + 32 + 448 + + ro + + + + 20 + Dummy_x14 + USINT + 8 + 480 + + ro + + + + 32 + SyncError + USINT + 8 + 488 + + ro + + + + + DT7000 + 72 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + OUT1 + SINT + 8 + 16 + + ro + R + + + + 2 + OUT2 + INT + 16 + 24 + + ro + R + + + + 3 + OUT3 + DINT + 32 + 40 + + ro + R + + + + + INT + 16 + + + SINT + 8 + + + STRING(3) + 24 + + + STRING(11) + 88 + + + BIT1 + 1 + + + BIT2 + 2 + + + BIT3 + 3 + + + BIT4 + 4 + + + UDINT + 32 + + + UINT + 16 + + + DINT + 32 + + + USINT + 8 + + + + + #x1000 + Device Type + UDINT + 32 + + #x00001389 + + + ro + m + + + + #x1008 + Device Name + STRING(11) + 88 + + xmc43_slave + + + ro + + + + #x1009 + Hardware Version + STRING(3) + 24 + + 1.0 + + + ro + o + + + + #x100A + Software Version + STRING(3) + 24 + + 1.0 + + + ro + + + + #x1018 + Identity Object + DT1018 + 144 + + + Max SubIndex + + 4 + + + + Vendor ID + + #x1337 + + + + Product Code + + #x10cc + + + + Revision Number + + 0 + + + + Serial Number + + #x00000000 + + + + + ro + + + + #x1600 + Outputs + DT1600 + 112 + + + Max SubIndex + + 3 + + + + OUT1 + + #x70000108 + + + + OUT2 + + #x70000210 + + + + OUT3 + + #x70000320 + + + + + rw + + + + #x10F1 + ErrorSettings + DT10F1 + 40 + + + Max SubIndex + + 2 + + + + Dummy_x01 + + 0 + + + + SyncErrorCounterLimit + + 2 + + + + + ro + + + + #x1A00 + IN1 + DT1A00 + 80 + + + Max SubIndex + + 2 + + + + IN1 + + #x60000001 + + + + Padding + + #x00000007 + + + + + rw + + + + #x1A01 + IN2 + DT1A01 + 80 + + + Max SubIndex + + 2 + + + + IN2 + + #x60010002 + + + + Padding + + #x00000006 + + + + + ro + + + + #x1A02 + IN3 + DT1A02 + 80 + + + Max SubIndex + + 2 + + + + IN3 + + #x60020003 + + + + Padding + + #x00000005 + + + + + ro + + + + #x1A03 + IN4 + DT1A03 + 80 + + + Max SubIndex + + 2 + + + + IN4 + + #x60030004 + + + + Padding + + #x00000004 + + + + + ro + + + + #x1C00 + Sync Manager Communication Type + DT1C00 + 48 + + + Max SubIndex + + 4 + + + + Communications Type SM0 + + 1 + + + + Communications Type SM1 + + 2 + + + + Communications Type SM2 + + 3 + + + + Communications Type SM3 + + 4 + + + + + ro + + + + #x1C12 + Sync Manager 2 PDO Assignment + DT1C12 + 32 + + + Max SubIndex + + 1 + + + + PDO Mapping + + #x1600 + + + + + rw + + + + #x1C13 + Sync Manager 3 PDO Assignment + DT1C13 + 80 + + + Max SubIndex + + 4 + + + + PDO Mapping + + #x1A00 + + + + PDO Mapping + + #x1A01 + + + + PDO Mapping + + #x1A02 + + + + PDO Mapping + + #x1A03 + + + + + rw + + + + #x1C32 + SyncMgrParam + DT1C32 + 496 + + + Max SubIndex + + 32 + + + + SyncType + + 1 + + + + CycleTime + + 0 + + + + ShiftTime + + 0 + + + + SyncTypeSupport + + #x6 + + + + MinCycleTime + + 125000 + + + + CalcCopyTime + + 0 + + + + MinDelayTime + + 0 + + + + GetCycleTime + + 0 + + + + DelayTime + + 0 + + + + Sync0CycleTime + + 0 + + + + SMEventMissedCnt + + 0 + + + + CycleTimeTooSmallCnt + + 0 + + + + ShiftTimeTooSmallCnt + + 0 + + + + RxPDOToggleFailed + + 0 + + + + MinCycleDist + + 0 + + + + MaxCycleDist + + 0 + + + + MinSMSYNCDist + + 0 + + + + MaxSMSYNCDist + + 0 + + + + Dummy_x14 + + 0 + + + + SyncError + + 0 + + + + + ro + + + + #x6000 + IN1 + BIT1 + 1 + + 0 + + + ro + T + + + + #x6001 + IN2 + BIT2 + 2 + + 0 + + + ro + T + + + + #x6002 + IN3 + BIT3 + 3 + + 0 + + + ro + T + + + + #x6003 + IN4 + BIT4 + 4 + + 0 + + + ro + T + + + + #x7000 + Outputs + DT7000 + 72 + + + Max SubIndex + + 3 + + + + OUT1 + + 0 + + + + OUT2 + + 0 + + + + OUT3 + + 0 + + + + + ro + + + + #x8000 + PARAM1 + DINT + 32 + + 0 + + + rw + + + + #x8001 + PARAM2 + DINT + 32 + + 0 + + + rw + + + + + + Outputs + Inputs + MBoxState + MBoxOut + MBoxIn + Outputs + Inputs + + #x1600 + Outputs + + #x7000 + 1 + 8 + OUT1 + SINT + + + #x7000 + 2 + 16 + OUT2 + INT + + + #x7000 + 3 + 32 + OUT3 + DINT + + + + #x1A00 + IN1 + + #x6000 + 0 + 1 + IN1 + BIT1 + + + 0 + 0 + 7 + + + + #x1A01 + IN2 + + #x6001 + 0 + 2 + IN2 + BIT2 + + + 0 + 0 + 6 + + + + #x1A02 + IN3 + + #x6002 + 0 + 3 + IN3 + BIT3 + + + 0 + 0 + 5 + + + + #x1A03 + IN4 + + #x6003 + 0 + 4 + IN4 + BIT4 + + + 0 + 0 + 4 + + + + + + + + 256 + 80068106000000000000 + 0010800080108000 + + + + + diff --git a/applications/rtl_xmc4_dynpdo/slave_objectlist.c b/applications/rtl_xmc4_dynpdo/slave_objectlist.c new file mode 100644 index 0000000..7f24692 --- /dev/null +++ b/applications/rtl_xmc4_dynpdo/slave_objectlist.c @@ -0,0 +1,283 @@ +#ifndef SOES_V1 +#include "esc.h" +#include "esc_coe.h" +#include "utypes.h" +#include + +#ifndef HW_REV +#define HW_REV "1.0" +#endif + +#ifndef SW_REV +#define SW_REV "1.0" +#endif + +static const char acName1000[] = "Device Type"; +static const char acName1000_0[] = "Device Type"; +static const char acName1008[] = "Device Name"; +static const char acName1008_0[] = "Device Name"; +static const char acName1009[] = "Hardware Version"; +static const char acName1009_0[] = "Hardware Version"; +static const char acName100A[] = "Software Version"; +static const char acName100A_0[] = "Software Version"; +static const char acName1018[] = "Identity Object"; +static const char acName1018_00[] = "Max SubIndex"; +static const char acName1018_01[] = "Vendor ID"; +static const char acName1018_02[] = "Product Code"; +static const char acName1018_03[] = "Revision Number"; +static const char acName1018_04[] = "Serial Number"; +static const char acName10F1[] = "ErrorSettings"; +static const char acName10F1_00[] = "Max SubIndex"; +static const char acName10F1_01[] = "Dummy_x01"; +static const char acName10F1_02[] = "SyncErrorCounterLimit"; +static const char acName1600[] = "Outputs"; +static const char acName1600_00[] = "Max SubIndex"; +static const char acName1600_01[] = "OUT1"; +static const char acName1600_02[] = "OUT2"; +static const char acName1600_03[] = "OUT3"; +static const char acName1A00[] = "IN1"; +static const char acName1A00_00[] = "Max SubIndex"; +static const char acName1A00_01[] = "IN1"; +static const char acName1A00_02[] = "Padding"; +static const char acName1A01[] = "IN2"; +static const char acName1A01_00[] = "Max SubIndex"; +static const char acName1A01_01[] = "IN2"; +static const char acName1A01_02[] = "Padding"; +static const char acName1A02[] = "IN3"; +static const char acName1A02_00[] = "Max SubIndex"; +static const char acName1A02_01[] = "IN3"; +static const char acName1A02_02[] = "Padding"; +static const char acName1A03[] = "IN4"; +static const char acName1A03_00[] = "Max SubIndex"; +static const char acName1A03_01[] = "IN4"; +static const char acName1A03_02[] = "Padding"; +static const char acName1C00[] = "Sync Manager Communication Type"; +static const char acName1C00_00[] = "Max SubIndex"; +static const char acName1C00_01[] = "Communications Type SM0"; +static const char acName1C00_02[] = "Communications Type SM1"; +static const char acName1C00_03[] = "Communications Type SM2"; +static const char acName1C00_04[] = "Communications Type SM3"; +static const char acName1C12[] = "Sync Manager 2 PDO Assignment"; +static const char acName1C12_00[] = "Max SubIndex"; +static const char acName1C12_01[] = "PDO Mapping"; +static const char acName1C12_02[] = "PDO Mapping"; +static const char acName1C12_03[] = "PDO Mapping"; +static const char acName1C12_04[] = "PDO Mapping"; +static const char acName1C13[] = "Sync Manager 3 PDO Assignment"; +static const char acName1C13_00[] = "Max SubIndex"; +static const char acName1C13_01[] = "PDO Mapping"; +static const char acName1C13_02[] = "PDO Mapping"; +static const char acName1C13_03[] = "PDO Mapping"; +static const char acName1C13_04[] = "PDO Mapping"; +static const char acName1C32[] = "SyncMgrParam"; +static const char acName1C32_00[] = "Max SubIndex"; +static const char acName1C32_01[] = "SyncType"; +static const char acName1C32_02[] = "CycleTime"; +static const char acName1C32_03[] = "ShiftTime"; +static const char acName1C32_04[] = "SyncTypeSupport"; +static const char acName1C32_05[] = "MinCycleTime"; +static const char acName1C32_06[] = "CalcCopyTime"; +static const char acName1C32_07[] = "MinDelayTime"; +static const char acName1C32_08[] = "GetCycleTime"; +static const char acName1C32_09[] = "DelayTime"; +static const char acName1C32_0A[] = "Sync0CycleTime"; +static const char acName1C32_0B[] = "SMEventMissedCnt"; +static const char acName1C32_0C[] = "CycleTimeTooSmallCnt"; +static const char acName1C32_0D[] = "ShiftTimeTooSmallCnt"; +static const char acName1C32_0E[] = "RxPDOToggleFailed"; +static const char acName1C32_0F[] = "MinCycleDist"; +static const char acName1C32_10[] = "MaxCycleDist"; +static const char acName1C32_11[] = "MinSMSYNCDist"; +static const char acName1C32_12[] = "MaxSMSYNCDist"; +static const char acName1C32_14[] = "Dummy_x14"; +static const char acName1C32_20[] = "SyncError"; +static const char acName6000[] = "IN1"; +static const char acName6000_0[] = "IN1"; +static const char acName6001[] = "IN2"; +static const char acName6001_0[] = "IN2"; +static const char acName6002[] = "IN3"; +static const char acName6002_0[] = "IN3"; +static const char acName6003[] = "IN4"; +static const char acName6003_0[] = "IN4"; +static const char acName7000[] = "Outputs"; +static const char acName7000_00[] = "Max SubIndex"; +static const char acName7000_01[] = "OUT1"; +static const char acName7000_02[] = "OUT2"; +static const char acName7000_03[] = "OUT3"; +static const char acName8000[] = "PARAM1"; +static const char acName8000_0[] = "PARAM1"; +static const char acName8001[] = "PARAM2"; +static const char acName8001_0[] = "PARAM2"; + +const _objd SDO1000[] = +{ + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000_0, 0x00001389, NULL}, +}; +const _objd SDO1008[] = +{ + {0x0, DTYPE_VISIBLE_STRING, 40, ATYPE_RO, acName1008_0, 0, "slave"}, +}; +const _objd SDO1009[] = +{ + {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, HW_REV}, +}; +const _objd SDO100A[] = +{ + {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, SW_REV}, +}; +const _objd SDO1018[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1018_00, 4, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_01, 0x1337, NULL}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_02, 0x10cc, NULL}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_03, 0, NULL}, + {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_04, 0x00000000, NULL}, +}; +const _objd SDO10F1[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName10F1_00, 2, NULL}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName10F1_01, 0, &Obj.ErrorSettings.Dummy_x01}, + {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName10F1_02, 2, &Obj.ErrorSettings.SyncErrorCounterLimit}, +}; +const _objd SDO1600[] = +{ + /* Writeable PDO */ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RWpre, acName1600_00, 3, &Obj.PDO[0].maxsub}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1600_01, 0x70000108, &Obj.PDO[0].value[0]}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1600_02, 0x70000210, &Obj.PDO[0].value[1]}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1600_03, 0x70000320, &Obj.PDO[0].value[2]}, +}; +const _objd SDO1A00[] = +{ + /* Writeable PDO */ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RWpre, acName1A00_00, 2, &Obj.PDO[1].maxsub}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A00_01, 0x60000001, &Obj.PDO[1].value[0]}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A00_02, 0x00000007, &Obj.PDO[1].value[1]}, +}; +const _objd SDO1A01[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A01_00, 2, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_01, 0x60010002, NULL}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_02, 0x00000006, NULL}, +}; +const _objd SDO1A02[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A02_00, 2, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_01, 0x60020003, NULL}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_02, 0x00000005, NULL}, +}; +const _objd SDO1A03[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A03_00, 2, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A03_01, 0x60030004, NULL}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A03_02, 0x00000004, NULL}, +}; +const _objd SDO1C00[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_00, 4, NULL}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_01, 1, NULL}, + {0x02, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_02, 2, NULL}, + {0x03, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_03, 3, NULL}, + {0x04, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_04, 4, NULL}, +}; +const _objd SDO1C12[] = +{ + /* Writeable SM */ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RWpre, acName1C12_00, 1, &Obj.SM[0].maxsub}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_01, 0x1600, &Obj.SM[0].value[0]}, + {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_02, 0, &Obj.SM[0].value[1]}, + {0x03, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_03, 0, &Obj.SM[0].value[2]}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_04, 0, &Obj.SM[0].value[3]}, +}; +const _objd SDO1C13[] = +{ + /* Writeable SM */ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RWpre, acName1C13_00, 4, &Obj.SM[1].maxsub}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_01, 0x1A00, &Obj.SM[1].value[0]}, + {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_02, 0x1A01, &Obj.SM[1].value[1]}, + {0x03, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_03, 0x1A02, &Obj.SM[1].value[2]}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_04, 0x1A03, &Obj.SM[1].value[3]}, +}; +const _objd SDO1C32[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C32_00, 32, NULL}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_01, 1, &Obj.SyncMgrParam.SyncType}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_02, 0, &Obj.SyncMgrParam.CycleTime}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_03, 0, &Obj.SyncMgrParam.ShiftTime}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_04, 0x6, &Obj.SyncMgrParam.SyncTypeSupport}, + {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_05, 125000, &Obj.SyncMgrParam.MinCycleTime}, + {0x06, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_06, 0, &Obj.SyncMgrParam.CalcCopyTime}, + {0x07, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_07, 0, &Obj.SyncMgrParam.MinDelayTime}, + {0x08, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_08, 0, &Obj.SyncMgrParam.GetCycleTime}, + {0x09, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_09, 0, &Obj.SyncMgrParam.DelayTime}, + {0x0A, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_0A, 0, &Obj.SyncMgrParam.Sync0CycleTime}, + {0x0B, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0B, 0, &Obj.SyncMgrParam.SMEventMissedCnt}, + {0x0C, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0C, 0, &Obj.SyncMgrParam.CycleTimeTooSmallCnt}, + {0x0D, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0D, 0, &Obj.SyncMgrParam.ShiftTimeTooSmallCnt}, + {0x0E, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0E, 0, &Obj.SyncMgrParam.RxPDOToggleFailed}, + {0x0F, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_0F, 0, &Obj.SyncMgrParam.MinCycleDist}, + {0x10, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_10, 0, &Obj.SyncMgrParam.MaxCycleDist}, + {0x11, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_11, 0, &Obj.SyncMgrParam.MinSMSYNCDist}, + {0x12, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_12, 0, &Obj.SyncMgrParam.MaxSMSYNCDist}, + {0x14, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C32_14, 0, &Obj.SyncMgrParam.Dummy_x14}, + {0x20, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C32_20, 0, &Obj.SyncMgrParam.SyncError}, +}; +const _objd SDO6000[] = +{ + {0x0, DTYPE_BIT1, 1, ATYPE_TXPDO | ATYPE_RO, acName6000_0, 0, &Obj.IN1}, +}; +const _objd SDO6001[] = +{ + {0x0, DTYPE_BIT2, 2, ATYPE_TXPDO | ATYPE_RO, acName6001_0, 0, &Obj.IN2}, +}; +const _objd SDO6002[] = +{ + {0x0, DTYPE_BIT3, 3, ATYPE_TXPDO | ATYPE_RO, acName6002_0, 0, &Obj.IN3}, +}; +const _objd SDO6003[] = +{ + {0x0, DTYPE_BIT4, 4, ATYPE_TXPDO | ATYPE_RO, acName6003_0, 0, &Obj.IN4}, +}; +const _objd SDO7000[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_00, 3, NULL}, + {0x01, DTYPE_INTEGER8, 8, ATYPE_RXPDO | ATYPE_RO, acName7000_01, 0, &Obj.Outputs.OUT1}, + {0x02, DTYPE_INTEGER16, 16, ATYPE_RXPDO | ATYPE_RO, acName7000_02, 0, &Obj.Outputs.OUT2}, + {0x03, DTYPE_INTEGER32, 32, ATYPE_RXPDO | ATYPE_RO, acName7000_03, 0, &Obj.Outputs.OUT3}, +}; +const _objd SDO8000[] = +{ + {0x0, DTYPE_INTEGER32, 32, ATYPE_RW, acName8000_0, 0x42, &Obj.PARAM1}, +}; +const _objd SDO8001[] = +{ + {0x0, DTYPE_INTEGER32, 32, ATYPE_RW, acName8001_0, 99, &Obj.PARAM2}, +}; + +const _objectlist SDOobjects[] = +{ + {0x1000, OTYPE_VAR, 0, 0, acName1000, SDO1000}, + {0x1008, OTYPE_VAR, 0, 0, acName1008, SDO1008}, + {0x1009, OTYPE_VAR, 0, 0, acName1009, SDO1009}, + {0x100A, OTYPE_VAR, 0, 0, acName100A, SDO100A}, + {0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018}, + {0x10F1, OTYPE_RECORD, 2, 0, acName10F1, SDO10F1}, + {0x1600, OTYPE_RECORD, 3, 0, acName1600, SDO1600}, + {0x1A00, OTYPE_RECORD, 2, 0, acName1A00, SDO1A00}, + {0x1A01, OTYPE_RECORD, 2, 0, acName1A01, SDO1A01}, + {0x1A02, OTYPE_RECORD, 2, 0, acName1A02, SDO1A02}, + {0x1A03, OTYPE_RECORD, 2, 0, acName1A03, SDO1A03}, + {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, + {0x1C12, OTYPE_ARRAY, 1, 0, acName1C12, SDO1C12}, + {0x1C13, OTYPE_ARRAY, 4, 0, acName1C13, SDO1C13}, + {0x1C32, OTYPE_RECORD, 32, 0, acName1C32, SDO1C32}, + {0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000}, + {0x6001, OTYPE_VAR, 0, 0, acName6001, SDO6001}, + {0x6002, OTYPE_VAR, 0, 0, acName6002, SDO6002}, + {0x6003, OTYPE_VAR, 0, 0, acName6003, SDO6003}, + {0x7000, OTYPE_RECORD, 3, 0, acName7000, SDO7000}, + {0x8000, OTYPE_VAR, 0, 0, acName8000, SDO8000}, + {0x8001, OTYPE_VAR, 0, 0, acName8001, SDO8001}, + {0xffff, 0xff, 0xff, 0xff, NULL, NULL} +}; +#endif diff --git a/applications/rtl_xmc4_dynpdo/utypes.h b/applications/rtl_xmc4_dynpdo/utypes.h new file mode 100644 index 0000000..795ae5b --- /dev/null +++ b/applications/rtl_xmc4_dynpdo/utypes.h @@ -0,0 +1,78 @@ +#ifndef __UTYPES_H__ +#define __UTYPES_H__ + +#include +#include "config.h" + +/* NOTE: Not packed, does not use bitfields */ + +typedef struct +{ + /* Inputs */ + uint8_t IN1; /* (BIT1) */ + uint8_t IN2; /* (BIT2) */ + uint8_t IN3; /* (BIT3) */ + uint8_t IN4; /* (BIT4) */ + + /* Outputs */ + struct + { + int8_t OUT1; + int16_t OUT2; + int32_t OUT3; + } Outputs; + + /* Parameters */ + int32_t PARAM1; + int32_t PARAM2; + + /* Manufacturer specific data */ + struct + { + uint16_t SyncType; + uint32_t CycleTime; + uint32_t ShiftTime; + uint16_t SyncTypeSupport; + uint32_t MinCycleTime; + uint32_t CalcCopyTime; + uint32_t MinDelayTime; + uint16_t GetCycleTime; + uint32_t DelayTime; + uint32_t Sync0CycleTime; + uint16_t SMEventMissedCnt; + uint16_t CycleTimeTooSmallCnt; + uint16_t ShiftTimeTooSmallCnt; + uint16_t RxPDOToggleFailed; + uint32_t MinCycleDist; + uint32_t MaxCycleDist; + uint32_t MinSMSYNCDist; + uint32_t MaxSMSYNCDist; + uint8_t Dummy_x14; + uint8_t SyncError; + } SyncMgrParam; + + struct + { + uint8_t Dummy_x01; + uint16_t SyncErrorCounterLimit; + } ErrorSettings; + + /* Storage for configurable PDO:s */ + struct + { + uint8_t maxsub; + uint32_t value[4]; + } PDO[2]; + + /* Storage for configurable Sync Managers */ + struct + { + uint8_t maxsub; + uint16_t value[4]; + } SM[2]; + +} _Objects; + +extern _Objects Obj; + +#endif /* __UTYPES_H__ */ diff --git a/cmake/toolchain/rt-kernel-xmc4.cmake b/cmake/toolchain/rt-kernel-xmc4.cmake new file mode 100644 index 0000000..ca9ca05 --- /dev/null +++ b/cmake/toolchain/rt-kernel-xmc4.cmake @@ -0,0 +1,29 @@ +# Guard against multiple inclusion +if(_TOOLCHAIN_CMAKE_) + return() +endif() +set(_TOOLCHAIN_CMAKE_ TRUE) + +INCLUDE(CMakeForceCompiler) +SET(CMAKE_SYSTEM_NAME rt-kernel) + +# specify the cross compiler +CMAKE_FORCE_C_COMPILER(arm-eabi-gcc GNU) +CMAKE_FORCE_CXX_COMPILER(arm-eabi-g++ GNU) + +set(ARCH xmc4) +set(CPU cortex-m4f) +set(BSP xmc48relax) +set(MACHINE_FLAGS "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16") + +set(SOES_DEMO applications/rtl_xmc4_dynpdo) + +include_directories( + ${SOES_SOURCE_DIR}/${SOES_DEMO} + ${SOES_SOURCE_DIR}/soes/hal/rt-kernel-xmc4 + ) + +set(HAL_SOURCES + ${SOES_SOURCE_DIR}/soes/hal/rt-kernel-xmc4/esc_hw.c + ${SOES_SOURCE_DIR}/soes/hal/rt-kernel-xmc4/esc_hw_eep.c + )