Merge pull request #52 from hefloryd/feature/soesv3

Feature/soesv3
pull/58/head
Hans-Erik Floryd 2019-05-09 15:45:42 +02:00 committed by GitHub
commit b46bb0ab0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
92 changed files with 4965 additions and 7189 deletions

1
.gitignore vendored
View File

@ -33,3 +33,4 @@
/build
soes/version.h
applications/xmc4300_slavedemo/XMC_Peripheral_Library

View File

@ -5,8 +5,8 @@ cmake_minimum_required (VERSION 2.8.4)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
project (SOES)
set (SOES_VERSION_MAJOR 2)
set (SOES_VERSION_MINOR 2)
set (SOES_VERSION_MAJOR 3)
set (SOES_VERSION_MINOR 0)
set (SOES_VERSION_PATCH 0)
# Generate version numbers

View File

@ -1,7 +1,6 @@
add_executable (demo
main.c
slave.c
slave_objectlist.c
)
target_link_libraries(demo LINK_PUBLIC soes)

View File

@ -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__ */

View File

@ -1,48 +1,54 @@
#include <stdio.h>
#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;
}

View File

@ -1,300 +0,0 @@
#include <stddef.h>
#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();
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Slave id="evb9252_dig" productCode="1234">
<Slave xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="com.rtlabs.emf.esx" fileVersion="2" id="evb9252_dig" productCode="1234" additionalInfo="0x0190">
<Name>lan9252</Name>
<Vendor>
<Id>0x1337</Id>
@ -24,275 +24,332 @@
<BootStrap>0010800080108000</BootStrap>
</Eeprom>
<Dictionary>
<Item>
<Name>Device Type</Name>
<Item Managed="true">
<Index>0x1000</Index>
<Name>Device Type</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x01901389</DefaultValue>
</Item>
<Item Managed="true">
<Name>Device Name</Name>
<Index>0x1008</Index>
<Name>Device Name</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>evb9252_dig</DefaultValue>
<Length>11</Length>
</Item>
<Item>
<Name>Hardware Version</Name>
<Item Managed="false">
<Index>0x1009</Index>
<Name>Hardware Version</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>1.0</DefaultValue>
</Item>
<Item>
<Name>Software Version</Name>
<Item Managed="false">
<Index>0x100A</Index>
<Name>Software Version</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>1.0</DefaultValue>
</Item>
<Item Managed="true">
<Name>Identity Object</Name>
<Index>0x1018</Index>
<Name>Identity Object</Name>
<DataType>RECORD</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>Vendor ID</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x1337</DefaultValue>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Name>Product Code</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>1234</DefaultValue>
</SubItem>
<SubItem>
<Index>0x03</Index>
<Name>Revision Number</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
</SubItem>
<SubItem>
<Index>0x04</Index>
<Name>Serial Number</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x00000000</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>LEDs</Name>
<Index>0x1600</Index>
<Name>LEDs</Name>
<DataType>RECORD</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>2</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>LED0</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x70000108</DefaultValue>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Name>LED1</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x70000208</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Buttons</Name>
<Index>0x1A00</Index>
<Name>Buttons</Name>
<DataType>RECORD</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>Button1</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x60000108</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager Communication Type</Name>
<Index>0x1C00</Index>
<Name>Sync Manager Communication Type</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>Communications Type SM0</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Name>Communications Type SM1</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>2</DefaultValue>
</SubItem>
<SubItem>
<Index>0x03</Index>
<Name>Communications Type SM2</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>3</DefaultValue>
</SubItem>
<SubItem>
<Index>0x04</Index>
<Name>Communications Type SM3</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager 2 PDO Assignment</Name>
<Index>0x1C12</Index>
<Name>Sync Manager 2 PDO Assignment</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1600</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager 3 PDO Assignment</Name>
<Index>0x1C13</Index>
<Name>Sync Manager 3 PDO Assignment</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1A00</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Buttons</Name>
<Index>0x6000</Index>
<Name>Buttons</Name>
<DataType>RECORD</DataType>
<Variable>Buttons</Variable>
<VariableType>Input</VariableType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Access>RO</Access>
<Name>Button1</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>0</DefaultValue>
<Access>RO</Access>
<Variable>Button1</Variable>
<VariableType>Input</VariableType>
</SubItem>
</Item>
<Item Managed="true">
<Name>LEDs</Name>
<Index>0x7000</Index>
<Name>LEDs</Name>
<DataType>RECORD</DataType>
<Variable>LEDs</Variable>
<VariableType>Output</VariableType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>2</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Access>RO</Access>
<Name>LED0</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>0</DefaultValue>
<Access>RO</Access>
<Variable>LED0</Variable>
<VariableType>Output</VariableType>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Access>RO</Access>
<Name>LED1</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>0</DefaultValue>
<Access>RO</Access>
<Variable>LED1</Variable>
<VariableType>Output</VariableType>
</SubItem>
</Item>
<Item Managed="true">
<Name>Parameters</Name>
<Index>0x8000</Index>
<Name>Parameters</Name>
<DataType>RECORD</DataType>
<Variable>Parameters</Variable>
<VariableType>Parameter</VariableType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Access>RW</Access>
<Name>Multiplier</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
<Access>RW</Access>
<Variable>Multiplier</Variable>
<VariableType>Parameter</VariableType>
</SubItem>
</Item>
</Dictionary>
<SmAssignment>
<Index>0x1C12</Index>
<Entry>
<Index>0x01</Index>
<AssignedPdo>0x1600</AssignedPdo>
</Entry>
</SmAssignment>
<SmAssignment>
<Index>0x1C13</Index>
<Entry>
<Index>0x01</Index>
<AssignedPdo>0x1A00</AssignedPdo>
</Entry>
</SmAssignment>
<RxPdo>
<Index>0x1600</Index>
<Container>LEDs</Container>
<Name>LEDs</Name>
<Entry>
<Index>0x7000</Index>
<SubIndex>1</SubIndex>
<Index>0x1</Index>
<MappedIndex>0x7000</MappedIndex>
<MappedSubIndex>0x01</MappedSubIndex>
<Variable>LED0</Variable>
</Entry>
<Entry>
<Index>0x7000</Index>
<SubIndex>2</SubIndex>
<Index>0x2</Index>
<MappedIndex>0x7000</MappedIndex>
<MappedSubIndex>0x02</MappedSubIndex>
<Variable>LED1</Variable>
</Entry>
</RxPdo>
<TxPdo>
<Index>0x1A00</Index>
<Container>Buttons</Container>
<Name>Buttons</Name>
<Entry>
<Index>0x6000</Index>
<SubIndex>1</SubIndex>
<Index>0x1</Index>
<MappedIndex>0x6000</MappedIndex>
<MappedSubIndex>0x01</MappedSubIndex>
<Variable>Button1</Variable>
</Entry>
</TxPdo>
<Input>
<Index>0x6000</Index>
<Name>Buttons</Name>
<Type>RECORD</Type>
<ObjectType>RECORD</ObjectType>
<Member>
<Index>0x01</Index>
<Access>RO</Access>
<Name>Button1</Name>
<Type>UNSIGNED8</Type>
<DefaultValue>0</DefaultValue>
</Member>
</Input>
<Output>
<Index>0x7000</Index>
<Name>LEDs</Name>
<Type>RECORD</Type>
<ObjectType>RECORD</ObjectType>
<Member>
<Index>0x01</Index>
<Access>RO</Access>
<Name>LED0</Name>
<Type>UNSIGNED8</Type>
<DefaultValue>0</DefaultValue>
</Member>
<Member>
<Index>0x02</Index>
<Access>RO</Access>
<Name>LED1</Name>
<Type>UNSIGNED8</Type>
<DefaultValue>0</DefaultValue>
</Member>
</Output>
<Parameter>
<Index>0x8000</Index>
<Name>Parameters</Name>
<Type>RECORD</Type>
<ObjectType>RECORD</ObjectType>
<Member>
<Index>0x01</Index>
<Access>RW</Access>
<Name>Multiplier</Name>
<Type>UNSIGNED32</Type>
<DefaultValue>0</DefaultValue>
</Member>
</Parameter>
</Slave>
</Slave>

View File

@ -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__ */

View File

@ -26,7 +26,7 @@
<BitSize>144</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -80,7 +80,7 @@
<BitSize>80</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -114,7 +114,7 @@
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -147,7 +147,7 @@
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -179,7 +179,7 @@
<BitSize>32</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -211,7 +211,7 @@
<BitSize>32</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -234,7 +234,7 @@
<BitSize>24</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -258,7 +258,7 @@
<BitSize>32</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -292,7 +292,7 @@
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -311,10 +311,6 @@
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>STRING(3)</Name>
<BitSize>24</BitSize>
</DataType>
<DataType>
<Name>STRING(11)</Name>
<BitSize>88</BitSize>
@ -327,6 +323,10 @@
<Name>UINT</Name>
<BitSize>16</BitSize>
</DataType>
<DataType>
<Name>STRING(0)</Name>
<BitSize>0</BitSize>
</DataType>
<DataType>
<Name>USINT</Name>
<BitSize>8</BitSize>
@ -361,8 +361,8 @@
<Object>
<Index>#x1009</Index>
<Name>Hardware Version</Name>
<Type>STRING(3)</Type>
<BitSize>24</BitSize>
<Type>STRING(0)</Type>
<BitSize>0</BitSize>
<Info>
<DefaultString>1.0</DefaultString>
</Info>
@ -374,8 +374,8 @@
<Object>
<Index>#x100A</Index>
<Name>Software Version</Name>
<Type>STRING(3)</Type>
<BitSize>24</BitSize>
<Type>STRING(0)</Type>
<BitSize>0</BitSize>
<Info>
<DefaultString>1.0</DefaultString>
</Info>
@ -390,7 +390,7 @@
<BitSize>144</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>4</DefaultValue>
</Info>
@ -431,7 +431,7 @@
<BitSize>80</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>2</DefaultValue>
</Info>
@ -460,7 +460,7 @@
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -483,7 +483,7 @@
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>4</DefaultValue>
</Info>
@ -524,7 +524,7 @@
<BitSize>32</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -547,7 +547,7 @@
<BitSize>32</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -570,7 +570,7 @@
<BitSize>24</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -593,7 +593,7 @@
<BitSize>32</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>2</DefaultValue>
</Info>
@ -622,7 +622,7 @@
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -652,14 +652,14 @@
<Name>LEDs</Name>
<Entry>
<Index>#x7000</Index>
<SubIndex>1</SubIndex>
<SubIndex>#x1</SubIndex>
<BitLen>8</BitLen>
<Name>LED0</Name>
<DataType>USINT</DataType>
</Entry>
<Entry>
<Index>#x7000</Index>
<SubIndex>2</SubIndex>
<SubIndex>#x2</SubIndex>
<BitLen>8</BitLen>
<Name>LED1</Name>
<DataType>USINT</DataType>
@ -670,14 +670,14 @@
<Name>Buttons</Name>
<Entry>
<Index>#x6000</Index>
<SubIndex>1</SubIndex>
<SubIndex>#x1</SubIndex>
<BitLen>8</BitLen>
<Name>Button1</Name>
<DataType>USINT</DataType>
</Entry>
</TxPdo>
<Mailbox DataLinkLayer="true">
<CoE CompleteAccess="false" PdoUpload="true" SdoInfo="true"/>
<CoE CompleteAccess="false" PdoUpload="false" SdoInfo="true"/>
<FoE/>
</Mailbox>
<Eeprom>

View File

@ -1,66 +1,70 @@
#include "soes/esc_coe.h"
#include "esc_coe.h"
#include "utypes.h"
#include <stddef.h>
#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[] =

View File

@ -1,47 +1,45 @@
#ifndef __UTYPES_H__
#define __UTYPES_H__
#include <cc.h>
#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__ */

View File

@ -1,35 +0,0 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include <cc.h>
#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__ */

View File

@ -1,49 +0,0 @@
#include <kern.h>
#include "slave.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)
{
}
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);
return 0;
}

View File

@ -1,298 +0,0 @@
#include <stddef.h>
#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();
}

View File

@ -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__ */

View File

@ -1,47 +0,0 @@
#ifndef __UTYPES_H__
#define __UTYPES_H__
#include <cc.h>
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint8_t Button1;
} CC_PACKED Buttons;
CC_PACKED_END
} CC_PACKED _Rbuffer;
CC_PACKED_END
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint8_t LED0;
uint8_t LED1;
} CC_PACKED LEDs;
CC_PACKED_END
} CC_PACKED _Wbuffer;
CC_PACKED_END
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint32_t Multiplier;
} CC_PACKED Parameters;
CC_PACKED_END
} CC_PACKED _Cbuffer;
CC_PACKED_END
extern _Rbuffer Rb;
extern _Wbuffer Wb;
extern _Cbuffer Cb;
#endif /* __UTYPES_H__ */

View File

@ -1,35 +0,0 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include <cc.h>
#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 0x24
#define SM2_act 1
#define SM3_sma 0x1180
#define SM3_smc 0x20
#define SM3_act 1
#endif /* __CONFIG_H__ */

View File

@ -1,7 +1,13 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#ifndef __ECAT_OPTIONS_H__
#define __ECAT_OPTIONS_H__
#include <cc.h>
#include "cc.h"
#define USE_FOE 0
#define USE_EOE 1
#define MAX_INPUT_SIZE 128
#define MAX_OUTPUT_SIZE 128
#define MBXSIZE 128
#define MBXSIZEBOOT 128
@ -26,10 +32,13 @@
#define MBX1_smc_b 0x22
#define SM2_sma 0x1100
#define SM2_smc 0x24
#define SM2_smc 0x64
#define SM2_act 1
#define SM3_sma 0x1180
#define SM3_smc 0x20
#define SM3_act 1
#endif /* __CONFIG_H__ */
#define MAX_MAPPINGS_SM2 2
#define MAX_MAPPINGS_SM3 1
#endif /* __ECAT_OPTIONS_H__ */

View File

@ -1,312 +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
* ESC hardware layer functions.
*
* Function to read and write commands to the ESC. Used to read/write ESC
* registers and memory.
*/
#include <kern.h>
#include <bsp.h>
#include <xmc4.h>
#include <eru.h>
#include <string.h>
#include "esc_hw.h"
#include "slave.h"
#include "esc_eep.h"
#define ESCADDR(x) (((uint8_t *) ECAT0_BASE) + x)
static volatile esc_registers_t * ecat0 = (esc_registers_t *)ECAT0_BASE;
static int use_all_interrupts = 0;
//static sem_t * ecat_isr_sem;
static void sync0_isr (void * arg);
static volatile uint8_t read_ack;
static const eru_cfg_t cfg = {
.base = ERU1_BASE,
.channel = 2,
.in_a = 0,
.in_b = 3,
.exicon = ERU_EXICON_PE_ENABLED |
ERU_EXICON_LD_ENABLED |
ERU_EXICON_RE_ENABLED |
ERU_EXICON_OCS(2) |
ERU_EXICON_SS(1),
.exocon = ERU_EXOCON_ISS(0) |
ERU_EXOCON_GP(1) |
ERU_EXOCON_IPEEN(0),
.irq = IRQ_ERU1_SR7,
.isr = sync0_isr,
.arg = NULL,
};
static const scu_ecat_cfg_t port_control =
{
.con = {0},
.conp0 = {
.rxd[0] = ECAT_PORT0_CTRL_RXDO0,
.rxd[1] = ECAT_PORT0_CTRL_RXDO1,
.rxd[2] = ECAT_PORT0_CTRL_RXDO2,
.rxd[3] = ECAT_PORT0_CTRL_RXDO3,
.rx_clk = ECAT_PORT0_CTRL_RX_CLK,
.rx_dv = ECAT_PORT0_CTRL_RX_DV,
.rx_err = ECAT_PORT0_CTRL_RX_ERR,
.link = ECAT_PORT0_CTRL_LINK,
.tx_clk = ECAT_PORT0_CTRL_TX_CLK,
.tx_shift = ECAT_PORT0_CTRL_TX_SHIFT
},
.conp1 = {
.rxd[0] = ECAT_PORT1_CTRL_RXDO0,
.rxd[1] = ECAT_PORT1_CTRL_RXDO1,
.rxd[2] = ECAT_PORT1_CTRL_RXDO2,
.rxd[3] = ECAT_PORT1_CTRL_RXDO3,
.rx_clk = ECAT_PORT1_CTRL_RX_CLK,
.rx_dv = ECAT_PORT1_CTRL_RX_DV,
.rx_err = ECAT_PORT1_CTRL_RX_ERR,
.link = ECAT_PORT1_CTRL_LINK,
.tx_clk = ECAT_PORT1_CTRL_TX_CLK,
.tx_shift = ECAT_PORT1_CTRL_TX_SHIFT
}
};
/* EtherCAT module clock ungating and deassert reset API (Enables ECAT) */
void ESC_enable(void)
{
scu_put_peripheral_in_reset (SCU_PERIPHERAL_ECAT0);
scu_ungate_clock_to_peripheral (SCU_PERIPHERAL_ECAT0);
scu_release_peripheral_from_reset (SCU_PERIPHERAL_ECAT0);
}
/* EtherCAT module clock gating and assert reset API (Disables ECAT)*/
void ESC_disable(void)
{
scu_put_peripheral_in_reset (SCU_PERIPHERAL_ECAT0);
scu_gate_clock_to_peripheral (SCU_PERIPHERAL_ECAT0);
}
/** ESC read function used by the Slave stack.
*
* @param[in] address = address of ESC register to read
* @param[out] buf = pointer to buffer to read in
* @param[in] len = number of bytes to read
*/
void ESC_read (uint16_t address, void *buf, uint16_t len)
{
if(use_all_interrupts == 0)
{
ESCvar.ALevent = etohs ((uint16_t)ecat0->AL_EVENT_REQ);
}
memcpy (buf, ESCADDR(address), len);
}
/** ESC write function used by the Slave stack.
*
* @param[in] address = address of ESC register to write
* @param[out] buf = pointer to buffer to write from
* @param[in] len = number of bytes to write
*/
void ESC_write (uint16_t address, void *buf, uint16_t len)
{
if(use_all_interrupts == 0)
{
ESCvar.ALevent = etohs ((uint16_t)ecat0->AL_EVENT_REQ);
}
memcpy (ESCADDR(address), buf, len);
}
/** ESC reset hardware.
*/
void ESC_reset (void)
{
/* disable ESC to force reset */
ESC_disable ();
/* initialize EEPROM emulation */
EEP_init ();
}
/** ESC interrupt enable function by the Slave stack in IRQ mode.
*
* @param[in] mask = of interrupts to enable
*/
void ESC_interrupt_enable (uint32_t mask)
{
if(ESCREG_ALEVENT_DC_SYNC0 & mask)
{
mask &= ~ESCREG_ALEVENT_DC_SYNC0;
int_enable(cfg.irq);
}
if(ESCREG_ALEVENT_DC_SYNC1 & mask)
{
mask &= ~ESCREG_ALEVENT_DC_SYNC1;
UASSERT(0,EARG);
}
if(ESCREG_ALEVENT_DC_LATCH & mask)
{
mask &= ~ESCREG_ALEVENT_DC_LATCH;
UASSERT(0,EARG);
}
ecat0->AL_EVENT_MASK |= mask;
}
/** ESC interrupt disable function by the Slave stack in IRQ mode.
*
* @param[in] mask = interrupts to disable
*/
void ESC_interrupt_disable (uint32_t mask)
{
if(ESCREG_ALEVENT_DC_SYNC0 & mask)
{
mask &= ~ESCREG_ALEVENT_DC_SYNC0;
int_disable(cfg.irq);
}
if(ESCREG_ALEVENT_DC_SYNC1 & mask)
{
mask &= ~ESCREG_ALEVENT_DC_SYNC1;
UASSERT(0,EARG);
}
if(ESCREG_ALEVENT_DC_LATCH & mask)
{
mask &= ~ESCREG_ALEVENT_DC_LATCH;
UASSERT(0,EARG);
}
ecat0->AL_EVENT_MASK &= ~mask;
}
/** ESC emulated EEPROM handler
*/
void ESC_eep_handler(void)
{
EEP_process ();
EEP_hw_process();
}
/** SYNC0 ISR handler
*
* @param[in] arg = NOT USED
*/
static void sync0_isr (void * arg)
{
DIG_process(DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG);
read_ack = ecat0->DC_SYNC0_STAT;
}
/** PDI ISR handler
*
* @param[in] arg = NOT USED
*/
static void ecat_isr (void * arg)
{
ESC_read (ESCREG_LOCALTIME, (void *) &ESCvar.Time, sizeof (ESCvar.Time));
ESCvar.Time = etohl (ESCvar.Time);
CC_ATOMIC_SET(ESCvar.ALevent, etohl(ecat0->AL_EVENT_REQ));
if(ESCvar.ALevent & ESCREG_ALEVENT_SM2)
{
if(ESCvar.dcsync == 0)
{
DIG_process(DIG_PROCESS_OUTPUTS_FLAG | DIG_PROCESS_APP_HOOK_FLAG |
DIG_PROCESS_INPUTS_FLAG);
}
else
{
DIG_process(DIG_PROCESS_OUTPUTS_FLAG);
}
}
#if 1
if(ESCvar.ALevent & (ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP))
{
/* Mask interrupts while servicing them */
ecat0->AL_EVENT_MASK &= ~(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP);
extern flags_t * ecat_events;
flags_set(ecat_events, EVENT_ISR);
//sem_signal(ecat_isr_sem);
}
#endif
}
#if 0
/* Function for PDI ISR serving task */
static void isr_run(void * arg)
{
while(1)
{
sem_wait(ecat_isr_sem);
ecat_slv_worker(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP);
}
}
#endif
/** ESC and CPU related HW init
*
* @param[in] arg = esc_cfg provided by the application
*/
void ESC_init (const esc_cfg_t * config)
{
eep_config_t ecat_config;
ESC_reset();
scu_configure_ethercat_signals(&port_control);
/* read config from emulated EEPROM */
memset(&ecat_config, 0, sizeof(eep_config_t));
EEP_read (0, (uint8_t *) &ecat_config, sizeof(eep_config_t));
ESC_enable();
/* words 0x0-0x3 */
ecat0->EEP_DATA[0U] = ecat_config.dword[0U];
ecat0->EEP_DATA[1U] = ecat_config.dword[1U];
ecat0->EEP_CONT_STAT |= (uint16_t)(BIT(10)); /* ESI EEPROM Reload */
/* words 0x4-0x7 */
ecat0->EEP_DATA[0U] = ecat_config.dword[2U];
ecat0->EEP_DATA[1U] = ecat_config.dword[3U];
ecat0->EEP_CONT_STAT |= (uint16_t)(BIT(10)); /* ESI EEPROM Reload */
while (ecat0->EEP_CONT_STAT & BIT(12)) /* ESI EEPROM loading status */
{
/* Wait until the EEPROM_Loaded signal is active */
}
/* Configure CPU interrupts */
if(config->use_interrupt != 0)
{
// ecat_isr_sem = sem_create(0);
// task_spawn ("soes_isr", isr_run, 9, 2048, NULL);
use_all_interrupts = 0;
ecat0->AL_EVENT_MASK = 0;
ecat0->AL_EVENT_MASK = (ESCREG_ALEVENT_SMCHANGE |
ESCREG_ALEVENT_EEP |
ESCREG_ALEVENT_CONTROL |
ESCREG_ALEVENT_SM0 |
ESCREG_ALEVENT_SM1);
int_connect (IRQ_ECAT0_SR0, ecat_isr, NULL);
int_enable (IRQ_ECAT0_SR0);
// /* Activate for running external sync IRQ */
// scu_put_peripheral_in_reset (SCU_PERIPHERAL_ERU1);
// scu_ungate_clock_to_peripheral (SCU_PERIPHERAL_ERU1);
// scu_release_peripheral_from_reset (SCU_PERIPHERAL_ERU1);
//
// eru_configure(&cfg);
// /* Let the stack decide when to enable */
// int_disable(cfg.irq);
}
}

View File

@ -1,179 +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
* ESC hardware specifoc EEPROM emulation functions.
*/
#ifndef __esc_hw__
#define __esc_hw__
#include <kern.h>
/* ================================================================================ */
/* ================ ECAT [ECAT0] ================ */
/* ================================================================================ */
#define EVENT_PERIODIC BIT(0)
#define EVENT_TX BIT(1)
#define EVENT_ISR BIT(2)
/**
* @brief EtherCAT 0 (ECAT)
*/
typedef struct esc_registers
{ /*!< (@ 0x54010000) ECAT Structure */
uint8_t TYPE; /*!< (@ 0x54010000) Type of EtherCAT Controller */
uint8_t REVISION; /*!< (@ 0x54010001) Revision of EtherCAT Controller */
uint16_t BUILD; /*!< (@ 0x54010002) Build Version */
uint8_t FMMU_NUM; /*!< (@ 0x54010004) FMMUs Supported */
uint8_t SYNC_MANAGER; /*!< (@ 0x54010005) SyncManagers Supported */
uint8_t RAM_SIZE; /*!< (@ 0x54010006) RAM Size */
uint8_t PORT_DESC; /*!< (@ 0x54010007) Port Descriptor */
uint16_t FEATURE; /*!< (@ 0x54010008) ESC Features Supported */
uint16_t RESERVED[3];
uint16_t STATION_ADR; /*!< (@ 0x54010010) Configured Station Address */
uint16_t STATION_ALIAS; /*!< (@ 0x54010012) Configured Station Alias */
uint32_t RESERVED1[3];
uint8_t WR_REG_ENABLE; /*!< (@ 0x54010020) Write Register Enable */
uint8_t WR_REG_PROTECT; /*!< (@ 0x54010021) Write Register Protection */
uint16_t RESERVED2[7];
uint8_t ESC_WR_ENABLE; /*!< (@ 0x54010030) ESC Write Enable */
uint8_t ESC_WR_PROTECT; /*!< (@ 0x54010031) ESC Write Protection */
uint16_t RESERVED3[7];
union
{
uint8_t ESC_RESET_ECAT_READMode; /*!< (@ 0x54010040) ESC Reset ECAT [READ Mode] */
uint8_t ESC_RESET_ECAT_WRITEMode; /*!< (@ 0x54010040) ESC Reset ECAT [WRITE Mode] */
};
union {
uint8_t ESC_RESET_PDI_READMode; /*!< (@ 0x54010041) ESC Reset PDI [READ Mode] */
uint8_t ESC_RESET_PDI_WRITEMode; /*!< (@ 0x54010041) ESC Reset PDI [WRITE Mode] */
};
uint16_t RESERVED4[95];
uint32_t ESC_DL_CONTROL; /*!< (@ 0x54010100) ESC DL Control */
uint32_t RESERVED5;
uint16_t PHYSICAL_RW_OFFSET; /*!< (@ 0x54010108) Physical Read/Write Offset */
uint16_t RESERVED6[3];
uint16_t ESC_DL_STATUS; /*!< (@ 0x54010110) ESC DL Status */
uint16_t RESERVED7[7];
uint16_t AL_CONTROL; /*!< (@ 0x54010120) AL Control */
uint16_t RESERVED8[7];
uint16_t AL_STATUS; /*!< (@ 0x54010130) AL Status */
uint16_t RESERVED9;
uint16_t AL_STATUS_CODE; /*!< (@ 0x54010134) AL Status Code */
uint16_t RESERVED10;
uint8_t RUN_LED; /*!< (@ 0x54010138) RUN LED Override */
uint8_t ERR_LED; /*!< (@ 0x54010139) RUN ERR Override */
uint16_t RESERVED11[3];
uint8_t PDI_CONTROL; /*!< (@ 0x54010140) PDI Control */
uint8_t ESC_CONFIG; /*!< (@ 0x54010141) ESC Configuration */
uint16_t RESERVED12[7];
uint8_t PDI_CONFIG; /*!< (@ 0x54010150) PDI Control */
uint8_t SYNC_LATCH_CONFIG; /*!< (@ 0x54010151) Sync/Latch[1:0] PDI Configuration */
uint16_t PDI_EXT_CONFIG; /*!< (@ 0x54010152) PDI Synchronous Microcontroller extended Configuration */
uint32_t RESERVED13[43];
uint16_t EVENT_MASK; /*!< (@ 0x54010200) ECAT Event Mask */
uint16_t RESERVED14;
uint32_t AL_EVENT_MASK; /*!< (@ 0x54010204) PDI AL Event Mask */
uint32_t RESERVED15[2];
uint16_t EVENT_REQ; /*!< (@ 0x54010210) ECAT Event Request */
uint16_t RESERVED16[7];
uint32_t AL_EVENT_REQ; /*!< (@ 0x54010220) AL Event Request */
uint32_t RESERVED17[55];
uint16_t RX_ERR_COUNT0; /*!< (@ 0x54010300) RX Error Counter Port 0 */
uint16_t RX_ERR_COUNT1; /*!< (@ 0x54010302) RX Error Counter Port 1 */
uint32_t RESERVED18;
uint8_t FWD_RX_ERR_COUNT0; /*!< (@ 0x54010308) Forwarded RX Error Counter Port 0 */
uint8_t FWD_RX_ERR_COUNT1; /*!< (@ 0x54010309) Forwarded RX Error Counter Port 1 */
uint16_t RESERVED19;
uint8_t PROC_ERR_COUNT; /*!< (@ 0x5401030C) ECAT Processing Unit Error Counter */
uint8_t PDI_ERR_COUNT; /*!< (@ 0x5401030D) PDI Error Counter */
uint16_t RESERVED20;
uint8_t LOST_LINK_COUNT0; /*!< (@ 0x54010310) Lost Link Counter Port 0 */
uint8_t LOST_LINK_COUNT1; /*!< (@ 0x54010311) Lost Link Counter Port 1 */
uint16_t RESERVED21[119];
uint16_t WD_DIVIDE; /*!< (@ 0x54010400) Watchdog Divider */
uint16_t RESERVED22[7];
uint16_t WD_TIME_PDI; /*!< (@ 0x54010410) Watchdog Time PDI */
uint16_t RESERVED23[7];
uint16_t WD_TIME_PDATA; /*!< (@ 0x54010420) Watchdog Time Process Data */
uint16_t RESERVED24[15];
uint16_t WD_STAT_PDATA; /*!< (@ 0x54010440) Watchdog Status Process Data */
uint8_t WD_COUNT_PDATA; /*!< (@ 0x54010442) Watchdog Counter Process Data */
uint8_t WD_COUNT_PDI; /*!< (@ 0x54010443) Watchdog Counter PDI */
uint32_t RESERVED25[47];
uint8_t EEP_CONF; /*!< (@ 0x54010500) EEPROM Configuration */
uint8_t EEP_STATE; /*!< (@ 0x54010501) EEPROM PDI Access State */
uint16_t EEP_CONT_STAT; /*!< (@ 0x54010502) EEPROM Control/Status */
uint32_t EEP_ADR; /*!< (@ 0x54010504) EEPROM Address */
uint32_t EEP_DATA[2]; /*!< (@ 0x54010508) EEPROM Read/Write data */
uint16_t MII_CONT_STAT; /*!< (@ 0x54010510) MII Management Control/Status */
uint8_t MII_PHY_ADR; /*!< (@ 0x54010512) PHY Address */
uint8_t MII_PHY_REG_ADR; /*!< (@ 0x54010513) PHY Register Address */
uint16_t MII_PHY_DATA; /*!< (@ 0x54010514) PHY Data */
uint8_t MII_ECAT_ACS_STATE; /*!< (@ 0x54010516) MII ECAT ACS STATE */
uint8_t MII_PDI_ACS_STATE; /*!< (@ 0x54010517) MII PDI ACS STATE */
uint32_t RESERVED26[250];
uint32_t DC_RCV_TIME_PORT0; /*!< (@ 0x54010900) Receive Time Port 0 */
uint32_t DC_RCV_TIME_PORT1; /*!< (@ 0x54010904) Receive Time Port 1 */
uint32_t RESERVED27[2];
union
{
uint32_t READMode_DC_SYS_TIME[2]; /*!< (@ 0x54010910) System Time read access */
uint32_t DC_SYS_TIME_WRITEMode; /*!< (@ 0x54010910) System Time [WRITE Mode] */
};
uint32_t RECEIVE_TIME_PU[2]; /*!< (@ 0x54010918) Local time of the beginning of a frame */
uint32_t DC_SYS_TIME_OFFSET[2]; /*!< (@ 0x54010920) Difference between local time and System Time */
uint32_t DC_SYS_TIME_DELAY; /*!< (@ 0x54010928) System Time Delay */
uint32_t DC_SYS_TIME_DIFF; /*!< (@ 0x5401092C) System Time Difference */
uint16_t DC_SPEED_COUNT_START; /*!< (@ 0x54010930) Speed Counter Start */
uint16_t DC_SPEED_COUNT_DIFF; /*!< (@ 0x54010932) Speed Counter Diff */
uint8_t DC_SYS_TIME_FIL_DEPTH; /*!< (@ 0x54010934) System Time Difference Filter Depth */
uint8_t DC_SPEED_COUNT_FIL_DEPTH; /*!< (@ 0x54010935) Speed Counter Filter Depth */
uint16_t RESERVED28[37];
uint8_t DC_CYC_CONT; /*!< (@ 0x54010980) Cyclic Unit Control */
uint8_t DC_ACT; /*!< (@ 0x54010981) Activation register */
uint16_t DC_PULSE_LEN; /*!< (@ 0x54010982) Pulse Length of SyncSignals */
uint8_t DC_ACT_STAT; /*!< (@ 0x54010984) Activation Status */
uint8_t RESERVED29[9];
uint8_t DC_SYNC0_STAT; /*!< (@ 0x5401098E) SYNC0 Status */
uint8_t DC_SYNC1_STAT; /*!< (@ 0x5401098F) SYNC1 Status */
uint32_t DC_CYC_START_TIME[2]; /*!< (@ 0x54010990) Start Time Cyclic Operation */
uint32_t DC_NEXT_SYNC1_PULSE[2]; /*!< (@ 0x54010998) System time of next SYNC1 pulse in ns */
uint32_t DC_SYNC0_CYC_TIME; /*!< (@ 0x540109A0) SYNC0 Cycle Time */
uint32_t DC_SYNC1_CYC_TIME; /*!< (@ 0x540109A4) SYNC1 Cycle Time */
uint8_t DC_LATCH0_CONT; /*!< (@ 0x540109A8) Latch0 Control */
uint8_t DC_LATCH1_CONT; /*!< (@ 0x540109A9) Latch1 Control */
uint32_t RESERVED30;
uint8_t DC_LATCH0_STAT; /*!< (@ 0x540109AE) Latch0 Status */
uint8_t DC_LATCH1_STAT; /*!< (@ 0x540109AF) Latch1 Status */
uint32_t DC_LATCH0_TIME_POS[2]; /*!< (@ 0x540109B0) Register captures System time at the positive
edge of the Latch0 signal */
uint32_t DC_LATCH0_TIME_NEG[2]; /*!< (@ 0x540109B8) Register captures System time at the negative
edge of the Latch0 signal */
uint32_t DC_LATCH1_TIME_POS[2]; /*!< (@ 0x540109C0) Register captures System time at the positive
edge of the Latch1 signal */
uint32_t DC_LATCH1_TIME_NEG[2]; /*!< (@ 0x540109C8) Register captures System time at the negative
edge of the Latch1 signal */
uint32_t RESERVED31[8];
uint32_t DC_ECAT_CNG_EV_TIME; /*!< (@ 0x540109F0) EtherCAT Buffer Change Event Time */
uint32_t RESERVED32;
uint32_t DC_PDI_START_EV_TIME; /*!< (@ 0x540109F8) PDI Buffer Start Event Time */
uint32_t DC_PDI_CNG_EV_TIME; /*!< (@ 0x540109FC) PDI Buffer Change Event Time */
uint32_t RESERVED33[256];
uint32_t ID; /*!< (@ 0x54010E00) ECAT0 Module ID */
uint32_t RESERVED34;
uint32_t STATUS; /*!< (@ 0x54010E08) ECAT0 Status */
} esc_registers_t;
void EEP_hw_process (void);
void ESC_eep_handler(void);
void ESC_interrupt_enable (uint32_t mask);
void ESC_interrupt_disable (uint32_t mask);
#endif

View File

@ -1,311 +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
* ESC hardware specific EEPROM emulation functions.
*/
#include <cc.h>
#include <fce.h>
#include <string.h>
#include <drivers/nor/nor.h>
#include "esc.h"
#include "esc_hw_eep.h"
extern const uint8_t _binary_sii_eeprom_bin_start;
extern const uint8_t _binary_sii_eeprom_bin_end;
#define SII_EE_DEFLT (&_binary_sii_eeprom_bin_start)
#define SII_EE_DEFLT_SIZE (uint32_t)(&_binary_sii_eeprom_bin_end - &_binary_sii_eeprom_bin_start)
#define EEP_DEFAULT_BTN_INIT() { }
#define EEP_DEFAULT_BTN_STATE() 0
#define EEP_BUSY_LED_INIT() { }
#define EEP_BUSY_LED_ON() { }
#define EEP_BUSY_LED_OFF() { }
#if EEP_BYTES_PER_BLOCK > EEP_BYTES_PER_SECTOR
#error EEP_BYTES_PER_BLOCK needs to fit into EEP_BYTES_PER_SECTOR
#endif
/** CRC engine configuration */
static const fce_kernel_cfg_t fce_config =
{
.crc_kernel_addr = FCE_KE0_BASE,
.kernel_cfg = 0,
.seed = 0xffffffff
};
static uint8_t eep_buf[EEP_EMU_BYTES];
static uint8_t eep_buf_dirty;
static uint32_t eep_last_write;
static uint8_t eep_write_req;
static eep_block_t *eep_curr_block;
static eep_block_t *eep_next_block;
static uint32_t *eep_write_src;
static uint32_t *eep_write_dst;
static uint32_t eep_write_page;
static eep_block_t eep_write_buf;
static drv_t * drv;
static void init_flash_data(void);
static void find_latest_block(eep_block_t *addr);
static eep_block_t *get_next_block(eep_block_t *block);
static eep_block_t *cleanup_unused_sect(eep_block_t *block);
static int32_t is_sector_empty(uint32_t *addr);
/** Initialize EEPROM emulation (load default data, validate checksums, ...).
*
*/
void EEP_init (void)
{
/* initialize write buffer */
memset(&eep_write_buf, 0, EEP_BYTES_PER_BLOCK);
/* Initialize the FCE Configuration */
fce_init(&fce_config);
drv = dev_find_driver ("/pflash");
ASSERT (drv != NULL);
/* try to find latest block in both sectors */
eep_curr_block = NULL;
if (!EEP_DEFAULT_BTN_STATE()) {
find_latest_block((eep_block_t *) EEP_SECTOR_A);
find_latest_block((eep_block_t *) EEP_SECTOR_B);
}
EEP_BUSY_LED_ON();
/* no valid block found -> initialize flash with default data */
if (eep_curr_block == NULL) {
init_flash_data();
}
/* cleanup unused block */
cleanup_unused_sect(eep_curr_block);
/* copy data from block to emu buffer */
memcpy(eep_buf, eep_curr_block->data, EEP_EMU_BYTES);
/* initialize state variables */
eep_buf_dirty = 0;
eep_last_write = 0;
eep_write_req = 0;
eep_next_block = NULL;
}
/** EEPROM emulation controller side periodic task.
*
*/
void EEP_hw_process (void)
{
/* check for dirty buffer and set write */
if (eep_buf_dirty) {
int32_t idle_time = ((int32_t) ESCvar.Time) - ((int32_t) eep_last_write);
if (idle_time > EEP_IDLE_TIMEOUT) {
eep_buf_dirty = 0;
eep_write_req = 1;
}
}
/* check for write process */
if (eep_next_block != NULL) {
/* write flash page */
nor_write(drv, EEP_FLASH_SECTOR_OFFSET((uint32_t)eep_write_dst),
EEP_BYTES_PER_PAGE, (const uint8_t *)eep_write_src);
eep_write_src += (EEP_BYTES_PER_PAGE / sizeof(*eep_write_src));
eep_write_dst += (EEP_BYTES_PER_PAGE / sizeof(*eep_write_dst));
/* update counter */
eep_write_page++;
/* check for finished job */
if (eep_write_page >= EEP_PAGES_PER_BLOCK) {
/* update block pointer and reset write state */
eep_curr_block = eep_next_block;
eep_next_block = NULL;
}
return;
}
/* start write of new block */
if (eep_write_req) {
EEP_BUSY_LED_ON();
/* get next block */
eep_next_block = get_next_block(eep_curr_block);
/* copy data */
memcpy(eep_write_buf.data, eep_buf, EEP_EMU_BYTES);
/* setup header */
eep_write_buf.header.seq = eep_curr_block->header.seq + 1;
eep_write_buf.header.crc = fce_crc32 (&fce_config,
(const uint32_t *)eep_write_buf.data, EEP_DATA_BYTES);
/* initialize write position */
eep_write_src = (uint32_t *) &eep_write_buf;
eep_write_dst = (uint32_t *) eep_next_block;
eep_write_page = 0;
/* reset write request */
eep_write_req = 0;
}
}
/** EEPROM read function
*
* @param[in] addr = EEPROM byte address
* @param[out] data = pointer to buffer of output data
* @param[in] count = number of bytes to read
* @return 0 on OK, 1 on error
*/
int8_t EEP_read (uint32_t addr, uint8_t *data, uint16_t count)
{
if (addr >= EEP_EMU_BYTES) {
return 1;
}
/* read data from ram buffer */
memcpy(data, eep_buf + addr, count);
return 0;
}
/** EEPROM write function
*
* @param[in] addr = EEPROM byte address
* @param[out] data = pointer to buffer of input data
* @param[in] count = number of bytes to write
* @return 0 on OK, 1 on error
*/
int8_t EEP_write (uint32_t addr, uint8_t *data, uint16_t count)
{
if (addr >= EEP_EMU_BYTES) {
return 1;
}
/* write data to ram buffer */
memcpy(eep_buf + addr, data, count);
/* mark buffer as dirty */
eep_buf_dirty = 1;
eep_write_req = 0;
eep_last_write = ESCvar.Time;
return 0;
}
static void init_flash_data(void)
{
uint32_t i;
const uint32_t *src;
uint32_t dst;
/* erase both sectors */
nor_erase(drv, EEP_FLASH_SECTOR_OFFSET(EEP_SECTOR_A), EEP_BYTES_PER_SECTOR);
nor_erase(drv, EEP_FLASH_SECTOR_OFFSET(EEP_SECTOR_B), EEP_BYTES_PER_SECTOR);
/* copy default data to write buffer */
memcpy(eep_write_buf.data, SII_EE_DEFLT, (SII_EE_DEFLT_SIZE < EEP_EMU_BYTES) ? SII_EE_DEFLT_SIZE : EEP_EMU_BYTES);
/*
* memcpy(eep_write_buf.data, SII_EE_DEFLT, (SII_EE_DEFLT_SIZE < EEP_EMU_BYTES) ? SII_EE_DEFLT_SIZE : EEP_EMU_BYTES);
*/
/* setup header data */
eep_write_buf.header.seq = 0;
eep_write_buf.header.crc = fce_crc32 (&fce_config,
(const uint32_t *)eep_write_buf.data, EEP_DATA_BYTES);
/* write pages */
src = (const uint32_t *) &eep_write_buf;
dst = EEP_SECTOR_A;
for (i = 0; i < EEP_PAGES_PER_BLOCK; i++) {
nor_write(drv, EEP_FLASH_SECTOR_OFFSET(dst), EEP_BYTES_PER_PAGE,
(const uint8_t *)src);
src += (EEP_BYTES_PER_PAGE / sizeof(*src));
dst += EEP_BYTES_PER_PAGE;
}
/* set current block */
eep_curr_block = (eep_block_t *) EEP_SECTOR_A;
}
static void find_latest_block(eep_block_t *addr)
{
uint32_t blk, crc;
for (blk = 0; blk < EPP_BLOCKS_PER_SECT; blk++, addr++) {
/* check crc, skip invalid blocks */
crc = fce_crc32 (&fce_config, (const uint32_t *) addr->data,
EEP_DATA_BYTES);
if (addr->header.crc != crc) {
continue;
}
/* check sequence number and update last pointer */
if (eep_curr_block == NULL || (addr->header.seq - eep_curr_block->header.seq) > 0) {
eep_curr_block = addr;
}
}
}
static eep_block_t *get_next_block(eep_block_t *block)
{
/* simple case: new block fits in current sector */
uint32_t sect_offset = ((uint32_t)block) & (EEP_BYTES_PER_SECTOR - 1);
if ((sect_offset + EEP_BYTES_PER_BLOCK) < EEP_BYTES_PER_SECTOR) {
return block + 1;
}
/* use other sector */
return cleanup_unused_sect(block);
}
static eep_block_t *cleanup_unused_sect(eep_block_t *block)
{
/* get other sector */
uint32_t sect_addr = (((uint32_t)block) & ~(EEP_BYTES_PER_SECTOR - 1));
if (sect_addr == EEP_SECTOR_A) {
sect_addr = EEP_SECTOR_B;
} else {
sect_addr = EEP_SECTOR_A;
}
/* check if sector is empty, erase if not */
if (!is_sector_empty((uint32_t *)sect_addr)) {
nor_erase(drv, EEP_FLASH_SECTOR_OFFSET(sect_addr), EEP_BYTES_PER_SECTOR);
}
return (eep_block_t *) sect_addr;
}
static int32_t is_sector_empty(uint32_t *addr)
{
uint32_t i;
/* check for all bytes erased */
for (i=0; i<EEP_BYTES_PER_SECTOR; i+=sizeof(uint32_t), addr++) {
if (*addr != 0) {
return 0;
}
}
return 1;
}

View File

@ -1,54 +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
* ESC hardware specifoc EEPROM emulation functions.
*/
#ifndef __esc_hw_eep__
#define __esc_hw_eep__
#include <bsp.h>
#include <cc.h>
#include "esc_eep.h"
/* idle timeout in ns before actual flash write will be issued */
#define EEP_IDLE_TIMEOUT 100000000
/* Pages per emulated EEPROM block */
#define EEP_BYTES_PER_SECTOR XMC4_EEPROM_SECTOR_SIZE_BYTES
#define EEP_BYTES_PER_PAGE XMC4_PAGE_SIZE_BYTES
#define EEP_PAGES_PER_BLOCK 16
/* block header */
typedef struct CC_PACKED
{
int32_t seq;
uint32_t crc;
} eep_header_t;
/* calculate resulting sizes */
#define EEP_BYTES_PER_BLOCK (EEP_PAGES_PER_BLOCK * EEP_BYTES_PER_PAGE)
#define EPP_BLOCKS_PER_SECT (EEP_BYTES_PER_SECTOR / EEP_BYTES_PER_BLOCK)
#define EEP_DATA_BYTES (EEP_BYTES_PER_BLOCK - sizeof(eep_header_t))
/* eeprom size increments in steps of 0x80 bytes */
#define EEP_EMU_BYTES (EEP_DATA_BYTES & ~0x7f)
/* block structure */
typedef struct CC_PACKED
{
eep_header_t header;
uint8_t data[EEP_DATA_BYTES];
} eep_block_t;
/* periodic task */
void EEP_hw_process (void);
#endif

View File

@ -1,19 +1,22 @@
#include <kern.h>
#include <xmc4.h>
#include <bsp.h>
#include "esc.h"
#include "esc_eoe.h"
#include "slave.h"
#include "esc_hw.h"
#include "config.h"
#include "ecat_slv.h"
#include "options.h"
#include "utypes.h"
#include <lwip/sys.h>
#include <lwip/netifapi.h>
#include <netif/etharp.h>
#include <string.h>
#define CFG_HOSTNAME "xmc48relax"
static struct netif * found_if;
static mbox_t * pbuf_mbox;
static tmr_t * ecat_timer;
static uint8_t mac_address[6] = {0x1E, 0x30, 0x6C, 0xA2, 0x45, 0x5E};
static void appl_get_buffer (eoe_pbuf_t * ebuf);
@ -23,88 +26,69 @@ static int appl_store_ethernet_settings (void);
static void appl_handle_recv_buffer (uint8_t port, eoe_pbuf_t * ebuf);
static int appl_fetch_send_buffer (uint8_t port, eoe_pbuf_t * ebuf);
flags_t * ecat_events;
/* Application variables */
_Objects Obj;
/**
* This function gets input values and updates Rb.Button1
*/
void cb_get_Button1()
extern sem_t * ecat_isr_sem;
struct netif * net_add_interface (err_t (*netif_fn) (struct netif * netif))
{
Rb.Button1.B = gpio_get(GPIO_BUTTON1);
struct netif * netif;
ip_addr_t ipaddr;
ip_addr_t netmask;
ip_addr_t gateway;
err_enum_t error;
netif = malloc (sizeof(struct netif));
UASSERT (netif != NULL, EMEM);
/* Set default (zero) values */
ip_addr_set_zero (&ipaddr);
ip_addr_set_zero (&netmask);
ip_addr_set_zero (&gateway);
/* Let lwIP TCP/IP thread initialise and add the interface. The interface
* will be down until net_configure() is called.
*/
error = netifapi_netif_add (
netif, &ipaddr, &netmask, &gateway, NULL, netif_fn, tcpip_input);
UASSERT (error == ERR_OK, EARG);
return netif;
}
/**
* This function gets input values and updates Rb.Button2
*/
void cb_get_Button2()
void cb_get_inputs (void)
{
Rb.Button2.B = gpio_get(GPIO_BUTTON2);
static int count;
Obj.Buttons.Button1 = gpio_get(GPIO_BUTTON1);
if(Obj.Buttons.Button1 == 0)
{
count++;
if(count > 1000)
{
ESC_ALstatusgotoerror((ESCsafeop | ESCerror), ALERR_WATCHDOG);
}
}
else
{
count = 0;
}
}
/**
* This function sets output values according to Wb.LEDgroup1
*/
void cb_set_LEDgroup1()
void cb_set_outputs (void)
{
gpio_set(GPIO_LED1_B, Wb.LEDgroup1.LED);
gpio_set(GPIO_LED1, Obj.LEDgroup0.LED0);
gpio_set(GPIO_LED2, Obj.LEDgroup1.LED1);
}
/**
* This function sets output values according to Wb.LEDgroup2
*/
void cb_set_LEDgroup2()
void cb_state_change (uint8_t * as, uint8_t * an)
{
gpio_set(GPIO_LED2_B, Wb.LEDgroup2.LED);
}
if (*as == SAFEOP_TO_OP)
{
/* Enable watchdog interrupt */
ESC_ALeventmaskwrite(ESC_ALeventmaskread() | ESCREG_ALEVENT_WD);
}
/**
* This function sets output values according to Wb.LEDgroup3
*/
void cb_set_LEDgroup3()
{
gpio_set(GPIO_LED3_B, Wb.LEDgroup3.LED);
}
/**
* This function sets output values according to Wb.LEDgroup4
*/
void cb_set_LEDgroup4()
{
gpio_set(GPIO_LED4_B, Wb.LEDgroup4.LED);
}
/**
* This function sets output values according to Wb.LEDgroup5
*/
void cb_set_LEDgroup5()
{
gpio_set(GPIO_LED5_B, Wb.LEDgroup5.LED5);
gpio_set(GPIO_LED6_B, Wb.LEDgroup5.LED678 & 0x1);
gpio_set(GPIO_LED7_B, Wb.LEDgroup5.LED678 & 0x2);
gpio_set(GPIO_LED8_B, Wb.LEDgroup5.LED678 & 0x4);
}
/**
* This function is called after a SDO write of the object Cb.Parameters.
*/
void cb_post_write_Parameters(int subindex)
{
}
/**
* This function is called after a SDO write of the object Cb.variableRW.
*/
void cb_post_write_variableRW(int subindex)
{
}
/** Optional: Hook called after state change for application specific
* actions for specific state changes.
*/
void pre_state_change_hook (uint8_t * as, uint8_t * an)
{
/* Clean up data if we have been in INIT state */
if ((*as == INIT_TO_PREOP) && (*an == ESCinit))
{
@ -123,50 +107,6 @@ void pre_state_change_hook (uint8_t * as, uint8_t * an)
}
}
/* Configuration parameters for EoE
* Function callbacks to interact with an TCP/IP stack
*/
static eoe_cfg_t eoe_config =
{
.get_buffer = appl_get_buffer,
.free_buffer = appl_free_buffer,
.load_eth_settings = appl_load_eth_settings,
.store_ethernet_settings = appl_store_ethernet_settings,
.handle_recv_buffer = appl_handle_recv_buffer,
.fetch_send_buffer = appl_fetch_send_buffer,
};
/* 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 = 1000,
.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 = pre_state_change_hook,
.post_state_change_hook = NULL,
.application_hook = NULL,
.safeoutput_override = NULL,
.pre_object_download_hook = NULL,
.post_object_download_hook = NULL,
.rxpdo_override = NULL,
.txpdo_override = NULL,
.esc_hw_interrupt_enable = ESC_interrupt_enable,
.esc_hw_interrupt_disable = ESC_interrupt_disable,
.esc_hw_eep_handler = ESC_eep_handler
};
/* Callback to allocate a buffer */
static void appl_get_buffer (eoe_pbuf_t * ebuf)
{
@ -281,7 +221,7 @@ static void appl_handle_recv_buffer (uint8_t port, eoe_pbuf_t * ebuf)
}
else
{
flags_set(ecat_events, EVENT_TX);
sem_signal(ecat_isr_sem);
}
}
/* Normal procedure to pass the Ethernet frame to lwIP to handle */
@ -332,7 +272,7 @@ static err_t transmit_frame (struct netif *netif, struct pbuf *p)
{
/* Create a pbuf ref to keep the buf alive until it is sent over EoE */
pbuf_ref(p);
flags_set(ecat_events, EVENT_TX);
sem_signal(ecat_isr_sem);
}
return ERR_OK;
}
@ -355,27 +295,54 @@ err_t eoe_netif_init (struct netif * netif)
return ERR_OK;
}
/* Periodic EtherCAT timer */
static void soes_timer (tmr_t * timer, void * arg)
/* Callback on fragment sent event, we trigger a stack cycle to handle mailbox traffic
* if we might have more fragements in queue.
*/
void eoe_frame_sent (void)
{
flags_t * ev = arg;
flags_set(ev, EVENT_PERIODIC);
sem_signal(ecat_isr_sem);
}
/* Main EtherCAT loop */
void main_run(void * arg)
int main (void)
{
uint32_t mask = EVENT_ISR | EVENT_TX | EVENT_PERIODIC;
uint32_t flags;
static esc_cfg_t config =
{
.user_arg = NULL,
.use_interrupt = 1,
.watchdog_cnt = INT32_MAX, /* Use HW SM watchdog instead */
.set_defaults_hook = NULL,
.pre_state_change_hook = NULL,
.post_state_change_hook = cb_state_change,
.application_hook = NULL,
.safeoutput_override = NULL,
.pre_object_download_hook = NULL,
.post_object_download_hook = NULL,
.rxpdo_override = NULL,
.txpdo_override = NULL,
.esc_hw_interrupt_enable = ESC_interrupt_enable,
.esc_hw_interrupt_disable = ESC_interrupt_disable,
.esc_hw_eep_handler = ESC_eep_handler,
.esc_check_dc_handler = NULL
};
/* Configuration parameters for EoE
* Function callbacks to interact with an TCP/IP stack
*/
static eoe_cfg_t eoe_config =
{
.get_buffer = appl_get_buffer,
.free_buffer = appl_free_buffer,
.load_eth_settings = appl_load_eth_settings,
.store_ethernet_settings = appl_store_ethernet_settings,
.handle_recv_buffer = appl_handle_recv_buffer,
.fetch_send_buffer = appl_fetch_send_buffer,
.fragment_sent_event = eoe_frame_sent,
};
/* Create an mailbox for interprocess communication between TCP/IP stack and
* EtherCAT stack.
*/
pbuf_mbox = mbox_create (10);
/* Create periodic events to run the EtherCAT stack and application */
ecat_events = flags_create (0);
ecat_timer = tmr_create (tick_from_ms (1), soes_timer, ecat_events, TMR_CYCL);
tmr_start (ecat_timer);
/* Set up dummy IF */
found_if = net_add_interface(eoe_netif_init);
if(found_if == NULL)
@ -384,55 +351,11 @@ void main_run(void * arg)
}
/* Init EoE */
EOE_config(&eoe_config);
EOE_init();
/* Init EtherCAT slave stack */
ecat_slv_init(&config);
for(;;)
{
if(config.use_interrupt != 0)
{
/* Wait for incoming event from application or EtherCAT stack */
flags_wait_any (ecat_events, mask, &flags);
/* Cyclic event */
if(flags & EVENT_PERIODIC)
{
DIG_process(DIG_PROCESS_WD_FLAG);
ecat_slv_poll();
ESC_eoeprocess_tx();
flags_clr(ecat_events, EVENT_PERIODIC);
}
/* Low prio interrupt from the ESC */
if(flags & EVENT_ISR)
{
ecat_slv_poll();
ESC_eoeprocess_tx();
flags_clr(ecat_events, EVENT_ISR);
ESC_interrupt_enable(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP);
}
/* The TCP/IP stack have posted a TX job */
if(flags & EVENT_TX)
{
ESC_eoeprocess_tx();
flags_clr(ecat_events, EVENT_TX);
}
}
else
{
ecat_slv();
ESC_eoeprocess_tx();
}
}
}
rprintf ("Hello world\n");
ecat_slv_init (&config);
/* Start the main application loop */
int main(void)
{
rprintf("Hello Main\n");
task_spawn ("soes", main_run, 4, 2048, NULL);
/* The stack is run from interrupt and a worker thread in esc_hw.c */
return 0;
}

Binary file not shown.

View File

@ -1,352 +0,0 @@
#ifndef SOES_V1
#include <stddef.h>
#include "utypes.h"
#include "esc.h"
#include "esc_coe.h"
#include "esc_foe.h"
#include "esc_eoe.h"
#include "config.h"
#include "slave.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 */
case 0x8000:
{
cb_post_write_Parameters(subindex);
break;
}
case 0x8001:
{
cb_post_write_variableRW(subindex);
break;
}
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.LEDgroup1
Wb.LEDgroup1.LED = 0;
// Set safe values for Wb.LEDgroup2
Wb.LEDgroup2.LED = 0;
// Set safe values for Wb.LEDgroup3
Wb.LEDgroup3.LED = 0;
// Set safe values for Wb.LEDgroup4
Wb.LEDgroup4.LED = 0;
// Set safe values for Wb.LEDgroup5
Wb.LEDgroup5.LED5 = 0;
Wb.LEDgroup5.LED678 = 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_LEDgroup1();
cb_set_LEDgroup2();
cb_set_LEDgroup3();
cb_set_LEDgroup4();
cb_set_LEDgroup5();
}
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_Button1();
cb_get_Button2();
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_eoeprocess();
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

View File

@ -1,99 +0,0 @@
#ifndef __SLAVE_H__
#define __SLAVE_H__
#include "utypes.h"
#include "esc.h"
/**
* This function gets input values and updates Rb.Button1
*/
void cb_get_Button1();
/**
* This function gets input values and updates Rb.Button2
*/
void cb_get_Button2();
/**
* This function sets output values according to Wb.LEDgroup1
*/
void cb_set_LEDgroup1();
/**
* This function sets output values according to Wb.LEDgroup2
*/
void cb_set_LEDgroup2();
/**
* This function sets output values according to Wb.LEDgroup3
*/
void cb_set_LEDgroup3();
/**
* This function sets output values according to Wb.LEDgroup4
*/
void cb_set_LEDgroup4();
/**
* This function sets output values according to Wb.LEDgroup5
*/
void cb_set_LEDgroup5();
/**
* This function is called after a SDO write of the object Cb.Parameters.
*/
void cb_post_write_Parameters(int subindex);
/**
* This function is called after a SDO write of the object Cb.variableRW.
*/
void cb_post_write_variableRW(int subindex);
#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 /* __SLAVE_H__ */

Binary file not shown.

View File

@ -0,0 +1,14 @@
#include <stddef.h>
#include "utypes.h"
#include "ecat_options.h"
#include "esc.h"
/* Global variables used by the stack */
uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)];
_MBXcontrol MBXcontrol[MBXBUFFERS];
_ESCvar ESCvar;
_SMmap SMmap2[MAX_MAPPINGS_SM2];
_SMmap SMmap3[MAX_MAPPINGS_SM3];
/* Application variables */
_Objects _Obj;

View File

@ -1,298 +1,421 @@
<?xml version="1.0" encoding="UTF-8"?>
<Slave id="evb9252_dig" productCode="1234">
<Name>lan9252</Name>
<Slave xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="com.rtlabs.emf.esx" fileVersion="2" id="slave30" productCode="0x3030">
<Name>slave30 product</Name>
<Vendor>
<Id>0x1337</Id>
<Name>rt-labs AB</Name>
<Name>rt-labs</Name>
</Vendor>
<Group>
<Type>lan9252_spi</Type>
<Name>lan9252</Name>
<Type>sdk test</Type>
<Name>sdk test</Name>
</Group>
<Fmmu>Outputs</Fmmu>
<Fmmu>Inputs</Fmmu>
<Fmmu>MBoxState</Fmmu>
<Sm ControlByte="0x26" DefaultSize="128" StartAddress="0x1000">MBoxOut</Sm>
<Sm ControlByte="0x22" DefaultSize="128" StartAddress="0x1080">MBoxIn</Sm>
<Sm ControlByte="0x24" DefaultSize="0" StartAddress="0x1100">Outputs</Sm>
<Sm ControlByte="0x64" DefaultSize="0" StartAddress="0x1100">Outputs</Sm>
<Sm ControlByte="0x20" DefaultSize="0" StartAddress="0x1180">Inputs</Sm>
<Mailbox CoE="true" FoE="true">
<Mailbox CoE="true" EoE="true">
<Bootstrap Length="128" Start="0x1000"/>
<Standard Length="128" Start="0x1000"/>
</Mailbox>
<Eeprom>
<ConfigData>8002000000000000</ConfigData>
<ConfigData>8006810600000000</ConfigData>
<BootStrap>0010800080108000</BootStrap>
</Eeprom>
<Dictionary>
<Item>
<Name>Device Type</Name>
<Index>0x1000</Index>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x01901389</DefaultValue>
</Item>
<Item Managed="true">
<Name>Device Name</Name>
<Index>0x1008</Index>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>evb9252_dig</DefaultValue>
</Item>
<Item>
<Name>Hardware Version</Name>
<Index>0x1009</Index>
<Name>Hardware Version</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>1.0</DefaultValue>
<Length>4</Length>
</Item>
<Item>
<Name>Software Version</Name>
<Index>0x100A</Index>
<Name>Software Version</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>1.0</DefaultValue>
<Length>4</Length>
</Item>
<Item Managed="true">
<Index>0x1000</Index>
<Name>Device Type</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x00001389</DefaultValue>
</Item>
<Item Managed="true">
<Index>0x1008</Index>
<Name>Device Name</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>slave30</DefaultValue>
<Length>7</Length>
</Item>
<Item Managed="true">
<Name>Identity Object</Name>
<Index>0x1018</Index>
<Name>Identity Object</Name>
<DataType>RECORD</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>Vendor ID</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x1337</DefaultValue>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Name>Product Code</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>1234</DefaultValue>
<DefaultValue>0x3030</DefaultValue>
</SubItem>
<SubItem>
<Index>0x03</Index>
<Name>Revision Number</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
</SubItem>
<SubItem>
<Index>0x04</Index>
<Name>Serial Number</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x00000000</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>LEDs</Name>
<Index>0x1600</Index>
<Name>LEDgroup0</Name>
<DataType>RECORD</DataType>
<SubItem>
<Name>Number of Elements</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>2</DefaultValue>
</SubItem>
<SubItem>
<Name>LED0</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x70000108</DefaultValue>
</SubItem>
<SubItem>
<Name>LED1</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x70000208</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Buttons</Name>
<Index>0x1A00</Index>
<DataType>RECORD</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>LED0</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x70000108</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x1601</Index>
<Name>LEDgroup1</Name>
<DataType>RECORD</DataType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>LED1</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x70010108</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x1A00</Index>
<Name>Buttons</Name>
<DataType>RECORD</DataType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>Button1</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x60000108</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager Communication Type</Name>
<Index>0x1C00</Index>
<Name>Sync Manager Communication Type</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>Communications Type SM0</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Name>Communications Type SM1</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>2</DefaultValue>
</SubItem>
<SubItem>
<Index>0x03</Index>
<Name>Communications Type SM2</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>3</DefaultValue>
</SubItem>
<SubItem>
<Index>0x04</Index>
<Name>Communications Type SM3</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager 2 PDO Assignment</Name>
<Index>0x1C12</Index>
<Name>Sync Manager 2 PDO Assignment</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
<DefaultValue>2</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1600</DefaultValue>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1601</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager 3 PDO Assignment</Name>
<Index>0x1C13</Index>
<Name>Sync Manager 3 PDO Assignment</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1A00</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Buttons</Name>
<Index>0x6000</Index>
<Name>Buttons</Name>
<DataType>RECORD</DataType>
<Variable>Buttons</Variable>
<VariableType>Input</VariableType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Access>RO</Access>
<Name>Button1</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>0</DefaultValue>
<Access>RO</Access>
<PdoMapping>TX</PdoMapping>
<Variable>Button1</Variable>
<VariableType>Input</VariableType>
</SubItem>
</Item>
<Item Managed="true">
<Name>LEDs</Name>
<Index>0x7000</Index>
<Name>LEDgroup0</Name>
<DataType>RECORD</DataType>
<Variable>LEDs</Variable>
<Variable>LEDgroup0</Variable>
<VariableType>Output</VariableType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>2</DefaultValue>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Access>RO</Access>
<Name>LED0</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>0</DefaultValue>
<Access>RO</Access>
<PdoMapping>RX</PdoMapping>
<Variable>LED0</Variable>
<VariableType>Output</VariableType>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x7001</Index>
<Name>LEDgroup1</Name>
<DataType>RECORD</DataType>
<Variable>LEDgroup1</Variable>
<VariableType>Output</VariableType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Access>RO</Access>
<Name>LED1</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>0</DefaultValue>
<Access>RO</Access>
<PdoMapping>RX</PdoMapping>
<Variable>LED1</Variable>
<VariableType>Output</VariableType>
</SubItem>
</Item>
<Item Managed="true">
<Name>Parameters</Name>
<Index>0x8000</Index>
<Name>Parameters</Name>
<DataType>RECORD</DataType>
<Variable>Parameters</Variable>
<VariableType>Parameter</VariableType>
<SubItem>
<Name>Number of Elements</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Access>RO</Access>
<Name>Multiplier</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
<Access>RW</Access>
<PdoMapping>TX_AND_RX</PdoMapping>
<Variable>Multiplier</Variable>
<VariableType>Parameter</VariableType>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x8001</Index>
<Access>RO</Access>
<Name>variableRW</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
<Variable>variableRW</Variable>
<VariableType>Parameter</VariableType>
</Item>
</Dictionary>
<RxPdo>
<Index>0x1600</Index>
<Container>LEDs</Container>
<Name>LEDs</Name>
<SmAssignment>
<Index>0x1C12</Index>
<Entry>
<Index>0x7000</Index>
<SubIndex>1</SubIndex>
<Variable>LED0</Variable>
<Index>0x01</Index>
<AssignedPdo>0x1600</AssignedPdo>
</Entry>
<Entry>
<Index>0x7000</Index>
<SubIndex>2</SubIndex>
<Index>0x02</Index>
<AssignedPdo>0x1601</AssignedPdo>
</Entry>
</SmAssignment>
<SmAssignment>
<Index>0x1C13</Index>
<Entry>
<Index>0x01</Index>
<AssignedPdo>0x1A00</AssignedPdo>
</Entry>
</SmAssignment>
<RxPdo>
<Index>0x1600</Index>
<Name>LEDgroup0</Name>
<Entry>
<Index>0x1</Index>
<MappedIndex>0x7000</MappedIndex>
<MappedSubIndex>0x01</MappedSubIndex>
<Variable>LED0</Variable>
</Entry>
</RxPdo>
<RxPdo>
<Index>0x1601</Index>
<Name>LEDgroup1</Name>
<Entry>
<Index>0x1</Index>
<MappedIndex>0x7001</MappedIndex>
<MappedSubIndex>0x01</MappedSubIndex>
<Variable>LED1</Variable>
</Entry>
</RxPdo>
<TxPdo>
<Index>0x1A00</Index>
<Container>Buttons</Container>
<Name>Buttons</Name>
<Entry>
<Index>0x6000</Index>
<SubIndex>1</SubIndex>
<Index>0x1</Index>
<MappedIndex>0x6000</MappedIndex>
<MappedSubIndex>0x01</MappedSubIndex>
<Variable>Button1</Variable>
</Entry>
</TxPdo>
<Input>
<Index>0x6000</Index>
<Name>Buttons</Name>
<Type>RECORD</Type>
<PdoMapping>TX</PdoMapping>
<ObjectType>RECORD</ObjectType>
<Member>
<Index>0x01</Index>
<Name>Button1</Name>
<Type>UNSIGNED8</Type>
<PdoMapping>TX</PdoMapping>
</Member>
</Input>
<Output>
<Name>LEDs</Name>
<Type>RECORD</Type>
<Index>0x7000</Index>
<Name>LEDgroup0</Name>
<PdoMapping>RX</PdoMapping>
<ObjectType>RECORD</ObjectType>
<Member>
<Index>0x01</Index>
<Name>LED0</Name>
<Type>UNSIGNED8</Type>
<PdoMapping>RX</PdoMapping>
</Member>
</Output>
<Output>
<Index>0x7001</Index>
<Name>LEDgroup1</Name>
<PdoMapping>RX</PdoMapping>
<ObjectType>RECORD</ObjectType>
<Member>
<Index>0x01</Index>
<Name>LED1</Name>
<Type>UNSIGNED8</Type>
<PdoMapping>RX</PdoMapping>
</Member>
</Output>
<Parameter>
<Index>0x8000</Index>
<Name>Parameters</Name>
<Type>RECORD</Type>
<PdoMapping>NONE</PdoMapping>
<ObjectType>RECORD</ObjectType>
<Member>
<Index>0x01</Index>
<Name>Multiplier</Name>
<Type>UNSIGNED32</Type>
<PdoMapping>TX_AND_RX</PdoMapping>
</Member>
</Parameter>
</Slave>
<Parameter>
<Index>0x8001</Index>
<Name>variableRW</Name>
<Type>UNSIGNED32</Type>
<PdoMapping>NONE</PdoMapping>
<ObjectType>VAR</ObjectType>
</Parameter>
</Slave>

View File

@ -2,23 +2,23 @@
<EtherCATInfo>
<Vendor>
<Id>#x1337</Id>
<Name LcId="1033">rt-labs AB</Name>
<Name LcId="1033">rt-labs</Name>
</Vendor>
<Descriptions>
<Groups>
<Group>
<Type>lan9252_spi</Type>
<Name LcId="1033">lan9252</Name>
<Type>sdk test</Type>
<Name LcId="1033">sdk test</Name>
</Group>
</Groups>
<Devices>
<Device Physics="YY">
<Type ProductCode="1234" RevisionNo="0">evb9252_dig</Type>
<Name LcId="1033">lan9252</Name>
<GroupType>lan9252_spi</GroupType>
<Type ProductCode="#x3030" RevisionNo="0">slave30</Type>
<Name LcId="1033">slave30 product</Name>
<GroupType>sdk test</GroupType>
<Profile>
<ProfileNo>5001</ProfileNo>
<AddInfo>400</AddInfo>
<AddInfo>0</AddInfo>
<Dictionary>
<DataTypes>
<DataType>
@ -26,7 +26,7 @@
<BitSize>144</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -77,10 +77,10 @@
</DataType>
<DataType>
<Name>DT1600</Name>
<BitSize>80</BitSize>
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -98,12 +98,26 @@
<Access>ro</Access>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT1601</Name>
<BitSize>48</BitSize>
<SubItem>
<SubIdx>2</SubIdx>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>1</SubIdx>
<Name>LED1</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>48</BitOffs>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
@ -114,7 +128,7 @@
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -147,7 +161,7 @@
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -168,18 +182,18 @@
<DataType>
<Name>DT1C12ARR</Name>
<BaseType>UINT</BaseType>
<BitSize>16</BitSize>
<BitSize>32</BitSize>
<ArrayInfo>
<LBound>1</LBound>
<Elements>1</Elements>
<Elements>2</Elements>
</ArrayInfo>
</DataType>
<DataType>
<Name>DT1C12</Name>
<BitSize>32</BitSize>
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -190,7 +204,7 @@
<SubItem>
<Name>Elements</Name>
<Type>DT1C12ARR</Type>
<BitSize>16</BitSize>
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
@ -211,7 +225,7 @@
<BitSize>32</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -234,7 +248,7 @@
<BitSize>24</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -250,15 +264,16 @@
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
<PdoMapping>T</PdoMapping>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT7000</Name>
<BitSize>32</BitSize>
<BitSize>24</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -272,18 +287,34 @@
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
<PdoMapping>R</PdoMapping>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT7001</Name>
<BitSize>24</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>2</SubIdx>
<SubIdx>1</SubIdx>
<Name>LED1</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>24</BitOffs>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
<PdoMapping>R</PdoMapping>
</Flags>
</SubItem>
</DataType>
@ -292,7 +323,7 @@
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
@ -307,17 +338,14 @@
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>rw</Access>
<Access>ro</Access>
<PdoMapping>TR</PdoMapping>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>STRING(3)</Name>
<BitSize>24</BitSize>
</DataType>
<DataType>
<Name>STRING(11)</Name>
<BitSize>88</BitSize>
<Name>STRING(4)</Name>
<BitSize>32</BitSize>
</DataType>
<DataType>
<Name>UDINT</Name>
@ -327,42 +355,21 @@
<Name>UINT</Name>
<BitSize>16</BitSize>
</DataType>
<DataType>
<Name>STRING(7)</Name>
<BitSize>56</BitSize>
</DataType>
<DataType>
<Name>USINT</Name>
<BitSize>8</BitSize>
</DataType>
</DataTypes>
<Objects>
<Object>
<Index>#x1000</Index>
<Name>Device Type</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<Info>
<DefaultValue>#x01901389</DefaultValue>
</Info>
<Flags>
<Access>ro</Access>
<Category>m</Category>
</Flags>
</Object>
<Object>
<Index>#x1008</Index>
<Name>Device Name</Name>
<Type>STRING(11)</Type>
<BitSize>88</BitSize>
<Info>
<DefaultString>evb9252_dig</DefaultString>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1009</Index>
<Name>Hardware Version</Name>
<Type>STRING(3)</Type>
<BitSize>24</BitSize>
<Type>STRING(4)</Type>
<BitSize>32</BitSize>
<Info>
<DefaultString>1.0</DefaultString>
</Info>
@ -374,8 +381,8 @@
<Object>
<Index>#x100A</Index>
<Name>Software Version</Name>
<Type>STRING(3)</Type>
<BitSize>24</BitSize>
<Type>STRING(4)</Type>
<BitSize>32</BitSize>
<Info>
<DefaultString>1.0</DefaultString>
</Info>
@ -383,6 +390,31 @@
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1000</Index>
<Name>Device Type</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<Info>
<DefaultValue>#x00001389</DefaultValue>
</Info>
<Flags>
<Access>ro</Access>
<Category>m</Category>
</Flags>
</Object>
<Object>
<Index>#x1008</Index>
<Name>Device Name</Name>
<Type>STRING(7)</Type>
<BitSize>56</BitSize>
<Info>
<DefaultString>slave30</DefaultString>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1018</Index>
<Name>Identity Object</Name>
@ -390,7 +422,7 @@
<BitSize>144</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>4</DefaultValue>
</Info>
@ -404,7 +436,7 @@
<SubItem>
<Name>Product Code</Name>
<Info>
<DefaultValue>1234</DefaultValue>
<DefaultValue>#x3030</DefaultValue>
</Info>
</SubItem>
<SubItem>
@ -426,14 +458,14 @@
</Object>
<Object>
<Index>#x1600</Index>
<Name>LEDs</Name>
<Name>LEDgroup0</Name>
<Type>DT1600</Type>
<BitSize>80</BitSize>
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>2</DefaultValue>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
@ -442,10 +474,27 @@
<DefaultValue>#x70000108</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1601</Index>
<Name>LEDgroup1</Name>
<Type>DT1601</Type>
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>LED1</Name>
<Info>
<DefaultValue>#x70000208</DefaultValue>
<DefaultValue>#x70010108</DefaultValue>
</Info>
</SubItem>
</Info>
@ -460,7 +509,7 @@
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -483,7 +532,7 @@
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>4</DefaultValue>
</Info>
@ -521,12 +570,12 @@
<Index>#x1C12</Index>
<Name>Sync Manager 2 PDO Assignment</Name>
<Type>DT1C12</Type>
<BitSize>32</BitSize>
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
<DefaultValue>2</DefaultValue>
</Info>
</SubItem>
<SubItem>
@ -535,6 +584,12 @@
<DefaultValue>#x1600</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>PDO Mapping</Name>
<Info>
<DefaultValue>#x1601</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
@ -547,7 +602,7 @@
<BitSize>32</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -570,7 +625,7 @@
<BitSize>24</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -588,14 +643,14 @@
</Object>
<Object>
<Index>#x7000</Index>
<Name>LEDs</Name>
<Name>LEDgroup0</Name>
<Type>DT7000</Type>
<BitSize>32</BitSize>
<BitSize>24</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>2</DefaultValue>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
@ -604,6 +659,23 @@
<DefaultValue>0</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x7001</Index>
<Name>LEDgroup1</Name>
<Type>DT7001</Type>
<BitSize>24</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>LED1</Name>
<Info>
@ -622,7 +694,7 @@
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Number of Elements</Name>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
@ -638,28 +710,45 @@
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x8001</Index>
<Name>variableRW</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<Info>
<DefaultValue>0</DefaultValue>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
</Objects>
</Dictionary>
</Profile>
<Fmmu>Outputs</Fmmu>
<Fmmu>Inputs</Fmmu>
<Fmmu>MBoxState</Fmmu>
<Sm ControlByte="#x26" DefaultSize="128" Enable="1" StartAddress="#x1000">MBoxOut</Sm>
<Sm ControlByte="#x22" DefaultSize="128" Enable="1" StartAddress="#x1080">MBoxIn</Sm>
<Sm ControlByte="#x24" Enable="1" StartAddress="#x1100">Outputs</Sm>
<Sm ControlByte="#x64" Enable="1" StartAddress="#x1100">Outputs</Sm>
<Sm ControlByte="#x20" Enable="1" StartAddress="#x1180">Inputs</Sm>
<RxPdo Fixed="true" Mandatory="true" Sm="2">
<Index>#x1600</Index>
<Name>LEDs</Name>
<Name>LEDgroup0</Name>
<Entry>
<Index>#x7000</Index>
<SubIndex>1</SubIndex>
<SubIndex>#x1</SubIndex>
<BitLen>8</BitLen>
<Name>LED0</Name>
<DataType>USINT</DataType>
</Entry>
</RxPdo>
<RxPdo Fixed="true" Mandatory="true" Sm="2">
<Index>#x1601</Index>
<Name>LEDgroup1</Name>
<Entry>
<Index>#x7000</Index>
<SubIndex>2</SubIndex>
<Index>#x7001</Index>
<SubIndex>#x1</SubIndex>
<BitLen>8</BitLen>
<Name>LED1</Name>
<DataType>USINT</DataType>
@ -670,19 +759,19 @@
<Name>Buttons</Name>
<Entry>
<Index>#x6000</Index>
<SubIndex>1</SubIndex>
<SubIndex>#x1</SubIndex>
<BitLen>8</BitLen>
<Name>Button1</Name>
<DataType>USINT</DataType>
</Entry>
</TxPdo>
<Mailbox DataLinkLayer="true">
<CoE CompleteAccess="false" PdoUpload="true" SdoInfo="true"/>
<FoE/>
<EoE/>
<CoE CompleteAccess="false" PdoAssign="false" PdoUpload="false" SdoInfo="true"/>
</Mailbox>
<Eeprom>
<ByteSize>256</ByteSize>
<ConfigData>8002000000000000</ConfigData>
<ConfigData>8006810600000000</ConfigData>
<BootStrap>0010800080108000</BootStrap>
</Eeprom>
</Device>

View File

@ -1,80 +1,94 @@
#include "soes/esc_coe.h"
#include "esc_coe.h"
#include "utypes.h"
#include <stddef.h>
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";
#ifndef HW_REV
#define HW_REV "1.0"
#endif
#ifndef SW_REV
#define SW_REV "1.0"
#endif
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 acName1000[] = "Device Type";
static const char acName1008[] = "Device Name";
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[] = "LEDgroup0";
static const char acName1600_00[] = "Max SubIndex";
static const char acName1600_01[] = "LED0";
static const char acName1600_02[] = "LED1";
static const char acName1601[] = "LEDgroup1";
static const char acName1601_00[] = "Max SubIndex";
static const char acName1601_01[] = "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 acName1C12_02[] = "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[] = "LEDgroup0";
static const char acName7000_00[] = "Max SubIndex";
static const char acName7000_01[] = "LED0";
static const char acName7000_02[] = "LED1";
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[] = "Number of Elements";
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, 0x01901389, NULL},
};
const _objd SDO1008[] =
{
{0x0, DTYPE_VISIBLE_STRING, 88, ATYPE_RO, acName1008_0, 0, "evb9252_dig"},
};
const _objd SDO1009[] =
{
{0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, "1.0"},
{0x0, DTYPE_VISIBLE_STRING, 32, 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, 32, ATYPE_RO, acName100A, 0, SW_REV},
};
const _objd SDO1000[] =
{
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 0x00001389, NULL},
};
const _objd SDO1008[] =
{
{0x0, DTYPE_VISIBLE_STRING, 56, ATYPE_RO, acName1008, 0, "slave30"},
};
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, 1234, NULL},
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_02, 0x3030, 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, 2, NULL},
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1600_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70000108, NULL},
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_02, 0x70000208, 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 SDO1A00[] =
{
@ -91,8 +105,9 @@ const _objd SDO1C00[] =
};
const _objd SDO1C12[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 1, NULL},
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 2, NULL},
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_01, 0x1600, NULL},
{0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_02, 0x1601, NULL},
};
const _objd SDO1C13[] =
{
@ -102,18 +117,26 @@ 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 | ATYPE_TXPDO, 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},
{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[] =
{
{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 | ATYPE_TXPDO | ATYPE_RXPDO, acName8000_01, 0, &Obj.Parameters.Multiplier},
};
const _objd SDO8001[] =
{
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName8001, 0, &Obj.variableRW},
};
const _objectlist SDOobjects[] =
@ -123,13 +146,16 @@ const _objectlist SDOobjects[] =
{0x1009, OTYPE_VAR, 0, 0, acName1009, SDO1009},
{0x100A, OTYPE_VAR, 0, 0, acName100A, SDO100A},
{0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018},
{0x1600, OTYPE_RECORD, 2, 0, acName1600, SDO1600},
{0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600},
{0x1601, OTYPE_RECORD, 1, 0, acName1601, SDO1601},
{0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00},
{0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00},
{0x1C12, OTYPE_ARRAY, 1, 0, acName1C12, SDO1C12},
{0x1C12, OTYPE_ARRAY, 2, 0, acName1C12, SDO1C12},
{0x1C13, OTYPE_ARRAY, 1, 0, acName1C13, SDO1C13},
{0x6000, OTYPE_RECORD, 1, 0, acName6000, SDO6000},
{0x7000, OTYPE_RECORD, 2, 0, acName7000, SDO7000},
{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}
};

View File

@ -1,310 +0,0 @@
#ifndef SOES_V1
#include "esc_coe.h"
#include "utypes.h"
#include <stddef.h>
#ifndef HW_REV
#define HW_REV "1.0"
#endif
#ifndef SW_REV
#define SW_REV "1.0"
#endif
static const char acName1000[] = "Device Type";
static const char acName1000_0[] = "Device Type";
static const char acName1008[] = "Device Name";
static const char acName1008_0[] = "Device Name";
static const char acName1009[] = "Hardware Version";
static const char acName1009_0[] = "Hardware Version";
static const char acName100A[] = "Software Version";
static const char acName100A_0[] = "Software Version";
static const char acName1018[] = "Identity Object";
static const char acName1018_00[] = "Max SubIndex";
static const char acName1018_01[] = "Vendor ID";
static const char acName1018_02[] = "Product Code";
static const char acName1018_03[] = "Revision Number";
static const char acName1018_04[] = "Serial Number";
static const char acName10F1[] = "ErrorSettings";
static const char acName10F1_00[] = "Max SubIndex";
static const char acName10F1_01[] = "Dummy_x01";
static const char acName10F1_02[] = "SyncErrorCounterLimit";
static const char acName1600[] = "LEDgroup1";
static const char acName1600_00[] = "Max SubIndex";
static const char acName1600_01[] = "LED";
static const char acName1601[] = "LEDgroup2";
static const char acName1601_00[] = "Max SubIndex";
static const char acName1601_01[] = "LED";
static const char acName1602[] = "LEDgroup3";
static const char acName1602_00[] = "Max SubIndex";
static const char acName1602_01[] = "LED";
static const char acName1603[] = "LEDgroup4";
static const char acName1603_00[] = "Max SubIndex";
static const char acName1603_01[] = "LED";
static const char acName1604[] = "LEDgroup5";
static const char acName1604_00[] = "Max SubIndex";
static const char acName1604_01[] = "LED5";
static const char acName1604_02[] = "LED678";
static const char acName1A00[] = "Button1";
static const char acName1A00_00[] = "Max SubIndex";
static const char acName1A00_01[] = "B";
static const char acName1A01[] = "Button2";
static const char acName1A01_00[] = "Max SubIndex";
static const char acName1A01_01[] = "B";
static const char acName1C00[] = "Sync Manager Communication Type";
static const char acName1C00_00[] = "Max SubIndex";
static const char acName1C00_01[] = "Communications Type SM0";
static const char acName1C00_02[] = "Communications Type SM1";
static const char acName1C00_03[] = "Communications Type SM2";
static const char acName1C00_04[] = "Communications Type SM3";
static const char acName1C12[] = "Sync Manager 2 PDO Assignment";
static const char acName1C12_00[] = "Max SubIndex";
static const char acName1C12_01[] = "PDO Mapping";
static const char acName1C12_02[] = "PDO Mapping";
static const char acName1C12_03[] = "PDO Mapping";
static const char acName1C12_04[] = "PDO Mapping";
static const char acName1C12_05[] = "PDO Mapping";
static const char acName1C13[] = "Sync Manager 3 PDO Assignment";
static const char acName1C13_00[] = "Max SubIndex";
static const char acName1C13_01[] = "PDO Mapping";
static const char acName1C13_02[] = "PDO Mapping";
static const char acName1C32[] = "SyncMgrParam";
static const char acName1C32_00[] = "Max SubIndex";
static const char acName1C32_01[] = "SyncType";
static const char acName1C32_02[] = "CycleTime";
static const char acName1C32_03[] = "ShiftTime";
static const char acName1C32_04[] = "SyncTypeSupport";
static const char acName1C32_05[] = "MinCycleTime";
static const char acName1C32_06[] = "CalcCopyTime";
static const char acName1C32_07[] = "MinDelayTime";
static const char acName1C32_08[] = "GetCycleTime";
static const char acName1C32_09[] = "DelayTime";
static const char acName1C32_0A[] = "Sync0CycleTime";
static const char acName1C32_0B[] = "SMEventMissedCnt";
static const char acName1C32_0C[] = "CycleTimeTooSmallCnt";
static const char acName1C32_0D[] = "ShiftTimeTooSmallCnt";
static const char acName1C32_0E[] = "RxPDOToggleFailed";
static const char acName1C32_0F[] = "MinCycleDist";
static const char acName1C32_10[] = "MaxCycleDist";
static const char acName1C32_11[] = "MinSMSYNCDist";
static const char acName1C32_12[] = "MaxSMSYNCDist";
static const char acName1C32_14[] = "Dummy_x14";
static const char acName1C32_20[] = "SyncError";
static const char acName6005[] = "Button1";
static const char acName6005_00[] = "Max SubIndex";
static const char acName6005_01[] = "B";
static const char acName6006[] = "Button2";
static const char acName6006_00[] = "Max SubIndex";
static const char acName6006_01[] = "B";
static const char acName7005[] = "LEDgroup1";
static const char acName7005_00[] = "Max SubIndex";
static const char acName7005_01[] = "LED";
static const char acName7006[] = "LEDgroup2";
static const char acName7006_00[] = "Max SubIndex";
static const char acName7006_01[] = "LED";
static const char acName7007[] = "LEDgroup3";
static const char acName7007_00[] = "Max SubIndex";
static const char acName7007_01[] = "LED";
static const char acName7008[] = "LEDgroup4";
static const char acName7008_00[] = "Max SubIndex";
static const char acName7008_01[] = "LED";
static const char acName7009[] = "LEDgroup5";
static const char acName7009_00[] = "Max SubIndex";
static const char acName7009_01[] = "LED5";
static const char acName7009_02[] = "LED678";
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},
};
const _objd SDO1008[] =
{
{0x0, DTYPE_VISIBLE_STRING, 88, ATYPE_RO, acName1008_0, 0, "xmc48_slave"},
};
const _objd SDO1009[] =
{
{0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, HW_REV},
};
const _objd SDO100A[] =
{
{0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, SW_REV},
};
const _objd SDO1018[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1018_00, 4, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_01, 0x1337, NULL},
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_02, 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, &Mb.ErrorSettings.Dummy_x01},
{0x02, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName10F1_02, 2, &Mb.ErrorSettings.SyncErrorCounterLimit},
};
const _objd SDO1600[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1600_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70050120, NULL},
};
const _objd SDO1601[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70060108, NULL},
};
const _objd SDO1602[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_01, 0x70070108, NULL},
};
const _objd SDO1603[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1603_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1603_01, 0x70080108, NULL},
};
const _objd SDO1604[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1604_00, 2, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1604_01, 0x70090108, NULL},
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1604_02, 0x70090208, NULL},
};
const _objd SDO1A00[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60050108, NULL},
};
const _objd SDO1A01[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A01_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_01, 0x60060120, 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, 5, NULL},
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_01, 0x1600, NULL},
{0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_02, 0x1601, NULL},
{0x03, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_03, 0x1602, NULL},
{0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_04, 0x1603, NULL},
{0x05, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_05, 0x1604, NULL},
};
const _objd SDO1C13[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 2, NULL},
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_01, 0x1A00, NULL},
{0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_02, 0x1A01, NULL},
};
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},
};
const _objd SDO6005[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6005_00, 1, NULL},
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6005_01, 0, &Rb.Button1.B},
};
const _objd SDO6006[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6006_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName6006_01, 0, &Rb.Button2.B},
};
const _objd SDO7005[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7005_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName7005_01, 0, &Wb.LEDgroup1.LED},
};
const _objd SDO7006[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7006_00, 1, NULL},
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7006_01, 0, &Wb.LEDgroup2.LED},
};
const _objd SDO7007[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7007_00, 1, NULL},
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7007_01, 0, &Wb.LEDgroup3.LED},
};
const _objd SDO7008[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7008_00, 1, NULL},
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7008_01, 0, &Wb.LEDgroup4.LED},
};
const _objd SDO7009[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7009_00, 2, NULL},
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7009_01, 0, &Wb.LEDgroup5.LED5},
{0x02, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7009_02, 0, &Wb.LEDgroup5.LED678},
};
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},
};
const _objd SDO8001[] =
{
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8001_0, 0, &Cb.variableRW},
};
const _objectlist SDOobjects[] =
{
{0x1000, OTYPE_VAR, 0, 0, acName1000, SDO1000},
{0x1008, OTYPE_VAR, 0, 0, acName1008, SDO1008},
{0x1009, OTYPE_VAR, 0, 0, acName1009, SDO1009},
{0x100A, OTYPE_VAR, 0, 0, acName100A, SDO100A},
{0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018},
{0x10F1, OTYPE_RECORD, 2, 0, acName10F1, SDO10F1},
{0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600},
{0x1601, OTYPE_RECORD, 1, 0, acName1601, SDO1601},
{0x1602, OTYPE_RECORD, 1, 0, acName1602, SDO1602},
{0x1603, OTYPE_RECORD, 1, 0, acName1603, SDO1603},
{0x1604, OTYPE_RECORD, 2, 0, acName1604, SDO1604},
{0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00},
{0x1A01, OTYPE_RECORD, 1, 0, acName1A01, SDO1A01},
{0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00},
{0x1C12, OTYPE_ARRAY, 5, 0, acName1C12, SDO1C12},
{0x1C13, OTYPE_ARRAY, 2, 0, acName1C13, SDO1C13},
{0x1C32, OTYPE_RECORD, 32, 0, acName1C32, SDO1C32},
{0x6005, OTYPE_RECORD, 1, 0, acName6005, SDO6005},
{0x6006, OTYPE_RECORD, 1, 0, acName6006, SDO6006},
{0x7005, OTYPE_RECORD, 1, 0, acName7005, SDO7005},
{0x7006, OTYPE_RECORD, 1, 0, acName7006, SDO7006},
{0x7007, OTYPE_RECORD, 1, 0, acName7007, SDO7007},
{0x7008, OTYPE_RECORD, 1, 0, acName7008, SDO7008},
{0x7009, OTYPE_RECORD, 2, 0, acName7009, SDO7009},
{0x8000, OTYPE_RECORD, 1, 0, acName8000, SDO8000},
{0x8001, OTYPE_VAR, 0, 0, acName8001, SDO8001},
{0xffff, 0xff, 0xff, 0xff, NULL, NULL}
};
#endif

View File

@ -1,121 +1,50 @@
#ifndef __UTYPES_H__
#define __UTYPES_H__
#include <cc.h>
#include "cc.h"
/* Object dictionary storage */
/* Inputs */
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
/* Inputs */
struct
{
uint8_t B;
} CC_PACKED Button1;
CC_PACKED_END
CC_PACKED_BEGIN
struct
{
uint32_t B;
} CC_PACKED Button2;
CC_PACKED_END
} CC_PACKED _Rbuffer;
CC_PACKED_END
uint8_t Button1;
} Buttons;
/* Outputs */
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint32_t LED;
} CC_PACKED LEDgroup1;
CC_PACKED_END
CC_PACKED_BEGIN
struct
{
uint8_t LED;
} CC_PACKED LEDgroup2;
CC_PACKED_END
CC_PACKED_BEGIN
struct
{
uint8_t LED;
} CC_PACKED LEDgroup3;
CC_PACKED_END
CC_PACKED_BEGIN
struct
{
uint8_t LED;
} CC_PACKED LEDgroup4;
CC_PACKED_END
CC_PACKED_BEGIN
struct
{
uint8_t LED5;
uint8_t LED678;
} CC_PACKED LEDgroup5;
CC_PACKED_END
} CC_PACKED _Wbuffer;
CC_PACKED_END
/* Parameters */
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
/* Outputs */
struct
{
uint8_t LED0;
} LEDgroup0;
struct
{
uint8_t LED1;
} LEDgroup1;
/* Parameters */
struct
{
uint32_t Multiplier;
} CC_PACKED Parameters;
CC_PACKED_END
} Parameters;
uint32_t variableRW;
} CC_PACKED _Cbuffer;
CC_PACKED_END
/* Manufacturer specific data */
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint16_t SyncType;
uint32_t CycleTime;
uint32_t ShiftTime;
uint16_t SyncTypeSupport;
uint32_t MinCycleTime;
uint32_t CalcCopyTime;
uint32_t MinDelayTime;
uint16_t GetCycleTime;
uint32_t DelayTime;
uint32_t Sync0CycleTime;
uint16_t SMEventMissedCnt;
uint16_t CycleTimeTooSmallCnt;
uint16_t ShiftTimeTooSmallCnt;
uint16_t RxPDOToggleFailed;
uint32_t MinCycleDist;
uint32_t MaxCycleDist;
uint32_t MinSMSYNCDist;
uint32_t MaxSMSYNCDist;
uint8_t Dummy_x14;
uint8_t SyncError;
} 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
/* 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__ */

View File

@ -1,6 +1,5 @@
add_executable (rtl_slavedemo
soes.c
objectlist.c
led_handler.c
bootstrap.c

View File

@ -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
};

View File

@ -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__ */

View File

@ -4,8 +4,128 @@
*/
#include <kern.h>
#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);

View File

@ -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 <kern.h>
#include <flash_drv.h>
#include <esc.h>
#include <esc_coe.h>
#include <esc_foe.h>
#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);
}
}

View File

@ -18,7 +18,6 @@
typedef struct
{
uint8_t state;
uint8_t button;
uint32_t encoder;
} _Rbuffer;

View File

@ -0,0 +1,14 @@
add_custom_command (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sii_eeprom.o
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sii_eeprom.bin
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND arm-eabi-objcopy -I binary -O elf32-littlearm -B arm sii_eeprom.bin ${CMAKE_CURRENT_BINARY_DIR}/sii_eeprom.o
)
add_executable (demo
slave_objectlist.c
main.c
${CMAKE_CURRENT_BINARY_DIR}/sii_eeprom.o
)
target_link_libraries(demo LINK_PUBLIC soes)

View File

@ -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__ */

View File

@ -0,0 +1,78 @@
/*
* Licensed under the GNU General Public License version 2 with exceptions. See
* LICENSE file in the project root for full license information
*/
#include <kern.h>
#include "esc.h"
#include "esc_hw.h"
#include "ecat_slv.h"
#include "options.h"
#include "utypes.h"
#include "bsp.h"
/* Application variables */
_Objects Obj;
/*
* This function is called to get input values
*/
void cb_get_inputs()
{
Obj.Buttons.Button1 = gpio_get (GPIO_BUTTON1);
}
/*
* 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 */
uint16_t dc_checker (void)
{
/* Indicate we run DC */
ESCvar.dcsync = 1;
/* Fetch the sync counter limit (SDO10F1) */
ESCvar.synccounterlimit = Obj.ErrorSettings.SyncErrorCounterLimit;
return 0;
}
int main (void)
{
static esc_cfg_t config =
{
.user_arg = NULL,
.use_interrupt = 1,
.watchdog_cnt = INT32_MAX, /* Use HW SM watchdog instead */
.set_defaults_hook = NULL,
.pre_state_change_hook = NULL,
.post_state_change_hook = cb_state_change,
.application_hook = NULL,
.safeoutput_override = NULL,
.pre_object_download_hook = NULL,
.post_object_download_hook = NULL,
.rxpdo_override = NULL,
.txpdo_override = NULL,
.esc_hw_interrupt_enable = ESC_interrupt_enable,
.esc_hw_interrupt_disable = ESC_interrupt_disable,
.esc_hw_eep_handler = ESC_eep_handler,
.esc_check_dc_handler = dc_checker
};
rprintf ("Hello world\n");
ecat_slv_init (&config);
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,289 @@
#include "esc_coe.h"
#include "utypes.h"
#include <stddef.h>
#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 acName10F1[] = "ErrorSettings";
static const char acName10F1_00[] = "Max SubIndex";
static const char acName10F1_01[] = "Local Error Reaction";
static const char acName10F1_02[] = "SyncErrorCounterLimit";
static const char acName1600[] = "RXPDO 1";
static const char acName1600_00[] = "Max SubIndex";
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[] = "Button1";
static const char acName1A01[] = "TXPDO 2";
static const char acName1A01_00[] = "Max SubIndex";
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";
static const char acName1C00_02[] = "Communications Type SM1";
static const char acName1C00_03[] = "Communications Type SM2";
static const char acName1C00_04[] = "Communications Type SM3";
static const char acName1C12[] = "Sync Manager 2 PDO Assignment";
static const char acName1C12_00[] = "Max SubIndex";
static const char acName1C12_01[] = "PDO Mapping";
static const char acName1C12_02[] = "PDO Mapping";
static const char acName1C12_03[] = "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[] = "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[] = "Sync mode";
static const char acName1C32_02[] = "CycleTime";
static const char acName1C32_03[] = "ShiftTime";
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[] = "Shift too short counter";
static const char acName1C32_0E[] = "RxPDOToggleFailed";
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[] = "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";
const _objd SDO1000[] =
{
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 0x00001389, NULL},
};
const _objd SDO1008[] =
{
{0x0, DTYPE_VISIBLE_STRING, 80, ATYPE_RO, acName1008, 0, "xmc48relax"},
};
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, 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_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, 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[] =
{
{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_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[] =
{
{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_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[] =
{
{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_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 SDO6000[] =
{
{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, 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[] =
{
{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_UNSIGNED32, 32, ATYPE_RW, acName8001, 0, &Obj.variableRW},
};
const _objectlist SDOobjects[] =
{
{0x1000, OTYPE_VAR, 0, 0, acName1000, SDO1000},
{0x1008, OTYPE_VAR, 0, 0, acName1008, SDO1008},
{0x1009, OTYPE_VAR, 0, 0, acName1009, SDO1009},
{0x100A, OTYPE_VAR, 0, 0, acName100A, SDO100A},
{0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018},
{0x10F1, OTYPE_RECORD, 2, 0, acName10F1, SDO10F1},
{0x1600, OTYPE_RECORD, 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, 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}
};

View File

@ -0,0 +1,99 @@
#ifndef __UTYPES_H__
#define __UTYPES_H__
#include "cc.h"
/* Object dictionary storage */
typedef struct
{
/* Inputs */
struct
{
uint8_t Button1;
} Buttons;
/* Outputs */
struct
{
uint8_t LED0;
} LEDgroup0;
struct
{
uint8_t LED1;
} LEDgroup1;
/* Parameters */
struct
{
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 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 Shift_too_short_counter;
uint16_t RxPDOToggleFailed;
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;
/* Dynamic TX PDO:s */
struct
{
uint8_t maxsub;
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;
extern _Objects Obj;
#endif /* __UTYPES_H__ */

View File

@ -1,35 +0,0 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include <cc.h>
#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 0x24
#define SM2_act 1
#define SM3_sma 0x1180
#define SM3_smc 0x20
#define SM3_act 1
#endif /* __CONFIG_H__ */

View File

@ -1,184 +0,0 @@
#include <kern.h>
#include <xmc4.h>
#include <bsp.h>
#include "slave.h"
#include "esc_hw.h"
#include "config.h"
#define SAMPLE_CODE 0
/**
* This function reads physical input values and assigns the corresponding members
* of Rb.Buttons
*/
void cb_get_Buttons()
{
Rb.Buttons.Button1 = gpio_get(GPIO_BUTTON1);
}
/**
* This function writes physical output values from the corresponding members of
* Wb.LEDs
*/
void cb_set_LEDgroup0()
{
gpio_set(GPIO_LED1, Wb.LEDgroup0.LED0);
}
/**
* This function writes physical output values from the corresponding members of
* Wb.LEDs
*/
void cb_set_LEDgroup1()
{
gpio_set(GPIO_LED2, Wb.LEDgroup1.LED1);
}
/**
* This function is called after a SDO write of the object Cb.Parameters.
*/
void cb_post_write_variableRW(int subindex)
{
}
/** Optional: Hook called after state change for application specific
* actions for specific state changes.
*/
void pre_state_change_hook (uint8_t * as, uint8_t * an)
{
}
/** 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 SAMPLE_CODE
/* Add specific step change hooks here */
if ((*as == BOOT_TO_INIT) && (*an == ESCinit))
{
rprintf("boot BOOT_TO_INIT\n");
upgrade_finished();
/* If we return here */
ESC_ALerror (ALERR_NOVALIDFIRMWARE);
/* Upgrade failed, enter init with error */
*an = (ESCinit | ESCerror);
}
else if((*as == PREOP_TO_SAFEOP))
{
rprintf("boot PREOP_TO_SAFEOP\n");
ESC_ALerror (ALERR_NOVALIDFIRMWARE);
/* Stay in preop with error bit set */
*an = (ESCpreop | ESCerror);
}
#endif
}
void user_post_dl_objecthandler (uint16_t index, uint8_t subindex)
{
#if SAMPLE_CODE
switch (index)
{
case 0x1c12:
{
RXPDOsize = ESC_SM2_sml = sizeRXPDO();
break;
}
/* Handle post-write of parameter values */
default:
break;
}
#endif
}
int user_pre_dl_objecthandler (uint16_t index, uint8_t subindex)
{
#if SAMPLE_CODE
if (index == 0x1c12)
{
SDO_abort (index, subindex, ABORT_READONLY);
return 0;
}
if (index == 0x1c13)
{
SDO_abort (index, subindex, ABORT_READONLY);
return 0;
}
#endif
return 1;
}
/* Called from stack when stopping outputs */
void user_safeoutput (void)
{
#if SAMPLE_CODE
DPRINT ("APP_safeoutput\n");
// Set safe values for Wb.LEDgroup0
Wb.LEDgroup0.LED0 = 1;
// Set safe values for Wb.LEDgroup1
Wb.LEDgroup1.LED1 = 1;
#endif
}
/* 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 = 100,
.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 = user_safeoutput,
.pre_object_download_hook = user_pre_dl_objecthandler,
.post_object_download_hook = user_post_dl_objecthandler,
.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
};
void main_run(void * arg)
{
ecat_slv_init(&config);
while(1)
{
if(config.use_interrupt != 0)
{
DIG_process(DIG_PROCESS_WD_FLAG);
}
else
{
ecat_slv();
}
task_delay(1);
}
}
int main(void)
{
rprintf("Hello Main\n");
task_spawn ("soes", main_run, 8, 2048, NULL);
return 0;
}

Binary file not shown.

View File

@ -1,334 +0,0 @@
#ifndef SOES_V1
#include <stddef.h>
#include "utypes.h"
#include "esc.h"
#include "esc_coe.h"
#include "esc_foe.h"
#include "config.h"
#include "slave.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 */
case 0x8001:
{
cb_post_write_variableRW(subindex);
break;
}
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.LEDgroup0
Wb.LEDgroup0.LED0 = 0;
// Set safe values for Wb.LEDgroup1
Wb.LEDgroup1.LED1 = 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_LEDgroup0();
cb_set_LEDgroup1();
}
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_Buttons();
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

View File

@ -1,74 +0,0 @@
#ifndef __SLAVE_H__
#define __SLAVE_H__
#include "utypes.h"
#include "esc.h"
/**
* This function gets input values and updates Rb.Buttons
*/
void cb_get_Buttons();
/**
* This function sets output values according to Wb.LEDgroup0
*/
void cb_set_LEDgroup0();
/**
* This function sets output values according to Wb.LEDgroup1
*/
void cb_set_LEDgroup1();
/**
* This function is called after a SDO write of the object Cb.variableRW.
*/
void cb_post_write_variableRW(int subindex);
#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 /* __SLAVE_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,218 +0,0 @@
#ifndef SOES_V1
#include "esc_coe.h"
#include "utypes.h"
#include <stddef.h>
static const char acName1000[] = "Device Type";
static const char acName1000_0[] = "Device Type";
static const char acName1008[] = "Device Name";
static const char acName1008_0[] = "Device Name";
static const char acName1009[] = "Hardware Version";
static const char acName1009_0[] = "Hardware Version";
static const char acName100A[] = "Software Version";
static const char acName100A_0[] = "Software Version";
static const char acName1018[] = "Identity Object";
static const char acName1018_00[] = "Max SubIndex";
static const char acName1018_01[] = "Vendor ID";
static const char acName1018_02[] = "Product Code";
static const char acName1018_03[] = "Revision Number";
static const char acName1018_04[] = "Serial Number";
static const char acName10F1[] = "ErrorSettings";
static const char acName10F1_00[] = "Max SubIndex";
static const char acName10F1_01[] = "Dummy_x01";
static const char acName10F1_02[] = "SyncErrorCounterLimit";
static const char acName1600[] = "LEDgroup0";
static const char acName1600_00[] = "Max SubIndex";
static const char acName1600_01[] = "LED0";
static const char acName1601[] = "LEDgroup1";
static const char acName1601_00[] = "Max SubIndex";
static const char acName1601_01[] = "LED1";
static const char acName1A00[] = "Buttons";
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[] = "Max SubIndex";
static const char acName1C00_01[] = "Communications Type SM0";
static const char acName1C00_02[] = "Communications Type SM1";
static const char acName1C00_03[] = "Communications Type SM2";
static const char acName1C00_04[] = "Communications Type SM3";
static const char acName1C12[] = "Sync Manager 2 PDO Assignment";
static const char acName1C12_00[] = "Max SubIndex";
static const char acName1C12_01[] = "PDO Mapping";
static const char acName1C12_02[] = "PDO Mapping";
static const char acName1C13[] = "Sync Manager 3 PDO Assignment";
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_02[] = "CycleTime";
static const char acName1C32_03[] = "ShiftTime";
static const char acName1C32_04[] = "SyncTypeSupport";
static const char acName1C32_05[] = "MinCycleTime";
static const char acName1C32_06[] = "CalcCopyTime";
static const char acName1C32_07[] = "MinDelayTime";
static const char acName1C32_08[] = "GetCycleTime";
static const char acName1C32_09[] = "DelayTime";
static const char acName1C32_0A[] = "Sync0CycleTime";
static const char acName1C32_0B[] = "SMEventMissedCnt";
static const char acName1C32_0C[] = "CycleTimeTooSmallCnt";
static const char acName1C32_0D[] = "ShiftTimeTooSmallCnt";
static const char acName1C32_0E[] = "RxPDOToggleFailed";
static const char acName1C32_0F[] = "MinCycleDist";
static const char acName1C32_10[] = "MaxCycleDist";
static const char acName1C32_11[] = "MinSMSYNCDist";
static const char acName1C32_12[] = "MaxSMSYNCDist";
static const char acName1C32_14[] = "Dummy_x14";
static const char acName1C32_20[] = "SyncError";
static const char 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 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},
};
const _objd SDO1008[] =
{
{0x0, DTYPE_VISIBLE_STRING, 88, ATYPE_RO, acName1008_0, 0, "xmc43_slave"},
};
const _objd SDO1009[] =
{
{0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, "1.0"},
};
const _objd SDO100A[] =
{
{0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, "1.0"},
};
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, 4300, 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, &Mb.ErrorSettings.Dummy_x01},
{0x02, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName10F1_02, 2, &Mb.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},
};
const _objd SDO1601[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70060108, NULL},
};
const _objd SDO1A00[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60050108, 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, 2, NULL},
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_01, 0x1600, NULL},
{0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_02, 0x1601, 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 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},
};
const _objd SDO6005[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6005_00, 1, NULL},
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6005_01, 0, &Rb.Buttons.Button1},
};
const _objd SDO7005[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7005_00, 1, NULL},
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7005_01, 0, &Wb.LEDgroup0.LED0},
};
const _objd SDO7006[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7006_00, 1, NULL},
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7006_01, 0, &Wb.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},
};
const _objd SDO8001[] =
{
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName8001_0, 0, &Cb.variableRW},
};
const _objectlist SDOobjects[] =
{
{0x1000, OTYPE_VAR, 0, 0, acName1000, SDO1000},
{0x1008, OTYPE_VAR, 0, 0, acName1008, SDO1008},
{0x1009, OTYPE_VAR, 0, 0, acName1009, SDO1009},
{0x100A, OTYPE_VAR, 0, 0, acName100A, SDO100A},
{0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018},
{0x10F1, OTYPE_RECORD, 2, 0, acName10F1, SDO10F1},
{0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600},
{0x1601, OTYPE_RECORD, 1, 0, acName1601, SDO1601},
{0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00},
{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},
{0x8000, OTYPE_RECORD, 1, 0, acName8000, SDO8000},
{0x8001, OTYPE_VAR, 0, 0, acName8001, SDO8001},
{0xffff, 0xff, 0xff, 0xff, NULL, NULL}
};
#endif

View File

@ -1,96 +0,0 @@
#ifndef __UTYPES_H__
#define __UTYPES_H__
#include <cc.h>
/* Inputs */
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint8_t Button1;
} CC_PACKED Buttons;
CC_PACKED_END
} CC_PACKED _Rbuffer;
CC_PACKED_END
/* Outputs */
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint8_t LED0;
} CC_PACKED LEDgroup0;
CC_PACKED_END
CC_PACKED_BEGIN
struct
{
uint8_t LED1;
} CC_PACKED LEDgroup1;
CC_PACKED_END
} CC_PACKED _Wbuffer;
CC_PACKED_END
/* Parameters */
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint32_t Multiplier;
} CC_PACKED Parameters;
CC_PACKED_END
uint32_t variableRW;
} CC_PACKED _Cbuffer;
CC_PACKED_END
/* Manufacturer specific data */
CC_PACKED_BEGIN
typedef struct
{
CC_PACKED_BEGIN
struct
{
uint16_t SyncType;
uint32_t CycleTime;
uint32_t ShiftTime;
uint16_t SyncTypeSupport;
uint32_t MinCycleTime;
uint32_t CalcCopyTime;
uint32_t MinDelayTime;
uint16_t GetCycleTime;
uint32_t DelayTime;
uint32_t Sync0CycleTime;
uint16_t SMEventMissedCnt;
uint16_t CycleTimeTooSmallCnt;
uint16_t ShiftTimeTooSmallCnt;
uint16_t RxPDOToggleFailed;
uint32_t MinCycleDist;
uint32_t MaxCycleDist;
uint32_t MinSMSYNCDist;
uint32_t MaxSMSYNCDist;
uint8_t Dummy_x14;
uint8_t SyncError;
} 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
extern _Rbuffer Rb;
extern _Wbuffer Wb;
extern _Cbuffer Cb;
extern _Mbuffer Mb;
#endif /* __UTYPES_H__ */

Binary file not shown.

View File

@ -0,0 +1,263 @@
<?xml version="1.0" encoding="UTF-8"?>
<Slave xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="com.rtlabs.emf.esx" fileVersion="2" id="am335xice" productCode="0x9876">
<Name>slave</Name>
<Vendor>
<Id>0x1337</Id>
<Name>rt-labs</Name>
</Vendor>
<Group>
<Type>am335xice_t</Type>
<Name>am335xice_n</Name>
</Group>
<Fmmu>Outputs</Fmmu>
<Fmmu>Inputs</Fmmu>
<Fmmu>MBoxState</Fmmu>
<Sm ControlByte="0x26" DefaultSize="512" StartAddress="0x1000">MBoxOut</Sm>
<Sm ControlByte="0x22" DefaultSize="512" StartAddress="0x1200">MBoxIn</Sm>
<Sm ControlByte="0x24" DefaultSize="0" StartAddress="0x1400">Outputs</Sm>
<Sm ControlByte="0x20" DefaultSize="0" StartAddress="0x1A00">Inputs</Sm>
<Mailbox CoE="true">
<Bootstrap Length="512" Start="0x1000"/>
<Standard Length="512" Start="0x1000"/>
</Mailbox>
<Eeprom>
<ByteSize>2048</ByteSize>
<ConfigData>8006E08800000000</ConfigData>
<BootStrap>0010000200120002</BootStrap>
</Eeprom>
<Dictionary>
<Item Managed="true">
<Index>0x1000</Index>
<Name>Device Type</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x00001389</DefaultValue>
</Item>
<Item Managed="true">
<Index>0x1008</Index>
<Name>Device Name</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>am335xice</DefaultValue>
<Length>9</Length>
</Item>
<Item>
<Index>0x1009</Index>
<Name>Hardware Version</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>1.0</DefaultValue>
<Length>3</Length>
</Item>
<Item>
<Index>0x100A</Index>
<Name>Software Version</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>1.0</DefaultValue>
<Length>3</Length>
</Item>
<Item Managed="true">
<Index>0x1018</Index>
<Name>Identity Object</Name>
<DataType>RECORD</DataType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>Vendor ID</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x1337</DefaultValue>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Name>Product Code</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x9876</DefaultValue>
</SubItem>
<SubItem>
<Index>0x03</Index>
<Name>Revision Number</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
</SubItem>
<SubItem>
<Index>0x04</Index>
<Name>Serial Number</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x00000000</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x1600</Index>
<Name>LED</Name>
<DataType>RECORD</DataType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>LED</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x70000020</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x1A00</Index>
<Name>BUTTON</Name>
<DataType>RECORD</DataType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>BUTTON</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x60000020</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x1C00</Index>
<Name>Sync Manager Communication Type</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>Communications Type SM0</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x02</Index>
<Name>Communications Type SM1</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>2</DefaultValue>
</SubItem>
<SubItem>
<Index>0x03</Index>
<Name>Communications Type SM2</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>3</DefaultValue>
</SubItem>
<SubItem>
<Index>0x04</Index>
<Name>Communications Type SM3</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x1C12</Index>
<Name>Sync Manager 2 PDO Assignment</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1600</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x1C13</Index>
<Name>Sync Manager 3 PDO Assignment</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Index>0x01</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1A00</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Index>0x6000</Index>
<Access>RO</Access>
<Name>BUTTON</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
<PdoMapping>TX</PdoMapping>
<Variable>BUTTON</Variable>
<VariableType>Input</VariableType>
</Item>
<Item Managed="true">
<Index>0x7000</Index>
<Access>RO</Access>
<Name>LED</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
<PdoMapping>RX</PdoMapping>
<Variable>LED</Variable>
<VariableType>Output</VariableType>
</Item>
</Dictionary>
<SmAssignment>
<Index>0x1C12</Index>
<Entry>
<Index>0x01</Index>
<AssignedPdo>0x1600</AssignedPdo>
</Entry>
</SmAssignment>
<SmAssignment>
<Index>0x1C13</Index>
<Entry>
<Index>0x01</Index>
<AssignedPdo>0x1A00</AssignedPdo>
</Entry>
</SmAssignment>
<RxPdo>
<Index>0x1600</Index>
<Name>LED</Name>
<Entry>
<Index>0x1</Index>
<MappedIndex>0x7000</MappedIndex>
<MappedSubIndex>0x00</MappedSubIndex>
<Variable>LED</Variable>
</Entry>
</RxPdo>
<TxPdo>
<Index>0x1A00</Index>
<Name>BUTTON</Name>
<Entry>
<Index>0x1</Index>
<MappedIndex>0x6000</MappedIndex>
<MappedSubIndex>0x00</MappedSubIndex>
<Variable>BUTTON</Variable>
</Entry>
</TxPdo>
<Input>
<Index>0x6000</Index>
<Name>BUTTON</Name>
<Type>UNSIGNED32</Type>
<PdoMapping>TX</PdoMapping>
<ObjectType>VAR</ObjectType>
</Input>
<Output>
<Index>0x7000</Index>
<Name>LED</Name>
<Type>UNSIGNED32</Type>
<PdoMapping>RX</PdoMapping>
<ObjectType>VAR</ObjectType>
</Output>
</Slave>

View File

@ -0,0 +1,537 @@
<?xml version="1.0" encoding="UTF-8"?>
<EtherCATInfo>
<Vendor>
<Id>#x1337</Id>
<Name LcId="1033">rt-labs</Name>
</Vendor>
<Descriptions>
<Groups>
<Group>
<Type>am335xice_t</Type>
<Name LcId="1033">am335xice_n</Name>
</Group>
</Groups>
<Devices>
<Device Physics="YY">
<Type ProductCode="#x9876" RevisionNo="0">am335xice</Type>
<Name LcId="1033">slave</Name>
<GroupType>am335xice_t</GroupType>
<Profile>
<ProfileNo>5001</ProfileNo>
<AddInfo>0</AddInfo>
<Dictionary>
<DataTypes>
<DataType>
<Name>DT1018</Name>
<BitSize>144</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>1</SubIdx>
<Name>Vendor ID</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>2</SubIdx>
<Name>Product Code</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>48</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>3</SubIdx>
<Name>Revision Number</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>80</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>4</SubIdx>
<Name>Serial Number</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>112</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT1600</Name>
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>1</SubIdx>
<Name>LED</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT1A00</Name>
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>1</SubIdx>
<Name>BUTTON</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT1C00ARR</Name>
<BaseType>USINT</BaseType>
<BitSize>32</BitSize>
<ArrayInfo>
<LBound>1</LBound>
<Elements>4</Elements>
</ArrayInfo>
</DataType>
<DataType>
<Name>DT1C00</Name>
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<Name>Elements</Name>
<Type>DT1C00ARR</Type>
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT1C12ARR</Name>
<BaseType>UINT</BaseType>
<BitSize>16</BitSize>
<ArrayInfo>
<LBound>1</LBound>
<Elements>1</Elements>
</ArrayInfo>
</DataType>
<DataType>
<Name>DT1C12</Name>
<BitSize>32</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<Name>Elements</Name>
<Type>DT1C12ARR</Type>
<BitSize>16</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT1C13ARR</Name>
<BaseType>UINT</BaseType>
<BitSize>16</BitSize>
<ArrayInfo>
<LBound>1</LBound>
<Elements>1</Elements>
</ArrayInfo>
</DataType>
<DataType>
<Name>DT1C13</Name>
<BitSize>32</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<Name>Elements</Name>
<Type>DT1C13ARR</Type>
<BitSize>16</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>STRING(3)</Name>
<BitSize>24</BitSize>
</DataType>
<DataType>
<Name>UDINT</Name>
<BitSize>32</BitSize>
</DataType>
<DataType>
<Name>UINT</Name>
<BitSize>16</BitSize>
</DataType>
<DataType>
<Name>USINT</Name>
<BitSize>8</BitSize>
</DataType>
<DataType>
<Name>STRING(9)</Name>
<BitSize>72</BitSize>
</DataType>
</DataTypes>
<Objects>
<Object>
<Index>#x1000</Index>
<Name>Device Type</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<Info>
<DefaultValue>#x00001389</DefaultValue>
</Info>
<Flags>
<Access>ro</Access>
<Category>m</Category>
</Flags>
</Object>
<Object>
<Index>#x1008</Index>
<Name>Device Name</Name>
<Type>STRING(9)</Type>
<BitSize>72</BitSize>
<Info>
<DefaultString>am335xice</DefaultString>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1009</Index>
<Name>Hardware Version</Name>
<Type>STRING(3)</Type>
<BitSize>24</BitSize>
<Info>
<DefaultString>1.0</DefaultString>
</Info>
<Flags>
<Access>ro</Access>
<Category>o</Category>
</Flags>
</Object>
<Object>
<Index>#x100A</Index>
<Name>Software Version</Name>
<Type>STRING(3)</Type>
<BitSize>24</BitSize>
<Info>
<DefaultString>1.0</DefaultString>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1018</Index>
<Name>Identity Object</Name>
<Type>DT1018</Type>
<BitSize>144</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>4</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Vendor ID</Name>
<Info>
<DefaultValue>#x1337</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Product Code</Name>
<Info>
<DefaultValue>#x9876</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Revision Number</Name>
<Info>
<DefaultValue>0</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Serial Number</Name>
<Info>
<DefaultValue>#x00000000</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1600</Index>
<Name>LED</Name>
<Type>DT1600</Type>
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>LED</Name>
<Info>
<DefaultValue>#x70000020</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1A00</Index>
<Name>BUTTON</Name>
<Type>DT1A00</Type>
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>BUTTON</Name>
<Info>
<DefaultValue>#x60000020</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1C00</Index>
<Name>Sync Manager Communication Type</Name>
<Type>DT1C00</Type>
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>4</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Communications Type SM0</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Communications Type SM1</Name>
<Info>
<DefaultValue>2</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Communications Type SM2</Name>
<Info>
<DefaultValue>3</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Communications Type SM3</Name>
<Info>
<DefaultValue>4</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1C12</Index>
<Name>Sync Manager 2 PDO Assignment</Name>
<Type>DT1C12</Type>
<BitSize>32</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>PDO Mapping</Name>
<Info>
<DefaultValue>#x1600</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1C13</Index>
<Name>Sync Manager 3 PDO Assignment</Name>
<Type>DT1C13</Type>
<BitSize>32</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>PDO Mapping</Name>
<Info>
<DefaultValue>#x1A00</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x6000</Index>
<Name>BUTTON</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<Info>
<DefaultValue>0</DefaultValue>
</Info>
<Flags>
<Access>ro</Access>
<PdoMapping>T</PdoMapping>
</Flags>
</Object>
<Object>
<Index>#x7000</Index>
<Name>LED</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<Info>
<DefaultValue>0</DefaultValue>
</Info>
<Flags>
<Access>ro</Access>
<PdoMapping>R</PdoMapping>
</Flags>
</Object>
</Objects>
</Dictionary>
</Profile>
<Fmmu>Outputs</Fmmu>
<Fmmu>Inputs</Fmmu>
<Fmmu>MBoxState</Fmmu>
<Sm ControlByte="#x26" DefaultSize="512" Enable="1" StartAddress="#x1000">MBoxOut</Sm>
<Sm ControlByte="#x22" DefaultSize="512" Enable="1" StartAddress="#x1200">MBoxIn</Sm>
<Sm ControlByte="#x24" Enable="1" StartAddress="#x1400">Outputs</Sm>
<Sm ControlByte="#x20" Enable="1" StartAddress="#x1A00">Inputs</Sm>
<RxPdo Fixed="true" Mandatory="true" Sm="2">
<Index>#x1600</Index>
<Name>LED</Name>
<Entry>
<Index>#x7000</Index>
<SubIndex>#x0</SubIndex>
<BitLen>32</BitLen>
<Name>LED</Name>
<DataType>UDINT</DataType>
</Entry>
</RxPdo>
<TxPdo Fixed="true" Mandatory="true" Sm="3">
<Index>#x1A00</Index>
<Name>BUTTON</Name>
<Entry>
<Index>#x6000</Index>
<SubIndex>#x0</SubIndex>
<BitLen>32</BitLen>
<Name>BUTTON</Name>
<DataType>UDINT</DataType>
</Entry>
</TxPdo>
<Mailbox DataLinkLayer="true">
<CoE CompleteAccess="false" PdoUpload="false" SdoInfo="true"/>
</Mailbox>
<Eeprom>
<ByteSize>2048</ByteSize>
<ConfigData>8006E08800000000</ConfigData>
<BootStrap>0010000200120002</BootStrap>
</Eeprom>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>

View File

@ -0,0 +1,120 @@
#include "esc_coe.h"
#include "utypes.h"
#include <stddef.h>
#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}
};

View File

@ -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__ */

View File

@ -0,0 +1,85 @@
#include "esc_hw.h"
#include "ecat_slv.h"
#include "options.h"
#include "utypes.h"
#include <string.h>
#include "tiescutils.h"
#include <examples/board/include/board_i2cLed.h>
#include <examples/board/include/board_rotary_switch.h>
#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;
}

View File

@ -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__ */

View File

@ -1,35 +0,0 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include <cc.h>
#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__ */

View File

@ -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__ */

Binary file not shown.

View File

@ -1,229 +1,248 @@
<?xml version="1.0" encoding="UTF-8"?>
<Slave fileVersion="1" id="k2gice" productCode="0x1234">
<Name>k2gice</Name>
<Slave xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="com.rtlabs.emf.esx" fileVersion="2" id="k2gice" productCode="0x4291ce">
<Name>k2gice_n</Name>
<Vendor>
<Id>0x1337</Id>
<Name>rt-labs</Name>
</Vendor>
<Group>
<Type>k2gice_t</Type>
<Name>k2gice_n</Name>
<Name>am335xice_n</Name>
</Group>
<Fmmu>Outputs</Fmmu>
<Fmmu>Inputs</Fmmu>
<Fmmu>MBoxState</Fmmu>
<Sm ControlByte="0x26" DefaultSize="128" StartAddress="0x1000">MBoxOut</Sm>
<Sm ControlByte="0x22" DefaultSize="128" StartAddress="0x1080">MBoxIn</Sm>
<Sm ControlByte="0x24" DefaultSize="0" StartAddress="0x1100">Outputs</Sm>
<Sm ControlByte="0x20" DefaultSize="0" StartAddress="0x1180">Inputs</Sm>
<Sm ControlByte="0x26" DefaultSize="512" StartAddress="0x1000">MBoxOut</Sm>
<Sm ControlByte="0x22" DefaultSize="512" StartAddress="0x1200">MBoxIn</Sm>
<Sm ControlByte="0x24" DefaultSize="0" StartAddress="0x1400">Outputs</Sm>
<Sm ControlByte="0x20" DefaultSize="0" StartAddress="0x1A00">Inputs</Sm>
<Mailbox CoE="true">
<Bootstrap Length="128" Start="0x1000"/>
<Standard Length="128" Start="0x1000"/>
<Bootstrap Length="512" Start="0x1000"/>
<Standard Length="512" Start="0x1000"/>
</Mailbox>
<Eeprom>
<ByteSize>2048</ByteSize>
<ConfigData>800CE08800000000</ConfigData>
<BootStrap>0010800080108000</BootStrap>
<BootStrap>0010000200120002</BootStrap>
</Eeprom>
<Dictionary>
<Item>
<Name>Device Type</Name>
<Item Managed="true">
<Index>0x1000</Index>
<Name>Device Type</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x00001389</DefaultValue>
</Item>
<Item Managed="true">
<Name>Device Name</Name>
<Index>0x1008</Index>
<Name>Device Name</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>k2gice</DefaultValue>
<Length>6</Length>
</Item>
<Item>
<Name>Hardware Version</Name>
<Index>0x1009</Index>
<Name>Hardware Version</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>1.0</DefaultValue>
<Length>3</Length>
</Item>
<Item>
<Name>Software Version</Name>
<Index>0x100A</Index>
<Name>Software Version</Name>
<DataType>VISIBLE_STRING</DataType>
<DefaultValue>1.0</DefaultValue>
<Length>3</Length>
</Item>
<Item Managed="true">
<Name>Identity Object</Name>
<Index>0x1018</Index>
<Name>Identity Object</Name>
<DataType>RECORD</DataType>
<SubItem>
<Name>Max SubIndex</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
<SubItem>
<Name>Vendor ID</Name>
<Index>0x01</Index>
<Name>Vendor ID</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x1337</DefaultValue>
</SubItem>
<SubItem>
<Name>Product Code</Name>
<Index>0x02</Index>
<Name>Product Code</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x1234</DefaultValue>
<DefaultValue>0x4291ce</DefaultValue>
</SubItem>
<SubItem>
<Name>Revision Number</Name>
<Index>0x03</Index>
<Name>Revision Number</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
</SubItem>
<SubItem>
<Name>Serial Number</Name>
<Index>0x04</Index>
<Name>Serial Number</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x00000000</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>LED</Name>
<Index>0x1600</Index>
<Name>LED</Name>
<DataType>RECORD</DataType>
<SubItem>
<Name>Max SubIndex</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Name>LED</Name>
<Index>0x01</Index>
<Name>LED</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x70000020</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>BUTTON</Name>
<Index>0x1A00</Index>
<Name>BUTTON</Name>
<DataType>RECORD</DataType>
<SubItem>
<Name>Max SubIndex</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Name>BUTTON</Name>
<Index>0x01</Index>
<Name>BUTTON</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0x60000020</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager Communication Type</Name>
<Index>0x1C00</Index>
<Name>Sync Manager Communication Type</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Max SubIndex</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
<SubItem>
<Name>Communications Type SM0</Name>
<Index>0x01</Index>
<Name>Communications Type SM0</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Name>Communications Type SM1</Name>
<Index>0x02</Index>
<Name>Communications Type SM1</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>2</DefaultValue>
</SubItem>
<SubItem>
<Name>Communications Type SM2</Name>
<Index>0x03</Index>
<Name>Communications Type SM2</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>3</DefaultValue>
</SubItem>
<SubItem>
<Name>Communications Type SM3</Name>
<Index>0x04</Index>
<Name>Communications Type SM3</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>4</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager 2 PDO Assignment</Name>
<Index>0x1C12</Index>
<Name>Sync Manager 2 PDO Assignment</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Max SubIndex</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Name>PDO Mapping</Name>
<Index>0x01</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1600</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>Sync Manager 3 PDO Assignment</Name>
<Index>0x1C13</Index>
<Name>Sync Manager 3 PDO Assignment</Name>
<DataType>ARRAY</DataType>
<SubItem>
<Name>Max SubIndex</Name>
<Index>0x00</Index>
<Name>Max SubIndex</Name>
<DataType>UNSIGNED8</DataType>
<DefaultValue>1</DefaultValue>
</SubItem>
<SubItem>
<Name>PDO Mapping</Name>
<Index>0x01</Index>
<Name>PDO Mapping</Name>
<DataType>UNSIGNED16</DataType>
<DefaultValue>0x1A00</DefaultValue>
</SubItem>
</Item>
<Item Managed="true">
<Name>BUTTON</Name>
<Index>0x6000</Index>
<Access>RO</Access>
<Name>BUTTON</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
<Access>RO</Access>
<PdoMapping>TX</PdoMapping>
<Variable>BUTTON</Variable>
<VariableType>Input</VariableType>
</Item>
<Item Managed="true">
<Name>LED</Name>
<Index>0x7000</Index>
<Access>RO</Access>
<Name>LED</Name>
<DataType>UNSIGNED32</DataType>
<DefaultValue>0</DefaultValue>
<Access>RO</Access>
<PdoMapping>RX</PdoMapping>
<Variable>LED</Variable>
<VariableType>Output</VariableType>
</Item>
</Dictionary>
<SmAssignment>
<Index>0x1C12</Index>
<Entry>
<Index>0x01</Index>
<AssignedPdo>0x1600</AssignedPdo>
</Entry>
</SmAssignment>
<SmAssignment>
<Index>0x1C13</Index>
<Entry>
<Index>0x01</Index>
<AssignedPdo>0x1A00</AssignedPdo>
</Entry>
</SmAssignment>
<RxPdo>
<Index>0x1600</Index>
<Container>LED</Container>
<Name>LED</Name>
<Entry>
<Index>0x7000</Index>
<SubIndex>0</SubIndex>
<Index>0x1</Index>
<MappedIndex>0x7000</MappedIndex>
<MappedSubIndex>0x00</MappedSubIndex>
<Variable>LED</Variable>
</Entry>
</RxPdo>
<TxPdo>
<Index>0x1A00</Index>
<Container>BUTTON</Container>
<Name>BUTTON</Name>
<Entry>
<Index>0x6000</Index>
<SubIndex>0</SubIndex>
<Index>0x1</Index>
<MappedIndex>0x6000</MappedIndex>
<MappedSubIndex>0x00</MappedSubIndex>
<Variable>BUTTON</Variable>
</Entry>
</TxPdo>
@ -231,12 +250,14 @@
<Index>0x6000</Index>
<Name>BUTTON</Name>
<Type>UNSIGNED32</Type>
<PdoMapping>TX</PdoMapping>
<ObjectType>VAR</ObjectType>
</Input>
<Output>
<Index>0x7000</Index>
<Name>LED</Name>
<Type>UNSIGNED32</Type>
<PdoMapping>RX</PdoMapping>
<ObjectType>VAR</ObjectType>
</Output>
</Slave>
</Slave>

View File

@ -8,13 +8,13 @@
<Groups>
<Group>
<Type>k2gice_t</Type>
<Name LcId="1033">k2gice_n</Name>
<Name LcId="1033">am335xice_n</Name>
</Group>
</Groups>
<Devices>
<Device Physics="YY">
<Type ProductCode="#x1234" RevisionNo="0">k2gice</Type>
<Name LcId="1033">k2gice</Name>
<Type ProductCode="#x4291ce" RevisionNo="0">k2gice</Type>
<Name LcId="1033">k2gice_n</Name>
<GroupType>k2gice_t</GroupType>
<Profile>
<ProfileNo>5001</ProfileNo>
@ -312,7 +312,7 @@
<SubItem>
<Name>Product Code</Name>
<Info>
<DefaultValue>#x1234</DefaultValue>
<DefaultValue>#x4291ce</DefaultValue>
</Info>
</SubItem>
<SubItem>
@ -475,6 +475,7 @@
</Info>
<Flags>
<Access>ro</Access>
<PdoMapping>T</PdoMapping>
</Flags>
</Object>
<Object>
@ -487,6 +488,7 @@
</Info>
<Flags>
<Access>ro</Access>
<PdoMapping>R</PdoMapping>
</Flags>
</Object>
</Objects>
@ -495,16 +497,16 @@
<Fmmu>Outputs</Fmmu>
<Fmmu>Inputs</Fmmu>
<Fmmu>MBoxState</Fmmu>
<Sm ControlByte="#x26" DefaultSize="128" Enable="1" StartAddress="#x1000">MBoxOut</Sm>
<Sm ControlByte="#x22" DefaultSize="128" Enable="1" StartAddress="#x1080">MBoxIn</Sm>
<Sm ControlByte="#x24" Enable="1" StartAddress="#x1100">Outputs</Sm>
<Sm ControlByte="#x20" Enable="1" StartAddress="#x1180">Inputs</Sm>
<Sm ControlByte="#x26" DefaultSize="512" Enable="1" StartAddress="#x1000">MBoxOut</Sm>
<Sm ControlByte="#x22" DefaultSize="512" Enable="1" StartAddress="#x1200">MBoxIn</Sm>
<Sm ControlByte="#x24" Enable="1" StartAddress="#x1400">Outputs</Sm>
<Sm ControlByte="#x20" Enable="1" StartAddress="#x1A00">Inputs</Sm>
<RxPdo Fixed="true" Mandatory="true" Sm="2">
<Index>#x1600</Index>
<Name>LED</Name>
<Entry>
<Index>#x7000</Index>
<SubIndex>0</SubIndex>
<SubIndex>#x0</SubIndex>
<BitLen>32</BitLen>
<Name>LED</Name>
<DataType>UDINT</DataType>
@ -515,19 +517,19 @@
<Name>BUTTON</Name>
<Entry>
<Index>#x6000</Index>
<SubIndex>0</SubIndex>
<SubIndex>#x0</SubIndex>
<BitLen>32</BitLen>
<Name>BUTTON</Name>
<DataType>UDINT</DataType>
</Entry>
</TxPdo>
<Mailbox DataLinkLayer="true">
<CoE CompleteAccess="false" PdoUpload="true" SdoInfo="true"/>
<CoE CompleteAccess="false" PdoUpload="false" SdoInfo="true"/>
</Mailbox>
<Eeprom>
<ByteSize>2048</ByteSize>
<ConfigData>800CE08800000000</ConfigData>
<BootStrap>0010800080108000</BootStrap>
<ConfigData>800EE08800000000</ConfigData>
<BootStrap>0010000200120002</BootStrap>
</Eeprom>
</Device>
</Devices>

View File

@ -1,4 +1,3 @@
#ifndef SOES_V1
#include "esc_coe.h"
#include "utypes.h"
#include <stddef.h>
@ -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

View File

@ -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 <string.h>
#include "tiescutils.h"
#include <examples/board/include/board_i2cLed.h>
#include <examples/board/include/board_rotary_switch.h>
/* 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)

View File

@ -1,41 +1,31 @@
#ifndef __UTYPES_H__
#define __UTYPES_H__
#include <cc.h>
#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__ */

View File

@ -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 \

View File

@ -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 0
#define MAX_MAPPINGS_SM3 0
#endif /* __ECAT_OPTIONS_H__ */

View File

@ -1,15 +1,136 @@
#include <string.h>
/*
* 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;
uint8_t * rxpdo = (uint8_t *)&Wb.LED;
uint8_t * txpdo = (uint8_t *)&Rb.button;
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;
}

View File

@ -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 <stddef.h>
#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();
}

View File

@ -1,14 +0,0 @@
#ifndef _SOES_H_
#define _SOES_H_
#include <xmc_gpio.h>
#include <xmc_scu.h>
#define P_LED P4_1
#define P_BTN P3_4
extern void soes_init (void);
extern void soes_task (void);
#endif

View File

@ -16,21 +16,27 @@
#include <cc.h>
CC_PACKED_BEGIN
typedef struct
{
uint8_t state;
uint8_t button;
uint32_t encoder;
} _Rbuffer;
}CC_PACKED _Rbuffer;
CC_PACKED_END
CC_PACKED_BEGIN
typedef struct
{
uint8_t LED;
} _Wbuffer;
}CC_PACKED _Wbuffer;
CC_PACKED_END
CC_PACKED_BEGIN
typedef struct
{
uint32_t reset_counter;
} _Cbuffer;
}CC_PACKED _Cbuffer;
CC_PACKED_END
#endif

View File

@ -0,0 +1,29 @@
# Guard against multiple inclusion
if(_TOOLCHAIN_CMAKE_)
return()
endif()
set(_TOOLCHAIN_CMAKE_ TRUE)
INCLUDE(CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME rt-kernel)
# specify the cross compiler
CMAKE_FORCE_C_COMPILER(arm-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-eabi-g++ GNU)
set(ARCH xmc4)
set(CPU cortex-m4f)
set(BSP xmc48relax)
set(MACHINE_FLAGS "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16")
set(SOES_DEMO applications/rtl_xmc4_dynpdo)
include_directories(
${SOES_SOURCE_DIR}/${SOES_DEMO}
${SOES_SOURCE_DIR}/soes/hal/rt-kernel-xmc4
)
set(HAL_SOURCES
${SOES_SOURCE_DIR}/soes/hal/rt-kernel-xmc4/esc_hw.c
${SOES_SOURCE_DIR}/soes/hal/rt-kernel-xmc4/esc_hw_eep.c
)

View File

@ -11,6 +11,9 @@ add_library (soes
esc_eoe.h
esc_eep.c
esc_eep.h
ecat_slv.c
ecat_slv.h
options.h
${HAL_SOURCES}
)

View File

@ -1,69 +1,92 @@
#ifndef SOES_V1
/*
* Licensed under the GNU General Public License version 2 with exceptions. See
* LICENSE file in the project root for full license information
*/
#include <stddef.h>
#include "utypes.h"
#include "esc.h"
#include "esc_coe.h"
#include "esc_foe.h"
#include "config.h"
#include "k2gice.h"
#include "esc_eoe.h"
#include "ecat_slv.h"
#define IS_RXPDO(index) ((index) >= 0x1600 && (index) < 0x1800)
#define IS_TXPDO(index) ((index) >= 0x1A00 && (index) < 0x1C00)
/* Global variables used by the stack */
uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)];
_MBXcontrol MBXcontrol[MBXBUFFERS];
_SMmap SMmap2[MAX_MAPPINGS_SM2];
_SMmap SMmap3[MAX_MAPPINGS_SM3];
_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.
#if MAX_MAPPINGS_SM2 > 0
static uint8_t rxpdo[MAX_RXPDO_SIZE] __attribute__((aligned (8)));
#else
extern uint8_t * rxpdo;
#endif
#if MAX_MAPPINGS_SM3 > 0
static uint8_t txpdo[MAX_TXPDO_SIZE] __attribute__((aligned (8)));
#else
extern uint8_t * txpdo;
#endif
/** 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.
* @return SDO abort code, or 0 on success
*/
int ESC_pre_objecthandler (uint16_t index, uint8_t subindex)
uint32_t ESC_pre_objecthandler (uint16_t index,
uint8_t subindex,
void * data,
size_t size,
uint16_t flags)
{
int result = 1;
uint32_t abort = 0;
if(ESCvar.pre_object_download_hook)
if (IS_RXPDO (index) ||
IS_TXPDO (index) ||
index == RX_PDO_OBJIDX ||
index == TX_PDO_OBJIDX)
{
result = (ESCvar.pre_object_download_hook)(index, subindex);
if (subindex > 0 && COE_maxSub (index) != 0)
{
abort = ABORT_SUBINDEX0_NOT_ZERO;
}
}
return result;
if (ESCvar.pre_object_download_hook)
{
abort = (ESCvar.pre_object_download_hook) (index,
subindex,
data,
size,
flags);
}
return abort;
}
/** Mandatory: Hook called from the slave stack SDO Download handler to act on
/** 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)
void ESC_objecthandler (uint16_t index, uint8_t subindex, uint16_t flags)
{
switch (index)
if (ESCvar.post_object_download_hook != NULL)
{
/* Handle post-write of parameter values */
default:
{
if(ESCvar.post_object_download_hook != NULL)
{
(ESCvar.post_object_download_hook)(index, subindex);
}
break;
}
(ESCvar.post_object_download_hook)(index, subindex, flags);
}
}
/** Mandatory: Hook called from the slave stack ESC_stopoutputs to act on state changes
/** 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)
{
@ -73,14 +96,9 @@ void APP_safeoutput (void)
{
(ESCvar.safeoutput_override)();
}
else
{
// Set safe values for Wb.LED
Wb.LED = 0;
}
}
/** Mandatory: Write local process data to Sync Manager 3, Master Inputs.
/** Write local process data to Sync Manager 3, Master Inputs.
*/
void TXPDO_update (void)
{
@ -90,11 +108,15 @@ void TXPDO_update (void)
}
else
{
ESC_write (SM3_sma, &Rb, ESCvar.TXPDOsize);
if (MAX_MAPPINGS_SM3 > 0)
{
COE_pdoPack (txpdo, ESCvar.sm3mappings, SMmap3);
}
ESC_write (ESC_SM3_sma, txpdo, ESCvar.ESC_SM3_sml);
}
}
/** Mandatory: Read Sync Manager 2 to local process data, Master Outputs.
/** Read Sync Manager 2 to local process data, Master Outputs.
*/
void RXPDO_update (void)
{
@ -104,11 +126,25 @@ void RXPDO_update (void)
}
else
{
ESC_read (SM2_sma, &Wb, ESCvar.RXPDOsize);
ESC_read (ESC_SM2_sma, rxpdo, ESCvar.ESC_SM2_sml);
if (MAX_MAPPINGS_SM2 > 0)
{
COE_pdoUnpack (rxpdo, ESCvar.sm2mappings, SMmap2);
}
}
}
/** Mandatory: Function to update local I/O, call read ethercat outputs, call
/* Set the watchdog count value, don't have any affect when using
* HW watchdog 0x4xx
*
* @param[in] watchdogcnt = new watchdog count value
*/
void APP_setwatchdog (int watchdogcnt)
{
CC_ATOMIC_SET(ESCvar.watchdogcnt, watchdogcnt);
}
/* 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.
*/
@ -117,7 +153,6 @@ 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);
@ -127,11 +162,7 @@ void DIG_process (uint8_t flags)
((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);
ESC_ALstatusgotoerror((ESCsafeop | ESCerror), ALERR_WATCHDOG);
}
else if(((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) == 0))
{
@ -147,12 +178,8 @@ void DIG_process (uint8_t flags)
{
RXPDO_update();
CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt);
if(ESCvar.dcsync > 0)
{
CC_ATOMIC_ADD(ESCvar.synccounter, 1);
}
/* Set outputs */
cb_set_LED();
cb_set_outputs();
}
else if (ESCvar.ALevent & ESCREG_ALEVENT_SM2)
{
@ -163,27 +190,6 @@ void DIG_process (uint8_t flags)
/* 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)
{
@ -197,13 +203,13 @@ void DIG_process (uint8_t flags)
if(CC_ATOMIC_GET(ESCvar.App.state) > 0)
{
/* Update inputs */
cb_get_BUTTON();
cb_get_inputs();
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
@ -221,10 +227,17 @@ void ecat_slv_worker (uint32_t event_mask)
while ((ESC_mbxprocess() > 0) || (ESCvar.txcue > 0))
{
ESC_coeprocess();
#if USE_FOE
ESC_foeprocess();
#endif
#if USE_EOE
ESC_eoeprocess();
#endif
ESC_xoeprocess();
}
#if USE_EOE
ESC_eoeprocess_tx();
#endif
/* Call emulated eeprom handler if set */
if (ESCvar.esc_hw_eep_handler != NULL)
{
@ -238,18 +251,7 @@ void ecat_slv_worker (uint32_t 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.
@ -269,9 +271,17 @@ void ecat_slv_poll (void)
if (ESC_mbxprocess())
{
ESC_coeprocess();
#if USE_FOE
ESC_foeprocess();
#endif
#if USE_EOE
ESC_eoeprocess();
#endif
ESC_xoeprocess();
}
#if USE_EOE
ESC_eoeprocess_tx();
#endif
/* Call emulated eeprom handler if set */
if (ESCvar.esc_hw_eep_handler != NULL)
@ -280,6 +290,9 @@ void ecat_slv_poll (void)
}
}
/*
* Poll all events in a free-run application
*/
void ecat_slv (void)
{
ecat_slv_poll();
@ -287,16 +300,13 @@ void ecat_slv (void)
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;
@ -313,8 +323,15 @@ void ecat_slv_init (esc_cfg_t * config)
ESCvar.DLstatus = etohs (ESCvar.DLstatus);
}
#if USE_FOE
/* Init FoE */
FOE_init();
#endif
#if USE_EOE
/* Init EoE */
EOE_init();
#endif
/* reset ESC to init state */
ESC_ALstatus (ESCinit);
@ -323,4 +340,3 @@ void ecat_slv_init (esc_cfg_t * config)
ESC_stopinput();
ESC_stopoutput();
}
#endif

View File

@ -1,18 +1,25 @@
#ifndef __K2GICE_H__
#define __K2GICE_H__
#ifndef __ECAT_SLV_H__
#define __ECAT_SLV_H__
#include "utypes.h"
#include "ecat_slv.h"
#include "options.h"
#include "esc.h"
/**
* This function gets input values and updates Rb.BUTTON
* This function is called when to get input values
*/
void cb_get_BUTTON();
void cb_get_inputs();
/**
* This function sets output values according to Wb.LED
* This function is called when to set outputs values
*/
void cb_set_LED();
void cb_set_outputs();
/** Set the watchdog count value
*
* @param[in] watchdogcnt = new watchdog count value
*/
void APP_setwatchdog (int watchdogcnt);
#define DIG_PROCESS_INPUTS_FLAG 0x01
#define DIG_PROCESS_OUTPUTS_FLAG 0x02
@ -37,12 +44,6 @@ void DIG_process (uint8_t flags);
*/
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
@ -61,4 +62,4 @@ void ecat_slv (void);
*/
void ecat_slv_init (esc_cfg_t * config);
#endif /* __K2GICE_H__ */
#endif /* __ECAT_SLV_H__ */

View File

@ -41,6 +41,48 @@ void ESC_ALstatus (uint8_t status)
ESC_write (ESCREG_ALSTATUS, &dummy, sizeof (dummy));
}
/** Write AL Status and AL Status code to the ESC.
* Call pre- and poststate change hook
*
* @param[in] status = Write current slave status to register 0x130 AL Status
* reflecting actual state and error indication if present
* @param[in] errornumber = Write an by EtherCAT specified Error number
* register 0x134 AL Status Code
*/
void ESC_ALstatusgotoerror (uint8_t status, uint16_t errornumber)
{
uint8_t an, as;
if(status & ESCop)
{
/* Erroneous input, ignore */
return;
}
/* Mask error ack of current state */
as = ESCvar.ALstatus & ESCREG_AL_ERRACKMASK;
an = as;
/* Set the state transition, new state in high bits and old in bits */
as = ((status & ESCREG_AL_ERRACKMASK) << 4) | (as & 0x0f);
/* Call post state change hook case it have been configured */
if (ESCvar.pre_state_change_hook != NULL)
{
ESCvar.pre_state_change_hook (&as, &an);
}
/* Stop outputs if active */
if ((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0)
{
ESC_stopoutput();
}
ESC_ALerror(errornumber);
ESC_ALstatus(status);
an = status;
/* Call post state change hook case it have been configured */
if (ESCvar.post_state_change_hook != NULL)
{
ESCvar.post_state_change_hook (&as, &an);
}
}
/** Write ALeventMask register 0x204.
*
* @param[in] n = AL Event Mask
@ -208,51 +250,16 @@ uint16_t ESC_checkDC (void)
uint16_t ret = 0;
uint8_t sync_act = ESC_SYNCactivation();
uint32_t sync0_cycletime = ESC_SYNC0cycletime();
uint16_t sync_type_supported1c32 = 0;
uint32_t mincycletime = 0;
/* Do we need to check sync settings? */
if((sync_act & (ESCREG_SYNC_ACT_ACTIVATED | ESCREG_SYNC_AUTO_ACTIVATED)) > 0)
{
/* If the sync unit is active at least on signal should be activated */
if(COE_getSyncMgrPara(0x1c32, 0x4, &sync_type_supported1c32, DTYPE_UNSIGNED16) == 0)
/* Trigger a by the application given DC check handler, return error if
* non is given
*/
ret = ALERR_DCINVALIDSYNCCFG;
if(ESCvar.esc_check_dc_handler != NULL)
{
ret = ALERR_DCINVALIDSYNCCFG;
}
else if(COE_getSyncMgrPara(0x1c32, 0x5, &mincycletime, DTYPE_UNSIGNED32) == 0)
{
ret = ALERR_DCINVALIDSYNCCFG;
}
else if(COE_getSyncMgrPara(0x10F1, 0x2, &ESCvar.synccounterlimit, DTYPE_UNSIGNED16) == 0)
{
ret = ALERR_DCINVALIDSYNCCFG;
}
else if((sync_act & (ESCREG_SYNC_SYNC0_EN | ESCREG_SYNC_SYNC1_EN)) == 0)
{
ret = ALERR_DCINVALIDSYNCCFG;
}
/* Do we support activated signals */
else if(((sync_type_supported1c32 & SYNCTYPE_SUPPORT_DCSYNC0) == 0) &&
((sync_act & ESCREG_SYNC_SYNC0_EN) > 0))
{
ret = ALERR_DCINVALIDSYNCCFG;
}
/* Do we support activated signals */
else if(((sync_type_supported1c32 & SYNCTYPE_SUPPORT_DCSYNC1) == 0) &&
((sync_act & ESCREG_SYNC_SYNC1_EN) > 0))
{
ret = ALERR_DCINVALIDSYNCCFG;
}
else if((sync0_cycletime != 0) && (sync0_cycletime < mincycletime))
{
ret = ALERR_DCSYNC0CYCLETIME;
}
else
{
ESCvar.dcsync = 1;
ESCvar.synccounter = 0;
ret = (ESCvar.esc_check_dc_handler)();
}
}
else
@ -310,7 +317,7 @@ uint8_t ESC_checkmbx (uint8_t state)
uint8_t ESC_startmbx (uint8_t state)
{
/* Assign SM settings */
ESCvar.activembxsize = ESCvar.mbxsize;
ESCvar.activembxsize = MBXSIZE;
ESCvar.activemb0 = &ESCvar.mb[0];
ESCvar.activemb1 = &ESCvar.mb[1];
@ -344,7 +351,7 @@ uint8_t ESC_startmbx (uint8_t state)
uint8_t ESC_startmbxboot (uint8_t state)
{
/* Assign SM settings */
ESCvar.activembxsize = ESCvar.mbxsizeboot;
ESCvar.activembxsize = MBXSIZEBOOT;
ESCvar.activemb0 = &ESCvar.mbboot[0];
ESCvar.activemb1 = &ESCvar.mbboot[1];
@ -971,7 +978,7 @@ void ESC_state (void)
{
/* get station address */
ESC_address ();
COE_initDefaultSyncMgrPara ();
COE_initDefaultValues ();
an = ESC_startmbx (ac);
break;
}
@ -1029,8 +1036,24 @@ void ESC_state (void)
case PREOP_TO_SAFEOP:
case SAFEOP_TO_SAFEOP:
{
ESCvar.ESC_SM2_sml = sizeOfPDO (RX_PDO_OBJIDX);
ESCvar.ESC_SM3_sml = sizeOfPDO (TX_PDO_OBJIDX);
ESCvar.ESC_SM2_sml = sizeOfPDO (RX_PDO_OBJIDX, &ESCvar.sm2mappings,
SMmap2, MAX_MAPPINGS_SM2);
if (ESCvar.sm2mappings < 0)
{
an = ESCpreop | ESCerror;
ESC_ALerror (ALERR_INVALIDOUTPUTSM);
break;
}
ESCvar.ESC_SM3_sml = sizeOfPDO (TX_PDO_OBJIDX, &ESCvar.sm3mappings,
SMmap3, MAX_MAPPINGS_SM3);
if (ESCvar.sm3mappings < 0)
{
an = ESCpreop | ESCerror;
ESC_ALerror (ALERR_INVALIDINPUTSM);
break;
}
an = ESC_startinput (ac);
if (an == ac)
{
@ -1111,7 +1134,7 @@ void ESC_state (void)
}
ESC_ALstatus (an);
DPRINT ("state %x\n", an);
}
/** Function copying the application configuration variable
* data to the stack local variable.
@ -1121,20 +1144,21 @@ void ESC_state (void)
*/
void ESC_config (esc_cfg_t * cfg)
{
/* Copy configuration data */
static sm_cfg_t mb0 = {MBX0_sma, MBX0_sml, MBX0_sme, MBX0_smc, 0};
static sm_cfg_t mb1 = {MBX1_sma, MBX1_sml, MBX1_sme, MBX1_smc, 0};
static sm_cfg_t mbboot0 = {MBX0_sma_b, MBX0_sml_b, MBX0_sme_b, MBX0_smc_b, 0};
static sm_cfg_t mbboot1 = {MBX1_sma_b, MBX1_sml_b, MBX1_sme_b, MBX1_smc_b, 0};
/* Configure stack */
ESCvar.use_interrupt = cfg->use_interrupt;
ESCvar.watchdogcnt = cfg->watchdog_cnt;
ESCvar.mbxsize = cfg->mbxsize;
ESCvar.mbxsizeboot = cfg->mbxsizeboot;
ESCvar.mbxbuffers = cfg->mbxbuffers;
ESCvar.mb[0] = cfg->mb[0];
ESCvar.mb[1] = cfg->mb[1];
ESCvar.mbboot[0] = cfg->mb_boot[0];
ESCvar.mbboot[1] = cfg->mb_boot[1];
ESCvar.pdosm[0] = cfg->pdosm[0];
ESCvar.pdosm[1] = cfg->pdosm[1];
ESCvar.mb[0] = mb0;
ESCvar.mb[1] = mb1;
ESCvar.mbboot[0] = mbboot0;
ESCvar.mbboot[1] = mbboot1;
ESCvar.set_defaults_hook = cfg->set_defaults_hook;
ESCvar.pre_state_change_hook = cfg->pre_state_change_hook;
ESCvar.post_state_change_hook = cfg->post_state_change_hook;
ESCvar.application_hook = cfg->application_hook;
@ -1146,4 +1170,5 @@ void ESC_config (esc_cfg_t * cfg)
ESCvar.esc_hw_interrupt_enable = cfg->esc_hw_interrupt_enable;
ESCvar.esc_hw_interrupt_disable = cfg->esc_hw_interrupt_disable;
ESCvar.esc_hw_eep_handler = cfg->esc_hw_eep_handler;
ESCvar.esc_check_dc_handler = cfg->esc_check_dc_handler;
}

View File

@ -12,6 +12,8 @@
#define __esc__
#include <cc.h>
#include <esc_coe.h>
#include "options.h"
#define ESCREG_ADDRESS 0x0010
#define ESCREG_DLSTATUS 0x0110
@ -27,6 +29,7 @@
#define ESCREG_ALEVENT_DC_SYNC0 0x0004
#define ESCREG_ALEVENT_DC_SYNC1 0x0008
#define ESCREG_ALEVENT_EEP 0x0020
#define ESCREG_ALEVENT_WD 0x0040
#define ESCREG_ALEVENT_SM0 0x0100
#define ESCREG_ALEVENT_SM1 0x0200
#define ESCREG_ALEVENT_SM2 0x0400
@ -123,6 +126,8 @@
#define ABORT_UNSUPPORTED 0x06010000
#define ABORT_WRITEONLY 0x06010001
#define ABORT_READONLY 0x06010002
#define ABORT_SUBINDEX0_NOT_ZERO 0x06010003
#define ABORT_EXCEEDS_MBOX_SIZE 0x06010005
#define ABORT_NOOBJECT 0x06020000
#define ABORT_TYPEMISMATCH 0x06070010
#define ABORT_NOSUBINDEX 0x06090011
@ -233,23 +238,25 @@ typedef struct esc_cfg
void * user_arg;
int use_interrupt;
int watchdog_cnt;
size_t mbxsize;
size_t mbxsizeboot;
int mbxbuffers;
sm_cfg_t mb[2];
sm_cfg_t mb_boot[2];
sm_cfg_t pdosm[2];
void (*set_defaults_hook) (void);
void (*pre_state_change_hook) (uint8_t * as, uint8_t * an);
void (*post_state_change_hook) (uint8_t * as, uint8_t * an);
void (*application_hook) (void);
void (*safeoutput_override) (void);
int (*pre_object_download_hook) (uint16_t index, uint8_t subindex);
void (*post_object_download_hook) (uint16_t index, uint8_t subindex);
uint32_t (*pre_object_download_hook) (uint16_t index,
uint8_t subindex,
void * data,
size_t size,
uint16_t flags);
void (*post_object_download_hook) (uint16_t index,
uint8_t subindex,
uint16_t flags);
void (*rxpdo_override) (void);
void (*txpdo_override) (void);
void (*esc_hw_interrupt_enable) (uint32_t mask);
void (*esc_hw_interrupt_disable) (uint32_t mask);
void (*esc_hw_eep_handler) (void);
uint16_t (*esc_check_dc_handler) (void);
} esc_cfg_t;
typedef struct
@ -344,31 +351,33 @@ typedef struct
{
/* Configuration input is saved so the user variable may go out-of-scope */
int use_interrupt;
size_t mbxsize;
size_t mbxsizeboot;
int mbxbuffers;
sm_cfg_t mb[2];
sm_cfg_t mbboot[2];
sm_cfg_t pdosm[2];
void (*set_defaults_hook) (void);
void (*pre_state_change_hook) (uint8_t * as, uint8_t * an);
void (*post_state_change_hook) (uint8_t * as, uint8_t * an);
void (*application_hook) (void);
void (*safeoutput_override) (void);
int (*pre_object_download_hook) (uint16_t index, uint8_t subindex);
void (*post_object_download_hook) (uint16_t index, uint8_t subindex);
uint32_t (*pre_object_download_hook) (uint16_t index,
uint8_t subindex,
void * data,
size_t size,
uint16_t flags);
void (*post_object_download_hook) (uint16_t index,
uint8_t subindex,
uint16_t flags);
void (*rxpdo_override) (void);
void (*txpdo_override) (void);
void (*esc_hw_interrupt_enable) (uint32_t mask);
void (*esc_hw_interrupt_disable) (uint32_t mask);
void (*esc_hw_eep_handler) (void);
uint16_t (*esc_check_dc_handler) (void);
uint8_t MBXrun;
size_t activembxsize;
sm_cfg_t * activemb0;
sm_cfg_t * activemb1;
uint16_t ESC_SM2_sml;
uint16_t ESC_SM3_sml;
uint16_t TXPDOsize;
uint16_t RXPDOsize;
uint8_t dcsync;
uint16_t synccounterlimit;
uint16_t ALstatus;
@ -391,6 +400,8 @@ typedef struct
uint8_t toggle;
int sm2mappings;
int sm3mappings;
uint8_t SMtestresult;
uint32_t PrevTime;
@ -584,13 +595,13 @@ typedef struct
#define ESC_MBX1_sml (ESCvar.activemb1->cfg_sml)
#define ESC_MBX1_sme (ESCvar.activemb1->cfg_sme)
#define ESC_MBX1_smc (ESCvar.activemb1->cfg_smc)
#define ESC_MBXBUFFERS (ESCvar.mbxbuffers)
#define ESC_SM2_sma (ESCvar.pdosm[0].cfg_sma)
#define ESC_SM2_smc (ESCvar.pdosm[0].cfg_smc)
#define ESC_SM2_act (ESCvar.pdosm[0].cfg_smact)
#define ESC_SM3_sma (ESCvar.pdosm[1].cfg_sma)
#define ESC_SM3_smc (ESCvar.pdosm[1].cfg_smc)
#define ESC_SM3_act (ESCvar.pdosm[1].cfg_smact)
#define ESC_MBXBUFFERS (MBXBUFFERS)
#define ESC_SM2_sma (SM2_sma)
#define ESC_SM2_smc (SM2_smc)
#define ESC_SM2_act (SM2_act)
#define ESC_SM3_sma (SM3_sma)
#define ESC_SM3_smc (SM3_smc)
#define ESC_SM3_act (SM3_act)
#define ESC_MBXHSIZE sizeof(_MBXh)
#define ESC_MBXDSIZE (ESC_MBXSIZE - ESC_MBXHSIZE)
@ -606,6 +617,7 @@ uint32_t ESC_ALeventread (void);
void ESC_ALeventmaskwrite (uint32_t mask);
uint32_t ESC_ALeventmaskread (void);
void ESC_ALstatus (uint8_t status);
void ESC_ALstatusgotoerror (uint8_t status, uint16_t errornumber);
void ESC_SMstatus (uint8_t n);
uint8_t ESC_WDstatus (void);
uint8_t ESC_claimbuffer (void);
@ -632,6 +644,8 @@ extern void APP_safeoutput ();
extern _ESCvar ESCvar;
extern _MBXcontrol MBXcontrol[];
extern uint8_t MBX[];
extern _SMmap SMmap2[];
extern _SMmap SMmap3[];
/* ATOMIC operations are used when running interrupt driven */
#ifndef CC_ATOMIC_SET

View File

@ -18,6 +18,10 @@
#define BITS2BYTES(b) ((b + 7) >> 3)
/* Fetch value from object dictionary */
#define OBJ_VALUE_FETCH(v, o) \
((o).data ? *(__typeof__ (v) *)(o).data : (__typeof__ (v))(o).value)
/** Search for an object sub-index.
*
* @param[in] nidx = local array index of object we want to find sub-index to
@ -61,182 +65,134 @@ int32_t SDO_findobject (uint16_t index)
return n;
}
/** Get the value for requested SDO 0x1C32 or 0x1C33 sub index
/**
* Calculate the size in Bytes of RxPDO or TxPDOs by adding the
* objects in SyncManager SDO 1C1x.
*
* @param[in] index = value on index of object we want to locate
* @param[in] subindex = value on subindex of object we want to locate
* @param[out] buf = buf to copy value to
* @param[in] datatype = EtherCAT datatype of buf
* @return 1 if value was found, else 0.
*/
int COE_getSyncMgrPara (uint16_t index, uint8_t subindex, void * buf, uint16_t datatype)
{
int result = 0;
int32_t nidx;
int32_t snidx;
const _objd *objd;
nidx = SDO_findobject(index);
if(nidx < 0)
{
return result;
}
else if((index != 0x1c32) && (index != 0x1c33) && (index != 0x10F1))
{
return result;
}
snidx = SDO_findsubindex(nidx, subindex);
if(snidx >= 0)
{
objd = SDOobjects[nidx].objdesc;
if((objd[snidx].data != NULL) &&
(objd[snidx].datatype == datatype))
{
memcpy(buf, objd[snidx].data, objd[snidx].bitlength / 8 );
result = 1;
}
else
{
if((datatype == DTYPE_UNSIGNED32) &&
(objd[snidx].datatype == datatype))
{
*(uint32_t *)buf = objd[snidx].value;
result = 1;
}
else if((datatype == DTYPE_UNSIGNED16) &&
(objd[snidx].datatype == datatype))
{
*(uint16_t *)buf = (uint16_t)objd[snidx].value;
result = 1;
}
else if((datatype == DTYPE_UNSIGNED8) &&
(objd[snidx].datatype == datatype))
{
*(uint8_t *)buf = (uint8_t)objd[snidx].value;
result = 1;
}
}
}
return result;
}
/** Init default values for SDO Sync Objects
* A list of mapped objects is created for fast lookup of
* dynamically mapped process data. The max size of the list (@a
* max_mappings) can be set to 0 if dynamic processdata is not
* supported.
*
*/
void COE_initDefaultSyncMgrPara (void)
{
uint32_t i,j;
const _objd *objd;
int32_t n = 0;
* The output variable @a nmappings is set to 0 if dynamic processdata
* is not supported. It is set to the number of mapped objects if
* dynamic processdata is supported, or -1 if the mapping was
* incorrect.
/* 1C3x */
for(i = 0x1C32; i <= 0x1C33; i ++)
{
/* Look if index is present */
n = SDO_findobject(i);
if(n < 0)
{
continue;
}
/* Load default values */
objd = SDOobjects[n].objdesc;
for(j = 1; j <= SDOobjects[n].maxsub; j++ )
{
if(objd[j].data != NULL)
{
*(uint32_t *)objd[j].data = objd[j].value;
}
if(objd[j].subindex >= SDOobjects[n].maxsub)
{
break;
}
}
}
/* Look if index is present */
n = SDO_findobject(0x10F1);
if(n >= 0)
{
/* Load default values */
objd = SDOobjects[n].objdesc;
for(j = 1; j <= objd[0].value; j++ )
{
if(objd[j].data != NULL)
{
*(uint32_t *)objd[j].data = objd[j].value;
}
}
}
}
/** Calculate the size in Bytes of RxPDO or TxPDOs by adding the objects
* in SyncManager
* SDO 1C1x.
*
* @param[in] index = SM index
* @param[out] nmappings = number of mapped objects in SM, or -1 if
* mapping is invalid
* @param[out] mappings = list of mapped objects in SM
* @param[out] max_mappings = max number of mapped objects in SM
* @return size of RxPDO or TxPDOs in Bytes.
*/
uint16_t sizeOfPDO (uint16_t index)
uint16_t sizeOfPDO (uint16_t index, int * nmappings, _SMmap * mappings,
int max_mappings)
{
uint16_t size = 0, hobj, l, si, c, sic;
uint16_t offset = 0, hobj;
uint8_t si, sic, c;
int16_t nidx;
const _objd *objd;
const _objd *objd1c1x;
int mapIx = 0;
if ((index != RX_PDO_OBJIDX) && (index != TX_PDO_OBJIDX))
{
return 0;
}
nidx = SDO_findobject (index);
if(nidx < 0)
{
return size;
}
else if((index != RX_PDO_OBJIDX) && (index != TX_PDO_OBJIDX))
{
return size;
return 0;
}
objd1c1x = objd = SDOobjects[nidx].objdesc;
objd1c1x = SDOobjects[nidx].objdesc;
if (objd1c1x[0].data)
{
si = *((uint8_t *) objd1c1x[0].data);
}
else
{
si = (uint8_t) objd1c1x[0].value;
}
si = OBJ_VALUE_FETCH (si, objd1c1x[0]);
if (si)
{
for (sic = 1; sic <= si; sic++)
{
if (objd1c1x[sic].data)
{
hobj = *((uint16_t *) objd1c1x[sic].data);
hobj = htoes(hobj);
}
else
{
hobj = (uint16_t) objd1c1x[sic].value;
}
hobj = OBJ_VALUE_FETCH (hobj, objd1c1x[sic]);
nidx = SDO_findobject (hobj);
if (nidx > 0)
if (nidx >= 0)
{
uint8_t maxsub;
objd = SDOobjects[nidx].objdesc;
l = (uint8_t) objd->value;
for (c = 1; c <= l; c++)
maxsub = OBJ_VALUE_FETCH (maxsub, objd[0]);
for (c = 1; c <= maxsub; c++)
{
size += ((objd + c)->value & 0xff);
uint32_t value = OBJ_VALUE_FETCH (value, objd[c]);
uint8_t bitlength = value & 0xFF;
if (max_mappings > 0)
{
uint16_t index = value >> 16;
uint8_t subindex = (value >> 8) & 0xFF;
const _objd * mapping;
if (mapIx == max_mappings)
{
/* Too many mapped objects */
*nmappings = -1;
return 0;
}
DPRINT ("%04x:%02x @ %d\n", index, subindex, offset);
if (index == 0 && subindex == 0)
{
/* Padding element */
mapping = NULL;
}
else
{
nidx = SDO_findobject (index);
if (nidx >= 0)
{
int16_t nsub;
nsub = SDO_findsubindex (nidx, subindex);
if (nsub < 0)
{
/* Mapped subindex does not exist */
*nmappings = -1;
return 0;
}
mapping = &SDOobjects[nidx].objdesc[nsub];
}
else
{
/* Mapped index does not exist */
*nmappings = -1;
return 0;
}
}
mappings[mapIx].obj = mapping;
mappings[mapIx++].offset = offset;
}
offset += bitlength;
}
}
}
}
return BITS2BYTES (size);
if (max_mappings > 0)
{
*nmappings = mapIx;
}
else
{
*nmappings = 0;
}
return BITS2BYTES (offset);
}
/** Copy to mailbox.
@ -456,6 +412,8 @@ void SDO_download (void)
uint16_t size, actsize;
const _objd *objd;
uint32_t *mbxdata;
uint32_t abort;
coesdo = (_COEsdo *) &MBX[0];
index = etohs (coesdo->index);
subindex = coesdo->subindex;
@ -466,7 +424,7 @@ void SDO_download (void)
if (nsub >= 0)
{
objd = SDOobjects[nidx].objdesc;
uint8_t access = (objd + nsub)->access & 0x3f;
uint8_t access = (objd + nsub)->flags & 0x3f;
uint8_t state = ESCvar.ALstatus & 0x0f;
if (access == ATYPE_RW ||
(access == ATYPE_RWpre && state == ESCpreop))
@ -479,14 +437,21 @@ void SDO_download (void)
}
else
{
/* normal upload */
/* normal download */
size = (etohl (coesdo->size) & 0xffff);
mbxdata = (&(coesdo->size)) + 1;
}
actsize = ((objd + nsub)->bitlength + 7) >> 3;
if (actsize == size)
{
if (ESC_pre_objecthandler (index, subindex))
abort = ESC_pre_objecthandler (
index,
subindex,
mbxdata,
size,
(objd + nsub)->flags
);
if (abort == 0)
{
copy2mbx (mbxdata, (objd + nsub)->data, size);
MBXout = ESC_claimbuffer ();
@ -503,8 +468,12 @@ void SDO_download (void)
coeres->size = htoel (0);
MBXcontrol[MBXout].state = MBXstate_outreq;
}
/* external object write handler */
ESC_objecthandler (index, subindex);
/* external object write handler */
ESC_objecthandler (index, subindex, (objd + nsub)->flags);
}
else
{
SDO_abort (index, subindex, abort);
}
}
else
@ -822,7 +791,7 @@ void SDO_geted (void)
COE_VALUEINFO_OBJECT + COE_VALUEINFO_MAPPABLE;
coel->datatype = htoes ((objd + nsub)->datatype);
coel->bitlength = htoes ((objd + nsub)->bitlength);
coel->access = htoes ((objd + nsub)->access);
coel->access = htoes ((objd + nsub)->flags);
s = (uint8_t *) (objd + nsub)->name;
d = (uint8_t *) &(coel->name);
while (*s && (n < (ESC_MBXDSIZE - 0x10)))
@ -958,3 +927,325 @@ void ESC_coeprocess (void)
}
}
}
/**
* Get value from bitmap
*
* This function gets a value from a bitmap.
*
* @param[in] bitmap = bitmap containing value
* @param[in] offset = start offset
* @param[in] length = number of bits to get
* @return bitslice value
*/
static uint64_t COE_bitsliceGet (uint64_t * bitmap, int offset, int length)
{
const int word_offset = offset / 64;
const int bit_offset = offset % 64;
const uint64_t mask = (length == 64) ? UINT64_MAX : (1ULL << length) - 1;
uint64_t w0;
uint64_t w1 = 0;
/* Get the least significant word */
w0 = bitmap[word_offset];
w0 = w0 >> bit_offset;
/* Get the most significant word, if required */
if (length + bit_offset > 64)
{
w1 = bitmap[word_offset + 1];
w1 = w1 << (64 - bit_offset);
}
w0 = (w1 | w0);
return (w0 & mask);
}
/**
* Set value in bitmap
*
* This function sets a value in a bitmap.
*
* @param[in] bitmap = bitmap to contain value
* @param[in] offset = start offset
* @param[in] length = number of bits to set
* @param[in] value = value to set
*/
static void COE_bitsliceSet (uint64_t * bitmap, int offset, int length,
uint64_t value)
{
const int word_offset = offset / 64;
const int bit_offset = offset % 64;
const uint64_t mask = (length == 64) ? UINT64_MAX : (1ULL << length) - 1;
const uint64_t mask0 = mask << bit_offset;
uint64_t v0 = value << bit_offset;
uint64_t w0 = bitmap[word_offset];
/* Set the least significant word */
w0 = (w0 & ~mask0) | (v0 & mask0);
bitmap[word_offset] = w0;
/* Set the most significant word, if required */
if (length + bit_offset > 64)
{
const uint64_t mask1 = mask >> (64 - bit_offset);
uint64_t v1 = value >> (64 - bit_offset);
uint64_t w1 = bitmap[word_offset + 1];
w1 = (w1 & ~mask1) | (v1 & mask1);
bitmap[word_offset + 1] = w1;
}
}
/**
* Get object value
*
* This function atomically gets an object value.
*
* @param[in] obj = object description
* @return object value
*/
static uint64_t COE_getValue (const _objd * obj)
{
uint64_t value = 0;
/* TODO: const data */
switch(obj->datatype)
{
case DTYPE_BIT1:
case DTYPE_BIT2:
case DTYPE_BIT3:
case DTYPE_BIT4:
case DTYPE_BIT5:
case DTYPE_BIT6:
case DTYPE_BIT7:
case DTYPE_BIT8:
case DTYPE_BOOLEAN:
case DTYPE_UNSIGNED8:
case DTYPE_INTEGER8:
value = *(uint8_t *)obj->data;
break;
case DTYPE_UNSIGNED16:
case DTYPE_INTEGER16:
value = *(uint16_t *)obj->data;
break;
case DTYPE_REAL32:
case DTYPE_UNSIGNED32:
case DTYPE_INTEGER32:
value = *(uint32_t *)obj->data;
break;
case DTYPE_REAL64:
case DTYPE_UNSIGNED64:
case DTYPE_INTEGER64:
/* FIXME: must be atomic */
value = *(uint64_t *)obj->data;
break;
default:
CC_ASSERT (0);
}
return value;
}
/**
* Set object value
*
* This function atomically sets an object value.
*
* @param[in] obj = object description
* @param[in] value = new value
*/
static void COE_setValue (const _objd * obj, uint64_t value)
{
switch(obj->datatype)
{
case DTYPE_BIT1:
case DTYPE_BIT2:
case DTYPE_BIT3:
case DTYPE_BIT4:
case DTYPE_BIT5:
case DTYPE_BIT6:
case DTYPE_BIT7:
case DTYPE_BIT8:
case DTYPE_BOOLEAN:
case DTYPE_UNSIGNED8:
case DTYPE_INTEGER8:
*(uint8_t *)obj->data = value & UINT8_MAX;
break;
case DTYPE_UNSIGNED16:
case DTYPE_INTEGER16:
*(uint16_t *)obj->data = value & UINT16_MAX;
break;
case DTYPE_REAL32:
case DTYPE_UNSIGNED32:
case DTYPE_INTEGER32:
*(uint32_t *)obj->data = value & UINT32_MAX;
break;
case DTYPE_REAL64:
case DTYPE_UNSIGNED64:
case DTYPE_INTEGER64:
/* FIXME: must be atomic */
*(uint64_t *)obj->data = value;
break;
default:
DPRINT ("ignored\n");
break;
}
}
/**
* Init default values for SDO objects
*/
void COE_initDefaultValues (void)
{
int i;
const _objd *objd;
int n;
uint8_t maxsub;
/* Set default values from object descriptor */
for (n = 0; SDOobjects[n].index != 0xffff; n++)
{
objd = SDOobjects[n].objdesc;
maxsub = SDOobjects[n].maxsub;
i = 0;
do
{
if (objd[i].data != NULL)
{
/* TODO: bitlength > 64 */
COE_setValue (&objd[i], objd[i].value);
DPRINT ("%04x:%02x = %x\n", SDOobjects[n].index, objd[i].subindex, objd[i].value);
}
} while (objd[i++].subindex < maxsub);
}
/* Let application override default values */
if (ESCvar.set_defaults_hook != NULL)
{
ESCvar.set_defaults_hook();
}
}
/**
* Pack process data
*
* This function reads mapped objects and constructs the process data
* inputs (TXPDO).
*
* @param[in] buffer = input process data
* @param[in] nmappings = number of mappings in sync manager
* @param[in] mappings = list of mapped objects in sync manager
*/
void COE_pdoPack (uint8_t * buffer, int nmappings, _SMmap * mappings)
{
int ix;
/* Check that buffer is aligned on 64-bit boundary */
CC_ASSERT (((uintptr_t)buffer & 0x07) == 0);
for (ix = 0; ix < nmappings; ix++)
{
const _objd * obj = mappings[ix].obj;
uint16_t offset = mappings[ix].offset;
if (obj != NULL)
{
if (obj->bitlength > 64)
{
memcpy (
&buffer[BITS2BYTES (offset)],
obj->data,
BITS2BYTES (obj->bitlength)
);
}
else
{
/* Atomically get object value */
uint64_t value = COE_getValue (obj);
COE_bitsliceSet (
(uint64_t *)buffer,
offset,
obj->bitlength,
value
);
}
}
}
}
/**
* Unpack process data
*
* This function unpacks process data output (RXPDO) and writes to the
* mapped objects.
*
* @param[in] buffer = output process data
* @param[in] nmappings = number of mappings in sync manager
* @param[in] mappings = list of mapped objects in sync manager
*/
void COE_pdoUnpack (uint8_t * buffer, int nmappings, _SMmap * mappings)
{
int ix;
/* Check that buffer is aligned on 64-bit boundary */
CC_ASSERT (((uintptr_t)buffer & 0x07) == 0);
for (ix = 0; ix < nmappings; ix++)
{
const _objd * obj = mappings[ix].obj;
uint16_t offset = mappings[ix].offset;
if (obj != NULL)
{
if (obj->bitlength > 64)
{
memcpy (
obj->data,
&buffer[BITS2BYTES (offset)],
BITS2BYTES (obj->bitlength)
);
}
else
{
/* Atomically set object value */
uint64_t value = COE_bitsliceGet (
(uint64_t *)buffer,
offset,
obj->bitlength
);
COE_setValue (obj, value);
}
}
}
}
/**
* Fetch max subindex
*
* This function fetches the value of subindex 0 (max subindex).
*
* @param[in] index = object index
*/
uint8_t COE_maxSub (uint16_t index)
{
int nidx;
uint8_t maxsub;
nidx = SDO_findobject (index);
if (nidx == -1)
return 0;
maxsub = OBJ_VALUE_FETCH (maxsub, SDOobjects[nidx].objdesc[0]);
return maxsub;
}

View File

@ -19,9 +19,9 @@ typedef struct CC_PACKED
uint16_t subindex;
uint16_t datatype;
uint16_t bitlength;
uint16_t access;
uint16_t flags;
const char *name;
uint32_t value;
uint64_t value;
void *data;
} _objd;
CC_PACKED_END
@ -38,6 +38,12 @@ typedef struct CC_PACKED
} _objectlist;
CC_PACKED_END
typedef struct
{
const _objd * obj;
uint16_t offset;
} _SMmap;
#define OBJH_READ 0
#define OBJH_WRITE 1
@ -75,23 +81,37 @@ CC_PACKED_END
#define DTYPE_BIT7 0x0036
#define DTYPE_BIT8 0x0037
#define ATYPE_RO 0x07
#define ATYPE_RW 0x3F
#define ATYPE_RWpre 0x0F
#define ATYPE_Rpre 0x01
#define ATYPE_Rsafe 0x02
#define ATYPE_Rop 0x04
#define ATYPE_Wpre 0x08
#define ATYPE_Wsafe 0x10
#define ATYPE_Wop 0x20
#define ATYPE_RXPDO 0x40
#define ATYPE_TXPDO 0x80
#define ATYPE_RO (ATYPE_Rpre | ATYPE_Rsafe | ATYPE_Rop)
#define ATYPE_RW (ATYPE_Wpre | ATYPE_Wsafe | ATYPE_Wop | ATYPE_RO)
#define ATYPE_RWpre (ATYPE_Wpre | ATYPE_RO)
#define TX_PDO_OBJIDX 0x1c13
#define RX_PDO_OBJIDX 0x1c12
void ESC_coeprocess (void);
uint16_t sizeOfPDO (uint16_t index);
uint16_t sizeOfPDO (uint16_t index, int * nmappings, _SMmap * sm, int max_mappings);
void SDO_abort (uint16_t index, uint8_t subindex, uint32_t abortcode);
void COE_initDefaultSyncMgrPara (void);
int COE_getSyncMgrPara (uint16_t index, uint8_t subindex, void * buf, uint16_t datatype);
void COE_initDefaultValues (void);
extern void ESC_objecthandler (uint16_t index, uint8_t subindex);
extern int ESC_pre_objecthandler (uint16_t index, uint8_t subindex);
void COE_pdoPack (uint8_t * buffer, int nmappings, _SMmap * sm);
void COE_pdoUnpack (uint8_t * buffer, int nmappings, _SMmap * sm);
uint8_t COE_maxSub (uint16_t index);
extern void ESC_objecthandler (uint16_t index, uint8_t subindex, uint16_t flags);
extern uint32_t ESC_pre_objecthandler (uint16_t index,
uint8_t subindex,
void * data,
size_t size,
uint16_t flags);
extern const _objectlist SDOobjects[];
#endif

View File

@ -901,6 +901,10 @@ static void EOE_send_fragment ()
EOEvar.txframeoffset += len_to_send;
EOEvar.txfragmentno += 1;
}
if(eoe_cfg->fragment_sent_event != NULL)
{
eoe_cfg->fragment_sent_event();
}
}
}

View File

@ -43,6 +43,8 @@ typedef struct eoe_cfg
void (*handle_recv_buffer) (uint8_t port, eoe_pbuf_t * ebuf);
/** Callback to fetch a buffer to send */
int (*fetch_send_buffer) (uint8_t port, eoe_pbuf_t * ebuf);
/** Callback to notify the application fragment sent */
void (*fragment_sent_event) (void);
} eoe_cfg_t;
int EOE_ecat_get_mac (uint8_t port, uint8_t mac[]);

View File

@ -16,15 +16,17 @@
#include <eru.h>
#include <string.h>
#include "esc_hw.h"
#include "slave.h"
#include "esc_eep.h"
#include "ecat_slv.h"
#include "esc_hw_eep.h"
#define ESCADDR(x) (((uint8_t *) ECAT0_BASE) + x)
/* Global sem to make it possible to kick worker from the application */
sem_t * ecat_isr_sem;
static volatile esc_registers_t * ecat0 = (esc_registers_t *)ECAT0_BASE;
static int use_all_interrupts = 0;
static sem_t * ecat_isr_sem;
static void sync0_isr (void * arg);
static volatile uint8_t read_ack;
@ -175,7 +177,6 @@ void ESC_interrupt_disable (uint32_t mask)
mask &= ~ESCREG_ALEVENT_DC_LATCH;
UASSERT(0,EARG);
}
ecat0->AL_EVENT_MASK &= ~mask;
}
@ -193,6 +194,22 @@ void ESC_eep_handler(void)
*/
static void sync0_isr (void * arg)
{
/* Subtract the sync counter to check the pace compared to the SM IRQ */
if((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0)
{
CC_ATOMIC_SUB(ESCvar.synccounter, 1);
}
/* Check so we're inside the limit */
if((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_ALstatusgotoerror((ESCsafeop | ESCerror), ALERR_SYNCERROR);
CC_ATOMIC_SET(ESCvar.synccounter, 0);
}
}
DIG_process(DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG);
read_ack = ecat0->DC_SYNC0_STAT;
}
@ -203,13 +220,14 @@ static void sync0_isr (void * arg)
*/
static void ecat_isr (void * arg)
{
ESC_read (ESCREG_LOCALTIME, (void *) &ESCvar.Time, sizeof (ESCvar.Time));
ESCvar.Time = etohl (ESCvar.Time);
CC_ATOMIC_SET(ESCvar.ALevent, etohl(ecat0->AL_EVENT_REQ));
/* Handle SM2 interrupt */
if(ESCvar.ALevent & ESCREG_ALEVENT_SM2)
{
/* Is DC active or not */
if(ESCvar.dcsync == 0)
{
DIG_process(DIG_PROCESS_OUTPUTS_FLAG | DIG_PROCESS_APP_HOOK_FLAG |
@ -217,10 +235,16 @@ static void ecat_isr (void * arg)
}
else
{
/* Add the sync counter to check the pace compared to the SM IRQ */
if((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0)
{
CC_ATOMIC_ADD(ESCvar.synccounter, 1);
}
DIG_process(DIG_PROCESS_OUTPUTS_FLAG);
}
}
/* Handle low prio interrupts */
if(ESCvar.ALevent & (ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP))
{
@ -229,16 +253,38 @@ static void ecat_isr (void * arg)
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP);
sem_signal(ecat_isr_sem);
}
/* SM watchdog */
if(ESCvar.ALevent & ESCREG_ALEVENT_WD)
{
uint16_t wd;
/* Ack the WD IRQ */
wd = ecat0->WD_STAT_PDATA;
/* Check if the WD have expired and if we're in OP */
if(((wd & 0x1) == 0) &&
((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0))
{
ESC_ALstatusgotoerror((ESCsafeop | ESCerror), ALERR_WATCHDOG);
ecat0->AL_EVENT_MASK &= ~ESCREG_ALEVENT_WD;
}
}
}
/* Function for PDI ISR serving task */
/* Function for low prio PDI interrupts and flushing of EEPROM RAM buffer
* to flash.
*/
static void isr_run(void * arg)
{
while(1)
{
sem_wait(ecat_isr_sem);
ecat_slv_worker(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP);
/* Do while to handle write of eeprom, the write to flash is delayed */
do
{
ecat_slv_worker(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP);
}while(eep_write_pending);
}
}

View File

@ -63,6 +63,7 @@ static eep_block_t *cleanup_unused_sect(eep_block_t *block);
static int32_t is_sector_empty(uint32_t *addr);
uint8_t eep_write_pending;
/** Initialize EEPROM emulation (load default data, validate checksums, ...).
*
@ -135,6 +136,7 @@ void EEP_hw_process (void)
/* update block pointer and reset write state */
eep_curr_block = eep_next_block;
eep_next_block = NULL;
eep_write_pending = 0;
}
return;
@ -204,6 +206,7 @@ int8_t EEP_write (uint32_t addr, uint8_t *data, uint16_t count)
eep_buf_dirty = 1;
eep_write_req = 0;
eep_last_write = ESCvar.Time;
eep_write_pending = 1;
return 0;
}

View File

@ -18,7 +18,6 @@
/* idle timeout in ns before actual flash write will be issued */
#define EEP_IDLE_TIMEOUT 100000000
/* Pages per emulated EEPROM block */
#define EEP_BYTES_PER_SECTOR XMC4_EEPROM_SECTOR_SIZE_BYTES
#define EEP_BYTES_PER_PAGE XMC4_PAGE_SIZE_BYTES
@ -39,6 +38,8 @@ typedef struct CC_PACKED
/* eeprom size increments in steps of 0x80 bytes */
#define EEP_EMU_BYTES (EEP_DATA_BYTES & ~0x7f)
extern uint8_t eep_write_pending;
/* block structure */
typedef struct CC_PACKED
{

View File

@ -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);
}

147
soes/options.h 100644
View File

@ -0,0 +1,147 @@
/*
* Licensed under the GNU General Public License version 2 with exceptions. See
* LICENSE file in the project root for full license information
*/
#ifndef __options__
#define __options__
/* User-defined options, Options defined here will override default values */
#include "ecat_options.h"
/* FoE support */
#ifndef USE_FOE
#define USE_FOE 1
#endif
/* EoE support */
#ifndef USE_EOE
#define USE_EOE 1
#endif
#ifndef MBXSIZE
#define MBXSIZE 128
#endif
#ifndef MBXSIZEBOOT
#define MBXSIZEBOOT 128
#endif
#ifndef MBXBUFFERS
#define MBXBUFFERS 3
#endif
#ifndef MBX0_sma
#define MBX0_sma 0x1000
#endif
#ifndef MBX0_sml
#define MBX0_sml MBXSIZE
#endif
#ifndef MBX0_sme
#define MBX0_sme MBX0_sma+MBX0_sml-1
#endif
#ifndef MBX0_smc
#define MBX0_smc 0x26
#endif
#ifndef MBX1_sma
#define MBX1_sma MBX0_sma+MBX0_sml
#endif
#ifndef MBX1_sml
#define MBX1_sml MBXSIZE
#endif
#ifndef MBX1_sme
#define MBX1_sme MBX1_sma+MBX1_sml-1
#endif
#ifndef MBX1_smc
#define MBX1_smc 0x22
#endif
#ifndef MBX0_sma_b
#define MBX0_sma_b 0x1000
#endif
#ifndef MBX0_sml_b
#define MBX0_sml_b MBXSIZEBOOT
#endif
#ifndef MBX0_sme_b
#define MBX0_sme_b MBX0_sma_b+MBX0_sml_b-1
#endif
#ifndef MBX0_smc_b
#define MBX0_smc_b 0x26
#endif
#ifndef MBX1_sma_b
#define MBX1_sma_b MBX0_sma_b+MBX0_sml_b
#endif
#ifndef MBX1_sml_b
#define MBX1_sml_b MBXSIZEBOOT
#endif
#ifndef MBX1_sme_b
#define MBX1_sme_b MBX1_sma_b+MBX1_sml_b-1
#endif
#ifndef MBX1_smc_b
#define MBX1_smc_b 0x22
#endif
#ifndef SM2_sma
#define SM2_sma 0x1100
#endif
#ifndef SM2_smc
#define SM2_smc 0x24
#endif
#ifndef SM2_act
#define SM2_act 1
#endif
#ifndef SM3_sma
#define SM3_sma 0x1180
#endif
#ifndef SM3_smc
#define SM3_smc 0x20
#endif
#ifndef SM3_act
#define SM3_act 1
#endif
/* Max number of dynamically mapped objects in SM2. May be 0 to
disable dynamic processdata. */
#ifndef MAX_MAPPINGS_SM2
#define MAX_MAPPINGS_SM2 16
#endif
/* Max number of dynamically mapped objects in SM3. May be 0 to
disable dynamic processdata. */
#ifndef MAX_MAPPINGS_SM3
#define MAX_MAPPINGS_SM3 16
#endif
/* Max processdata size (outputs). Only used if MAX_MAPPINGS_SM2 is
non-zero. */
#ifndef MAX_RXPDO_SIZE
#define MAX_RXPDO_SIZE 128
#endif
/* Max processdata size (inputs). Only used if MAX_MAPPINGS_SM3 is
non-zero. */
#ifndef MAX_TXPDO_SIZE
#define MAX_TXPDO_SIZE 128
#endif
#endif /* __options__ */