diff --git a/.gitignore b/.gitignore index a84c9a2..7f8f6c9 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ /build soes/version.h +applications/xmc4300_slavedemo/XMC_Peripheral_Library diff --git a/applications/linux_lan9252demo/CMakeLists.txt b/applications/linux_lan9252demo/CMakeLists.txt index b8bf8d4..b7f4417 100644 --- a/applications/linux_lan9252demo/CMakeLists.txt +++ b/applications/linux_lan9252demo/CMakeLists.txt @@ -1,7 +1,6 @@ add_executable (demo main.c - slave.c slave_objectlist.c ) target_link_libraries(demo LINK_PUBLIC soes) diff --git a/applications/linux_lan9252demo/config.h b/applications/linux_lan9252demo/config.h deleted file mode 100644 index 8e3321d..0000000 --- a/applications/linux_lan9252demo/config.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#include - -#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/linux_lan9252demo/ecat_options.h b/applications/linux_lan9252demo/ecat_options.h new file mode 100644 index 0000000..c91b2be --- /dev/null +++ b/applications/linux_lan9252demo/ecat_options.h @@ -0,0 +1,44 @@ +#ifndef __ECAT_OPTIONS_H__ +#define __ECAT_OPTIONS_H__ + +#include "cc.h" + +#define USE_FOE 1 +#define USE_EOE 0 + +#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 + +#define MAX_RXPDO_SIZE 42 +#define MAX_TXPDO_SIZE 42 + +#define MAX_MAPPINGS_SM2 2 +#define MAX_MAPPINGS_SM3 1 + +#endif /* __ECAT_OPTIONS_H__ */ diff --git a/applications/linux_lan9252demo/main.c b/applications/linux_lan9252demo/main.c index 69781a8..89c108f 100644 --- a/applications/linux_lan9252demo/main.c +++ b/applications/linux_lan9252demo/main.c @@ -1,48 +1,54 @@ #include -#include "slave.h" +#include "ecat_slv.h" +#include "utypes.h" -/** - * This function reads physical input values and assigns the corresponding members - * of Rb.Buttons - */ -void cb_get_Buttons() +/* Application variables */ +_Objects Obj; + +void cb_get_inputs (void) { - } -/** - * This function writes physical output values from the corresponding members of - * Wb.LEDs - */ - - -void cb_set_LEDs() +void cb_set_outputs (void) { - } - -/** - * This function is called after a SDO write of the object Cb.Parameters. - */ -void cb_post_write_Parameters(int subindex) +int main_run (void * arg) { + static esc_cfg_t config = + { + .user_arg = "/dev/lan9252", + .use_interrupt = 0, + .watchdog_cnt = 150, + .set_defaults_hook = NULL, + .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 = NULL, + .esc_hw_interrupt_disable = NULL, + .esc_hw_eep_handler = NULL, + .esc_check_dc_handler = NULL, + }; -} + printf ("Hello Main\n"); + ecat_slv_init (&config); -void main_run(void * arg) -{ - soes_init(); + while (1) + { + ecat_slv(); + } - while(1) { - soes(); - } -} - -int main(void) -{ - printf("Hello Main\n"); - main_run(NULL); return 0; } +int main (void) +{ + printf ("Hello Main\n"); + main_run (NULL); + return 0; +} diff --git a/applications/linux_lan9252demo/slave.c b/applications/linux_lan9252demo/slave.c deleted file mode 100644 index b8b5969..0000000 --- a/applications/linux_lan9252demo/slave.c +++ /dev/null @@ -1,300 +0,0 @@ -#include -#include "utypes.h" -#include "esc.h" -#include "esc_coe.h" -#include "esc_foe.h" -#include "config.h" -#include "slave.h" - -#define WATCHDOG_RESET_VALUE 150 -#define DEFAULTTXPDOMAP 0x1a00 -#define DEFAULTRXPDOMAP 0x1600 -#define DEFAULTTXPDOITEMS 1 -#define DEFAULTRXPDOITEMS 1 - -/* Global variables used by the stack */ -uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)]; -_MBXcontrol MBXcontrol[MBXBUFFERS]; -_ESCvar ESCvar; - -/* Application variables */ -_Rbuffer Rb; -_Wbuffer Wb; -_Cbuffer Cb; - -/* Private variables */ -uint16_t txpdomap = DEFAULTTXPDOMAP; -uint16_t rxpdomap = DEFAULTRXPDOMAP; -uint8_t txpdoitems = DEFAULTTXPDOITEMS; -uint8_t rxpdoitems = DEFAULTTXPDOITEMS; - -static int watchdog = WATCHDOG_RESET_VALUE; -static void (*application_loop_callback)(void) = NULL; - -/** Function to pre-qualify the incoming SDO download. - * - * @param[in] index = index of SDO download request to check - * @param[in] sub-index = sub-index of SDO download request to check - * @return 1 if the SDO Download is correct. 0 If not correct. - */ -int ESC_pre_objecthandler (uint16_t index, uint8_t subindex) -{ - if ((index == 0x1c12) && (subindex > 0) && (rxpdoitems != 0)) - { - SDO_abort (index, subindex, ABORT_READONLY); - return 0; - } - if ((index == 0x1c13) && (subindex > 0) && (txpdoitems != 0)) - { - SDO_abort (index, subindex, ABORT_READONLY); - return 0; - } - return 1; -} - -/** Mandatory: Hook called from the slave stack SDO Download handler to act on - * user specified Index and Sub-index. - * - * @param[in] index = index of SDO download request to handle - * @param[in] sub-index = sub-index of SDO download request to handle - */ -void ESC_objecthandler (uint16_t index, uint8_t subindex) -{ - switch (index) - { - case 0x1c12: - { - if (rxpdoitems > 1) - { - rxpdoitems = 1; - } - if ((rxpdomap != 0x1600) && (rxpdomap != 0x1601) - && (rxpdomap != 0x0000)) - { - rxpdomap = 0x1600; - } - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - break; - } - case 0x1c13: - { - if (txpdoitems > 1) - { - txpdoitems = 1; - } - if ((txpdomap != 0x1A00) && (txpdomap != 0x1A01) - && (rxpdomap != 0x0000)) - { - txpdomap = 0x1A00; - } - ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - break; - } - /* Handle post-write of parameter values */ - case 0x8000: - { - cb_post_write_Parameters(subindex); - break; - } - default: - break; - } -} - -/** Mandatory: Hook called from the slave stack ESC_stopoutputs to act on state changes - * forcing us to stop outputs. Here we can set them to a safe state. - * set - */ -void APP_safeoutput (void) -{ - DPRINT ("APP_safeoutput\n"); - - // Set safe values for Wb.LEDs - Wb.LEDs.LED0 = 0; - Wb.LEDs.LED1 = 0; - -} - -/** Mandatory: Write local process data to Sync Manager 3, Master Inputs. - */ -void TXPDO_update (void) -{ - ESC_write (SM3_sma, &Rb, ESCvar.TXPDOsize); -} -/** Mandatory: Read Sync Manager 2 to local process data, Master Outputs. - */ -void RXPDO_update (void) -{ - ESC_read (SM2_sma, &Wb, ESCvar.RXPDOsize); -} - -/** Mandatory: Function to update local I/O, call read ethercat outputs, call - * write ethercat inputs. Implement watch-dog counter to count-out if we have - * made state change affecting the App.state. - */ -void DIG_process (void) -{ - if (watchdog > 0) - { - watchdog--; - } - if (ESCvar.App.state & APPSTATE_OUTPUT) - { - /* SM2 trigger ? */ - if (ESCvar.ALevent & ESCREG_ALEVENT_SM2) - { - ESCvar.ALevent &= ~ESCREG_ALEVENT_SM2; - RXPDO_update(); - watchdog = WATCHDOG_RESET_VALUE; - - /* Set outputs */ - cb_set_LEDs(); - } - if (watchdog <= 0) - { - DPRINT("DIG_process watchdog expired\n"); - ESC_stopoutput(); - /* watchdog, invalid outputs */ - ESC_ALerror (ALERR_WATCHDOG); - /* goto safe-op with error bit set */ - ESC_ALstatus (ESCsafeop | ESCerror); - } - } - else - { - watchdog = WATCHDOG_RESET_VALUE; - } - if (ESCvar.App.state) - { - /* Update inputs */ - cb_get_Buttons(); - TXPDO_update(); - } -} - -/********** TODO: Generic code beyond this point ***************/ - -/** Optional: Hook called after state change for application specific - * actions for specific state changes. - */ -void post_state_change_hook (uint8_t * as, uint8_t * an) -{ -#if 0 - /* Add specific step change hooks here */ - if ((*as == BOOT_TO_INIT) && (*an == ESCinit)) - { - boot_inithook(); - } - else if((*as == INIT_TO_BOOT) && (*an & ESCerror ) == 0) - { - init_boothook(); - } -#endif -} - -/** - * Set callback run once every loop in the SOES application loop. - */ -void set_application_loop_hook(void (*callback)(void)) -{ - application_loop_callback = callback; -} - -/** - * SOES main function. It should be called periodically. - * Reads the EtherCAT state and status. Responsible for I/O updates. - */ -void soes (void) -{ - /* On init restore PDO mappings to default size */ - if((ESCvar.ALstatus & 0x0f) == ESCinit) - { - txpdomap = DEFAULTTXPDOMAP; - rxpdomap = DEFAULTRXPDOMAP; - txpdoitems = DEFAULTTXPDOITEMS; - rxpdoitems = DEFAULTTXPDOITEMS; - } - - /* Read local time from ESC */ - ESC_read (ESCREG_LOCALTIME, (void *) &ESCvar.Time, sizeof (ESCvar.Time)); - ESCvar.Time = etohl (ESCvar.Time); - - /* Check the state machine */ - ESC_state(); - /* Check the SM activation event */ - ESC_sm_act_event(); - - /* Check mailboxes */ - if (ESC_mbxprocess()) - { - ESC_coeprocess(); - ESC_foeprocess(); - ESC_xoeprocess(); - } - DIG_process(); - - if (application_loop_callback != NULL) - { - (application_loop_callback)(); - } -} - -/** - * Initialize the SOES stack. - */ -void soes_init (void) -{ - DPRINT ("SOES (Simple Open EtherCAT Slave)\n"); - - ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - - /* Setup config hooks */ - static esc_cfg_t config = - { - .user_arg = "/dev/lan9252", - .use_interrupt = 0, - .watchdog_cnt = 0, - .mbxsize = MBXSIZE, - .mbxsizeboot = MBXSIZEBOOT, - .mbxbuffers = MBXBUFFERS, - .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 = NULL, - .esc_hw_interrupt_disable = NULL, - .esc_hw_eep_handler = NULL - }; - - ESC_config (&config); - ESC_init (&config); - - /* wait until ESC is started up */ - while ((ESCvar.DLstatus & 0x0001) == 0) - { - ESC_read (ESCREG_DLSTATUS, (void *) &ESCvar.DLstatus, - sizeof (ESCvar.DLstatus)); - ESCvar.DLstatus = etohs (ESCvar.DLstatus); - } - - /* Init FoE */ - FOE_init(); - - /* reset ESC to init state */ - ESC_ALstatus (ESCinit); - ESC_ALerror (ALERR_NONE); - ESC_stopmbx(); - ESC_stopinput(); - ESC_stopoutput(); -} diff --git a/applications/linux_lan9252demo/slave.esx b/applications/linux_lan9252demo/slave.esx index fffdb28..bf0a7e3 100644 --- a/applications/linux_lan9252demo/slave.esx +++ b/applications/linux_lan9252demo/slave.esx @@ -1,5 +1,5 @@ - + lan9252 0x1337 @@ -24,275 +24,332 @@ 0010800080108000 - - Device Type + 0x1000 + Device Type UNSIGNED32 0x01901389 - Device Name 0x1008 + Device Name VISIBLE_STRING evb9252_dig + 11 - - Hardware Version + 0x1009 + Hardware Version VISIBLE_STRING 1.0 - - Software Version + 0x100A + Software Version VISIBLE_STRING 1.0 - Identity Object 0x1018 + Identity Object RECORD - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 4 + 0x01 Vendor ID UNSIGNED32 0x1337 + 0x02 Product Code UNSIGNED32 1234 + 0x03 Revision Number UNSIGNED32 0 + 0x04 Serial Number UNSIGNED32 0x00000000 - LEDs 0x1600 + LEDs RECORD - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 2 + 0x01 LED0 UNSIGNED32 0x70000108 + 0x02 LED1 UNSIGNED32 0x70000208 - Buttons 0x1A00 + Buttons RECORD - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 1 + 0x01 Button1 UNSIGNED32 0x60000108 - Sync Manager Communication Type 0x1C00 + Sync Manager Communication Type ARRAY - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 4 + 0x01 Communications Type SM0 UNSIGNED8 1 + 0x02 Communications Type SM1 UNSIGNED8 2 + 0x03 Communications Type SM2 UNSIGNED8 3 + 0x04 Communications Type SM3 UNSIGNED8 4 - Sync Manager 2 PDO Assignment 0x1C12 + Sync Manager 2 PDO Assignment ARRAY - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 1 + 0x01 PDO Mapping UNSIGNED16 0x1600 - Sync Manager 3 PDO Assignment 0x1C13 + Sync Manager 3 PDO Assignment ARRAY - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 1 + 0x01 PDO Mapping UNSIGNED16 0x1A00 - Buttons 0x6000 + Buttons RECORD Buttons Input - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 1 + 0x01 + RO Button1 UNSIGNED8 0 - RO Button1 Input - LEDs 0x7000 + LEDs RECORD LEDs Output - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 2 + 0x01 + RO LED0 UNSIGNED8 0 - RO LED0 Output + 0x02 + RO LED1 UNSIGNED8 0 - RO LED1 Output - Parameters 0x8000 + Parameters RECORD Parameters Parameter - Number of Elements + 0x00 + Max SubIndex UNSIGNED8 1 + 0x01 + RW Multiplier UNSIGNED32 0 - RW Multiplier Parameter + + 0x1C12 + + 0x01 + 0x1600 + + + + 0x1C13 + + 0x01 + 0x1A00 + + 0x1600 - LEDs LEDs - 0x7000 - 1 + 0x1 + 0x7000 + 0x01 LED0 - 0x7000 - 2 + 0x2 + 0x7000 + 0x02 LED1 0x1A00 - Buttons Buttons - 0x6000 - 1 + 0x1 + 0x6000 + 0x01 Button1 + 0x6000 Buttons - RECORD + RECORD + 0x01 + RO Button1 UNSIGNED8 + 0 + 0x7000 LEDs - RECORD + RECORD + 0x01 + RO LED0 UNSIGNED8 + 0 + 0x02 + RO LED1 UNSIGNED8 + 0 + 0x8000 Parameters - RECORD + RECORD + 0x01 + RW Multiplier UNSIGNED32 + 0 - \ No newline at end of file + diff --git a/applications/linux_lan9252demo/slave.h b/applications/linux_lan9252demo/slave.h deleted file mode 100644 index 1e55c98..0000000 --- a/applications/linux_lan9252demo/slave.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __SLAVE_H__ -#define __SLAVE_H__ - -#include "utypes.h" - -/** - * This function reads physical input values and assigns the corresponding members - * of Rb.Buttons - */ -void cb_get_Buttons(); - -/** - * This function writes physical output values from the corresponding members of - * Wb.LEDs - */ -void cb_set_LEDs(); - -/** - * This function is called after a SDO write of the object Cb.Parameters. - */ -void cb_post_write_Parameters(int subindex); - -/** - * This function sets an application loop callback function. - */ -void set_application_loop_hook(void (*callback)(void)); - -/** - * Main function for SOES application - */ -void soes (void); - -/** - * Initialize the SOES stack - */ -void soes_init (void); - -#endif /* __SLAVE_H__ */ diff --git a/applications/linux_lan9252demo/slave.xml b/applications/linux_lan9252demo/slave.xml index a0e1f16..f513292 100644 --- a/applications/linux_lan9252demo/slave.xml +++ b/applications/linux_lan9252demo/slave.xml @@ -26,7 +26,7 @@ 144 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -80,7 +80,7 @@ 80 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -114,7 +114,7 @@ 48 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -147,7 +147,7 @@ 48 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -179,7 +179,7 @@ 32 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -211,7 +211,7 @@ 32 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -234,7 +234,7 @@ 24 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -258,7 +258,7 @@ 32 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -292,7 +292,7 @@ 48 0 - Number of Elements + Max SubIndex USINT 8 0 @@ -311,10 +311,6 @@ - - STRING(3) - 24 - STRING(11) 88 @@ -327,6 +323,10 @@ UINT 16 + + STRING(0) + 0 + USINT 8 @@ -361,8 +361,8 @@ #x1009 Hardware Version - STRING(3) - 24 + STRING(0) + 0 1.0 @@ -374,8 +374,8 @@ #x100A Software Version - STRING(3) - 24 + STRING(0) + 0 1.0 @@ -390,7 +390,7 @@ 144 - Number of Elements + Max SubIndex 4 @@ -431,7 +431,7 @@ 80 - Number of Elements + Max SubIndex 2 @@ -460,7 +460,7 @@ 48 - Number of Elements + Max SubIndex 1 @@ -483,7 +483,7 @@ 48 - Number of Elements + Max SubIndex 4 @@ -524,7 +524,7 @@ 32 - Number of Elements + Max SubIndex 1 @@ -547,7 +547,7 @@ 32 - Number of Elements + Max SubIndex 1 @@ -570,7 +570,7 @@ 24 - Number of Elements + Max SubIndex 1 @@ -593,7 +593,7 @@ 32 - Number of Elements + Max SubIndex 2 @@ -622,7 +622,7 @@ 48 - Number of Elements + Max SubIndex 1 @@ -652,14 +652,14 @@ LEDs #x7000 - 1 + #x1 8 LED0 USINT #x7000 - 2 + #x2 8 LED1 USINT @@ -670,14 +670,14 @@ Buttons #x6000 - 1 + #x1 8 Button1 USINT - + diff --git a/applications/linux_lan9252demo/slave_objectlist.c b/applications/linux_lan9252demo/slave_objectlist.c index 0fb9696..d90f93e 100644 --- a/applications/linux_lan9252demo/slave_objectlist.c +++ b/applications/linux_lan9252demo/slave_objectlist.c @@ -1,66 +1,70 @@ -#include "soes/esc_coe.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[] = "Number of Elements"; +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 acName1600[] = "LEDs"; -static const char acName1600_00[] = "Number of Elements"; +static const char acName1600_00[] = "Max SubIndex"; static const char acName1600_01[] = "LED0"; static const char acName1600_02[] = "LED1"; static const char acName1A00[] = "Buttons"; -static const char acName1A00_00[] = "Number of Elements"; +static const char acName1A00_00[] = "Max SubIndex"; static const char acName1A00_01[] = "Button1"; static const char acName1C00[] = "Sync Manager Communication Type"; -static const char acName1C00_00[] = "Number of Elements"; +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[] = "Number of Elements"; +static const char acName1C12_00[] = "Max SubIndex"; static const char acName1C12_01[] = "PDO Mapping"; static const char acName1C13[] = "Sync Manager 3 PDO Assignment"; -static const char acName1C13_00[] = "Number of Elements"; +static const char acName1C13_00[] = "Max SubIndex"; static const char acName1C13_01[] = "PDO Mapping"; static const char acName6000[] = "Buttons"; -static const char acName6000_00[] = "Number of Elements"; +static const char acName6000_00[] = "Max SubIndex"; static const char acName6000_01[] = "Button1"; static const char acName7000[] = "LEDs"; -static const char acName7000_00[] = "Number of Elements"; +static const char acName7000_00[] = "Max SubIndex"; static const char acName7000_01[] = "LED0"; static const char acName7000_02[] = "LED1"; static const char acName8000[] = "Parameters"; -static const char acName8000_00[] = "Number of Elements"; +static const char acName8000_00[] = "Max SubIndex"; static const char acName8000_01[] = "Multiplier"; const _objd SDO1000[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000_0, 0x01901389, NULL}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 0x01901389, NULL}, }; const _objd SDO1008[] = { - {0x0, DTYPE_VISIBLE_STRING, 88, ATYPE_RO, acName1008_0, 0, "evb9252_dig"}, + {0x0, DTYPE_VISIBLE_STRING, 88, ATYPE_RO, acName1008, 0, "evb9252_dig"}, }; const _objd SDO1009[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, "1.0"}, + {0x0, DTYPE_VISIBLE_STRING, 0, ATYPE_RO, acName1009, 0, HW_REV}, }; const _objd SDO100A[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, "1.0"}, + {0x0, DTYPE_VISIBLE_STRING, 0, ATYPE_RO, acName100A, 0, SW_REV}, }; const _objd SDO1018[] = { @@ -102,18 +106,18 @@ const _objd SDO1C13[] = const _objd SDO6000[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6000_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6000_01, 0, &Rb.Buttons.Button1}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6000_01, 0, &Obj.Buttons.Button1}, }; const _objd SDO7000[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_00, 2, NULL}, - {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_01, 0, &Wb.LEDs.LED0}, - {0x02, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_02, 0, &Wb.LEDs.LED1}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_01, 0, &Obj.LEDs.LED0}, + {0x02, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_02, 0, &Obj.LEDs.LED1}, }; const _objd SDO8000[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName8000_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8000_01, 0, &Cb.Parameters.Multiplier}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8000_01, 0, &Obj.Parameters.Multiplier}, }; const _objectlist SDOobjects[] = diff --git a/applications/linux_lan9252demo/utypes.h b/applications/linux_lan9252demo/utypes.h index 1b84395..9749fcd 100644 --- a/applications/linux_lan9252demo/utypes.h +++ b/applications/linux_lan9252demo/utypes.h @@ -1,47 +1,45 @@ #ifndef __UTYPES_H__ #define __UTYPES_H__ -#include +#include "cc.h" + + +/* Object dictionary storage */ -CC_PACKED_BEGIN typedef struct { - CC_PACKED_BEGIN + /* Inputs */ struct { uint8_t Button1; - } CC_PACKED Buttons; - CC_PACKED_END -} CC_PACKED _Rbuffer; -CC_PACKED_END + } Buttons; -CC_PACKED_BEGIN -typedef struct -{ - CC_PACKED_BEGIN + + /* Outputs */ struct { uint8_t LED0; uint8_t LED1; - } CC_PACKED LEDs; - CC_PACKED_END -} CC_PACKED _Wbuffer; -CC_PACKED_END + } LEDs; -CC_PACKED_BEGIN -typedef struct -{ - CC_PACKED_BEGIN + + /* Parameters */ struct { uint32_t Multiplier; - } CC_PACKED Parameters; - CC_PACKED_END -} CC_PACKED _Cbuffer; -CC_PACKED_END + } Parameters; -extern _Rbuffer Rb; -extern _Wbuffer Wb; -extern _Cbuffer Cb; + + /* Manufacturer specific data */ + + /* Dynamic TX PDO:s */ + + /* Dynamic RX PDO:s */ + + /* Sync Managers */ + +} _Objects; + +extern _Objects Obj; #endif /* __UTYPES_H__ */ diff --git a/applications/rtl_lan9252demo/config.h b/applications/rtl_lan9252demo/config.h deleted file mode 100644 index 8e3321d..0000000 --- a/applications/rtl_lan9252demo/config.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#include - -#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_lan9252demo/ecat_options.h b/applications/rtl_lan9252demo/ecat_options.h new file mode 100644 index 0000000..c91b2be --- /dev/null +++ b/applications/rtl_lan9252demo/ecat_options.h @@ -0,0 +1,44 @@ +#ifndef __ECAT_OPTIONS_H__ +#define __ECAT_OPTIONS_H__ + +#include "cc.h" + +#define USE_FOE 1 +#define USE_EOE 0 + +#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 + +#define MAX_RXPDO_SIZE 42 +#define MAX_TXPDO_SIZE 42 + +#define MAX_MAPPINGS_SM2 2 +#define MAX_MAPPINGS_SM3 1 + +#endif /* __ECAT_OPTIONS_H__ */ diff --git a/applications/rtl_lan9252demo/main.c b/applications/rtl_lan9252demo/main.c index e79745d..7951706 100644 --- a/applications/rtl_lan9252demo/main.c +++ b/applications/rtl_lan9252demo/main.c @@ -1,49 +1,52 @@ -#include -#include "slave.h" +#include +#include "ecat_slv.h" +#include "utypes.h" -/** - * This function reads physical input values and assigns the corresponding members - * of Rb.Buttons - */ -void cb_get_Buttons() +/* Application variables */ +_Objects Obj; + +void cb_get_inputs (void) { - } -/** - * This function writes physical output values from the corresponding members of - * Wb.LEDs - */ - - -void cb_set_LEDs() +void cb_set_outputs (void) { - } - -/** - * This function is called after a SDO write of the object Cb.Parameters. - */ -void cb_post_write_Parameters(int subindex) +int main_run (void * arg) { + static esc_cfg_t config = + { + .user_arg = "/spi1/lan9252", + .use_interrupt = 0, + .watchdog_cnt = 150, + .set_defaults_hook = NULL, + .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 = NULL, + .esc_hw_interrupt_disable = NULL, + .esc_hw_eep_handler = NULL, + .esc_check_dc_handler = NULL, + }; -} + ecat_slv_init (&config); -void main_run(void * arg) -{ - soes_init(); - - while(1) { - soes(); - } -} - -int main(void) -{ - rprintf("Hello Main\n"); - task_spawn ("soes", main_run, 8, 2048, NULL); + while (1) + { + ecat_slv(); + } return 0; } +int main (void) +{ + rprintf ("Hello Main\n"); + task_spawn ("soes", main_run, 8, 2048, NULL); +} diff --git a/applications/rtl_lan9252demo/slave.c b/applications/rtl_lan9252demo/slave.c deleted file mode 100644 index 102ed01..0000000 --- a/applications/rtl_lan9252demo/slave.c +++ /dev/null @@ -1,298 +0,0 @@ -#include -#include "utypes.h" -#include "esc.h" -#include "esc_coe.h" -#include "esc_foe.h" -#include "config.h" -#include "slave.h" - -#define WATCHDOG_RESET_VALUE 150 -#define DEFAULTTXPDOMAP 0x1a00 -#define DEFAULTRXPDOMAP 0x1600 -#define DEFAULTTXPDOITEMS 1 -#define DEFAULTRXPDOITEMS 1 - -/* Global variables used by the stack */ -uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)]; -_MBXcontrol MBXcontrol[MBXBUFFERS]; -_ESCvar ESCvar; - -/* Application variables */ -_Rbuffer Rb; -_Wbuffer Wb; -_Cbuffer Cb; - -/* Private variables */ -uint16_t txpdomap = DEFAULTTXPDOMAP; -uint16_t rxpdomap = DEFAULTRXPDOMAP; -uint8_t txpdoitems = DEFAULTTXPDOITEMS; -uint8_t rxpdoitems = DEFAULTTXPDOITEMS; - -static int watchdog = WATCHDOG_RESET_VALUE; -static void (*application_loop_callback)(void) = NULL; - -/** Function to pre-qualify the incoming SDO download. - * - * @param[in] index = index of SDO download request to check - * @param[in] sub-index = sub-index of SDO download request to check - * @return 1 if the SDO Download is correct. 0 If not correct. - */ -int ESC_pre_objecthandler (uint16_t index, uint8_t subindex) -{ - if ((index == 0x1c12) && (subindex > 0) && (rxpdoitems != 0)) - { - SDO_abort (index, subindex, ABORT_READONLY); - return 0; - } - if ((index == 0x1c13) && (subindex > 0) && (txpdoitems != 0)) - { - SDO_abort (index, subindex, ABORT_READONLY); - return 0; - } - return 1; -} - -/** Mandatory: Hook called from the slave stack SDO Download handler to act on - * user specified Index and Sub-index. - * - * @param[in] index = index of SDO download request to handle - * @param[in] sub-index = sub-index of SDO download request to handle - */ -void ESC_objecthandler (uint16_t index, uint8_t subindex) -{ - switch (index) - { - case 0x1c12: - { - if (rxpdoitems > 1) - { - rxpdoitems = 1; - } - if ((rxpdomap != 0x1600) && (rxpdomap != 0x1601) - && (rxpdomap != 0x0000)) - { - rxpdomap = 0x1600; - } - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - break; - } - case 0x1c13: - { - if (txpdoitems > 1) - { - txpdoitems = 1; - } - if ((txpdomap != 0x1A00) && (txpdomap != 0x1A01) - && (rxpdomap != 0x0000)) - { - txpdomap = 0x1A00; - } - ESCvar.TXPDOsize = ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - break; - } - /* Handle post-write of parameter values */ - case 0x8000: - { - cb_post_write_Parameters(subindex); - break; - } - default: - break; - } -} - -/** Mandatory: Hook called from the slave stack ESC_stopoutputs to act on state changes - * forcing us to stop outputs. Here we can set them to a safe state. - * set - */ -void APP_safeoutput (void) -{ - DPRINT ("APP_safeoutput\n"); - - // Set safe values for Wb.LEDs - Wb.LEDs.LED0 = 0; - Wb.LEDs.LED1 = 0; - -} - -/** Mandatory: Write local process data to Sync Manager 3, Master Inputs. - */ -void TXPDO_update (void) -{ - ESC_write (SM3_sma, &Rb, ESCvar.TXPDOsize); -} -/** Mandatory: Read Sync Manager 2 to local process data, Master Outputs. - */ -void RXPDO_update (void) -{ - ESC_read (SM2_sma, &Wb, ESCvar.RXPDOsize); -} - -/** Mandatory: Function to update local I/O, call read ethercat outputs, call - * write ethercat inputs. Implement watch-dog counter to count-out if we have - * made state change affecting the App.state. - */ -void DIG_process (void) -{ - if (watchdog > 0) - { - watchdog--; - } - if (ESCvar.App.state & APPSTATE_OUTPUT) - { - /* SM2 trigger ? */ - if (ESCvar.ALevent & ESCREG_ALEVENT_SM2) - { - ESCvar.ALevent &= ~ESCREG_ALEVENT_SM2; - RXPDO_update(); - watchdog = WATCHDOG_RESET_VALUE; - - /* Set outputs */ - cb_set_LEDs(); - } - if (watchdog <= 0) - { - DPRINT("DIG_process watchdog expired\n"); - ESC_stopoutput(); - /* watchdog, invalid outputs */ - ESC_ALerror (ALERR_WATCHDOG); - /* goto safe-op with error bit set */ - ESC_ALstatus (ESCsafeop | ESCerror); - } - } - else - { - watchdog = WATCHDOG_RESET_VALUE; - } - if (ESCvar.App.state) - { - /* Update inputs */ - cb_get_Buttons(); - TXPDO_update(); - } -} - -/********** TODO: Generic code beyond this point ***************/ - -/** Optional: Hook called after state change for application specific - * actions for specific state changes. - */ -void post_state_change_hook (uint8_t * as, uint8_t * an) -{ -#if 0 - /* Add specific step change hooks here */ - if ((*as == BOOT_TO_INIT) && (*an == ESCinit)) - { - boot_inithook(); - } - else if((*as == INIT_TO_BOOT) && (*an & ESCerror ) == 0) - { - init_boothook(); - } -#endif -} - -/** - * Set callback run once every loop in the SOES application loop. - */ -void set_application_loop_hook(void (*callback)(void)) -{ - application_loop_callback = callback; -} - -/** - * SOES main function. It should be called periodically. - * Reads the EtherCAT state and status. Responsible for I/O updates. - */ -void soes (void) -{ - /* On init restore PDO mappings to default size */ - if((ESCvar.ALstatus & 0x0f) == ESCinit) - { - txpdomap = DEFAULTTXPDOMAP; - rxpdomap = DEFAULTRXPDOMAP; - txpdoitems = DEFAULTTXPDOITEMS; - rxpdoitems = DEFAULTTXPDOITEMS; - } - - /* Read local time from ESC */ - ESC_read (ESCREG_LOCALTIME, (void *) &ESCvar.Time, sizeof (ESCvar.Time)); - ESCvar.Time = etohl (ESCvar.Time); - - /* Check the state machine */ - ESC_state(); - - /* Check mailboxes */ - if (ESC_mbxprocess()) - { - ESC_coeprocess(); - ESC_foeprocess(); - ESC_xoeprocess(); - } - DIG_process(); - - if (application_loop_callback != NULL) - { - (application_loop_callback)(); - } -} - -/** - * Initialize the SOES stack. - */ -void soes_init (void) -{ - DPRINT ("SOES (Simple Open EtherCAT Slave)\n"); - - ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - - /* Setup config hooks */ - static esc_cfg_t config = - { - .user_arg = "/spi1/lan9252", - .use_interrupt = 0, - .watchdog_cnt = 0, - .mbxsize = MBXSIZE, - .mbxsizeboot = MBXSIZEBOOT, - .mbxbuffers = MBXBUFFERS, - .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 = NULL, - .esc_hw_interrupt_disable = NULL, - .esc_hw_eep_handler = NULL - }; - - ESC_config (&config); - ESC_init (&config); - - /* wait until ESC is started up */ - while ((ESCvar.DLstatus & 0x0001) == 0) - { - ESC_read (ESCREG_DLSTATUS, (void *) &ESCvar.DLstatus, - sizeof (ESCvar.DLstatus)); - ESCvar.DLstatus = etohs (ESCvar.DLstatus); - } - - /* Init FoE */ - FOE_init(); - - /* reset ESC to init state */ - ESC_ALstatus (ESCinit); - ESC_ALerror (ALERR_NONE); - ESC_stopmbx(); - ESC_stopinput(); - ESC_stopoutput(); -} diff --git a/applications/rtl_lan9252demo/slave.h b/applications/rtl_lan9252demo/slave.h deleted file mode 100644 index 1e55c98..0000000 --- a/applications/rtl_lan9252demo/slave.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __SLAVE_H__ -#define __SLAVE_H__ - -#include "utypes.h" - -/** - * This function reads physical input values and assigns the corresponding members - * of Rb.Buttons - */ -void cb_get_Buttons(); - -/** - * This function writes physical output values from the corresponding members of - * Wb.LEDs - */ -void cb_set_LEDs(); - -/** - * This function is called after a SDO write of the object Cb.Parameters. - */ -void cb_post_write_Parameters(int subindex); - -/** - * This function sets an application loop callback function. - */ -void set_application_loop_hook(void (*callback)(void)); - -/** - * Main function for SOES application - */ -void soes (void); - -/** - * Initialize the SOES stack - */ -void soes_init (void); - -#endif /* __SLAVE_H__ */ diff --git a/applications/rtl_lan9252demo/slave_objectlist.c b/applications/rtl_lan9252demo/slave_objectlist.c index 0fb9696..c3c6a58 100644 --- a/applications/rtl_lan9252demo/slave_objectlist.c +++ b/applications/rtl_lan9252demo/slave_objectlist.c @@ -1,66 +1,70 @@ -#include "soes/esc_coe.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[] = "Number of Elements"; +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 acName1600[] = "LEDs"; -static const char acName1600_00[] = "Number of Elements"; +static const char acName1600_00[] = "Max SubIndex"; static const char acName1600_01[] = "LED0"; static const char acName1600_02[] = "LED1"; static const char acName1A00[] = "Buttons"; -static const char acName1A00_00[] = "Number of Elements"; +static const char acName1A00_00[] = "Max SubIndex"; static const char acName1A00_01[] = "Button1"; static const char acName1C00[] = "Sync Manager Communication Type"; -static const char acName1C00_00[] = "Number of Elements"; +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[] = "Number of Elements"; +static const char acName1C12_00[] = "Max SubIndex"; static const char acName1C12_01[] = "PDO Mapping"; static const char acName1C13[] = "Sync Manager 3 PDO Assignment"; -static const char acName1C13_00[] = "Number of Elements"; +static const char acName1C13_00[] = "Max SubIndex"; static const char acName1C13_01[] = "PDO Mapping"; static const char acName6000[] = "Buttons"; -static const char acName6000_00[] = "Number of Elements"; +static const char acName6000_00[] = "Max SubIndex"; static const char acName6000_01[] = "Button1"; static const char acName7000[] = "LEDs"; -static const char acName7000_00[] = "Number of Elements"; +static const char acName7000_00[] = "Max SubIndex"; static const char acName7000_01[] = "LED0"; static const char acName7000_02[] = "LED1"; static const char acName8000[] = "Parameters"; -static const char acName8000_00[] = "Number of Elements"; +static const char acName8000_00[] = "Max SubIndex"; static const char acName8000_01[] = "Multiplier"; const _objd SDO1000[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000_0, 0x01901389, NULL}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 0x13890190, NULL}, }; const _objd SDO1008[] = { - {0x0, DTYPE_VISIBLE_STRING, 88, ATYPE_RO, acName1008_0, 0, "evb9252_dig"}, + {0x0, DTYPE_VISIBLE_STRING, 88, ATYPE_RO, acName1008, 0, "evb9252_dig"}, }; const _objd SDO1009[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, "1.0"}, + {0x0, DTYPE_VISIBLE_STRING, 0, ATYPE_RO, acName1009, 0, HW_REV}, }; const _objd SDO100A[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, "1.0"}, + {0x0, DTYPE_VISIBLE_STRING, 0, ATYPE_RO, acName100A, 0, SW_REV}, }; const _objd SDO1018[] = { @@ -102,18 +106,18 @@ const _objd SDO1C13[] = const _objd SDO6000[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6000_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6000_01, 0, &Rb.Buttons.Button1}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6000_01, 0, &Obj.Buttons.Button1}, }; const _objd SDO7000[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_00, 2, NULL}, - {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_01, 0, &Wb.LEDs.LED0}, - {0x02, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_02, 0, &Wb.LEDs.LED1}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_01, 0, &Obj.LEDs.LED0}, + {0x02, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_02, 0, &Obj.LEDs.LED1}, }; const _objd SDO8000[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName8000_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8000_01, 0, &Cb.Parameters.Multiplier}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8000_01, 0, &Obj.Parameters.Multiplier}, }; const _objectlist SDOobjects[] = diff --git a/applications/rtl_lan9252demo/utypes.h b/applications/rtl_lan9252demo/utypes.h index 1b84395..9749fcd 100644 --- a/applications/rtl_lan9252demo/utypes.h +++ b/applications/rtl_lan9252demo/utypes.h @@ -1,47 +1,45 @@ #ifndef __UTYPES_H__ #define __UTYPES_H__ -#include +#include "cc.h" + + +/* Object dictionary storage */ -CC_PACKED_BEGIN typedef struct { - CC_PACKED_BEGIN + /* Inputs */ struct { uint8_t Button1; - } CC_PACKED Buttons; - CC_PACKED_END -} CC_PACKED _Rbuffer; -CC_PACKED_END + } Buttons; -CC_PACKED_BEGIN -typedef struct -{ - CC_PACKED_BEGIN + + /* Outputs */ struct { uint8_t LED0; uint8_t LED1; - } CC_PACKED LEDs; - CC_PACKED_END -} CC_PACKED _Wbuffer; -CC_PACKED_END + } LEDs; -CC_PACKED_BEGIN -typedef struct -{ - CC_PACKED_BEGIN + + /* Parameters */ struct { uint32_t Multiplier; - } CC_PACKED Parameters; - CC_PACKED_END -} CC_PACKED _Cbuffer; -CC_PACKED_END + } Parameters; -extern _Rbuffer Rb; -extern _Wbuffer Wb; -extern _Cbuffer Cb; + + /* Manufacturer specific data */ + + /* Dynamic TX PDO:s */ + + /* Dynamic RX PDO:s */ + + /* Sync Managers */ + +} _Objects; + +extern _Objects Obj; #endif /* __UTYPES_H__ */ diff --git a/applications/rtl_slavedemo/CMakeLists.txt b/applications/rtl_slavedemo/CMakeLists.txt index 8562982..ac5a85a 100644 --- a/applications/rtl_slavedemo/CMakeLists.txt +++ b/applications/rtl_slavedemo/CMakeLists.txt @@ -1,6 +1,5 @@ add_executable (rtl_slavedemo - soes.c objectlist.c led_handler.c bootstrap.c diff --git a/applications/rtl_slavedemo/bootstrap.c b/applications/rtl_slavedemo/bootstrap.c index f833e66..9ae42df 100644 --- a/applications/rtl_slavedemo/bootstrap.c +++ b/applications/rtl_slavedemo/bootstrap.c @@ -46,7 +46,7 @@ void boot_inithook (void) } } -uint32_t flash_foe_buffer (foe_writefile_cfg_t * self, uint8_t * data) +uint32_t flash_foe_buffer (foe_writefile_cfg_t * self, uint8_t * data, size_t length) { uint32_t flash_cmd_failed = 0; uint32_t calculated_address = self->dest_start_address + self->address_offset; @@ -118,7 +118,6 @@ void bootstrap_foe_init (void) { .buffer_size = FLASH_WRITE_BLOCK_SIZE, /* Buffer size before we flush to destination */ .fbuffer = (uint8_t *)&fbuf, - .empty_write = 0xFF, .n_files = NELEMENTS (files), .files = files }; diff --git a/applications/rtl_slavedemo/ecat_options.h b/applications/rtl_slavedemo/ecat_options.h new file mode 100644 index 0000000..9ca00e4 --- /dev/null +++ b/applications/rtl_slavedemo/ecat_options.h @@ -0,0 +1,44 @@ +#ifndef __ECAT_OPTIONS_H__ +#define __ECAT_OPTIONS_H__ + +#include "cc.h" + +#define USE_FOE 1 +#define USE_EOE 0 + +#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 + +#define MAX_RXPDO_SIZE 42 +#define MAX_TXPDO_SIZE 42 + +#define MAX_MAPPINGS_SM2 1 +#define MAX_MAPPINGS_SM3 2 + +#endif /* __ECAT_OPTIONS_H__ */ diff --git a/applications/rtl_slavedemo/main.c b/applications/rtl_slavedemo/main.c index 24c12af..cca21ab 100644 --- a/applications/rtl_slavedemo/main.c +++ b/applications/rtl_slavedemo/main.c @@ -4,8 +4,128 @@ */ #include +#include "ecat_slv.h" +#include "utypes.h" +#include "bsp.h" +#include "bootstrap.h" -int main(void) +/* Application variables */ +_Rbuffer Rb; +_Wbuffer Wb; +_Cbuffer Cb; + +uint32_t encoder_scale; +uint32_t encoder_scale_mirror; + +void cb_get_inputs (void) +{ + Rb.button = gpio_get(GPIO_BUTTON_SW1); + //Rb.button = (flash_drv_get_active_swap() && 0x8); + Cb.reset_counter++; + Rb.encoder = Cb.reset_counter; +} + +void cb_set_outputs (void) +{ + gpio_set(GPIO_LED_BLUE, Wb.LED & BIT(0)); +} + +/** Optional: Hook called after state change for application specific + * actions for specific state changes. + */ +void post_state_change_hook (uint8_t * as, uint8_t * an) +{ + + /* Add specific step change hooks here */ + if ((*as == BOOT_TO_INIT) && (*an == ESCinit)) + { + boot_inithook (); + } + else if((*as == INIT_TO_BOOT) && (*an & ESCerror ) == 0) + { + init_boothook (); + } +} + +void post_object_download_hook (uint16_t index, uint8_t subindex, + uint16_t flags) +{ + switch(index) + { + case 0x7100: + { + switch (subindex) + { + case 0x01: + { + encoder_scale_mirror = encoder_scale; + break; + } + } + break; + } + case 0x8001: + { + switch (subindex) + { + case 0x01: + { + Cb.reset_counter = 0; + break; + } + } + break; + } + } +} + +void soes (void * arg) +{ + + /* Setup config hooks */ + static esc_cfg_t config = + { + .user_arg = "/spi0/et1100", + .use_interrupt = 0, + .set_defaults_hook = NULL, + .watchdog_cnt = 1000, + .pre_state_change_hook = NULL, + .post_state_change_hook = post_state_change_hook, + .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 = NULL, + .esc_hw_interrupt_disable = NULL, + .esc_hw_eep_handler = NULL + }; + + ecat_slv_init (&config); + + while (1) + { + ecat_slv(); + } +} + +uint8_t load1s, load5s, load10s; +void my_cyclic_callback (void * arg) +{ + while (1) + { + task_delay(tick_from_ms (20000)); + stats_get_load (&load1s, &load5s, &load10s); + DPRINT ("%d:%d:%d (1s:5s:10s)\n", + load1s, load5s, load10s); + DPRINT ("Local bootstate: %d App.state: %d\n", local_boot_state,App.state); + DPRINT ("AlStatus : 0x%x, AlError : 0x%x, Watchdog : %d \n", (ESCvar.ALstatus & 0x001f),ESCvar.ALerror,wd_cnt); + + } +} + +int main (void) { extern void led_run (void *arg); extern void led_error (void *arg); diff --git a/applications/rtl_slavedemo/soes.c b/applications/rtl_slavedemo/soes.c deleted file mode 100644 index 01e0810..0000000 --- a/applications/rtl_slavedemo/soes.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Licensed under the GNU General Public License version 2 with exceptions. See - * LICENSE file in the project root for full license information - */ - - /** \file - * \brief - * The application. - * - * The application, the main loop that service EtherCAT. - */ - -#include -#include - -#include -#include -#include -#include "utypes.h" -#include "config.h" -#include "bootstrap.h" - -#define WD_RESET 1000 -#define DEFAULTTXPDOMAP 0x1a00 -#define DEFAULTRXPDOMAP 0x1600 -#define DEFAULTTXPDOITEMS 1 -#define DEFAULTRXPDOITEMS 1 - -uint32_t encoder_scale; -uint32_t encoder_scale_mirror; - -/* Global variables used by the stack */ -uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)]; -_MBXcontrol MBXcontrol[MBXBUFFERS]; -_ESCvar ESCvar; - -/* Application variables */ -_Rbuffer Rb; -_Wbuffer Wb; -_Cbuffer Cb; - -/* Private variables */ -int wd_cnt = WD_RESET; -volatile uint8_t digoutput; -volatile uint8_t diginput; -uint16_t txpdomap = DEFAULTTXPDOMAP; -uint16_t rxpdomap = DEFAULTRXPDOMAP; -uint8_t txpdoitems = DEFAULTTXPDOITEMS; -uint8_t rxpdoitems = DEFAULTTXPDOITEMS; - - -extern uint32_t local_boot_state; - -/** Function to pre-qualify the incoming SDO download. - * - * @param[in] index = index of SDO download request to check - * @param[in] sub-index = sub-index of SDO download request to check - * @return 1 if the SDO Download is correct. 0 If not correct. - */ -int ESC_pre_objecthandler (uint16_t index, uint8_t subindex) -{ - if ((index == 0x1c12) && (subindex > 0) && (rxpdoitems != 0)) - { - SDO_abort (index, subindex, ABORT_READONLY); - return 0; - } - if ((index == 0x1c13) && (subindex > 0) && (txpdoitems != 0)) - { - SDO_abort (index, subindex, ABORT_READONLY); - return 0; - } - return 1; -} - - -/** Mandatory: Hook called from the slave stack SDO Download handler to act on - * user specified Index and Sub-index. - * - * @param[in] index = index of SDO download request to handle - * @param[in] sub-index = sub-index of SDO download request to handle - */ -void ESC_objecthandler (uint16_t index, uint8_t subindex) -{ - switch (index) - { - case 0x1c12: - { - if (rxpdoitems > 1) - { - rxpdoitems = 1; - } - if ((rxpdomap != 0x1600) && (rxpdomap != 0x1601) - && (rxpdomap != 0x0000)) - { - rxpdomap = 0x1600; - } - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - break; - } - case 0x1c13: - { - if (txpdoitems > 1) - { - txpdoitems = 1; - } - if ((txpdomap != 0x1A00) && (txpdomap != 0x1A01) - && (rxpdomap != 0x0000)) - { - txpdomap = 0x1A00; - } - ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - break; - } - case 0x7100: - { - switch (subindex) - { - case 0x01: - { - encoder_scale_mirror = encoder_scale; - break; - } - } - break; - } - case 0x8001: - { - switch (subindex) - { - case 0x01: - { - Cb.reset_counter = 0; - break; - } - } - break; - } - } -} - -/** Mandatory: Hook called from the slave stack ESC_stopoutputs to act on state changes - * forcing us to stop outputs. Here we can set them to a safe state. - * set - */ -void APP_safeoutput (void) -{ - DPRINT ("APP_safeoutput called\n"); - Wb.LED = 0; -} -/** Mandatory: Write local process data to Sync Manager 3, Master Inputs. - */ -void TXPDO_update (void) -{ - ESC_write (SM3_sma, &Rb.button, ESCvar.TXPDOsize); -} -/** Mandatory: Read Sync Manager 2 to local process data, Master Outputs. - */ -void RXPDO_update (void) -{ - ESC_read (SM2_sma, &Wb.LED, ESCvar.RXPDOsize); -} - -/** Mandatory: Function to update local I/O, call read ethercat outputs, call - * write ethercat inputs. Implement watch-dog counter to count-out if we have - * made state change affecting the App.state. - */ -void DIG_process (void) -{ - if (wd_cnt) - { - wd_cnt--; - } - if (ESCvar.App.state & APPSTATE_OUTPUT) - { - /* SM2 trigger ? */ - if (ESCvar.ALevent & ESCREG_ALEVENT_SM2) - { - ESCvar.ALevent &= ~ESCREG_ALEVENT_SM2; - RXPDO_update (); - wd_cnt = WD_RESET; - /* dummy output point */ - //gpio_set(GPIO_LED, Wb.LED & BIT(0)); - } - if (!wd_cnt) - { - DPRINT("DIG_process watchdog tripped\n"); - ESC_stopoutput (); - /* watchdog, invalid outputs */ - ESC_ALerror (ALERR_WATCHDOG); - /* goto safe-op with error bit set */ - ESC_ALstatus (ESCsafeop | ESCerror); - } - } - else - { - wd_cnt = WD_RESET; - } - if (ESCvar.App.state) - { - //Rb.button = gpio_get(GPIO_WAKEUP); - Rb.button = (flash_drv_get_active_swap() && 0x8); - Cb.reset_counter++; - Rb.encoder = Cb.reset_counter; - TXPDO_update (); - } -} - -/** Optional: Hook called after state change for application specific - * actions for specific state changes. - */ -void post_state_change_hook (uint8_t * as, uint8_t * an) -{ - - /* Add specific step change hooks here */ - if ((*as == BOOT_TO_INIT) && (*an == ESCinit)) - { - boot_inithook (); - } - else if((*as == INIT_TO_BOOT) && (*an & ESCerror ) == 0) - { - init_boothook (); - } -} - - -/** SOES main loop. Start by initializing the stack software followed by - * the application loop for cyclic read the EtherCAT state and staus, update - * of I/O. - */ -void soes (void *arg) -{ - DPRINT ("SOES (Simple Open EtherCAT Slave)\n"); - - ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - - /* Setup config hooks */ - static esc_cfg_t config = - { - .user_arg = "/spi0/et1100", - .use_interrupt = 0, - .watchdog_cnt = 0, - .mbxsize = MBXSIZE, - .mbxsizeboot = MBXSIZEBOOT, - .mbxbuffers = MBXBUFFERS, - .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 = NULL, - .esc_hw_interrupt_disable = NULL, - .esc_hw_eep_handler = NULL - }; - - ESC_config (&config); - ESC_init (&config); - - task_delay (tick_from_ms (200)); - - /* wait until ESC is started up */ - while ((ESCvar.DLstatus & 0x0001) == 0) - { - ESC_read (ESCREG_DLSTATUS, (void *) &ESCvar.DLstatus, - sizeof (ESCvar.DLstatus)); - ESCvar.DLstatus = etohs (ESCvar.DLstatus); - } - - /* Pre FoE to set up Application information */ - bootstrap_foe_init (); - /* Init FoE */ - FOE_init(); - - /* reset ESC to init state */ - ESC_ALstatus (ESCinit); - ESC_ALerror (ALERR_NONE); - ESC_stopmbx (); - ESC_stopinput (); - ESC_stopoutput (); - - DPRINT ("Application_loop GO\n"); - /* application run loop */ - while (1) - { - /* On init restore PDO mappings to default size */ - if((ESCvar.ALstatus & 0x0f) == ESCinit) - { - txpdomap = DEFAULTTXPDOMAP; - rxpdomap = DEFAULTRXPDOMAP; - txpdoitems = DEFAULTTXPDOITEMS; - rxpdoitems = DEFAULTTXPDOITEMS; - } - /* Read local time from ESC*/ - ESC_read (ESCREG_LOCALTIME, (void *) &ESCvar.Time, sizeof (ESCvar.Time)); - ESCvar.Time = etohl (ESCvar.Time); - - /* Check the state machine */ - ESC_state (); - - /* If else to two separate execution paths - * If we're running BOOSTRAP - * - MailBox - * - FoE - * Else we're running normal execution - * - MailBox - * - CoE - */ - if(local_boot_state) - { - if (ESC_mbxprocess ()) - { - ESC_foeprocess (); - ESC_xoeprocess (); - } - bootstrap_state (); - } - else - { - if (ESC_mbxprocess ()) - { - ESC_coeprocess (); - ESC_xoeprocess (); - } - DIG_process (); - } - }; -} - -uint8_t load1s, load5s, load10s; -void my_cyclic_callback (void * arg) -{ - while (1) - { - task_delay(tick_from_ms (20000)); - stats_get_load (&load1s, &load5s, &load10s); - DPRINT ("%d:%d:%d (1s:5s:10s)\n", - load1s, load5s, load10s); - DPRINT ("Local bootstate: %d App.state: %d\n", local_boot_state,App.state); - DPRINT ("AlStatus : 0x%x, AlError : 0x%x, Watchdog : %d \n", (ESCvar.ALstatus & 0x001f),ESCvar.ALerror,wd_cnt); - - } -} diff --git a/applications/rtl_slavedemo/utypes.h b/applications/rtl_slavedemo/utypes.h index f1ff222..814d605 100644 --- a/applications/rtl_slavedemo/utypes.h +++ b/applications/rtl_slavedemo/utypes.h @@ -18,7 +18,6 @@ typedef struct { - uint8_t state; uint8_t button; uint32_t encoder; } _Rbuffer; diff --git a/applications/rtl_xmc4_dynpdo/config.h b/applications/rtl_xmc4_dynpdo/config.h deleted file mode 100644 index 2fdf3c1..0000000 --- a/applications/rtl_xmc4_dynpdo/config.h +++ /dev/null @@ -1,44 +0,0 @@ -#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/ecat_options.h b/applications/rtl_xmc4_dynpdo/ecat_options.h new file mode 100644 index 0000000..bea5875 --- /dev/null +++ b/applications/rtl_xmc4_dynpdo/ecat_options.h @@ -0,0 +1,42 @@ +#ifndef __ECAT_OPTIONS_H__ +#define __ECAT_OPTIONS_H__ + +#define USE_FOE 0 +#define USE_EOE 0 + +#define MBXSIZE 512 +#define MBXSIZEBOOT 512 +#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 0x1400 +#define SM2_smc 0x64 +#define SM2_act 1 +#define SM3_sma 0x1A00 +#define SM3_smc 0x20 +#define SM3_act 1 + +#define MAX_MAPPINGS_SM2 10 +#define MAX_MAPPINGS_SM3 9 + +#define MAX_RXPDO_SIZE 512 +#define MAX_TXPDO_SIZE 512 + +#endif /* __ECAT_OPTIONS_H__ */ diff --git a/applications/rtl_xmc4_dynpdo/main.c b/applications/rtl_xmc4_dynpdo/main.c index bc33a2e..9a2ffa9 100644 --- a/applications/rtl_xmc4_dynpdo/main.c +++ b/applications/rtl_xmc4_dynpdo/main.c @@ -7,22 +7,37 @@ #include "esc.h" #include "esc_hw.h" #include "ecat_slv.h" -#include "config.h" +#include "options.h" #include "utypes.h" +#include "bsp.h" /* Application variables */ _Objects Obj; -void cb_get_inputs (void) +/* + * This function is called to get input values + */ +void cb_get_inputs() { - Obj.IN1 = 1; - Obj.IN2 = 2; - Obj.IN3 = 3; - Obj.IN4 = 4; + Obj.Buttons.Button1 = gpio_get (GPIO_BUTTON1); } -void cb_set_outputs (void) +/* + * This function is called to set output values + */ +void cb_set_outputs() { + gpio_set (GPIO_LED1, Obj.LEDgroup0.LED0); + gpio_set (GPIO_LED2, Obj.LEDgroup1.LED1); +} + +void cb_state_change (uint8_t * as, uint8_t * an) +{ + if (*as == SAFEOP_TO_OP) + { + /* Enable watchdog interrupt */ + ESC_ALeventmaskwrite (ESC_ALeventmaskread() | ESCREG_ALEVENT_WD); + } } /* Setup of DC */ @@ -30,7 +45,7 @@ uint16_t dc_checker (void) { /* Indicate we run DC */ ESCvar.dcsync = 1; - /* Fetch the sync counter limit SDO10F1*/ + /* Fetch the sync counter limit (SDO10F1) */ ESCvar.synccounterlimit = Obj.ErrorSettings.SyncErrorCounterLimit; return 0; } @@ -44,7 +59,7 @@ int main (void) .watchdog_cnt = INT32_MAX, /* Use HW SM watchdog instead */ .set_defaults_hook = NULL, .pre_state_change_hook = NULL, - .post_state_change_hook = NULL, + .post_state_change_hook = cb_state_change, .application_hook = NULL, .safeoutput_override = NULL, .pre_object_download_hook = NULL, diff --git a/applications/rtl_xmc4_dynpdo/sii_eeprom.bin b/applications/rtl_xmc4_dynpdo/sii_eeprom.bin index fde4363..903c89e 100644 Binary files a/applications/rtl_xmc4_dynpdo/sii_eeprom.bin and b/applications/rtl_xmc4_dynpdo/sii_eeprom.bin differ diff --git a/applications/rtl_xmc4_dynpdo/slave.esx b/applications/rtl_xmc4_dynpdo/slave.esx new file mode 100644 index 0000000..5401f5a --- /dev/null +++ b/applications/rtl_xmc4_dynpdo/slave.esx @@ -0,0 +1,1106 @@ + + + xmc48relax + + 0x1337 + rt-labs + + + xmc4 + xmc4 + + Outputs + Inputs + MBoxState + MBoxOut + MBoxIn + Outputs + Inputs + + + + + + 8006810600000000 + 0010000200120002 + + + + 0x1000 + Device Type + UNSIGNED32 + 0x00001389 + + + 0x1008 + Device Name + VISIBLE_STRING + xmc48relax + 10 + + + 0x1009 + Hardware Version + VISIBLE_STRING + 1.0 + 3 + + + 0x100A + Software Version + VISIBLE_STRING + 1.0 + 3 + + + 0x1018 + Identity Object + RECORD + + 0x00 + Max SubIndex + UNSIGNED8 + 4 + + + 0x01 + Vendor ID + UNSIGNED32 + 0x1337 + + + 0x02 + Product Code + UNSIGNED32 + 0x4800 + + + 0x03 + Revision Number + UNSIGNED32 + 0 + + + 0x04 + Serial Number + UNSIGNED32 + 0x00000000 + + + + 0x10F1 + ErrorSettings + RECORD + ErrorSettings + Manufacturer + + 0x00 + Max SubIndex + UNSIGNED8 + 2 + + + 0x01 + RW + Local Error Reaction + UNSIGNED32 + 0 + Local_Error_Reaction + Manufacturer + + + 0x02 + RW + SyncErrorCounterLimit + UNSIGNED16 + 2 + SyncErrorCounterLimit + Manufacturer + + + + 0x1600 + RXPDO 1 + RECORD + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + LED0 + UNSIGNED32 + 0x70000108 + + + + 0x1601 + RXPDO 2 + RECORD + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + LED1 + UNSIGNED32 + 0x70010108 + + + + 0x1602 + RW + PreOP + RXPDO 3 + RECORD + PDO1602 + + 0x00 + RW + PreOP + Max SubIndex + UNSIGNED8 + 8 + maxsub + + + 0x01 + RW + PreOP + PDO Entry 1602:01 + UNSIGNED32 + 0x00000000 + value + + + 0x02 + RW + PreOP + PDO Entry 1602:02 + UNSIGNED32 + 0x00000000 + value + + + 0x03 + RW + PreOP + PDO Entry 1602:03 + UNSIGNED32 + 0x00000000 + value + + + 0x04 + RW + PreOP + PDO Entry 1602:04 + UNSIGNED32 + 0x00000000 + value + + + 0x05 + RW + PreOP + PDO Entry 1602:05 + UNSIGNED32 + 0x00000000 + value + + + 0x06 + RW + PreOP + PDO Entry 1602:06 + UNSIGNED32 + 0x00000000 + value + + + 0x07 + RW + PreOP + PDO Entry 1602:07 + UNSIGNED32 + 0x00000000 + value + + + 0x08 + RW + PreOP + PDO Entry 1602:08 + UNSIGNED32 + 0x00000000 + value + + + + 0x1A00 + TXPDO 1 + RECORD + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + Button1 + UNSIGNED32 + 0x60000108 + + + + 0x1A01 + RW + PreOP + TXPDO 2 + RECORD + PDO1A01 + + 0x00 + RW + PreOP + Max SubIndex + UNSIGNED8 + 8 + maxsub + + + 0x01 + RW + PreOP + PDO Entry 1A01:01 + UNSIGNED32 + 0x00000000 + value + + + 0x02 + RW + PreOP + PDO Entry 1A01:02 + UNSIGNED32 + 0x00000000 + value + + + 0x03 + RW + PreOP + PDO Entry 1A01:03 + UNSIGNED32 + 0x00000000 + value + + + 0x04 + RW + PreOP + PDO Entry 1A01:04 + UNSIGNED32 + 0x00000000 + value + + + 0x05 + RW + PreOP + PDO Entry 1A01:05 + UNSIGNED32 + 0x00000000 + value + + + 0x06 + RW + PreOP + PDO Entry 1A01:06 + UNSIGNED32 + 0x00000000 + value + + + 0x07 + RW + PreOP + PDO Entry 1A01:07 + UNSIGNED32 + 0x00000000 + value + + + 0x08 + RW + PreOP + PDO Entry 1A01:08 + UNSIGNED32 + 0x00000000 + value + + + + 0x1C00 + Sync Manager Communication Type + ARRAY + + 0x00 + Max SubIndex + UNSIGNED8 + 4 + + + 0x01 + Communications Type SM0 + UNSIGNED8 + 1 + + + 0x02 + Communications Type SM1 + UNSIGNED8 + 2 + + + 0x03 + Communications Type SM2 + UNSIGNED8 + 3 + + + 0x04 + Communications Type SM3 + UNSIGNED8 + 4 + + + + 0x1C12 + RW + PreOP + Sync Manager 2 PDO Assignment + ARRAY + SM1C12 + + 0x00 + RW + PreOP + Max SubIndex + UNSIGNED8 + 8 + maxsub + + + 0x01 + RW + PreOP + PDO Mapping + UNSIGNED16 + 0x1600 + value + + + 0x02 + RW + PreOP + PDO Mapping + UNSIGNED16 + 0x1601 + value + + + 0x03 + RW + PreOP + SM Entry 1C12:03 + UNSIGNED16 + 0x0000 + value + + + 0x04 + RW + PreOP + SM Entry 1C12:04 + UNSIGNED16 + 0x0000 + value + + + 0x05 + RW + PreOP + SM Entry 1C12:05 + UNSIGNED16 + 0x0000 + value + + + 0x06 + RW + PreOP + SM Entry 1C12:06 + UNSIGNED16 + 0x0000 + value + + + 0x07 + RW + PreOP + SM Entry 1C12:07 + UNSIGNED16 + 0x0000 + value + + + 0x08 + RW + PreOP + SM Entry 1C12:08 + UNSIGNED16 + 0x0000 + value + + + + 0x1C13 + RW + PreOP + Sync Manager 3 PDO Assignment + ARRAY + SM1C13 + + 0x00 + RW + PreOP + Max SubIndex + UNSIGNED8 + 8 + maxsub + + + 0x01 + RW + PreOP + PDO Mapping + UNSIGNED16 + 0x1A00 + value + + + 0x02 + RW + PreOP + SM Entry 1C13:02 + UNSIGNED16 + 0x0000 + value + + + 0x03 + RW + PreOP + SM Entry 1C13:03 + UNSIGNED16 + 0x0000 + value + + + 0x04 + RW + PreOP + SM Entry 1C13:04 + UNSIGNED16 + 0x0000 + value + + + 0x05 + RW + PreOP + SM Entry 1C13:05 + UNSIGNED16 + 0x0000 + value + + + 0x06 + RW + PreOP + SM Entry 1C13:06 + UNSIGNED16 + 0x0000 + value + + + 0x07 + RW + PreOP + SM Entry 1C13:07 + UNSIGNED16 + 0x0000 + value + + + 0x08 + RW + PreOP + SM Entry 1C13:08 + UNSIGNED16 + 0x0000 + value + + + + 0x1C32 + SyncMgrParam + RECORD + SyncMgrParam + Manufacturer + + 0x00 + Max SubIndex + UNSIGNED8 + 32 + + + 0x01 + RW + Sync mode + UNSIGNED16 + 0 + Sync_mode + Manufacturer + + + 0x02 + RO + CycleTime + UNSIGNED32 + 0 + CycleTime + Manufacturer + + + 0x03 + RO + ShiftTime + UNSIGNED32 + 0 + ShiftTime + Manufacturer + + + 0x04 + RO + Sync modes supported + UNSIGNED16 + 0 + Sync_modes_supported + Manufacturer + + + 0x05 + RO + Minimum Cycle Time + UNSIGNED32 + 125000 + Minimum_Cycle_Time + Manufacturer + + + 0x06 + RO + Calc and Copy Time + UNSIGNED32 + 0 + Calc_and_Copy_Time + Manufacturer + + + 0x07 + RO + Minimum Delay Time + UNSIGNED32 + 0 + Minimum_Delay_Time + Manufacturer + + + 0x08 + RO + GetCycleTime + UNSIGNED16 + 0 + GetCycleTime + Manufacturer + + + 0x09 + RO + DelayTime + UNSIGNED32 + 0 + DelayTime + Manufacturer + + + 0x0A + RO + Sync0CycleTime + UNSIGNED32 + 0 + Sync0CycleTime + Manufacturer + + + 0x0B + RO + SMEventMissedCnt + UNSIGNED16 + 0 + SMEventMissedCnt + Manufacturer + + + 0x0C + RO + CycleTimeTooSmallCnt + UNSIGNED16 + 0 + CycleTimeTooSmallCnt + Manufacturer + + + 0x0D + RO + Shift too short counter + UNSIGNED16 + 0 + Shift_too_short_counter + Manufacturer + + + 0x0E + RO + RxPDOToggleFailed + UNSIGNED16 + 0 + RxPDOToggleFailed + Manufacturer + + + 0x0F + RO + Minimum Cycle Distance + UNSIGNED32 + 0 + Minimum_Cycle_Distance + Manufacturer + + + 0x10 + RO + Maximum Cycle Distance + UNSIGNED32 + 0 + Maximum_Cycle_Distance + Manufacturer + + + 0x11 + RO + Minimum SM Sync Distance + UNSIGNED32 + 0 + Minimum_SM_Sync_Distance + Manufacturer + + + 0x12 + RO + Maximum SM Sync Distance + UNSIGNED32 + 0 + Maximum_SM_Sync_Distance + Manufacturer + + + 0x20 + RO + SyncError + BOOLEAN + 0 + SyncError + Manufacturer + + + + 0x6000 + Buttons + RECORD + Buttons + Input + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + RO + Button1 + UNSIGNED8 + 0 + TX + Button1 + Input + + + + 0x7000 + LEDgroup0 + RECORD + LEDgroup0 + Output + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + RO + LED0 + UNSIGNED8 + 0 + RX + LED0 + Output + + + + 0x7001 + LEDgroup1 + RECORD + LEDgroup1 + Output + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + RO + LED1 + UNSIGNED8 + 0 + RX + LED1 + Output + + + + 0x8000 + Parameters + RECORD + Parameters + Parameter + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + RO + Multiplier + UNSIGNED32 + 0 + Multiplier + Parameter + + + + 0x8001 + RW + variableRW + UNSIGNED32 + 0 + variableRW + Parameter + + + + 0x1C12 + 8 + + 0x01 + 0x1600 + + + 0x02 + 0x1601 + + + + 0x1C13 + 8 + + 0x01 + 0x1A00 + + + + 0x1600 + RXPDO 1 + + 0x1 + 0x7000 + 0x01 + LED0 + + + + 0x1601 + RXPDO 2 + + 0x1 + 0x7001 + 0x01 + LED1 + + + + 0x1602 + 8 + RXPDO 3 + + + 0x1A00 + TXPDO 1 + + 0x1 + 0x6000 + 0x01 + Button1 + + + + 0x1A01 + 8 + TXPDO 2 + + + 0x6000 + Buttons + TX + RECORD + + 0x01 + Button1 + UNSIGNED8 + TX + + + + 0x7000 + LEDgroup0 + RX + RECORD + + 0x01 + LED0 + UNSIGNED8 + RX + + + + 0x7001 + LEDgroup1 + RX + RECORD + + 0x01 + LED1 + UNSIGNED8 + RX + + + + 0x8000 + Parameters + NONE + RECORD + + 0x01 + Multiplier + UNSIGNED32 + NONE + + + + 0x8001 + RW + variableRW + UNSIGNED32 + NONE + VAR + + + 0x10F1 + ErrorSettings + NONE + RECORD + + 0x01 + RW + Local Error Reaction + UNSIGNED32 + NONE + + + 0x02 + RW + SyncErrorCounterLimit + UNSIGNED16 + 2 + NONE + + + + 0x1C32 + SyncMgrParam + NONE + RECORD + + 0x01 + RW + Sync mode + UNSIGNED16 + NONE + + + 0x02 + CycleTime + UNSIGNED32 + NONE + + + 0x03 + ShiftTime + UNSIGNED32 + NONE + + + 0x04 + Sync modes supported + UNSIGNED16 + NONE + + + 0x05 + Minimum Cycle Time + UNSIGNED32 + 125000 + NONE + + + 0x06 + Calc and Copy Time + UNSIGNED32 + NONE + + + 0x07 + Minimum Delay Time + UNSIGNED32 + NONE + + + 0x08 + GetCycleTime + UNSIGNED16 + NONE + + + 0x09 + DelayTime + UNSIGNED32 + NONE + + + 0x0A + Sync0CycleTime + UNSIGNED32 + NONE + + + 0x0B + SMEventMissedCnt + UNSIGNED16 + NONE + + + 0x0C + CycleTimeTooSmallCnt + UNSIGNED16 + NONE + + + 0x0D + Shift too short counter + UNSIGNED16 + NONE + + + 0x0E + RxPDOToggleFailed + UNSIGNED16 + NONE + + + 0x0F + Minimum Cycle Distance + UNSIGNED32 + NONE + + + 0x10 + Maximum Cycle Distance + UNSIGNED32 + NONE + + + 0x11 + Minimum SM Sync Distance + UNSIGNED32 + NONE + + + 0x12 + Maximum SM Sync Distance + UNSIGNED32 + NONE + + + 0x20 + SyncError + NONE + + + diff --git a/applications/rtl_xmc4_dynpdo/slave.xml b/applications/rtl_xmc4_dynpdo/slave.xml index 173194a..ea3f53f 100644 --- a/applications/rtl_xmc4_dynpdo/slave.xml +++ b/applications/rtl_xmc4_dynpdo/slave.xml @@ -8,14 +8,13 @@ xmc4 - MyGroup - LeGroup + xmc4 - xmc43_slave - xmc43relax + xmc48relax + xmc48relax xmc4 5001 @@ -78,7 +77,7 @@ DT10F1 - 40 + 64 0 Max SubIndex @@ -91,12 +90,12 @@ 1 - Dummy_x01 - USINT - 8 + Local Error Reaction + UDINT + 32 16 - ro + rw @@ -104,7 +103,7 @@ SyncErrorCounterLimit UINT 16 - 24 + 48 rw @@ -112,7 +111,55 @@ DT1600 - 112 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + LED0 + UDINT + 32 + 16 + + ro + + + + + DT1601 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + LED1 + UDINT + 32 + 16 + + ro + + + + + DT1602 + 272 0 Max SubIndex @@ -125,7 +172,7 @@ 1 - OUT1 + PDO Entry 1602:01 UDINT 32 16 @@ -135,7 +182,7 @@ 2 - OUT2 + PDO Entry 1602:02 UDINT 32 48 @@ -145,7 +192,7 @@ 3 - OUT3 + PDO Entry 1602:03 UDINT 32 80 @@ -153,10 +200,60 @@ rw + + 4 + PDO Entry 1602:04 + UDINT + 32 + 112 + + rw + + + + 5 + PDO Entry 1602:05 + UDINT + 32 + 144 + + rw + + + + 6 + PDO Entry 1602:06 + UDINT + 32 + 176 + + rw + + + + 7 + PDO Entry 1602:07 + UDINT + 32 + 208 + + rw + + + + 8 + PDO Entry 1602:08 + UDINT + 32 + 240 + + rw + + DT1A00 - 80 + 48 0 Max SubIndex @@ -164,33 +261,23 @@ 8 0 - rw + ro 1 - IN1 + Button1 UDINT 32 16 - rw - - - - 2 - Padding - UDINT - 32 - 48 - - rw + ro DT1A01 - 80 + 272 0 Max SubIndex @@ -198,95 +285,87 @@ 8 0 - ro + rw 1 - IN2 + PDO Entry 1A01:01 UDINT 32 16 - ro + rw 2 - Padding + PDO Entry 1A01:02 UDINT 32 48 - ro - - - - - DT1A02 - 80 - - 0 - Max SubIndex - USINT - 8 - 0 - - ro + rw - 1 - IN3 + 3 + PDO Entry 1A01:03 UDINT 32 - 16 + 80 - ro + rw - 2 - Padding + 4 + PDO Entry 1A01:04 UDINT 32 - 48 + 112 - ro - - - - - DT1A03 - 80 - - 0 - Max SubIndex - USINT - 8 - 0 - - ro + rw - 1 - IN4 + 5 + PDO Entry 1A01:05 UDINT 32 - 16 + 144 - ro + rw - 2 - Padding + 6 + PDO Entry 1A01:06 UDINT 32 - 48 + 176 - ro + rw + + + + 7 + PDO Entry 1A01:07 + UDINT + 32 + 208 + + rw + + + + 8 + PDO Entry 1A01:08 + UDINT + 32 + 240 + + rw @@ -325,15 +404,15 @@ DT1C12ARR UINT - 16 + 128 1 - 1 + 8 DT1C12 - 32 + 144 0 Max SubIndex @@ -347,7 +426,7 @@ Elements DT1C12ARR - 16 + 128 16 rw @@ -357,15 +436,15 @@ DT1C13ARR UINT - 64 + 128 1 - 4 + 8 DT1C13 - 80 + 144 0 Max SubIndex @@ -379,7 +458,7 @@ Elements DT1C13ARR - 64 + 128 16 rw @@ -388,7 +467,7 @@ DT1C32 - 496 + 488 0 Max SubIndex @@ -401,12 +480,12 @@ 1 - SyncType + Sync mode UINT 16 16 - ro + rw @@ -431,7 +510,7 @@ 4 - SyncTypeSupport + Sync modes supported UINT 16 96 @@ -441,7 +520,7 @@ 5 - MinCycleTime + Minimum Cycle Time UDINT 32 112 @@ -451,7 +530,7 @@ 6 - CalcCopyTime + Calc and Copy Time UDINT 32 144 @@ -461,7 +540,7 @@ 7 - MinDelayTime + Minimum Delay Time UDINT 32 176 @@ -521,7 +600,7 @@ 13 - ShiftTimeTooSmallCnt + Shift too short counter UINT 16 320 @@ -541,7 +620,7 @@ 15 - MinCycleDist + Minimum Cycle Distance UDINT 32 352 @@ -551,7 +630,7 @@ 16 - MaxCycleDist + Maximum Cycle Distance UDINT 32 384 @@ -561,7 +640,7 @@ 17 - MinSMSYNCDist + Minimum SM Sync Distance UDINT 32 416 @@ -571,7 +650,7 @@ 18 - MaxSMSYNCDist + Maximum SM Sync Distance UDINT 32 448 @@ -579,30 +658,20 @@ ro - - 20 - Dummy_x14 - USINT - 8 - 480 - - ro - - 32 SyncError - USINT - 8 - 488 + BOOL + 1 + 480 ro - DT7000 - 72 + DT6000 + 24 0 Max SubIndex @@ -615,8 +684,33 @@ 1 - OUT1 - SINT + Button1 + USINT + 8 + 16 + + ro + T + + + + + DT7000 + 24 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + LED0 + USINT 8 16 @@ -624,61 +718,68 @@ R + + + DT7001 + 24 - 2 - OUT2 - INT - 16 - 24 + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + LED1 + USINT + 8 + 16 ro R + + + DT8000 + 48 - 3 - OUT3 - DINT + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + Multiplier + UDINT 32 - 40 + 16 ro - R - INT - 16 + STRING(10) + 80 - SINT - 8 + BOOL + 1 STRING(3) 24 - - STRING(11) - 88 - - - BIT1 - 1 - - - BIT2 - 2 - - - BIT3 - 3 - - - BIT4 - 4 - UDINT 32 @@ -687,10 +788,6 @@ UINT 16 - - DINT - 32 - USINT 8 @@ -713,10 +810,10 @@ #x1008 Device Name - STRING(11) - 88 + STRING(10) + 80 - xmc43_slave + xmc48relax ro @@ -768,7 +865,7 @@ Product Code - #x10cc + #x4800 @@ -788,46 +885,11 @@ ro - - #x1600 - Outputs - DT1600 - 112 - - - Max SubIndex - - 3 - - - - OUT1 - - #x70000108 - - - - OUT2 - - #x70000210 - - - - OUT3 - - #x70000320 - - - - - rw - - #x10F1 ErrorSettings DT10F1 - 40 + 64 Max SubIndex @@ -836,7 +898,7 @@ - Dummy_x01 + Local Error Reaction 0 @@ -853,119 +915,202 @@ - #x1A00 - IN1 - DT1A00 - 80 + #x1600 + RXPDO 1 + DT1600 + 48 Max SubIndex - 2 + 1 - IN1 + LED0 - #x60000001 - - - - Padding - - #x00000007 + #x70000108 - rw + ro + + + + #x1601 + RXPDO 2 + DT1601 + 48 + + + Max SubIndex + + 1 + + + + LED1 + + #x70010108 + + + + + ro + + + + #x1602 + RXPDO 3 + DT1602 + 272 + + + Max SubIndex + + 8 + + + + PDO Entry 1602:01 + + #x00000000 + + + + PDO Entry 1602:02 + + #x00000000 + + + + PDO Entry 1602:03 + + #x00000000 + + + + PDO Entry 1602:04 + + #x00000000 + + + + PDO Entry 1602:05 + + #x00000000 + + + + PDO Entry 1602:06 + + #x00000000 + + + + PDO Entry 1602:07 + + #x00000000 + + + + PDO Entry 1602:08 + + #x00000000 + + + + + rw + + + + #x1A00 + TXPDO 1 + DT1A00 + 48 + + + Max SubIndex + + 1 + + + + Button1 + + #x60000108 + + + + + ro #x1A01 - IN2 + TXPDO 2 DT1A01 - 80 + 272 Max SubIndex - 2 + 8 - IN2 + PDO Entry 1A01:01 - #x60010002 + #x00000000 - Padding + PDO Entry 1A01:02 - #x00000006 + #x00000000 + + + + PDO Entry 1A01:03 + + #x00000000 + + + + PDO Entry 1A01:04 + + #x00000000 + + + + PDO Entry 1A01:05 + + #x00000000 + + + + PDO Entry 1A01:06 + + #x00000000 + + + + PDO Entry 1A01:07 + + #x00000000 + + + + PDO Entry 1A01:08 + + #x00000000 - 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 + rw @@ -1013,12 +1158,12 @@ #x1C12 Sync Manager 2 PDO Assignment DT1C12 - 32 + 144 Max SubIndex - 1 + 8 @@ -1027,21 +1172,63 @@ #x1600 + + PDO Mapping + + #x1601 + + + + SM Entry 1C12:03 + + #x0000 + + + + SM Entry 1C12:04 + + #x0000 + + + + SM Entry 1C12:05 + + #x0000 + + + + SM Entry 1C12:06 + + #x0000 + + + + SM Entry 1C12:07 + + #x0000 + + + + SM Entry 1C12:08 + + #x0000 + + - rw + rw #x1C13 Sync Manager 3 PDO Assignment DT1C13 - 80 + 144 Max SubIndex - 4 + 8 @@ -1051,33 +1238,57 @@ - PDO Mapping + SM Entry 1C13:02 - #x1A01 + #x0000 - PDO Mapping + SM Entry 1C13:03 - #x1A02 + #x0000 - PDO Mapping + SM Entry 1C13:04 - #x1A03 + #x0000 + + + + SM Entry 1C13:05 + + #x0000 + + + + SM Entry 1C13:06 + + #x0000 + + + + SM Entry 1C13:07 + + #x0000 + + + + SM Entry 1C13:08 + + #x0000 - rw + rw #x1C32 SyncMgrParam DT1C32 - 496 + 488 Max SubIndex @@ -1086,9 +1297,9 @@ - SyncType + Sync mode - 1 + 0 @@ -1104,25 +1315,25 @@ - SyncTypeSupport - - #x6 - - - - MinCycleTime - - 125000 - - - - CalcCopyTime + Sync modes supported 0 - MinDelayTime + Minimum Cycle Time + + 125000 + + + + Calc and Copy Time + + 0 + + + + Minimum Delay Time 0 @@ -1158,7 +1369,7 @@ - ShiftTimeTooSmallCnt + Shift too short counter 0 @@ -1170,31 +1381,25 @@ - MinCycleDist + Minimum Cycle Distance 0 - MaxCycleDist + Maximum Cycle Distance 0 - MinSMSYNCDist + Minimum SM Sync Distance 0 - MaxSMSYNCDist - - 0 - - - - Dummy_x14 + Maximum SM Sync Distance 0 @@ -1212,82 +1417,64 @@ #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 + Buttons + DT6000 + 24 Max SubIndex - 3 + 1 - OUT1 + Button1 0 + + + ro + + + + #x7000 + LEDgroup0 + DT7000 + 24 + - OUT2 + Max SubIndex + + 1 + + + + LED0 0 + + + ro + + + + #x7001 + LEDgroup1 + DT7001 + 24 + - OUT3 + Max SubIndex + + 1 + + + + LED1 0 @@ -1299,20 +1486,31 @@ #x8000 - PARAM1 - DINT - 32 + Parameters + DT8000 + 48 - 0 + + Max SubIndex + + 1 + + + + Multiplier + + 0 + + - rw + ro #x8001 - PARAM2 - DINT + variableRW + UDINT 32 0 @@ -1327,109 +1525,60 @@ Outputs Inputs MBoxState - MBoxOut - MBoxIn - Outputs - Inputs - + MBoxOut + MBoxIn + Outputs + Inputs + #x1600 - Outputs + RXPDO 1 #x7000 - 1 + #x1 8 - OUT1 - SINT - - - #x7000 - 2 - 16 - OUT2 - INT - - - #x7000 - 3 - 32 - OUT3 - DINT + LED0 + USINT - + + #x1601 + RXPDO 2 + + #x7001 + #x1 + 8 + LED1 + USINT + + + + #x1602 + RXPDO 3 + + #x1A00 - IN1 + TXPDO 1 #x6000 - 0 - 1 - IN1 - BIT1 - - - 0 - 0 - 7 + #x1 + 8 + Button1 + USINT - + #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 - + TXPDO 2 - - + 256 - 80068106000000000000 - 0010800080108000 + 8006810600000000 + 0010000200120002 - + \ No newline at end of file diff --git a/applications/rtl_xmc4_dynpdo/slave_objectlist.c b/applications/rtl_xmc4_dynpdo/slave_objectlist.c index 7f24692..c925d60 100644 --- a/applications/rtl_xmc4_dynpdo/slave_objectlist.c +++ b/applications/rtl_xmc4_dynpdo/slave_objectlist.c @@ -1,5 +1,3 @@ -#ifndef SOES_V1 -#include "esc.h" #include "esc_coe.h" #include "utypes.h" #include @@ -13,13 +11,9 @@ #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"; @@ -28,29 +22,37 @@ 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_01[] = "Local Error Reaction"; static const char acName10F1_02[] = "SyncErrorCounterLimit"; -static const char acName1600[] = "Outputs"; +static const char acName1600[] = "RXPDO 1"; 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 acName1600_01[] = "LED0"; +static const char acName1601[] = "RXPDO 2"; +static const char acName1601_00[] = "Max SubIndex"; +static const char acName1601_01[] = "LED1"; +static const char acName1602[] = "RXPDO 3"; +static const char acName1602_00[] = "Max SubIndex"; +static const char acName1602_01[] = "PDO Entry 1602:01"; +static const char acName1602_02[] = "PDO Entry 1602:02"; +static const char acName1602_03[] = "PDO Entry 1602:03"; +static const char acName1602_04[] = "PDO Entry 1602:04"; +static const char acName1602_05[] = "PDO Entry 1602:05"; +static const char acName1602_06[] = "PDO Entry 1602:06"; +static const char acName1602_07[] = "PDO Entry 1602:07"; +static const char acName1602_08[] = "PDO Entry 1602:08"; +static const char acName1A00[] = "TXPDO 1"; 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 acName1A00_01[] = "Button1"; +static const char acName1A01[] = "TXPDO 2"; 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 acName1A01_01[] = "PDO Entry 1A01:01"; +static const char acName1A01_02[] = "PDO Entry 1A01:02"; +static const char acName1A01_03[] = "PDO Entry 1A01:03"; +static const char acName1A01_04[] = "PDO Entry 1A01:04"; +static const char acName1A01_05[] = "PDO Entry 1A01:05"; +static const char acName1A01_06[] = "PDO Entry 1A01:06"; +static const char acName1A01_07[] = "PDO Entry 1A01:07"; +static const char acName1A01_08[] = "PDO Entry 1A01:08"; static const char acName1C00[] = "Sync Manager Communication Type"; static const char acName1C00_00[] = "Max SubIndex"; static const char acName1C00_01[] = "Communications Type SM0"; @@ -61,116 +63,125 @@ 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 acName1C12_03[] = "SM Entry 1C12:03"; +static const char acName1C12_04[] = "SM Entry 1C12:04"; +static const char acName1C12_05[] = "SM Entry 1C12:05"; +static const char acName1C12_06[] = "SM Entry 1C12:06"; +static const char acName1C12_07[] = "SM Entry 1C12:07"; +static const char acName1C12_08[] = "SM Entry 1C12:08"; 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 acName1C13_02[] = "SM Entry 1C13:02"; +static const char acName1C13_03[] = "SM Entry 1C13:03"; +static const char acName1C13_04[] = "SM Entry 1C13:04"; +static const char acName1C13_05[] = "SM Entry 1C13:05"; +static const char acName1C13_06[] = "SM Entry 1C13:06"; +static const char acName1C13_07[] = "SM Entry 1C13:07"; +static const char acName1C13_08[] = "SM Entry 1C13:08"; static const char acName1C32[] = "SyncMgrParam"; static const char acName1C32_00[] = "Max SubIndex"; -static const char acName1C32_01[] = "SyncType"; +static const char acName1C32_01[] = "Sync mode"; 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_04[] = "Sync modes supported"; +static const char acName1C32_05[] = "Minimum Cycle Time"; +static const char acName1C32_06[] = "Calc and Copy Time"; +static const char acName1C32_07[] = "Minimum Delay Time"; 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_0D[] = "Shift too short counter"; 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_0F[] = "Minimum Cycle Distance"; +static const char acName1C32_10[] = "Maximum Cycle Distance"; +static const char acName1C32_11[] = "Minimum SM Sync Distance"; +static const char acName1C32_12[] = "Maximum SM Sync Distance"; 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 acName6000[] = "Buttons"; +static const char acName6000_00[] = "Max SubIndex"; +static const char acName6000_01[] = "Button1"; +static const char acName7000[] = "LEDgroup0"; 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"; +static const char acName7000_01[] = "LED0"; +static const char acName7001[] = "LEDgroup1"; +static const char acName7001_00[] = "Max SubIndex"; +static const char acName7001_01[] = "LED1"; +static const char acName8000[] = "Parameters"; +static const char acName8000_00[] = "Max SubIndex"; +static const char acName8000_01[] = "Multiplier"; +static const char acName8001[] = "variableRW"; const _objd SDO1000[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000_0, 0x00001389, NULL}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 0x00001389, NULL}, }; const _objd SDO1008[] = { - {0x0, DTYPE_VISIBLE_STRING, 40, ATYPE_RO, acName1008_0, 0, "slave"}, + {0x0, DTYPE_VISIBLE_STRING, 80, ATYPE_RO, acName1008, 0, "xmc48relax"}, }; const _objd SDO1009[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, HW_REV}, + {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009, 0, HW_REV}, }; const _objd SDO100A[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, SW_REV}, + {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A, 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}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_02, 0x4800, 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}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName10F1_01, 0, &Obj.ErrorSettings.Local_Error_Reaction}, {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]}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1600_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70000108, NULL}, +}; +const _objd SDO1601[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70010108, NULL}, +}; +const _objd SDO1602[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RWpre, acName1602_00, 8, &Obj.PDO1602.maxsub}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1602_01, 0x00000000, &Obj.PDO1602.value[0]}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1602_02, 0x00000000, &Obj.PDO1602.value[1]}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1602_03, 0x00000000, &Obj.PDO1602.value[2]}, + {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1602_04, 0x00000000, &Obj.PDO1602.value[3]}, + {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1602_05, 0x00000000, &Obj.PDO1602.value[4]}, + {0x06, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1602_06, 0x00000000, &Obj.PDO1602.value[5]}, + {0x07, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1602_07, 0x00000000, &Obj.PDO1602.value[6]}, + {0x08, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1602_08, 0x00000000, &Obj.PDO1602.value[7]}, }; 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]}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60000108, NULL}, }; 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}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RWpre, acName1A01_00, 8, &Obj.PDO1A01.maxsub}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A01_01, 0x00000000, &Obj.PDO1A01.value[0]}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A01_02, 0x00000000, &Obj.PDO1A01.value[1]}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A01_03, 0x00000000, &Obj.PDO1A01.value[2]}, + {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A01_04, 0x00000000, &Obj.PDO1A01.value[3]}, + {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A01_05, 0x00000000, &Obj.PDO1A01.value[4]}, + {0x06, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A01_06, 0x00000000, &Obj.PDO1A01.value[5]}, + {0x07, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A01_07, 0x00000000, &Obj.PDO1A01.value[6]}, + {0x08, DTYPE_UNSIGNED32, 32, ATYPE_RWpre, acName1A01_08, 0x00000000, &Obj.PDO1A01.value[7]}, }; const _objd SDO1C00[] = { @@ -182,76 +193,74 @@ const _objd SDO1C00[] = }; 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]}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RWpre, acName1C12_00, 8, &Obj.SM1C12.maxsub}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_01, 0x1600, &Obj.SM1C12.value[0]}, + {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_02, 0x1601, &Obj.SM1C12.value[1]}, + {0x03, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_03, 0x0000, &Obj.SM1C12.value[2]}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_04, 0x0000, &Obj.SM1C12.value[3]}, + {0x05, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_05, 0x0000, &Obj.SM1C12.value[4]}, + {0x06, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_06, 0x0000, &Obj.SM1C12.value[5]}, + {0x07, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_07, 0x0000, &Obj.SM1C12.value[6]}, + {0x08, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C12_08, 0x0000, &Obj.SM1C12.value[7]}, }; 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]}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RWpre, acName1C13_00, 8, &Obj.SM1C13.maxsub}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_01, 0x1A00, &Obj.SM1C13.value[0]}, + {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_02, 0x0000, &Obj.SM1C13.value[1]}, + {0x03, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_03, 0x0000, &Obj.SM1C13.value[2]}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_04, 0x0000, &Obj.SM1C13.value[3]}, + {0x05, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_05, 0x0000, &Obj.SM1C13.value[4]}, + {0x06, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_06, 0x0000, &Obj.SM1C13.value[5]}, + {0x07, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_07, 0x0000, &Obj.SM1C13.value[6]}, + {0x08, DTYPE_UNSIGNED16, 16, ATYPE_RWpre, acName1C13_08, 0x0000, &Obj.SM1C13.value[7]}, }; 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}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName1C32_01, 0, &Obj.SyncMgrParam.Sync_mode}, {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}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_04, 0, &Obj.SyncMgrParam.Sync_modes_supported}, + {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_05, 125000, &Obj.SyncMgrParam.Minimum_Cycle_Time}, + {0x06, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_06, 0, &Obj.SyncMgrParam.Calc_and_Copy_Time}, + {0x07, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_07, 0, &Obj.SyncMgrParam.Minimum_Delay_Time}, {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}, + {0x0D, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0D, 0, &Obj.SyncMgrParam.Shift_too_short_counter}, {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}, + {0x0F, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_0F, 0, &Obj.SyncMgrParam.Minimum_Cycle_Distance}, + {0x10, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_10, 0, &Obj.SyncMgrParam.Maximum_Cycle_Distance}, + {0x11, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_11, 0, &Obj.SyncMgrParam.Minimum_SM_Sync_Distance}, + {0x12, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_12, 0, &Obj.SyncMgrParam.Maximum_SM_Sync_Distance}, + {0x20, DTYPE_BOOLEAN, 1, 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}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6000_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_TXPDO, acName6000_01, 0, &Obj.Buttons.Button1}, }; 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}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_RXPDO, acName7000_01, 0, &Obj.LEDgroup0.LED0}, +}; +const _objd SDO7001[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7001_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_RXPDO, acName7001_01, 0, &Obj.LEDgroup1.LED1}, }; const _objd SDO8000[] = { - {0x0, DTYPE_INTEGER32, 32, ATYPE_RW, acName8000_0, 0x42, &Obj.PARAM1}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName8000_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName8000_01, 0, &Obj.Parameters.Multiplier}, }; const _objd SDO8001[] = { - {0x0, DTYPE_INTEGER32, 32, ATYPE_RW, acName8001_0, 99, &Obj.PARAM2}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8001, 0, &Obj.variableRW}, }; const _objectlist SDOobjects[] = @@ -262,22 +271,19 @@ const _objectlist SDOobjects[] = {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}, + {0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600}, + {0x1601, OTYPE_RECORD, 1, 0, acName1601, SDO1601}, + {0x1602, OTYPE_RECORD, 8, 0, acName1602, SDO1602}, + {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, + {0x1A01, OTYPE_RECORD, 8, 0, acName1A01, SDO1A01}, {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}, + {0x1C12, OTYPE_ARRAY, 8, 0, acName1C12, SDO1C12}, + {0x1C13, OTYPE_ARRAY, 8, 0, acName1C13, SDO1C13}, + {0x1C32, OTYPE_RECORD, 19, 0, acName1C32, SDO1C32}, + {0x6000, OTYPE_RECORD, 1, 0, acName6000, SDO6000}, + {0x7000, OTYPE_RECORD, 1, 0, acName7000, SDO7000}, + {0x7001, OTYPE_RECORD, 1, 0, acName7001, SDO7001}, + {0x8000, OTYPE_RECORD, 1, 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 index 795ae5b..f63a0e1 100644 --- a/applications/rtl_xmc4_dynpdo/utypes.h +++ b/applications/rtl_xmc4_dynpdo/utypes.h @@ -1,75 +1,96 @@ #ifndef __UTYPES_H__ #define __UTYPES_H__ -#include -#include "config.h" +#include "cc.h" -/* NOTE: Not packed, does not use bitfields */ +/* Object dictionary storage */ typedef struct { /* Inputs */ - uint8_t IN1; /* (BIT1) */ - uint8_t IN2; /* (BIT2) */ - uint8_t IN3; /* (BIT3) */ - uint8_t IN4; /* (BIT4) */ + + struct + { + uint8_t Button1; + } Buttons; /* Outputs */ + struct { - int8_t OUT1; - int16_t OUT2; - int32_t OUT3; - } Outputs; + uint8_t LED0; + } LEDgroup0; + struct + { + uint8_t LED1; + } LEDgroup1; /* Parameters */ - int32_t PARAM1; - int32_t PARAM2; - /* Manufacturer specific data */ struct { - uint16_t SyncType; + uint32_t Multiplier; + } Parameters; + uint32_t variableRW; + + /* Manufacturer specific data */ + + struct + { + uint32_t Local_Error_Reaction; + uint16_t SyncErrorCounterLimit; + } ErrorSettings; + struct + { + uint16_t Sync_mode; uint32_t CycleTime; uint32_t ShiftTime; - uint16_t SyncTypeSupport; - uint32_t MinCycleTime; - uint32_t CalcCopyTime; - uint32_t MinDelayTime; + uint16_t Sync_modes_supported; + uint32_t Minimum_Cycle_Time; + uint32_t Calc_and_Copy_Time; + uint32_t Minimum_Delay_Time; uint16_t GetCycleTime; uint32_t DelayTime; uint32_t Sync0CycleTime; uint16_t SMEventMissedCnt; uint16_t CycleTimeTooSmallCnt; - uint16_t ShiftTimeTooSmallCnt; + uint16_t Shift_too_short_counter; uint16_t RxPDOToggleFailed; - uint32_t MinCycleDist; - uint32_t MaxCycleDist; - uint32_t MinSMSYNCDist; - uint32_t MaxSMSYNCDist; - uint8_t Dummy_x14; + uint32_t Minimum_Cycle_Distance; + uint32_t Maximum_Cycle_Distance; + uint32_t Minimum_SM_Sync_Distance; + uint32_t Maximum_SM_Sync_Distance; 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 */ + /* Dynamic TX PDO:s */ + struct { uint8_t maxsub; - uint16_t value[4]; - } SM[2]; + uint32_t value[8]; + } PDO1A01; + + /* Dynamic RX PDO:s */ + + struct + { + uint8_t maxsub; + uint32_t value[8]; + } PDO1602; + + /* Dynamic Sync Managers */ + + struct + { + uint8_t maxsub; + uint32_t value[8]; + } SM1C12; + struct + { + uint8_t maxsub; + uint32_t value[8]; + } SM1C13; } _Objects; diff --git a/applications/rtl_xmc4_irq/config.h b/applications/rtl_xmc4_irq/config.h deleted file mode 100644 index abce50c..0000000 --- a/applications/rtl_xmc4_irq/config.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#include - -#define MBXSIZE 128 -#define MBXSIZEBOOT 256 -#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 0x64 -#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_irq/ecat_options.h b/applications/rtl_xmc4_irq/ecat_options.h new file mode 100644 index 0000000..ba8a47a --- /dev/null +++ b/applications/rtl_xmc4_irq/ecat_options.h @@ -0,0 +1,44 @@ +#ifndef __ECAT_OPTIONS_H__ +#define __ECAT_OPTIONS_H__ + +#include "cc.h" + +#define USE_FOE 0 +#define USE_EOE 0 + +#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 0x64 +#define SM2_act 1 +#define SM3_sma 0x1180 +#define SM3_smc 0x20 +#define SM3_act 1 + +#define MAX_RXPDO_SIZE 42 +#define MAX_TXPDO_SIZE 42 + +#define MAX_MAPPINGS_SM2 2 +#define MAX_MAPPINGS_SM3 1 + +#endif /* __ECAT_OPTIONS_H__ */ diff --git a/applications/rtl_xmc4_irq/main.c b/applications/rtl_xmc4_irq/main.c index 8efe475..13ee295 100644 --- a/applications/rtl_xmc4_irq/main.c +++ b/applications/rtl_xmc4_irq/main.c @@ -1,3 +1,7 @@ +/* + * Licensed under the GNU General Public License version 2 with exceptions. See + * LICENSE file in the project root for full license information + */ #include #include @@ -9,12 +13,15 @@ #include "config.h" #include "utypes.h" +/* Application variables */ +_Objects Obj; + /** * This function is called when to get input values */ void cb_get_inputs() { - Rb.Buttons.Button1 = gpio_get(GPIO_BUTTON1); + Obj.Buttons.Button1 = gpio_get(GPIO_BUTTON1); } /** @@ -22,20 +29,8 @@ void cb_get_inputs() */ void cb_set_outputs() { - gpio_set(GPIO_LED1, Wb.LEDgroup0.LED0); - gpio_set(GPIO_LED2, Wb.LEDgroup1.LED1); -} - -/** Optional: Hook called after state change for application specific - * actions for specific state changes. - */ -void post_state_change_hook (uint8_t * as, uint8_t * an) -{ - /* Add specific step change hooks here */ - if ((*as == SAFEOP_TO_OP)) - { - ESC_ALeventmaskwrite(ESC_ALeventmaskread() | ESCREG_ALEVENT_WD); - } + gpio_set(GPIO_LED1, Obj.LEDgroup0.LED0); + gpio_set(GPIO_LED2, Obj.LEDgroup1.LED1); } void safe_out(void) @@ -44,13 +39,22 @@ void safe_out(void) return; } +void cb_state_change (uint8_t * as, uint8_t * an) +{ + if (*as == SAFEOP_TO_OP) + { + /* Enable watchdog interrupt */ + ESC_ALeventmaskwrite(ESC_ALeventmaskread() | ESCREG_ALEVENT_WD); + } +} + /* Setup of DC */ uint16_t dc_checker(void) { /* Indicate we run DC */ ESCvar.dcsync = 1; /* Fetch the sync counter limit SDO10F1*/ - ESCvar.synccounterlimit = Mb.ErrorSettings.SyncErrorCounterLimit; + ESCvar.synccounterlimit = Obj.ErrorSettings.SyncErrorCounterLimit; return 0; } @@ -60,26 +64,16 @@ uint16_t dc_checker(void) */ int main(void) { - esc_cfg_t config = + 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, - .rxpdosaddress = &Wb, - .txpdosaddress = &Rb, - .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}, + .set_defaults_hook = NULL, .pre_state_change_hook = NULL, - .post_state_change_hook = post_state_change_hook, + .post_state_change_hook = cb_state_change, .application_hook = NULL, - .safeoutput_override = safe_out, + .safeoutput_override = NULL, .pre_object_download_hook = NULL, .post_object_download_hook = NULL, .rxpdo_override = NULL, @@ -87,7 +81,7 @@ int main(void) .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 + .esc_check_dc_handler = NULL }; rprintf("Hello Main\n"); diff --git a/applications/rtl_xmc4_irq/slave.bin b/applications/rtl_xmc4_irq/slave.bin index 03aba02..8dd83b3 100644 Binary files a/applications/rtl_xmc4_irq/slave.bin and b/applications/rtl_xmc4_irq/slave.bin differ diff --git a/applications/rtl_xmc4_irq/slave.c b/applications/rtl_xmc4_irq/slave.c deleted file mode 100644 index 9995605..0000000 --- a/applications/rtl_xmc4_irq/slave.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include "utypes.h" -#include "config.h" -#include "esc.h" - -/* Global variables used by the stack */ -uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)]; -_MBXcontrol MBXcontrol[MBXBUFFERS]; -_ESCvar ESCvar; - -/* Application variables */ -_Rbuffer Rb; -_Wbuffer Wb; -_Cbuffer Cb; -_Mbuffer Mb; diff --git a/applications/rtl_xmc4_irq/slave.esx b/applications/rtl_xmc4_irq/slave.esx index e2a35f6..ddd246f 100644 --- a/applications/rtl_xmc4_irq/slave.esx +++ b/applications/rtl_xmc4_irq/slave.esx @@ -1,5 +1,5 @@ - + xmc43relax 0x1337 @@ -16,724 +16,763 @@ MBoxIn Outputs Inputs - - + + 8006810600000000 - 0010000100110001 + 0010800080108000 - - Device Type + 0x1000 + Device Type UNSIGNED32 0x00001389 - Device Name 0x1008 + Device Name VISIBLE_STRING - xmc43_slave + xmc43relax + 10 - Hardware Version 0x1009 + Hardware Version VISIBLE_STRING 1.0 + 4 - Software Version 0x100A + Software Version VISIBLE_STRING 1.0 + 4 - Identity Object 0x1018 + Identity Object RECORD - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 4 - Vendor ID 0x01 + Vendor ID UNSIGNED32 0x1337 - Product Code 0x02 + Product Code UNSIGNED32 0x4300 - Revision Number 0x03 + Revision Number UNSIGNED32 0 - Serial Number 0x04 + Serial Number UNSIGNED32 0x00000000 - ErrorSettings 0x10F1 + ErrorSettings RECORD ErrorSettings Manufacturer - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 2 - Dummy_x01 0x01 - UNSIGNED8 + RW + Local Error Reaction + UNSIGNED32 0 - RO - Dummy_x01 + Local_Error_Reaction Manufacturer - SyncErrorCounterLimit 0x02 + RW + SyncErrorCounterLimit UNSIGNED16 2 - RW SyncErrorCounterLimit Manufacturer - LEDgroup0 0x1600 + LEDgroup0 RECORD - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 + 0x01 LED0 - 0x01 UNSIGNED32 - 0x70050108 + 0x70000108 - LEDgroup1 0x1601 + LEDgroup1 RECORD - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 + 0x01 LED1 - 0x01 UNSIGNED32 - 0x70060108 + 0x70010108 - Buttons 0x1A00 + Buttons RECORD - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - Button1 0x01 + Button1 UNSIGNED32 - 0x60050108 + 0x60000108 - Sync Manager Communication Type 0x1C00 + Sync Manager Communication Type ARRAY - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 4 - Communications Type SM0 0x01 + Communications Type SM0 UNSIGNED8 1 - Communications Type SM1 0x02 + Communications Type SM1 UNSIGNED8 2 - Communications Type SM2 0x03 + Communications Type SM2 UNSIGNED8 3 - Communications Type SM3 0x04 + Communications Type SM3 UNSIGNED8 4 - Sync Manager 2 PDO Assignment 0x1C12 + Sync Manager 2 PDO Assignment ARRAY - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 2 - PDO Mapping 0x01 + PDO Mapping UNSIGNED16 0x1600 - PDO Mapping 0x02 + PDO Mapping UNSIGNED16 0x1601 - Sync Manager 3 PDO Assignment 0x1C13 + Sync Manager 3 PDO Assignment ARRAY - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - PDO Mapping 0x01 + PDO Mapping UNSIGNED16 0x1A00 - SyncMgrParam 0x1C32 + SyncMgrParam RECORD SyncMgrParam Manufacturer - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 32 - SyncType 0x01 + RW + Sync mode UNSIGNED16 - 1 - RO - SyncType + 0 + Sync_mode Manufacturer - CycleTime 0x02 + RO + CycleTime UNSIGNED32 0 - RO CycleTime Manufacturer - ShiftTime 0x03 + RO + ShiftTime UNSIGNED32 0 - RO ShiftTime Manufacturer - SyncTypeSupport 0x04 - UNSIGNED16 - 0x6 RO - SyncTypeSupport + Sync modes supported + UNSIGNED16 + 0 + Sync_modes_supported Manufacturer - MinCycleTime 0x05 + RO + Minimum Cycle Time UNSIGNED32 125000 - RO - MinCycleTime + Minimum_Cycle_Time Manufacturer - CalcCopyTime 0x06 + RO + Calc and Copy Time UNSIGNED32 0 - RO - CalcCopyTime + Calc_and_Copy_Time Manufacturer - MinDelayTime 0x07 + RO + Minimum Delay Time UNSIGNED32 0 - RO - MinDelayTime + Minimum_Delay_Time Manufacturer - GetCycleTime 0x08 + RO + GetCycleTime UNSIGNED16 0 - RO GetCycleTime Manufacturer - DelayTime 0x09 + RO + DelayTime UNSIGNED32 0 - RO DelayTime Manufacturer - Sync0CycleTime 0x0A + RO + Sync0CycleTime UNSIGNED32 0 - RO Sync0CycleTime Manufacturer - SMEventMissedCnt 0x0B + RO + SMEventMissedCnt UNSIGNED16 0 - RO SMEventMissedCnt Manufacturer - CycleTimeTooSmallCnt 0x0C + RO + CycleTimeTooSmallCnt UNSIGNED16 0 - RO CycleTimeTooSmallCnt Manufacturer - ShiftTimeTooSmallCnt 0x0D + RO + Shift too short counter UNSIGNED16 0 - RO - ShiftTimeTooSmallCnt + Shift_too_short_counter Manufacturer - RxPDOToggleFailed 0x0E + RO + RxPDOToggleFailed UNSIGNED16 0 - RO RxPDOToggleFailed Manufacturer - MinCycleDist 0x0F + RO + Minimum Cycle Distance UNSIGNED32 0 - RO - MinCycleDist + Minimum_Cycle_Distance Manufacturer - MaxCycleDist 0x10 + RO + Maximum Cycle Distance UNSIGNED32 0 - RO - MaxCycleDist + Maximum_Cycle_Distance Manufacturer - MinSMSYNCDist 0x11 + RO + Minimum SM Sync Distance UNSIGNED32 0 - RO - MinSMSYNCDist + Minimum_SM_Sync_Distance Manufacturer - MaxSMSYNCDist 0x12 + RO + Maximum SM Sync Distance UNSIGNED32 0 - RO - MaxSMSYNCDist + Maximum_SM_Sync_Distance Manufacturer - Dummy_x14 - 0x14 - UNSIGNED8 - 0 - RO - Dummy_x14 - Manufacturer - - - SyncError 0x20 - UNSIGNED8 - 0 RO + SyncError + BOOLEAN + 0 SyncError Manufacturer + 0x6000 Buttons - 0x6005 RECORD Buttons Input - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - Button1 0x01 + RO + Button1 UNSIGNED8 0 - RO + TX Button1 Input + 0x7000 LEDgroup0 - 0x7005 RECORD LEDgroup0 Output - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - LED0 0x01 + RO + LED0 UNSIGNED8 0 - RO + RX LED0 Output + 0x7001 LEDgroup1 - 0x7006 RECORD LEDgroup1 Output - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - LED1 0x01 + RO + LED1 UNSIGNED8 0 - RO + RX LED1 Output - Parameters 0x8000 + Parameters RECORD Parameters Parameter - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - Multiplier 0x01 + RO + Multiplier UNSIGNED32 0 - RW Multiplier Parameter - variableRW 0x8001 + RW + variableRW UNSIGNED32 0 - RW variableRW Parameter + + 0x1C12 + + 0x01 + 0x1600 + + + 0x02 + 0x1601 + + + + 0x1C13 + + 0x01 + 0x1A00 + + 0x1600 - LEDgroup0 LEDgroup0 - 0x7005 - 1 + 0x1 + 0x7000 + 0x01 LED0 0x1601 - LEDgroup1 LEDgroup1 - 0x7006 - 1 + 0x1 + 0x7001 + 0x01 LED1 0x1A00 - Buttons Buttons - 0x6005 - 1 + 0x1 + 0x6000 + 0x01 Button1 - 0x6005 + 0x6000 Buttons + TX RECORD 0x01 Button1 UNSIGNED8 + TX - 0x7005 + 0x7000 LEDgroup0 + RX RECORD 0x01 LED0 UNSIGNED8 + RX - 0x7006 + 0x7001 LEDgroup1 + RX RECORD 0x01 LED1 UNSIGNED8 + RX 0x8000 Parameters + NONE RECORD 0x01 Multiplier UNSIGNED32 - RW + NONE 0x8001 + RW variableRW UNSIGNED32 - RW + NONE VAR - 0x1C32 - SyncMgrParam + 0x10F1 + ErrorSettings + NONE RECORD 0x01 - SyncType + RW + Local Error Reaction + UNSIGNED32 + NONE + + + 0x02 + RW + SyncErrorCounterLimit UNSIGNED16 - 1 + 2 + NONE + + + + 0x1C32 + SyncMgrParam + NONE + RECORD + + 0x01 + RW + Sync mode + UNSIGNED16 + NONE 0x02 CycleTime UNSIGNED32 + NONE 0x03 ShiftTime UNSIGNED32 + NONE 0x04 - SyncTypeSupport + Sync modes supported UNSIGNED16 - 0x6 + NONE 0x05 - MinCycleTime + Minimum Cycle Time UNSIGNED32 125000 + NONE 0x06 - CalcCopyTime + Calc and Copy Time UNSIGNED32 + NONE 0x07 - MinDelayTime + Minimum Delay Time UNSIGNED32 + NONE 0x08 GetCycleTime UNSIGNED16 + NONE 0x09 DelayTime UNSIGNED32 + NONE 0x0A Sync0CycleTime UNSIGNED32 + NONE 0x0B SMEventMissedCnt UNSIGNED16 + NONE 0x0C CycleTimeTooSmallCnt UNSIGNED16 + NONE 0x0D - ShiftTimeTooSmallCnt + Shift too short counter UNSIGNED16 + NONE 0x0E RxPDOToggleFailed UNSIGNED16 + NONE 0x0F - MinCycleDist + Minimum Cycle Distance UNSIGNED32 + NONE 0x10 - MaxCycleDist + Maximum Cycle Distance UNSIGNED32 + NONE 0x11 - MinSMSYNCDist + Minimum SM Sync Distance UNSIGNED32 + NONE 0x12 - MaxSMSYNCDist + Maximum SM Sync Distance UNSIGNED32 - - - 0x14 - Dummy_x14 - UNSIGNED8 + NONE 0x20 SyncError - UNSIGNED8 - RO + NONE - - 0x10F1 - ErrorSettings - RECORD - - 0x01 - Dummy_x01 - UNSIGNED8 - - - 0x02 - SyncErrorCounterLimit - UNSIGNED16 - 2 - RW - - - \ No newline at end of file + diff --git a/applications/rtl_xmc4_irq/slave.xml b/applications/rtl_xmc4_irq/slave.xml index 4de4aba..dee01df 100644 --- a/applications/rtl_xmc4_irq/slave.xml +++ b/applications/rtl_xmc4_irq/slave.xml @@ -13,7 +13,7 @@ - xmc43_slave + xmc43relax xmc43relax xmc4 @@ -77,7 +77,7 @@ DT10F1 - 40 + 64 0 Max SubIndex @@ -90,12 +90,12 @@ 1 - Dummy_x01 - USINT - 8 + Local Error Reaction + UDINT + 32 16 - ro + rw @@ -103,7 +103,7 @@ SyncErrorCounterLimit UINT 16 - 24 + 48 rw @@ -279,7 +279,7 @@ DT1C32 - 496 + 488 0 Max SubIndex @@ -292,12 +292,12 @@ 1 - SyncType + Sync mode UINT 16 16 - ro + rw @@ -322,7 +322,7 @@ 4 - SyncTypeSupport + Sync modes supported UINT 16 96 @@ -332,7 +332,7 @@ 5 - MinCycleTime + Minimum Cycle Time UDINT 32 112 @@ -342,7 +342,7 @@ 6 - CalcCopyTime + Calc and Copy Time UDINT 32 144 @@ -352,7 +352,7 @@ 7 - MinDelayTime + Minimum Delay Time UDINT 32 176 @@ -412,7 +412,7 @@ 13 - ShiftTimeTooSmallCnt + Shift too short counter UINT 16 320 @@ -432,7 +432,7 @@ 15 - MinCycleDist + Minimum Cycle Distance UDINT 32 352 @@ -442,7 +442,7 @@ 16 - MaxCycleDist + Maximum Cycle Distance UDINT 32 384 @@ -452,7 +452,7 @@ 17 - MinSMSYNCDist + Minimum SM Sync Distance UDINT 32 416 @@ -462,7 +462,7 @@ 18 - MaxSMSYNCDist + Maximum SM Sync Distance UDINT 32 448 @@ -470,29 +470,19 @@ ro - - 20 - Dummy_x14 - USINT - 8 - 480 - - ro - - 32 SyncError - USINT - 8 - 488 + BOOL + 1 + 480 ro - DT6005 + DT6000 24 0 @@ -512,11 +502,12 @@ 16 ro + T - DT7005 + DT7000 24 0 @@ -536,11 +527,12 @@ 16 ro + R - DT7006 + DT7001 24 0 @@ -560,6 +552,7 @@ 16 ro + R @@ -583,17 +576,21 @@ 32 16 - rw + ro - STRING(3) - 24 + STRING(4) + 32 - STRING(11) - 88 + STRING(10) + 80 + + + BOOL + 1 UDINT @@ -625,10 +622,10 @@ #x1008 Device Name - STRING(11) - 88 + STRING(10) + 80 - xmc43_slave + xmc43relax ro @@ -637,8 +634,8 @@ #x1009 Hardware Version - STRING(3) - 24 + STRING(4) + 32 1.0 @@ -650,8 +647,8 @@ #x100A Software Version - STRING(3) - 24 + STRING(4) + 32 1.0 @@ -704,7 +701,7 @@ #x10F1 ErrorSettings DT10F1 - 40 + 64 Max SubIndex @@ -713,7 +710,7 @@ - Dummy_x01 + Local Error Reaction 0 @@ -744,7 +741,7 @@ LED0 - #x70050108 + #x70000108 @@ -767,7 +764,7 @@ LED1 - #x70060108 + #x70010108 @@ -790,7 +787,7 @@ Button1 - #x60050108 + #x60000108 @@ -895,7 +892,7 @@ #x1C32 SyncMgrParam DT1C32 - 496 + 488 Max SubIndex @@ -904,9 +901,9 @@ - SyncType + Sync mode - 1 + 0 @@ -922,25 +919,25 @@ - SyncTypeSupport - - #x6 - - - - MinCycleTime - - 125000 - - - - CalcCopyTime + Sync modes supported 0 - MinDelayTime + Minimum Cycle Time + + 125000 + + + + Calc and Copy Time + + 0 + + + + Minimum Delay Time 0 @@ -976,7 +973,7 @@ - ShiftTimeTooSmallCnt + Shift too short counter 0 @@ -988,31 +985,25 @@ - MinCycleDist + Minimum Cycle Distance 0 - MaxCycleDist + Maximum Cycle Distance 0 - MinSMSYNCDist + Minimum SM Sync Distance 0 - MaxSMSYNCDist - - 0 - - - - Dummy_x14 + Maximum SM Sync Distance 0 @@ -1029,9 +1020,9 @@ - #x6005 + #x6000 Buttons - DT6005 + DT6000 24 @@ -1052,9 +1043,9 @@ - #x7005 + #x7000 LEDgroup0 - DT7005 + DT7000 24 @@ -1075,9 +1066,9 @@ - #x7006 + #x7001 LEDgroup1 - DT7006 + DT7001 24 @@ -1146,8 +1137,8 @@ #x1600 LEDgroup0 - #x7005 - 1 + #x7000 + #x1 8 LED0 USINT @@ -1157,8 +1148,8 @@ #x1601 LEDgroup1 - #x7006 - 1 + #x7001 + #x1 8 LED1 USINT @@ -1168,21 +1159,20 @@ #x1A00 Buttons - #x6005 - 1 + #x6000 + #x1 8 Button1 USINT - - + 256 8006810600000000 - 0010000100110001 + 0010800080108000 diff --git a/applications/rtl_xmc4_irq/slave_objectlist.c b/applications/rtl_xmc4_irq/slave_objectlist.c index 3fc2c21..496f07a 100644 --- a/applications/rtl_xmc4_irq/slave_objectlist.c +++ b/applications/rtl_xmc4_irq/slave_objectlist.c @@ -1,4 +1,3 @@ -#ifndef SOES_V1 #include "esc_coe.h" #include "utypes.h" #include @@ -12,13 +11,9 @@ #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"; @@ -27,7 +22,7 @@ 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_01[] = "Local Error Reaction"; static const char acName10F1_02[] = "SyncErrorCounterLimit"; static const char acName1600[] = "LEDgroup0"; static const char acName1600_00[] = "Max SubIndex"; @@ -53,56 +48,54 @@ static const char acName1C13_00[] = "Max SubIndex"; static const char acName1C13_01[] = "PDO Mapping"; static const char acName1C32[] = "SyncMgrParam"; static const char acName1C32_00[] = "Max SubIndex"; -static const char acName1C32_01[] = "SyncType"; +static const char acName1C32_01[] = "Sync mode"; 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_04[] = "Sync modes supported"; +static const char acName1C32_05[] = "Minimum Cycle Time"; +static const char acName1C32_06[] = "Calc and Copy Time"; +static const char acName1C32_07[] = "Minimum Delay Time"; 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_0D[] = "Shift too short counter"; 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_0F[] = "Minimum Cycle Distance"; +static const char acName1C32_10[] = "Maximum Cycle Distance"; +static const char acName1C32_11[] = "Minimum SM Sync Distance"; +static const char acName1C32_12[] = "Maximum SM Sync Distance"; static const char acName1C32_20[] = "SyncError"; -static const char acName6005[] = "Buttons"; -static const char acName6005_00[] = "Max SubIndex"; -static const char acName6005_01[] = "Button1"; -static const char acName7005[] = "LEDgroup0"; -static const char acName7005_00[] = "Max SubIndex"; -static const char acName7005_01[] = "LED0"; -static const char acName7006[] = "LEDgroup1"; -static const char acName7006_00[] = "Max SubIndex"; -static const char acName7006_01[] = "LED1"; +static const char acName6000[] = "Buttons"; +static const char acName6000_00[] = "Max SubIndex"; +static const char acName6000_01[] = "Button1"; +static const char acName7000[] = "LEDgroup0"; +static const char acName7000_00[] = "Max SubIndex"; +static const char acName7000_01[] = "LED0"; +static const char acName7001[] = "LEDgroup1"; +static const char acName7001_00[] = "Max SubIndex"; +static const char acName7001_01[] = "LED1"; static const char acName8000[] = "Parameters"; static const char acName8000_00[] = "Max SubIndex"; static const char acName8000_01[] = "Multiplier"; static const char acName8001[] = "variableRW"; -static const char acName8001_0[] = "variableRW"; const _objd SDO1000[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000_0, 0x00001389, NULL}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 0x00001389, NULL}, }; const _objd SDO1008[] = { - {0x0, DTYPE_VISIBLE_STRING, 88, ATYPE_RO, acName1008_0, 0, "xmc43_slave"}, + {0x0, DTYPE_VISIBLE_STRING, 80, ATYPE_RO, acName1008, 0, "xmc43relax"}, }; const _objd SDO1009[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, HW_REV}, + {0x0, DTYPE_VISIBLE_STRING, 32, ATYPE_RO, acName1009, 0, HW_REV}, }; const _objd SDO100A[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, SW_REV}, + {0x0, DTYPE_VISIBLE_STRING, 32, ATYPE_RO, acName100A, 0, SW_REV}, }; const _objd SDO1018[] = { @@ -115,23 +108,23 @@ const _objd SDO1018[] = const _objd SDO10F1[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName10F1_00, 2, NULL}, - {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName10F1_01, 0, &Mb.ErrorSettings.Dummy_x01}, - {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName10F1_02, 2, &Mb.ErrorSettings.SyncErrorCounterLimit}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName10F1_01, 0, &Obj.ErrorSettings.Local_Error_Reaction}, + {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName10F1_02, 2, &Obj.ErrorSettings.SyncErrorCounterLimit}, }; const _objd SDO1600[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1600_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70050108, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70000108, NULL}, }; const _objd SDO1601[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70060108, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70010108, NULL}, }; const _objd SDO1A00[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60050108, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60000108, NULL}, }; const _objd SDO1C00[] = { @@ -155,50 +148,49 @@ const _objd SDO1C13[] = const _objd SDO1C32[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C32_00, 32, NULL}, - {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_01, 1, &Mb.SyncMgrParam.SyncType}, - {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_02, 0, &Mb.SyncMgrParam.CycleTime}, - {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_03, 0, &Mb.SyncMgrParam.ShiftTime}, - {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_04, 0x6, &Mb.SyncMgrParam.SyncTypeSupport}, - {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_05, 125000, &Mb.SyncMgrParam.MinCycleTime}, - {0x06, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_06, 0, &Mb.SyncMgrParam.CalcCopyTime}, - {0x07, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_07, 0, &Mb.SyncMgrParam.MinDelayTime}, - {0x08, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_08, 0, &Mb.SyncMgrParam.GetCycleTime}, - {0x09, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_09, 0, &Mb.SyncMgrParam.DelayTime}, - {0x0A, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_0A, 0, &Mb.SyncMgrParam.Sync0CycleTime}, - {0x0B, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0B, 0, &Mb.SyncMgrParam.SMEventMissedCnt}, - {0x0C, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0C, 0, &Mb.SyncMgrParam.CycleTimeTooSmallCnt}, - {0x0D, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0D, 0, &Mb.SyncMgrParam.ShiftTimeTooSmallCnt}, - {0x0E, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0E, 0, &Mb.SyncMgrParam.RxPDOToggleFailed}, - {0x0F, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_0F, 0, &Mb.SyncMgrParam.MinCycleDist}, - {0x10, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_10, 0, &Mb.SyncMgrParam.MaxCycleDist}, - {0x11, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_11, 0, &Mb.SyncMgrParam.MinSMSYNCDist}, - {0x12, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_12, 0, &Mb.SyncMgrParam.MaxSMSYNCDist}, - {0x14, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C32_14, 0, &Mb.SyncMgrParam.Dummy_x14}, - {0x20, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C32_20, 0, &Mb.SyncMgrParam.SyncError}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName1C32_01, 0, &Obj.SyncMgrParam.Sync_mode}, + {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, 0, &Obj.SyncMgrParam.Sync_modes_supported}, + {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_05, 125000, &Obj.SyncMgrParam.Minimum_Cycle_Time}, + {0x06, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_06, 0, &Obj.SyncMgrParam.Calc_and_Copy_Time}, + {0x07, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_07, 0, &Obj.SyncMgrParam.Minimum_Delay_Time}, + {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.Shift_too_short_counter}, + {0x0E, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C32_0E, 0, &Obj.SyncMgrParam.RxPDOToggleFailed}, + {0x0F, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_0F, 0, &Obj.SyncMgrParam.Minimum_Cycle_Distance}, + {0x10, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_10, 0, &Obj.SyncMgrParam.Maximum_Cycle_Distance}, + {0x11, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_11, 0, &Obj.SyncMgrParam.Minimum_SM_Sync_Distance}, + {0x12, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1C32_12, 0, &Obj.SyncMgrParam.Maximum_SM_Sync_Distance}, + {0x20, DTYPE_BOOLEAN, 1, ATYPE_RO, acName1C32_20, 0, &Obj.SyncMgrParam.SyncError}, }; -const _objd SDO6005[] = +const _objd SDO6000[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6005_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6005_01, 0, &Rb.Buttons.Button1}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6000_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_TXPDO, acName6000_01, 0, &Obj.Buttons.Button1}, }; -const _objd SDO7005[] = +const _objd SDO7000[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7005_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7005_01, 0, &Wb.LEDgroup0.LED0}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7000_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_RXPDO, acName7000_01, 0, &Obj.LEDgroup0.LED0}, }; -const _objd SDO7006[] = +const _objd SDO7001[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7006_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7006_01, 0, &Wb.LEDgroup1.LED1}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7001_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_RXPDO, acName7001_01, 0, &Obj.LEDgroup1.LED1}, }; const _objd SDO8000[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName8000_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8000_01, 0, &Cb.Parameters.Multiplier}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName8000_01, 0, &Obj.Parameters.Multiplier}, }; const _objd SDO8001[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8001_0, 0, &Cb.variableRW}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8001, 0, &Obj.variableRW}, }; const _objectlist SDOobjects[] = @@ -215,12 +207,11 @@ const _objectlist SDOobjects[] = {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, {0x1C12, OTYPE_ARRAY, 2, 0, acName1C12, SDO1C12}, {0x1C13, OTYPE_ARRAY, 1, 0, acName1C13, SDO1C13}, - {0x1C32, OTYPE_RECORD, 32, 0, acName1C32, SDO1C32}, - {0x6005, OTYPE_RECORD, 1, 0, acName6005, SDO6005}, - {0x7005, OTYPE_RECORD, 1, 0, acName7005, SDO7005}, - {0x7006, OTYPE_RECORD, 1, 0, acName7006, SDO7006}, + {0x1C32, OTYPE_RECORD, 19, 0, acName1C32, SDO1C32}, + {0x6000, OTYPE_RECORD, 1, 0, acName6000, SDO6000}, + {0x7000, OTYPE_RECORD, 1, 0, acName7000, SDO7000}, + {0x7001, OTYPE_RECORD, 1, 0, acName7001, SDO7001}, {0x8000, OTYPE_RECORD, 1, 0, acName8000, SDO8000}, {0x8001, OTYPE_VAR, 0, 0, acName8001, SDO8001}, {0xffff, 0xff, 0xff, 0xff, NULL, NULL} }; -#endif diff --git a/applications/rtl_xmc4_irq/utypes.h b/applications/rtl_xmc4_irq/utypes.h index d95f90e..51e3325 100644 --- a/applications/rtl_xmc4_irq/utypes.h +++ b/applications/rtl_xmc4_irq/utypes.h @@ -1,96 +1,79 @@ #ifndef __UTYPES_H__ #define __UTYPES_H__ -#include +#include "cc.h" + + +/* Object dictionary storage */ -/* Inputs */ -CC_PACKED_BEGIN typedef struct { - CC_PACKED_BEGIN + /* Inputs */ struct { uint8_t Button1; - } CC_PACKED Buttons; - CC_PACKED_END -} CC_PACKED _Rbuffer; -CC_PACKED_END + } Buttons; -/* Outputs */ -CC_PACKED_BEGIN -typedef struct -{ - CC_PACKED_BEGIN + + /* Outputs */ struct { uint8_t LED0; - } CC_PACKED LEDgroup0; - CC_PACKED_END - CC_PACKED_BEGIN + } LEDgroup0; + struct { uint8_t LED1; - } CC_PACKED LEDgroup1; - CC_PACKED_END -} CC_PACKED _Wbuffer; -CC_PACKED_END + } LEDgroup1; -/* Parameters */ -CC_PACKED_BEGIN -typedef struct -{ - CC_PACKED_BEGIN + + /* Parameters */ struct { uint32_t Multiplier; - } CC_PACKED Parameters; - CC_PACKED_END - uint32_t variableRW; -} CC_PACKED _Cbuffer; -CC_PACKED_END + } Parameters; -/* Manufacturer specific data */ -CC_PACKED_BEGIN -typedef struct -{ - CC_PACKED_BEGIN + uint32_t variableRW; + + /* Manufacturer specific data */ struct { - uint16_t SyncType; + uint32_t Local_Error_Reaction; + uint16_t SyncErrorCounterLimit; + } ErrorSettings; + + struct + { + uint16_t Sync_mode; uint32_t CycleTime; uint32_t ShiftTime; - uint16_t SyncTypeSupport; - uint32_t MinCycleTime; - uint32_t CalcCopyTime; - uint32_t MinDelayTime; + uint16_t Sync_modes_supported; + uint32_t Minimum_Cycle_Time; + uint32_t Calc_and_Copy_Time; + uint32_t Minimum_Delay_Time; uint16_t GetCycleTime; uint32_t DelayTime; uint32_t Sync0CycleTime; uint16_t SMEventMissedCnt; uint16_t CycleTimeTooSmallCnt; - uint16_t ShiftTimeTooSmallCnt; + uint16_t Shift_too_short_counter; uint16_t RxPDOToggleFailed; - uint32_t MinCycleDist; - uint32_t MaxCycleDist; - uint32_t MinSMSYNCDist; - uint32_t MaxSMSYNCDist; - uint8_t Dummy_x14; + uint32_t Minimum_Cycle_Distance; + uint32_t Maximum_Cycle_Distance; + uint32_t Minimum_SM_Sync_Distance; + uint32_t Maximum_SM_Sync_Distance; uint8_t SyncError; - } CC_PACKED SyncMgrParam; - CC_PACKED_END - CC_PACKED_BEGIN - struct - { - uint8_t Dummy_x01; - uint16_t SyncErrorCounterLimit; - } CC_PACKED ErrorSettings; - CC_PACKED_END -} CC_PACKED _Mbuffer; -CC_PACKED_END + } SyncMgrParam; -extern _Rbuffer Rb; -extern _Wbuffer Wb; -extern _Cbuffer Cb; -extern _Mbuffer Mb; + + /* Dynamic TX PDO:s */ + + /* Dynamic RX PDO:s */ + + /* Sync Managers */ + +} _Objects; + +extern _Objects Obj; #endif /* __UTYPES_H__ */ diff --git a/applications/tiesc_am335x/am335xice.bin b/applications/tiesc_am335x/am335xice.bin new file mode 100644 index 0000000..f7d5de8 Binary files /dev/null and b/applications/tiesc_am335x/am335xice.bin differ diff --git a/applications/tiesc_am335x/am335xice.esx b/applications/tiesc_am335x/am335xice.esx new file mode 100644 index 0000000..3e97f9d --- /dev/null +++ b/applications/tiesc_am335x/am335xice.esx @@ -0,0 +1,263 @@ + + + slave + + 0x1337 + rt-labs + + + am335xice_t + am335xice_n + + Outputs + Inputs + MBoxState + MBoxOut + MBoxIn + Outputs + Inputs + + + + + + 2048 + 8006E08800000000 + 0010000200120002 + + + + 0x1000 + Device Type + UNSIGNED32 + 0x00001389 + + + 0x1008 + Device Name + VISIBLE_STRING + am335xice + 9 + + + 0x1009 + Hardware Version + VISIBLE_STRING + 1.0 + 3 + + + 0x100A + Software Version + VISIBLE_STRING + 1.0 + 3 + + + 0x1018 + Identity Object + RECORD + + 0x00 + Max SubIndex + UNSIGNED8 + 4 + + + 0x01 + Vendor ID + UNSIGNED32 + 0x1337 + + + 0x02 + Product Code + UNSIGNED32 + 0x9876 + + + 0x03 + Revision Number + UNSIGNED32 + 0 + + + 0x04 + Serial Number + UNSIGNED32 + 0x00000000 + + + + 0x1600 + LED + RECORD + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + LED + UNSIGNED32 + 0x70000020 + + + + 0x1A00 + BUTTON + RECORD + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + BUTTON + UNSIGNED32 + 0x60000020 + + + + 0x1C00 + Sync Manager Communication Type + ARRAY + + 0x00 + Max SubIndex + UNSIGNED8 + 4 + + + 0x01 + Communications Type SM0 + UNSIGNED8 + 1 + + + 0x02 + Communications Type SM1 + UNSIGNED8 + 2 + + + 0x03 + Communications Type SM2 + UNSIGNED8 + 3 + + + 0x04 + Communications Type SM3 + UNSIGNED8 + 4 + + + + 0x1C12 + Sync Manager 2 PDO Assignment + ARRAY + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + PDO Mapping + UNSIGNED16 + 0x1600 + + + + 0x1C13 + Sync Manager 3 PDO Assignment + ARRAY + + 0x00 + Max SubIndex + UNSIGNED8 + 1 + + + 0x01 + PDO Mapping + UNSIGNED16 + 0x1A00 + + + + 0x6000 + RO + BUTTON + UNSIGNED32 + 0 + TX + BUTTON + Input + + + 0x7000 + RO + LED + UNSIGNED32 + 0 + RX + LED + Output + + + + 0x1C12 + + 0x01 + 0x1600 + + + + 0x1C13 + + 0x01 + 0x1A00 + + + + 0x1600 + LED + + 0x1 + 0x7000 + 0x00 + LED + + + + 0x1A00 + BUTTON + + 0x1 + 0x6000 + 0x00 + BUTTON + + + + 0x6000 + BUTTON + UNSIGNED32 + TX + VAR + + + 0x7000 + LED + UNSIGNED32 + RX + VAR + + diff --git a/applications/tiesc_am335x/am335xice.xml b/applications/tiesc_am335x/am335xice.xml new file mode 100644 index 0000000..051ba2d --- /dev/null +++ b/applications/tiesc_am335x/am335xice.xml @@ -0,0 +1,537 @@ + + + + #x1337 + rt-labs + + + + + am335xice_t + am335xice_n + + + + + am335xice + slave + am335xice_t + + 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 + + + + + DT1600 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + LED + UDINT + 32 + 16 + + ro + + + + + DT1A00 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + BUTTON + UDINT + 32 + 16 + + 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 + + ro + + + + Elements + DT1C12ARR + 16 + 16 + + ro + + + + + DT1C13ARR + UINT + 16 + + 1 + 1 + + + + DT1C13 + 32 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + Elements + DT1C13ARR + 16 + 16 + + ro + + + + + STRING(3) + 24 + + + UDINT + 32 + + + UINT + 16 + + + USINT + 8 + + + STRING(9) + 72 + + + + + #x1000 + Device Type + UDINT + 32 + + #x00001389 + + + ro + m + + + + #x1008 + Device Name + STRING(9) + 72 + + am335xice + + + 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 + + #x9876 + + + + Revision Number + + 0 + + + + Serial Number + + #x00000000 + + + + + ro + + + + #x1600 + LED + DT1600 + 48 + + + Max SubIndex + + 1 + + + + LED + + #x70000020 + + + + + ro + + + + #x1A00 + BUTTON + DT1A00 + 48 + + + Max SubIndex + + 1 + + + + BUTTON + + #x60000020 + + + + + 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 + + + + + ro + + + + #x1C13 + Sync Manager 3 PDO Assignment + DT1C13 + 32 + + + Max SubIndex + + 1 + + + + PDO Mapping + + #x1A00 + + + + + ro + + + + #x6000 + BUTTON + UDINT + 32 + + 0 + + + ro + T + + + + #x7000 + LED + UDINT + 32 + + 0 + + + ro + R + + + + + + Outputs + Inputs + MBoxState + MBoxOut + MBoxIn + Outputs + Inputs + + #x1600 + LED + + #x7000 + #x0 + 32 + LED + UDINT + + + + #x1A00 + BUTTON + + #x6000 + #x0 + 32 + BUTTON + UDINT + + + + + + + 2048 + 8006E08800000000 + 0010000200120002 + + + + + \ No newline at end of file diff --git a/applications/tiesc_am335x/am335xice_objectlist.c b/applications/tiesc_am335x/am335xice_objectlist.c new file mode 100644 index 0000000..d3c3f48 --- /dev/null +++ b/applications/tiesc_am335x/am335xice_objectlist.c @@ -0,0 +1,120 @@ +#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 acName1008[] = "Device Name"; +static const char acName1009[] = "Hardware Version"; +static const char acName100A[] = "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 acName1600[] = "LED"; +static const char acName1600_00[] = "Max SubIndex"; +static const char acName1600_01[] = "LED"; +static const char acName1A00[] = "BUTTON"; +static const char acName1A00_00[] = "Max SubIndex"; +static const char acName1A00_01[] = "BUTTON"; +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 acName1C13[] = "Sync Manager 3 PDO Assignment"; +static const char acName1C13_00[] = "Max SubIndex"; +static const char acName1C13_01[] = "PDO Mapping"; +static const char acName6000[] = "BUTTON"; +static const char acName7000[] = "LED"; + +const _objd SDO1000[] = +{ + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 0x00001389, NULL}, +}; +const _objd SDO1008[] = +{ + {0x0, DTYPE_VISIBLE_STRING, 72, ATYPE_RO, acName1008, 0, "am335xice"}, +}; +const _objd SDO1009[] = +{ + {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009, 0, HW_REV}, +}; +const _objd SDO100A[] = +{ + {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A, 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, 0x9876, NULL}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_03, 0, NULL}, + {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_04, 0x00000000, NULL}, +}; +const _objd SDO1600[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1600_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70000020, NULL}, +}; +const _objd SDO1A00[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60000020, 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[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_01, 0x1600, NULL}, +}; +const _objd SDO1C13[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_01, 0x1A00, NULL}, +}; +const _objd SDO6000[] = +{ + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_TXPDO, acName6000, 0, &Obj.BUTTON}, +}; +const _objd SDO7000[] = +{ + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_RXPDO, acName7000, 0, &Obj.LED}, +}; + +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}, + {0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600}, + {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, + {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, + {0x1C12, OTYPE_ARRAY, 1, 0, acName1C12, SDO1C12}, + {0x1C13, OTYPE_ARRAY, 1, 0, acName1C13, SDO1C13}, + {0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000}, + {0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000}, + {0xffff, 0xff, 0xff, 0xff, NULL, NULL} +}; diff --git a/applications/tiesc_am335x/ecat_options.h b/applications/tiesc_am335x/ecat_options.h new file mode 100644 index 0000000..85b02a8 --- /dev/null +++ b/applications/tiesc_am335x/ecat_options.h @@ -0,0 +1,44 @@ +#ifndef __ECAT_OPTIONS_H__ +#define __ECAT_OPTIONS_H__ + +#include "cc.h" + +#define USE_FOE 0 +#define USE_EOE 0 + +#define MBXSIZE 512 +#define MBXSIZEBOOT 512 +#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 0x1400 +#define SM2_smc 0x24 +#define SM2_act 1 +#define SM3_sma 0x1A00 +#define SM3_smc 0x20 +#define SM3_act 1 + +#define MAX_RXPDO_SIZE 512 +#define MAX_TXPDO_SIZE 512 + +#define MAX_MAPPINGS_SM2 1 +#define MAX_MAPPINGS_SM3 1 + +#endif /* __ECAT_OPTIONS_H__ */ diff --git a/applications/tiesc_am335x/main.c b/applications/tiesc_am335x/main.c new file mode 100644 index 0000000..f1dded1 --- /dev/null +++ b/applications/tiesc_am335x/main.c @@ -0,0 +1,85 @@ +#include "esc_hw.h" +#include "ecat_slv.h" +#include "options.h" +#include "utypes.h" +#include +#include "tiescutils.h" +#include +#include + +#if 1 +/* Application variables */ +_Objects Obj; + +/** + * This function reads physical input values and assigns the corresponding members + * of Rb.Buttons + */ +void cb_get_inputs() +{ + volatile uint8_t io_input; + Board_readRotarySwitch((uint8_t *)&io_input); + Obj.BUTTON = io_input; +} + +/** + * This function writes physical output values from the corresponding members of + * Wb.LEDs + */ +void cb_set_outputs() +{ + volatile uint8_t io_output; + io_output = Obj.LED; + Board_setDigOutput(io_output); +} +#endif + + +/* Called from stack when stopping outputs */ +void user_safeoutput (void) +{ + memset(&Obj.LED, 0, (sizeof(Obj.LED))); + Board_setDigOutput(0); +} + +/* Configuration parameters for SOES + * SM and Mailbox parameters comes from the + * generated config.h + */ +static esc_cfg_t config = +{ + .user_arg = NULL, + .use_interrupt = 1, + .watchdog_cnt = 9998, + .set_defaults_hook = NULL, + .pre_state_change_hook = NULL, + .post_state_change_hook = NULL, + .application_hook = NULL, + .safeoutput_override = user_safeoutput, + .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 = NULL +}; + +int MainInit(void) +{ + ecat_slv_init(&config); + return 0; +} + +void MainLoop(void) +{ + ecat_slv_poll(); + DIG_process(DIG_PROCESS_WD_FLAG); +} + +int main() +{ + common_main(); + return 0; +} diff --git a/applications/tiesc_am335x/utypes.h b/applications/tiesc_am335x/utypes.h new file mode 100644 index 0000000..6dbfe69 --- /dev/null +++ b/applications/tiesc_am335x/utypes.h @@ -0,0 +1,31 @@ +#ifndef __UTYPES_H__ +#define __UTYPES_H__ + +#include "cc.h" + + +/* Object dictionary storage */ + +typedef struct +{ + /* Inputs */ + uint32_t BUTTON; + + /* Outputs */ + uint32_t LED; + + /* Parameters */ + + /* Manufacturer specific data */ + + /* Dynamic TX PDO:s */ + + /* Dynamic RX PDO:s */ + + /* Sync Managers */ + +} _Objects; + +extern _Objects Obj; + +#endif /* __UTYPES_H__ */ diff --git a/applications/tiesc_k2gice/config.h b/applications/tiesc_k2gice/config.h deleted file mode 100644 index 8e3321d..0000000 --- a/applications/tiesc_k2gice/config.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#include - -#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/tiesc_k2gice/ecat_options.h b/applications/tiesc_k2gice/ecat_options.h new file mode 100644 index 0000000..85b02a8 --- /dev/null +++ b/applications/tiesc_k2gice/ecat_options.h @@ -0,0 +1,44 @@ +#ifndef __ECAT_OPTIONS_H__ +#define __ECAT_OPTIONS_H__ + +#include "cc.h" + +#define USE_FOE 0 +#define USE_EOE 0 + +#define MBXSIZE 512 +#define MBXSIZEBOOT 512 +#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 0x1400 +#define SM2_smc 0x24 +#define SM2_act 1 +#define SM3_sma 0x1A00 +#define SM3_smc 0x20 +#define SM3_act 1 + +#define MAX_RXPDO_SIZE 512 +#define MAX_TXPDO_SIZE 512 + +#define MAX_MAPPINGS_SM2 1 +#define MAX_MAPPINGS_SM3 1 + +#endif /* __ECAT_OPTIONS_H__ */ diff --git a/applications/tiesc_k2gice/k2gice.bin b/applications/tiesc_k2gice/k2gice.bin index 1f43875..32fc959 100644 Binary files a/applications/tiesc_k2gice/k2gice.bin and b/applications/tiesc_k2gice/k2gice.bin differ diff --git a/applications/tiesc_k2gice/k2gice.c b/applications/tiesc_k2gice/k2gice.c deleted file mode 100644 index 54db3c3..0000000 --- a/applications/tiesc_k2gice/k2gice.c +++ /dev/null @@ -1,326 +0,0 @@ -#ifndef SOES_V1 -#include -#include "utypes.h" -#include "esc.h" -#include "esc_coe.h" -#include "esc_foe.h" -#include "config.h" -#include "k2gice.h" - -/* Global variables used by the stack */ -uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)]; -_MBXcontrol MBXcontrol[MBXBUFFERS]; -_ESCvar ESCvar; - -/* Application variables */ -_Rbuffer Rb; -_Wbuffer Wb; -_Cbuffer Cb; -_Mbuffer Mb; - -/* Private variables */ -static volatile int watchdog; - -/** Mandatory: Function to pre-qualify the incoming SDO download. - * - * @param[in] index = index of SDO download request to check - * @param[in] sub-index = sub-index of SDO download request to check - * @return 1 if the SDO Download is correct. 0 If not correct. - */ -int ESC_pre_objecthandler (uint16_t index, uint8_t subindex) -{ - int result = 1; - - if(ESCvar.pre_object_download_hook) - { - result = (ESCvar.pre_object_download_hook)(index, subindex); - } - - return result; -} - -/** Mandatory: Hook called from the slave stack SDO Download handler to act on - * user specified Index and Sub-index. - * - * @param[in] index = index of SDO download request to handle - * @param[in] sub-index = sub-index of SDO download request to handle - */ -void ESC_objecthandler (uint16_t index, uint8_t subindex) -{ - switch (index) - { - /* Handle post-write of parameter values */ - default: - { - if(ESCvar.post_object_download_hook != NULL) - { - (ESCvar.post_object_download_hook)(index, subindex); - } - break; - } - } -} - -/** Mandatory: Hook called from the slave stack ESC_stopoutputs to act on state changes - * forcing us to stop outputs. Here we can set them to a safe state. - * set - */ -void APP_safeoutput (void) -{ - DPRINT ("APP_safeoutput\n"); - - if(ESCvar.safeoutput_override != NULL) - { - (ESCvar.safeoutput_override)(); - } - else - { - // Set safe values for Wb.LED - Wb.LED = 0; - } -} - -/** Mandatory: Write local process data to Sync Manager 3, Master Inputs. - */ -void TXPDO_update (void) -{ - if(ESCvar.txpdo_override != NULL) - { - (ESCvar.txpdo_override)(); - } - else - { - ESC_write (SM3_sma, &Rb, ESCvar.TXPDOsize); - } -} - -/** Mandatory: Read Sync Manager 2 to local process data, Master Outputs. - */ -void RXPDO_update (void) -{ - if(ESCvar.rxpdo_override != NULL) - { - (ESCvar.rxpdo_override)(); - } - else - { - ESC_read (SM2_sma, &Wb, ESCvar.RXPDOsize); - } -} - -/** Mandatory: Function to update local I/O, call read ethercat outputs, call - * write ethercat inputs. Implement watch-dog counter to count-out if we have - * made state change affecting the App.state. - */ -void DIG_process (uint8_t flags) -{ - /* Handle watchdog */ - if((flags & DIG_PROCESS_WD_FLAG) > 0) - { - - if (CC_ATOMIC_GET(watchdog) > 0) - { - CC_ATOMIC_SUB(watchdog, 1); - } - - if ((CC_ATOMIC_GET(watchdog) <= 0) && - ((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0)) - { - DPRINT("DIG_process watchdog expired\n"); - ESC_stopoutput(); - /* watchdog, invalid outputs */ - ESC_ALerror (ALERR_WATCHDOG); - /* goto safe-op with error bit set */ - ESC_ALstatus (ESCsafeop | ESCerror); - } - else if(((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) == 0)) - { - CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt); - } - } - - /* Handle Outputs */ - if ((flags & DIG_PROCESS_OUTPUTS_FLAG) > 0) - { - if(((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0) && - (ESCvar.ALevent & ESCREG_ALEVENT_SM2)) - { - RXPDO_update(); - CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt); - if(ESCvar.dcsync > 0) - { - CC_ATOMIC_ADD(ESCvar.synccounter, 1); - } - /* Set outputs */ - cb_set_LED(); - } - else if (ESCvar.ALevent & ESCREG_ALEVENT_SM2) - { - RXPDO_update(); - } - } - - /* Call application */ - if ((flags & DIG_PROCESS_APP_HOOK_FLAG) > 0) - { - - if((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0) - { - CC_ATOMIC_SUB(ESCvar.synccounter, 1); - } - - if((ESCvar.dcsync > 0) && - ((CC_ATOMIC_GET(ESCvar.synccounter) < -ESCvar.synccounterlimit) || - (CC_ATOMIC_GET(ESCvar.synccounter) > ESCvar.synccounterlimit))) - { - if((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0) - { - DPRINT("sync error = %d\n", ESCvar.synccounter); - ESC_stopoutput(); - /* Sync error */ - ESC_ALerror (ALERR_SYNCERROR); - /* goto safe-op with error bit set */ - ESC_ALstatus (ESCsafeop | ESCerror); - CC_ATOMIC_SET(ESCvar.synccounter, 0); - } - } - /* Call application callback if set */ - if (ESCvar.application_hook != NULL) - { - (ESCvar.application_hook)(); - } - } - - /* Handle Inputs */ - if ((flags & DIG_PROCESS_INPUTS_FLAG) > 0) - { - if(CC_ATOMIC_GET(ESCvar.App.state) > 0) - { - /* Update inputs */ - cb_get_BUTTON(); - TXPDO_update(); - } - } -} - -/** - * Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application - * control what interrupts that should be served and re-activated with - * event mask argument - */ -void ecat_slv_worker (uint32_t event_mask) -{ - do - { - /* Check the state machine */ - ESC_state(); - /* Check the SM activation event */ - ESC_sm_act_event(); - - /* Check mailboxes */ - while ((ESC_mbxprocess() > 0) || (ESCvar.txcue > 0)) - { - ESC_coeprocess(); - ESC_foeprocess(); - ESC_xoeprocess(); - } - - /* Call emulated eeprom handler if set */ - if (ESCvar.esc_hw_eep_handler != NULL) - { - (ESCvar.esc_hw_eep_handler)(); - } - - CC_ATOMIC_SET(ESCvar.ALevent, ESC_ALeventread()); - - }while(ESCvar.ALevent & event_mask); - - ESC_ALeventmaskwrite(ESC_ALeventmaskread() | event_mask); -} - -/** - * ISR function. It should be called from ISR for applications entirely driven by - * interrupts. - * Read and handle events for the EtherCAT state, status, mailbox and eeprom. - */ -void ecat_slv_isr (void) -{ - ecat_slv_worker(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE - | ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP); -} - -/** - * Polling function. It should be called periodically for an application - * when only SM2/DC interrupt is active. - * Read and handle events for the EtherCAT state, status, mailbox and eeprom. - */ -void ecat_slv_poll (void) -{ - /* Read local time from ESC*/ - ESC_read (ESCREG_LOCALTIME, (void *) &ESCvar.Time, sizeof (ESCvar.Time)); - ESCvar.Time = etohl (ESCvar.Time); - - /* Check the state machine */ - ESC_state(); - /* Check the SM activation event */ - ESC_sm_act_event(); - - /* Check mailboxes */ - if (ESC_mbxprocess()) - { - ESC_coeprocess(); - ESC_foeprocess(); - ESC_xoeprocess(); - } - - /* Call emulated eeprom handler if set */ - if (ESCvar.esc_hw_eep_handler != NULL) - { - (ESCvar.esc_hw_eep_handler)(); - } -} - -void ecat_slv (void) -{ - ecat_slv_poll(); - DIG_process(DIG_PROCESS_WD_FLAG | DIG_PROCESS_OUTPUTS_FLAG | - DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG); -} - -/** - * Initialize the slave stack. - */ -void ecat_slv_init (esc_cfg_t * config) -{ - DPRINT ("Slave stack init started\n"); - - ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - - /* Init watchdog */ - watchdog = config->watchdog_cnt; - - /* Call stack configuration */ - ESC_config (config); - /* Call HW init */ - ESC_init (config); - - /* wait until ESC is started up */ - while ((ESCvar.DLstatus & 0x0001) == 0) - { - ESC_read (ESCREG_DLSTATUS, (void *) &ESCvar.DLstatus, - sizeof (ESCvar.DLstatus)); - ESCvar.DLstatus = etohs (ESCvar.DLstatus); - } - - /* Init FoE */ - FOE_init(); - - /* reset ESC to init state */ - ESC_ALstatus (ESCinit); - ESC_ALerror (ALERR_NONE); - ESC_stopmbx(); - ESC_stopinput(); - ESC_stopoutput(); -} -#endif diff --git a/applications/tiesc_k2gice/k2gice.esx b/applications/tiesc_k2gice/k2gice.esx index e70830c..831afef 100644 --- a/applications/tiesc_k2gice/k2gice.esx +++ b/applications/tiesc_k2gice/k2gice.esx @@ -1,229 +1,248 @@ - - k2gice + + k2gice_n 0x1337 rt-labs k2gice_t - k2gice_n + am335xice_n Outputs Inputs MBoxState - MBoxOut - MBoxIn - Outputs - Inputs + MBoxOut + MBoxIn + Outputs + Inputs - - + + 2048 800CE08800000000 - 0010800080108000 + 0010000200120002 - - Device Type + 0x1000 + Device Type UNSIGNED32 0x00001389 - Device Name 0x1008 + Device Name VISIBLE_STRING k2gice + 6 - Hardware Version 0x1009 + Hardware Version VISIBLE_STRING 1.0 + 3 - Software Version 0x100A + Software Version VISIBLE_STRING 1.0 + 3 - Identity Object 0x1018 + Identity Object RECORD - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 4 - Vendor ID 0x01 + Vendor ID UNSIGNED32 0x1337 - Product Code 0x02 + Product Code UNSIGNED32 - 0x1234 + 0x4291ce - Revision Number 0x03 + Revision Number UNSIGNED32 0 - Serial Number 0x04 + Serial Number UNSIGNED32 0x00000000 - LED 0x1600 + LED RECORD - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - LED 0x01 + LED UNSIGNED32 0x70000020 - BUTTON 0x1A00 + BUTTON RECORD - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - BUTTON 0x01 + BUTTON UNSIGNED32 0x60000020 - Sync Manager Communication Type 0x1C00 + Sync Manager Communication Type ARRAY - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 4 - Communications Type SM0 0x01 + Communications Type SM0 UNSIGNED8 1 - Communications Type SM1 0x02 + Communications Type SM1 UNSIGNED8 2 - Communications Type SM2 0x03 + Communications Type SM2 UNSIGNED8 3 - Communications Type SM3 0x04 + Communications Type SM3 UNSIGNED8 4 - Sync Manager 2 PDO Assignment 0x1C12 + Sync Manager 2 PDO Assignment ARRAY - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - PDO Mapping 0x01 + PDO Mapping UNSIGNED16 0x1600 - Sync Manager 3 PDO Assignment 0x1C13 + Sync Manager 3 PDO Assignment ARRAY - Max SubIndex 0x00 + Max SubIndex UNSIGNED8 1 - PDO Mapping 0x01 + PDO Mapping UNSIGNED16 0x1A00 - BUTTON 0x6000 + RO + BUTTON UNSIGNED32 0 - RO + TX BUTTON Input - LED 0x7000 + RO + LED UNSIGNED32 0 - RO + RX LED Output + + 0x1C12 + + 0x01 + 0x1600 + + + + 0x1C13 + + 0x01 + 0x1A00 + + 0x1600 - LED LED - 0x7000 - 0 + 0x1 + 0x7000 + 0x00 LED 0x1A00 - BUTTON BUTTON - 0x6000 - 0 + 0x1 + 0x6000 + 0x00 BUTTON @@ -231,12 +250,14 @@ 0x6000 BUTTON UNSIGNED32 + TX VAR 0x7000 LED UNSIGNED32 + RX VAR - \ No newline at end of file + diff --git a/applications/tiesc_k2gice/k2gice.h b/applications/tiesc_k2gice/k2gice.h deleted file mode 100644 index 1b41384..0000000 --- a/applications/tiesc_k2gice/k2gice.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __K2GICE_H__ -#define __K2GICE_H__ - -#include "utypes.h" -#include "esc.h" - -/** - * This function gets input values and updates Rb.BUTTON - */ -void cb_get_BUTTON(); - -/** - * This function sets output values according to Wb.LED - */ -void cb_set_LED(); - -#define DIG_PROCESS_INPUTS_FLAG 0x01 -#define DIG_PROCESS_OUTPUTS_FLAG 0x02 -#define DIG_PROCESS_WD_FLAG 0x04 -#define DIG_PROCESS_APP_HOOK_FLAG 0x08 -/** Implements the watch-dog counter to count if we should make a state change - * due to missing incoming SM2 events. Updates local I/O and run the application - * in the following order, call read EtherCAT outputs, execute user provided - * application hook and call write EtherCAT inputs. - * - * @param[in] flags = User input what to execute - */ -void DIG_process (uint8_t flags); - -/** - * Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application - * control what interrupts that should be served and re-activated with - * event mask argument - * - * @param[in] event_mask = Event mask for interrupts to serve and re-activate - * after served - */ -void ecat_slv_worker (uint32_t event_mask); - -/** - * ISR for SM0/1, EEPROM and AL CONTROL events in a SM/DC - * synchronization application - */ -CC_DEPRECATED void ecat_slv_isr (void); - -/** - * Poll SM0/1, EEPROM and AL CONTROL events in a SM/DC synchronization - * application - */ -void ecat_slv_poll (void); - -/** - * Poll all events in a free-run application - */ -void ecat_slv (void); - -/** - * Initialize the slave stack - * - * @param[in] config = User input how to configure the stack - */ -void ecat_slv_init (esc_cfg_t * config); - -#endif /* __K2GICE_H__ */ diff --git a/applications/tiesc_k2gice/k2gice.xml b/applications/tiesc_k2gice/k2gice.xml index 4746524..7f47d2b 100644 --- a/applications/tiesc_k2gice/k2gice.xml +++ b/applications/tiesc_k2gice/k2gice.xml @@ -8,13 +8,13 @@ k2gice_t - k2gice_n + am335xice_n - k2gice - k2gice + k2gice + k2gice_n k2gice_t 5001 @@ -312,7 +312,7 @@ Product Code - #x1234 + #x4291ce @@ -475,6 +475,7 @@ ro + T @@ -487,6 +488,7 @@ ro + R @@ -495,16 +497,16 @@ Outputs Inputs MBoxState - MBoxOut - MBoxIn - Outputs - Inputs + MBoxOut + MBoxIn + Outputs + Inputs #x1600 LED #x7000 - 0 + #x0 32 LED UDINT @@ -515,19 +517,19 @@ BUTTON #x6000 - 0 + #x0 32 BUTTON UDINT - + 2048 - 800CE08800000000 - 0010800080108000 + 800EE08800000000 + 0010000200120002 diff --git a/applications/tiesc_k2gice/k2gice_objectlist.c b/applications/tiesc_k2gice/k2gice_objectlist.c index 46cb82b..9b26fc0 100644 --- a/applications/tiesc_k2gice/k2gice_objectlist.c +++ b/applications/tiesc_k2gice/k2gice_objectlist.c @@ -1,4 +1,3 @@ -#ifndef SOES_V1 #include "esc_coe.h" #include "utypes.h" #include @@ -12,13 +11,9 @@ #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"; @@ -44,31 +39,29 @@ 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 acName6000[] = "BUTTON"; -static const char acName6000_0[] = "BUTTON"; static const char acName7000[] = "LED"; -static const char acName7000_0[] = "LED"; const _objd SDO1000[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000_0, 0x00001389, NULL}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 0x00001389, NULL}, }; const _objd SDO1008[] = { - {0x0, DTYPE_VISIBLE_STRING, 48, ATYPE_RO, acName1008_0, 0, "k2gice"}, + {0x0, DTYPE_VISIBLE_STRING, 48, ATYPE_RO, acName1008, 0, "k2gice"}, }; const _objd SDO1009[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, HW_REV}, + {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009, 0, HW_REV}, }; const _objd SDO100A[] = { - {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, SW_REV}, + {0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A, 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, 0x1234, NULL}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_02, 0x4291ce, NULL}, {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_03, 0, NULL}, {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_04, 0x00000000, NULL}, }; @@ -102,11 +95,11 @@ const _objd SDO1C13[] = }; const _objd SDO6000[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName6000_0, 0, &Rb.BUTTON}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_TXPDO, acName6000, 0, &Obj.BUTTON}, }; const _objd SDO7000[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName7000_0, 0, &Wb.LED}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_RXPDO, acName7000, 0, &Obj.LED}, }; const _objectlist SDOobjects[] = @@ -125,4 +118,3 @@ const _objectlist SDOobjects[] = {0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000}, {0xffff, 0xff, 0xff, 0xff, NULL, NULL} }; -#endif diff --git a/applications/tiesc_k2gice/main.c b/applications/tiesc_k2gice/main.c index e808b81..dcce577 100644 --- a/applications/tiesc_k2gice/main.c +++ b/applications/tiesc_k2gice/main.c @@ -1,38 +1,39 @@ -#include "k2gice.h" #include "esc_hw.h" -#include "config.h" +#include "ecat_slv.h" +#include "options.h" +#include "utypes.h" #include #include "tiescutils.h" #include #include +/* Application variables */ +_Objects Obj; + /** * This function reads physical input values and assigns the corresponding members - * of Rb.Buttons */ -void cb_get_BUTTON() +void cb_get_inputs() { volatile uint8_t io_input; - Board_readRotarySwitch(&io_input); - Rb.BUTTON = io_input; + Board_readRotarySwitch((uint8_t *)&io_input); + Obj.BUTTON = io_input; } /** - * This function writes physical output values from the corresponding members of - * Wb.LEDs + * This function writes physical output values from the corresponding members */ -void cb_set_LED() +void cb_set_outputs() { volatile uint8_t io_output; - io_output = Wb.LED; + io_output = Obj.LED; Board_setDigOutput(io_output); } - /* Called from stack when stopping outputs */ void user_safeoutput (void) { - memset(&Wb, 0, (sizeof(Wb))); + memset(&Obj.LED, 0, (sizeof(Obj.LED))); Board_setDigOutput(0); } @@ -44,16 +45,8 @@ static esc_cfg_t config = { .user_arg = NULL, .use_interrupt = 1, - .watchdog_cnt = 9999, - .mbxsize = MBXSIZE, - .mbxsizeboot = MBXSIZEBOOT, - .mbxbuffers = MBXBUFFERS, - .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}, + .watchdog_cnt = 9998, + .set_defaults_hook = NULL, .pre_state_change_hook = NULL, .post_state_change_hook = NULL, .application_hook = NULL, @@ -64,7 +57,8 @@ static esc_cfg_t config = .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_hw_eep_handler = ESC_eep_handler, + .esc_check_dc_handler = NULL }; int MainInit(void) diff --git a/applications/tiesc_k2gice/utypes.h b/applications/tiesc_k2gice/utypes.h index 68f5d9a..6dbfe69 100644 --- a/applications/tiesc_k2gice/utypes.h +++ b/applications/tiesc_k2gice/utypes.h @@ -1,41 +1,31 @@ #ifndef __UTYPES_H__ #define __UTYPES_H__ -#include +#include "cc.h" + + +/* Object dictionary storage */ -/* Inputs */ -CC_PACKED_BEGIN typedef struct { + /* Inputs */ uint32_t BUTTON; -} CC_PACKED _Rbuffer; -CC_PACKED_END -/* Outputs */ -CC_PACKED_BEGIN -typedef struct -{ + /* Outputs */ uint32_t LED; -} CC_PACKED _Wbuffer; -CC_PACKED_END -/* Parameters */ -CC_PACKED_BEGIN -typedef struct -{ -} CC_PACKED _Cbuffer; -CC_PACKED_END + /* Parameters */ -/* Manufacturer specific data */ -CC_PACKED_BEGIN -typedef struct -{ -} CC_PACKED _Mbuffer; -CC_PACKED_END + /* Manufacturer specific data */ -extern _Rbuffer Rb; -extern _Wbuffer Wb; -extern _Cbuffer Cb; -extern _Mbuffer Mb; + /* Dynamic TX PDO:s */ + + /* Dynamic RX PDO:s */ + + /* Sync Managers */ + +} _Objects; + +extern _Objects Obj; #endif /* __UTYPES_H__ */ diff --git a/applications/xmc4300_slavedemo/Makefile b/applications/xmc4300_slavedemo/Makefile index 91ad87c..dcbb186 100644 --- a/applications/xmc4300_slavedemo/Makefile +++ b/applications/xmc4300_slavedemo/Makefile @@ -13,7 +13,7 @@ SOES_DIR = ../../soes SRC = \ main.c \ objectlist.c \ - soes.c \ + $(SOES_DIR)/ecat_slv.c \ $(SOES_DIR)/esc.c \ $(SOES_DIR)/esc_coe.c \ $(SOES_DIR)/esc_eep.c \ diff --git a/applications/xmc4300_slavedemo/ecat_options.h b/applications/xmc4300_slavedemo/ecat_options.h new file mode 100644 index 0000000..0181a61 --- /dev/null +++ b/applications/xmc4300_slavedemo/ecat_options.h @@ -0,0 +1,44 @@ +#ifndef __ECAT_OPTIONS_H__ +#define __ECAT_OPTIONS_H__ + +#include "cc.h" + +#define USE_FOE 0 +#define USE_EOE 0 + +#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 + +#define MAX_RXPDO_SIZE 42 +#define MAX_TXPDO_SIZE 42 + +#define MAX_MAPPINGS_SM2 1 +#define MAX_MAPPINGS_SM3 2 + +#endif /* __ECAT_OPTIONS_H__ */ diff --git a/applications/xmc4300_slavedemo/main.c b/applications/xmc4300_slavedemo/main.c index c13e8c1..e75c4b5 100644 --- a/applications/xmc4300_slavedemo/main.c +++ b/applications/xmc4300_slavedemo/main.c @@ -1,15 +1,133 @@ -#include +/* + * Licensed under the GNU General Public License version 2 with exceptions. See + * LICENSE file in the project root for full license information + */ +#include "ecat_slv.h" +#include "utypes.h" #include "xmc_gpio.h" -#include "soes.h" +#ifdef XMC4800_F144x2048 +#define P_LED P5_8 +#define P_BTN P15_12 +#endif -int main(void) +#ifdef XMC4300_F100x256 +#define P_LED P4_1 +#define P_BTN P3_4 +#endif + +extern void ESC_eep_handler(void); + +/* Application variables */ +_Rbuffer Rb; +_Wbuffer Wb; +_Cbuffer Cb; + +uint32_t encoder_scale; +uint32_t encoder_scale_mirror; + +static const XMC_GPIO_CONFIG_t gpio_config_btn = { + .mode = XMC_GPIO_MODE_INPUT_INVERTED_PULL_UP, + .output_level = 0, + .output_strength = 0 +}; + +static const XMC_GPIO_CONFIG_t gpio_config_led = { + .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL, + .output_level = XMC_GPIO_OUTPUT_LEVEL_LOW, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE +}; + +void cb_get_inputs (void) { - soes_init(); - - while(1) { - soes_task(); - } + Rb.button = XMC_GPIO_GetInput(P_BTN); + Cb.reset_counter++; + Rb.encoder = ESCvar.Time; } +void cb_set_outputs (void) +{ + if (Wb.LED) + { + XMC_GPIO_SetOutputHigh(P_LED); + } + else + { + XMC_GPIO_SetOutputLow(P_LED); + } +} + +void post_object_download_hook (uint16_t index, uint8_t subindex, + uint16_t flags) +{ + switch(index) + { + case 0x7100: + { + switch (subindex) + { + case 0x01: + { + encoder_scale_mirror = encoder_scale; + break; + } + } + break; + } + case 0x8001: + { + switch (subindex) + { + case 0x01: + { + Cb.reset_counter = 0; + break; + } + } + break; + } + } +} + +void soes (void * arg) +{ + /* Setup config hooks */ + static esc_cfg_t config = + { + .user_arg = NULL, + .use_interrupt = 0, + .watchdog_cnt = 5000, + .set_defaults_hook = NULL, + .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 = post_object_download_hook, + .rxpdo_override = NULL, + .txpdo_override = NULL, + .esc_hw_interrupt_enable = NULL, + .esc_hw_interrupt_disable = NULL, + .esc_hw_eep_handler = ESC_eep_handler + }; + + DPRINT ("SOES (Simple Open EtherCAT Slave)\n"); + + // configure I/O + XMC_GPIO_Init(P_BTN, &gpio_config_btn); + XMC_GPIO_Init(P_LED, &gpio_config_led); + + ecat_slv_init (&config); + + while (1) + { + ecat_slv(); + } +} + +int main (void) +{ + soes (NULL); + return 0; +} diff --git a/applications/xmc4300_slavedemo/soes.c b/applications/xmc4300_slavedemo/soes.c deleted file mode 100644 index 8f0649e..0000000 --- a/applications/xmc4300_slavedemo/soes.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Licensed under the GNU General Public License version 2 with exceptions. See - * LICENSE file in the project root for full license information - */ - - /** \file - * \brief - * The application. - * - * The application, the main loop that service EtherCAT. - */ - -#include - -#include "esc.h" -#include "esc_coe.h" -#include "esc_eep.h" -#include "esc_hw_eep.h" - -#include "utypes.h" -#include "soes.h" - -#define WD_RESET 1000 -#define DEFAULTTXPDOMAP 0x1a00 -#define DEFAULTRXPDOMAP 0x1600 -#define DEFAULTTXPDOITEMS 1 -#define DEFAULTRXPDOITEMS 1 - -static const XMC_GPIO_CONFIG_t gpio_config_btn = { - .mode = XMC_GPIO_MODE_INPUT_INVERTED_PULL_UP, - .output_level = 0, - .output_strength = 0 -}; - -static const XMC_GPIO_CONFIG_t gpio_config_led = { - .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL, - .output_level = XMC_GPIO_OUTPUT_LEVEL_LOW, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE -}; - -uint32_t encoder_scale; -uint32_t encoder_scale_mirror; - -/* Global variables used by the stack */ -uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)]; -_MBXcontrol MBXcontrol[MBXBUFFERS]; -_ESCvar ESCvar; - -/* Application variables */ -_Rbuffer Rb; -_Wbuffer Wb; -_Cbuffer Cb; - -/* Private variables */ -volatile uint8_t digoutput; -volatile uint8_t diginput; -uint16_t txpdomap = DEFAULTTXPDOMAP; -uint16_t rxpdomap = DEFAULTRXPDOMAP; -uint8_t txpdoitems = DEFAULTTXPDOITEMS; -uint8_t rxpdoitems = DEFAULTTXPDOITEMS; - - -/** Function to pre-qualify the incoming SDO download. - * - * @param[in] index = index of SDO download request to check - * @param[in] sub-index = sub-index of SDO download request to check - * @return 1 if the SDO Download is correct. 0 If not correct. - */ -int ESC_pre_objecthandler (uint16_t index, uint8_t subindex) -{ - if ((index == 0x1c12) && (subindex > 0) && (rxpdoitems != 0)) - { - SDO_abort (index, subindex, ABORT_READONLY); - return 0; - } - if ((index == 0x1c13) && (subindex > 0) && (txpdoitems != 0)) - { - SDO_abort (index, subindex, ABORT_READONLY); - return 0; - } - return 1; -} - -/** Mandatory: Hook called from the slave stack SDO Download handler to act on - * user specified Index and Sub-index. - * - * @param[in] index = index of SDO download request to handle - * @param[in] sub-index = sub-index of SDO download request to handle - */ -void ESC_objecthandler (uint16_t index, uint8_t subindex) -{ - switch (index) - { - case 0x1c12: - { - if (rxpdoitems > 1) - { - rxpdoitems = 1; - } - if ((rxpdomap != 0x1600) && (rxpdomap != 0x1601) - && (rxpdomap != 0x0000)) - { - rxpdomap = 0x1600; - } - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - break; - } - case 0x1c13: - { - if (txpdoitems > 1) - { - txpdoitems = 1; - } - if ((txpdomap != 0x1A00) && (txpdomap != 0x1A01) - && (rxpdomap != 0x0000)) - { - txpdomap = 0x1A00; - } - ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - break; - } - case 0x7100: - { - switch (subindex) - { - case 0x01: - { - encoder_scale_mirror = encoder_scale; - break; - } - } - break; - } - case 0x8001: - { - switch (subindex) - { - case 0x01: - { - Cb.reset_counter = 0; - break; - } - } - break; - } - } -} - -/** Mandatory: Hook called from the slave stack ESC_stopoutputs to act on state changes - * forcing us to stop outputs. Here we can set them to a safe state. - * set - */ -void APP_safeoutput (void) -{ - DPRINT ("APP_safeoutput called\n"); - Wb.LED = 0; -} -/** Mandatory: Write local process data to Sync Manager 3, Master Inputs. - */ -void TXPDO_update (void) -{ - ESC_write (SM3_sma, &Rb.button, ESCvar.TXPDOsize); -} -/** Mandatory: Read Sync Manager 2 to local process data, Master Outputs. - */ -void RXPDO_update (void) -{ - ESC_read (SM2_sma, &Wb.LED, ESCvar.RXPDOsize); -} - -/** Mandatory: Function to update local I/O, call read ethercat outputs, call - * write ethercat inputs. Implement watch-dog counter to count-out if we have - * made state change affecting the App.state. - */ -void DIG_process (void) -{ - if (wd_cnt) - { - wd_cnt--; - } - if (ESCvar.App.state & APPSTATE_OUTPUT) - { - /* SM2 trigger ? */ - if (ESCvar.ALevent & ESCREG_ALEVENT_SM2) - { - ESCvar.ALevent &= ~ESCREG_ALEVENT_SM2; - RXPDO_update (); - wd_cnt = WD_RESET; - /* dummy output point */ - if (Wb.LED) { - XMC_GPIO_SetOutputHigh(P_LED); - } else { - XMC_GPIO_SetOutputLow(P_LED); - } - } - if (!wd_cnt) - { - DPRINT("DIG_process watchdog tripped\n"); - ESC_stopoutput (); - /* watchdog, invalid outputs */ - ESC_ALerror (ALERR_WATCHDOG); - /* goto safe-op with error bit set */ - ESC_ALstatus (ESCsafeop | ESCerror); - } - } - else - { - wd_cnt = WD_RESET; - } - if (ESCvar.App.state) - { - Rb.button = XMC_GPIO_GetInput(P_BTN); - Cb.reset_counter++; - Rb.encoder = ESCvar.Time; - TXPDO_update (); - } -} - -/** SOES main loop. Start by initializing the stack software followed by - * the application loop for cyclic read the EtherCAT state and staus, update - * of I/O. - */ -void soes_init (void) -{ - DPRINT ("SOES (Simple Open EtherCAT Slave)\n"); - - // configure I/O - XMC_GPIO_Init(P_BTN, &gpio_config_btn); - XMC_GPIO_Init(P_LED, &gpio_config_led); - - ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX); - ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX); - - /* Setup config hooks */ - static esc_cfg_t config = - { - .user_arg = NULL, - .use_interrupt = 0, - .watchdog_cnt = 0, - .mbxsize = MBXSIZE, - .mbxsizeboot = MBXSIZEBOOT, - .mbxbuffers = MBXBUFFERS, - .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 = NULL, - .esc_hw_interrupt_disable = NULL, - .esc_hw_eep_handler = NULL - }; - - ESC_config (&config); - ESC_init (NULL); - - /* wait until ESC is started up */ - do { - ESC_read (ESCREG_DLSTATUS, (void *) &ESCvar.DLstatus, - sizeof (ESCvar.DLstatus)); - ESCvar.DLstatus = etohs (ESCvar.DLstatus); - } while ((ESCvar.DLstatus & 0x0001) == 0); - - /* reset ESC to init state */ - ESC_ALstatus (ESCinit); - ESC_ALerror (ALERR_NONE); - ESC_stopmbx (); - ESC_stopinput (); - ESC_stopoutput (); -} - -void soes_task (void) -{ - /* On init restore PDO mappings to default size */ - if((ESCvar.ALstatus & 0x0f) == ESCinit) - { - txpdomap = DEFAULTTXPDOMAP; - rxpdomap = DEFAULTRXPDOMAP; - txpdoitems = DEFAULTTXPDOITEMS; - rxpdoitems = DEFAULTTXPDOITEMS; - } - /* Read local time from ESC*/ - ESC_read (ESCREG_LOCALTIME, (void *) &ESCvar.Time, sizeof (ESCvar.Time)); - ESCvar.Time = etohl (ESCvar.Time); - - /* Check the state machine */ - ESC_state(); - /* Check the SM activation event */ - ESC_sm_act_event(); - - /* If else to two separate execution paths - * If we're running BOOSTRAP - * - MailBox - * - FoE - * Else we're running normal execution - * - MailBox - * - CoE - */ - if (ESC_mbxprocess ()) - { - ESC_coeprocess (); - ESC_xoeprocess (); - } - DIG_process (); - EEP_process (); - EEP_hw_process(); -} - diff --git a/applications/xmc4300_slavedemo/soes.h b/applications/xmc4300_slavedemo/soes.h deleted file mode 100644 index a9580f5..0000000 --- a/applications/xmc4300_slavedemo/soes.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _SOES_H_ -#define _SOES_H_ - -#include -#include - -#define P_LED P4_1 -#define P_BTN P3_4 - -extern void soes_init (void); -extern void soes_task (void); - -#endif - diff --git a/soes/hal/tiesc/esc_hw.c b/soes/hal/tiesc/esc_hw.c index f61341f..c3b0690 100644 --- a/soes/hal/tiesc/esc_hw.c +++ b/soes/hal/tiesc/esc_hw.c @@ -14,10 +14,10 @@ #include "cc.h" #include "esc_hw.h" #include "esc_eep.h" -#include "k2gice.h" +#include "options.h" +#include "ecat_slv.h" #include "tiescbsp.h" #include "tieschw.h" -#include "config.h" extern PRUICSS_Handle pruIcss1Handle; extern uint32_t pd_read_addr_err, pd_write_addr_err; @@ -303,7 +303,9 @@ void PDI_Isr(void) if(ESCvar.ALevent & ESCREG_ALEVENT_SM2) { - DIG_process(DIG_PROCESS_OUTPUTS_FLAG | DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG); + DIG_process(DIG_PROCESS_OUTPUTS_FLAG | + DIG_PROCESS_APP_HOOK_FLAG | + DIG_PROCESS_INPUTS_FLAG); } } @@ -317,8 +319,8 @@ void ESC_init (const esc_cfg_t * config) escHwPruIcssHandle = pruIcss1Handle; bsp_set_sm_properties(escHwPruIcssHandle, 0, MBX0_sma, MBX0_sml); bsp_set_sm_properties(escHwPruIcssHandle, 1, MBX1_sma, MBX1_sml); - bsp_set_sm_properties(escHwPruIcssHandle, 2, SM2_sma, ESCvar.RXPDOsize); - bsp_set_sm_properties(escHwPruIcssHandle, 3, SM3_sma, ESCvar.TXPDOsize); + bsp_set_sm_properties(escHwPruIcssHandle, 2, SM2_sma, MAX_RXPDO_SIZE * 3); + bsp_set_sm_properties(escHwPruIcssHandle, 3, SM3_sma, MAX_TXPDO_SIZE * 3); bsp_write_dword(escHwPruIcssHandle, 0 , ESCREG_ALEVENTMASK); }