added new xmc irq sample and adopted old samples
parent
59d38dca2c
commit
39fb2c91e7
|
@ -1,38 +1,57 @@
|
|||
#include <stddef.h>
|
||||
#include "utypes.h"
|
||||
#include "soes/esc.h"
|
||||
#include "soes/esc_coe.h"
|
||||
#include "soes/esc_foe.h"
|
||||
#include "esc.h"
|
||||
#include "esc_coe.h"
|
||||
#include "esc_foe.h"
|
||||
#include "config.h"
|
||||
#include "slave.h"
|
||||
|
||||
#ifndef EEP_EMULATION
|
||||
#define EEP_EMULATION 0 /* Set to 1 for EEPROM emulation */
|
||||
#endif
|
||||
|
||||
#define WATCHDOG_RESET_VALUE 150
|
||||
#define DEFAULTTXPDOMAP 0x1a00
|
||||
#define DEFAULTRXPDOMAP 0x1600
|
||||
#define DEFAULTTXPDOITEMS 1
|
||||
#define DEFAULTRXPDOITEMS 1
|
||||
|
||||
volatile _ESCvar ESCvar;
|
||||
_MBX MBX[MBXBUFFERS];
|
||||
_MBXcontrol MBXcontrol[MBXBUFFERS];
|
||||
uint8_t MBXrun=0;
|
||||
uint16_t SM2_sml,SM3_sml;
|
||||
_Rbuffer Rb;
|
||||
_Wbuffer Wb;
|
||||
_Cbuffer Cb;
|
||||
_App App;
|
||||
uint16_t TXPDOsize,RXPDOsize;
|
||||
/* 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 unsigned int watchdog = WATCHDOG_RESET_VALUE;
|
||||
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.
|
||||
*
|
||||
|
@ -54,7 +73,7 @@ void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
|||
{
|
||||
rxpdomap = 0x1600;
|
||||
}
|
||||
RXPDOsize = SM2_sml = sizeRXPDO();
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
break;
|
||||
}
|
||||
case 0x1c13:
|
||||
|
@ -68,7 +87,7 @@ void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
|||
{
|
||||
txpdomap = 0x1A00;
|
||||
}
|
||||
TXPDOsize = SM3_sml = sizeTXPDO();
|
||||
ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
break;
|
||||
}
|
||||
/* Handle post-write of parameter values */
|
||||
|
@ -100,13 +119,13 @@ void APP_safeoutput (void)
|
|||
*/
|
||||
void TXPDO_update (void)
|
||||
{
|
||||
ESC_write (SM3_sma, &Rb, TXPDOsize);
|
||||
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, RXPDOsize);
|
||||
ESC_read (SM2_sma, &Wb, ESCvar.RXPDOsize);
|
||||
}
|
||||
|
||||
/** Mandatory: Function to update local I/O, call read ethercat outputs, call
|
||||
|
@ -119,7 +138,7 @@ void DIG_process (void)
|
|||
{
|
||||
watchdog--;
|
||||
}
|
||||
if (App.state & APPSTATE_OUTPUT)
|
||||
if (ESCvar.App.state & APPSTATE_OUTPUT)
|
||||
{
|
||||
/* SM2 trigger ? */
|
||||
if (ESCvar.ALevent & ESCREG_ALEVENT_SM2)
|
||||
|
@ -131,7 +150,7 @@ void DIG_process (void)
|
|||
/* Set outputs */
|
||||
cb_set_LEDs();
|
||||
}
|
||||
if (watchdog == 0)
|
||||
if (watchdog <= 0)
|
||||
{
|
||||
DPRINT("DIG_process watchdog expired\n");
|
||||
ESC_stopoutput();
|
||||
|
@ -145,7 +164,7 @@ void DIG_process (void)
|
|||
{
|
||||
watchdog = WATCHDOG_RESET_VALUE;
|
||||
}
|
||||
if (App.state)
|
||||
if (ESCvar.App.state)
|
||||
{
|
||||
/* Update inputs */
|
||||
cb_get_Buttons();
|
||||
|
@ -155,8 +174,6 @@ void DIG_process (void)
|
|||
|
||||
/********** TODO: Generic code beyond this point ***************/
|
||||
|
||||
static const char *spi_name = "/dev/lan9252";
|
||||
|
||||
/** Optional: Hook called after state change for application specific
|
||||
* actions for specific state changes.
|
||||
*/
|
||||
|
@ -204,6 +221,8 @@ void soes (void)
|
|||
|
||||
/* Check the state machine */
|
||||
ESC_state();
|
||||
/* Check the SM activation event */
|
||||
ESC_sm_act_event();
|
||||
|
||||
/* Check mailboxes */
|
||||
if (ESC_mbxprocess())
|
||||
|
@ -213,10 +232,6 @@ void soes (void)
|
|||
ESC_xoeprocess();
|
||||
}
|
||||
DIG_process();
|
||||
#if EEP_EMULATION
|
||||
EEP_process ();
|
||||
EEP_hw_process();
|
||||
#endif /* EEP_EMULATION */
|
||||
|
||||
if (application_loop_callback != NULL)
|
||||
{
|
||||
|
@ -231,19 +246,39 @@ void soes_init (void)
|
|||
{
|
||||
DPRINT ("SOES (Simple Open EtherCAT Slave)\n");
|
||||
|
||||
TXPDOsize = SM3_sml = sizeTXPDO();
|
||||
RXPDOsize = SM2_sml = sizeRXPDO();
|
||||
ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
|
||||
/* Setup post config hooks */
|
||||
/* 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 = post_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 = NULL,
|
||||
.esc_hw_interrupt_disable = NULL,
|
||||
.esc_hw_eep_handler = NULL
|
||||
};
|
||||
ESC_config ((esc_cfg_t *)&config);
|
||||
|
||||
ESC_reset();
|
||||
ESC_init ((void *)spi_name);
|
||||
ESC_config (&config);
|
||||
ESC_init (&config);
|
||||
|
||||
/* wait until ESC is started up */
|
||||
while ((ESCvar.DLstatus & 0x0001) == 0)
|
||||
|
|
|
@ -1,38 +1,57 @@
|
|||
#include <stddef.h>
|
||||
#include "utypes.h"
|
||||
#include "soes/esc.h"
|
||||
#include "soes/esc_coe.h"
|
||||
#include "soes/esc_foe.h"
|
||||
#include "esc.h"
|
||||
#include "esc_coe.h"
|
||||
#include "esc_foe.h"
|
||||
#include "config.h"
|
||||
#include "slave.h"
|
||||
|
||||
#ifndef EEP_EMULATION
|
||||
#define EEP_EMULATION 0 /* Set to 1 for EEPROM emulation */
|
||||
#endif
|
||||
|
||||
#define WATCHDOG_RESET_VALUE 150
|
||||
#define DEFAULTTXPDOMAP 0x1a00
|
||||
#define DEFAULTRXPDOMAP 0x1600
|
||||
#define DEFAULTTXPDOITEMS 1
|
||||
#define DEFAULTRXPDOITEMS 1
|
||||
|
||||
volatile _ESCvar ESCvar;
|
||||
_MBX MBX[MBXBUFFERS];
|
||||
_MBXcontrol MBXcontrol[MBXBUFFERS];
|
||||
uint8_t MBXrun=0;
|
||||
uint16_t SM2_sml,SM3_sml;
|
||||
_Rbuffer Rb;
|
||||
_Wbuffer Wb;
|
||||
_Cbuffer Cb;
|
||||
_App App;
|
||||
uint16_t TXPDOsize,RXPDOsize;
|
||||
/* 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 unsigned int watchdog = WATCHDOG_RESET_VALUE;
|
||||
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.
|
||||
*
|
||||
|
@ -54,7 +73,7 @@ void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
|||
{
|
||||
rxpdomap = 0x1600;
|
||||
}
|
||||
RXPDOsize = SM2_sml = sizeRXPDO();
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
break;
|
||||
}
|
||||
case 0x1c13:
|
||||
|
@ -68,7 +87,7 @@ void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
|||
{
|
||||
txpdomap = 0x1A00;
|
||||
}
|
||||
TXPDOsize = SM3_sml = sizeTXPDO();
|
||||
ESCvar.TXPDOsize = ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
break;
|
||||
}
|
||||
/* Handle post-write of parameter values */
|
||||
|
@ -100,13 +119,13 @@ void APP_safeoutput (void)
|
|||
*/
|
||||
void TXPDO_update (void)
|
||||
{
|
||||
ESC_write (SM3_sma, &Rb, TXPDOsize);
|
||||
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, RXPDOsize);
|
||||
ESC_read (SM2_sma, &Wb, ESCvar.RXPDOsize);
|
||||
}
|
||||
|
||||
/** Mandatory: Function to update local I/O, call read ethercat outputs, call
|
||||
|
@ -119,7 +138,7 @@ void DIG_process (void)
|
|||
{
|
||||
watchdog--;
|
||||
}
|
||||
if (App.state & APPSTATE_OUTPUT)
|
||||
if (ESCvar.App.state & APPSTATE_OUTPUT)
|
||||
{
|
||||
/* SM2 trigger ? */
|
||||
if (ESCvar.ALevent & ESCREG_ALEVENT_SM2)
|
||||
|
@ -131,7 +150,7 @@ void DIG_process (void)
|
|||
/* Set outputs */
|
||||
cb_set_LEDs();
|
||||
}
|
||||
if (watchdog == 0)
|
||||
if (watchdog <= 0)
|
||||
{
|
||||
DPRINT("DIG_process watchdog expired\n");
|
||||
ESC_stopoutput();
|
||||
|
@ -145,7 +164,7 @@ void DIG_process (void)
|
|||
{
|
||||
watchdog = WATCHDOG_RESET_VALUE;
|
||||
}
|
||||
if (App.state)
|
||||
if (ESCvar.App.state)
|
||||
{
|
||||
/* Update inputs */
|
||||
cb_get_Buttons();
|
||||
|
@ -155,8 +174,6 @@ void DIG_process (void)
|
|||
|
||||
/********** TODO: Generic code beyond this point ***************/
|
||||
|
||||
static const char *spi_name = "/spi1/lan9252";
|
||||
|
||||
/** Optional: Hook called after state change for application specific
|
||||
* actions for specific state changes.
|
||||
*/
|
||||
|
@ -213,10 +230,6 @@ void soes (void)
|
|||
ESC_xoeprocess();
|
||||
}
|
||||
DIG_process();
|
||||
#if EEP_EMULATION
|
||||
EEP_process ();
|
||||
EEP_hw_process();
|
||||
#endif /* EEP_EMULATION */
|
||||
|
||||
if (application_loop_callback != NULL)
|
||||
{
|
||||
|
@ -231,19 +244,39 @@ void soes_init (void)
|
|||
{
|
||||
DPRINT ("SOES (Simple Open EtherCAT Slave)\n");
|
||||
|
||||
TXPDOsize = SM3_sml = sizeTXPDO();
|
||||
RXPDOsize = SM2_sml = sizeRXPDO();
|
||||
ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
|
||||
/* Setup post config hooks */
|
||||
/* 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 = post_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 = NULL,
|
||||
.esc_hw_interrupt_disable = NULL,
|
||||
.esc_hw_eep_handler = NULL
|
||||
};
|
||||
ESC_config ((esc_cfg_t *)&config);
|
||||
|
||||
ESC_reset();
|
||||
ESC_init ((void *)spi_name);
|
||||
ESC_config (&config);
|
||||
ESC_init (&config);
|
||||
|
||||
/* wait until ESC is started up */
|
||||
while ((ESCvar.DLstatus & 0x0001) == 0)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <esc_coe.h>
|
||||
#include <esc_foe.h>
|
||||
#include "utypes.h"
|
||||
#include "config.h"
|
||||
#include "bootstrap.h"
|
||||
|
||||
#define WD_RESET 1000
|
||||
|
@ -28,16 +29,17 @@
|
|||
uint32_t encoder_scale;
|
||||
uint32_t encoder_scale_mirror;
|
||||
|
||||
volatile _ESCvar ESCvar;
|
||||
_MBX MBX[MBXBUFFERS];
|
||||
_MBXcontrol MBXcontrol[MBXBUFFERS];
|
||||
uint8_t MBXrun=0;
|
||||
uint16_t SM2_sml,SM3_sml;
|
||||
_Rbuffer Rb;
|
||||
_Wbuffer Wb;
|
||||
_Cbuffer Cb;
|
||||
_App App;
|
||||
uint16_t TXPDOsize,RXPDOsize;
|
||||
/* 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;
|
||||
|
@ -49,7 +51,27 @@ uint8_t rxpdoitems = DEFAULTTXPDOITEMS;
|
|||
|
||||
extern uint32_t local_boot_state;
|
||||
|
||||
static const char *spi_name = "/spi0/et1100";
|
||||
/** 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.
|
||||
|
@ -72,7 +94,7 @@ void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
|||
{
|
||||
rxpdomap = 0x1600;
|
||||
}
|
||||
RXPDOsize = SM2_sml = sizeRXPDO ();
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
break;
|
||||
}
|
||||
case 0x1c13:
|
||||
|
@ -86,7 +108,7 @@ void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
|||
{
|
||||
txpdomap = 0x1A00;
|
||||
}
|
||||
TXPDOsize = SM3_sml = sizeTXPDO ();
|
||||
ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
break;
|
||||
}
|
||||
case 0x7100:
|
||||
|
@ -129,13 +151,13 @@ void APP_safeoutput (void)
|
|||
*/
|
||||
void TXPDO_update (void)
|
||||
{
|
||||
ESC_write (SM3_sma, &Rb.button, TXPDOsize);
|
||||
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, RXPDOsize);
|
||||
ESC_read (SM2_sma, &Wb.LED, ESCvar.RXPDOsize);
|
||||
}
|
||||
|
||||
/** Mandatory: Function to update local I/O, call read ethercat outputs, call
|
||||
|
@ -148,7 +170,7 @@ void DIG_process (void)
|
|||
{
|
||||
wd_cnt--;
|
||||
}
|
||||
if (App.state & APPSTATE_OUTPUT)
|
||||
if (ESCvar.App.state & APPSTATE_OUTPUT)
|
||||
{
|
||||
/* SM2 trigger ? */
|
||||
if (ESCvar.ALevent & ESCREG_ALEVENT_SM2)
|
||||
|
@ -173,7 +195,7 @@ void DIG_process (void)
|
|||
{
|
||||
wd_cnt = WD_RESET;
|
||||
}
|
||||
if (App.state)
|
||||
if (ESCvar.App.state)
|
||||
{
|
||||
//Rb.button = gpio_get(GPIO_WAKEUP);
|
||||
Rb.button = (flash_drv_get_active_swap() && 0x8);
|
||||
|
@ -209,19 +231,39 @@ void soes (void *arg)
|
|||
{
|
||||
DPRINT ("SOES (Simple Open EtherCAT Slave)\n");
|
||||
|
||||
TXPDOsize = SM3_sml = sizeTXPDO ();
|
||||
RXPDOsize = SM2_sml = sizeRXPDO ();
|
||||
ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
|
||||
/* Setup post config hooks */
|
||||
/* 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 = post_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 = NULL,
|
||||
.esc_hw_interrupt_disable = NULL,
|
||||
.esc_hw_eep_handler = NULL
|
||||
};
|
||||
ESC_config ((esc_cfg_t *)&config);
|
||||
|
||||
ESC_reset();
|
||||
ESC_init (spi_name);
|
||||
ESC_config (&config);
|
||||
ESC_init (&config);
|
||||
|
||||
task_delay (tick_from_ms (200));
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#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__ */
|
|
@ -0,0 +1,184 @@
|
|||
#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.
|
@ -0,0 +1,327 @@
|
|||
#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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
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 & (ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
|
||||
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP));
|
||||
|
||||
ESC_ALeventmaskwrite(ESC_ALeventmaskread()
|
||||
| (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
|
|
@ -0,0 +1,739 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Slave fileVersion="1" id="xmc43_slave" productCode="4300">
|
||||
<Name>xmc43relax</Name>
|
||||
<Vendor>
|
||||
<Id>0x1337</Id>
|
||||
<Name>rt-labs</Name>
|
||||
</Vendor>
|
||||
<Group>
|
||||
<Type>xmc4</Type>
|
||||
<Name>xmc4</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>
|
||||
<Mailbox CoE="true" FoE="true">
|
||||
<Bootstrap Length="256" Start="0x1000"/>
|
||||
<Standard Length="128" Start="0x1000"/>
|
||||
</Mailbox>
|
||||
<Eeprom>
|
||||
<ConfigData>8006810600000000</ConfigData>
|
||||
<BootStrap>0010000100110001</BootStrap>
|
||||
</Eeprom>
|
||||
<Dictionary>
|
||||
<Item>
|
||||
<Name>Device Type</Name>
|
||||
<Index>0x1000</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0x00001389</DefaultValue>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>Device Name</Name>
|
||||
<Index>0x1008</Index>
|
||||
<DataType>VISIBLE_STRING</DataType>
|
||||
<DefaultValue>xmc43_slave</DefaultValue>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name>Hardware Version</Name>
|
||||
<Index>0x1009</Index>
|
||||
<DataType>VISIBLE_STRING</DataType>
|
||||
<DefaultValue>1.0</DefaultValue>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name>Software Version</Name>
|
||||
<Index>0x100A</Index>
|
||||
<DataType>VISIBLE_STRING</DataType>
|
||||
<DefaultValue>1.0</DefaultValue>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>Identity Object</Name>
|
||||
<Index>0x1018</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>4</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Vendor ID</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0x1337</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Product Code</Name>
|
||||
<Index>0x02</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>4300</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Revision Number</Name>
|
||||
<Index>0x03</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Serial Number</Name>
|
||||
<Index>0x04</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0x00000000</DefaultValue>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>ErrorSettings</Name>
|
||||
<Index>0x10F1</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<Variable>ErrorSettings</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>2</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Dummy_x01</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>Dummy_x01</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>SyncErrorCounterLimit</Name>
|
||||
<Index>0x02</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>2</DefaultValue>
|
||||
<Access>RW</Access>
|
||||
<Variable>SyncErrorCounterLimit</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>LEDgroup0</Name>
|
||||
<Index>0x1600</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>LED0</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0x70050108</DefaultValue>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>LEDgroup1</Name>
|
||||
<Index>0x1601</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>LED1</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0x70060108</DefaultValue>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>Buttons</Name>
|
||||
<Index>0x1A00</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Button1</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0x60050108</DefaultValue>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>Sync Manager Communication Type</Name>
|
||||
<Index>0x1C00</Index>
|
||||
<DataType>ARRAY</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>4</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Communications Type SM0</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Communications Type SM1</Name>
|
||||
<Index>0x02</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>2</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Communications Type SM2</Name>
|
||||
<Index>0x03</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>3</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Communications Type SM3</Name>
|
||||
<Index>0x04</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>4</DefaultValue>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>Sync Manager 2 PDO Assignment</Name>
|
||||
<Index>0x1C12</Index>
|
||||
<DataType>ARRAY</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>2</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>PDO Mapping</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0x1600</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>PDO Mapping</Name>
|
||||
<Index>0x02</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0x1601</DefaultValue>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>Sync Manager 3 PDO Assignment</Name>
|
||||
<Index>0x1C13</Index>
|
||||
<DataType>ARRAY</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>PDO Mapping</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0x1A00</DefaultValue>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>SyncMgrParam</Name>
|
||||
<Index>0x1C32</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<Variable>SyncMgrParam</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>32</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>SyncType</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>SyncType</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>CycleTime</Name>
|
||||
<Index>0x02</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>CycleTime</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>ShiftTime</Name>
|
||||
<Index>0x03</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>ShiftTime</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>SyncTypeSupport</Name>
|
||||
<Index>0x04</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0x6</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>SyncTypeSupport</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>MinCycleTime</Name>
|
||||
<Index>0x05</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>125000</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>MinCycleTime</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>CalcCopyTime</Name>
|
||||
<Index>0x06</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>CalcCopyTime</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>MinDelayTime</Name>
|
||||
<Index>0x07</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>MinDelayTime</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>GetCycleTime</Name>
|
||||
<Index>0x08</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>GetCycleTime</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>DelayTime</Name>
|
||||
<Index>0x09</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>DelayTime</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Sync0CycleTime</Name>
|
||||
<Index>0x0A</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>Sync0CycleTime</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>SMEventMissedCnt</Name>
|
||||
<Index>0x0B</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>SMEventMissedCnt</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>CycleTimeTooSmallCnt</Name>
|
||||
<Index>0x0C</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>CycleTimeTooSmallCnt</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>ShiftTimeTooSmallCnt</Name>
|
||||
<Index>0x0D</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>ShiftTimeTooSmallCnt</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>RxPDOToggleFailed</Name>
|
||||
<Index>0x0E</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>RxPDOToggleFailed</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>MinCycleDist</Name>
|
||||
<Index>0x0F</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>MinCycleDist</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>MaxCycleDist</Name>
|
||||
<Index>0x10</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>MaxCycleDist</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>MinSMSYNCDist</Name>
|
||||
<Index>0x11</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>MinSMSYNCDist</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>MaxSMSYNCDist</Name>
|
||||
<Index>0x12</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>MaxSMSYNCDist</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Dummy_x14</Name>
|
||||
<Index>0x14</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>Dummy_x14</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>SyncError</Name>
|
||||
<Index>0x20</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>SyncError</Variable>
|
||||
<VariableType>Manufacturer</VariableType>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>Buttons</Name>
|
||||
<Index>0x6005</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<Variable>Buttons</Variable>
|
||||
<VariableType>Input</VariableType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Button1</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>Button1</Variable>
|
||||
<VariableType>Input</VariableType>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>LEDgroup0</Name>
|
||||
<Index>0x7005</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<Variable>LEDgroup0</Variable>
|
||||
<VariableType>Output</VariableType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>LED0</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>LED0</Variable>
|
||||
<VariableType>Output</VariableType>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>LEDgroup1</Name>
|
||||
<Index>0x7006</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<Variable>LEDgroup1</Variable>
|
||||
<VariableType>Output</VariableType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>LED1</Name>
|
||||
<Index>0x01</Index>
|
||||
<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>
|
||||
<DataType>RECORD</DataType>
|
||||
<Variable>Parameters</Variable>
|
||||
<VariableType>Parameter</VariableType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Multiplier</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RW</Access>
|
||||
<Variable>Multiplier</Variable>
|
||||
<VariableType>Parameter</VariableType>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>variableRW</Name>
|
||||
<Index>0x8001</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RW</Access>
|
||||
<Variable>variableRW</Variable>
|
||||
<VariableType>Parameter</VariableType>
|
||||
</Item>
|
||||
</Dictionary>
|
||||
<RxPdo>
|
||||
<Index>0x1600</Index>
|
||||
<Container>LEDgroup0</Container>
|
||||
<Name>LEDgroup0</Name>
|
||||
<Entry>
|
||||
<Index>0x7005</Index>
|
||||
<SubIndex>1</SubIndex>
|
||||
<Variable>LED0</Variable>
|
||||
</Entry>
|
||||
</RxPdo>
|
||||
<RxPdo>
|
||||
<Index>0x1601</Index>
|
||||
<Container>LEDgroup1</Container>
|
||||
<Name>LEDgroup1</Name>
|
||||
<Entry>
|
||||
<Index>0x7006</Index>
|
||||
<SubIndex>1</SubIndex>
|
||||
<Variable>LED1</Variable>
|
||||
</Entry>
|
||||
</RxPdo>
|
||||
<TxPdo>
|
||||
<Index>0x1A00</Index>
|
||||
<Container>Buttons</Container>
|
||||
<Name>Buttons</Name>
|
||||
<Entry>
|
||||
<Index>0x6005</Index>
|
||||
<SubIndex>1</SubIndex>
|
||||
<Variable>Button1</Variable>
|
||||
</Entry>
|
||||
</TxPdo>
|
||||
<Input>
|
||||
<Index>0x6005</Index>
|
||||
<Name>Buttons</Name>
|
||||
<ObjectType>RECORD</ObjectType>
|
||||
<Member>
|
||||
<Index>0x01</Index>
|
||||
<Name>Button1</Name>
|
||||
<Type>UNSIGNED8</Type>
|
||||
</Member>
|
||||
</Input>
|
||||
<Output>
|
||||
<Index>0x7005</Index>
|
||||
<Name>LEDgroup0</Name>
|
||||
<ObjectType>RECORD</ObjectType>
|
||||
<Member>
|
||||
<Index>0x01</Index>
|
||||
<Name>LED0</Name>
|
||||
<Type>UNSIGNED8</Type>
|
||||
</Member>
|
||||
</Output>
|
||||
<Output>
|
||||
<Index>0x7006</Index>
|
||||
<Name>LEDgroup1</Name>
|
||||
<ObjectType>RECORD</ObjectType>
|
||||
<Member>
|
||||
<Index>0x01</Index>
|
||||
<Name>LED1</Name>
|
||||
<Type>UNSIGNED8</Type>
|
||||
</Member>
|
||||
</Output>
|
||||
<Parameter>
|
||||
<Index>0x8000</Index>
|
||||
<Name>Parameters</Name>
|
||||
<ObjectType>RECORD</ObjectType>
|
||||
<Member>
|
||||
<Index>0x01</Index>
|
||||
<Name>Multiplier</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
<Access>RW</Access>
|
||||
</Member>
|
||||
</Parameter>
|
||||
<Parameter>
|
||||
<Index>0x8001</Index>
|
||||
<Name>variableRW</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
<Access>RW</Access>
|
||||
<ObjectType>VAR</ObjectType>
|
||||
</Parameter>
|
||||
<Manufacturer>
|
||||
<Index>0x1C32</Index>
|
||||
<Name>SyncMgrParam</Name>
|
||||
<ObjectType>RECORD</ObjectType>
|
||||
<Member>
|
||||
<Index>0x01</Index>
|
||||
<Name>SyncType</Name>
|
||||
<Type>UNSIGNED16</Type>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x02</Index>
|
||||
<Name>CycleTime</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x03</Index>
|
||||
<Name>ShiftTime</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x04</Index>
|
||||
<Name>SyncTypeSupport</Name>
|
||||
<Type>UNSIGNED16</Type>
|
||||
<DefaultValue>0x6</DefaultValue>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x05</Index>
|
||||
<Name>MinCycleTime</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
<DefaultValue>125000</DefaultValue>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x06</Index>
|
||||
<Name>CalcCopyTime</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x07</Index>
|
||||
<Name>MinDelayTime</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x08</Index>
|
||||
<Name>GetCycleTime</Name>
|
||||
<Type>UNSIGNED16</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x09</Index>
|
||||
<Name>DelayTime</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x0A</Index>
|
||||
<Name>Sync0CycleTime</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x0B</Index>
|
||||
<Name>SMEventMissedCnt</Name>
|
||||
<Type>UNSIGNED16</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x0C</Index>
|
||||
<Name>CycleTimeTooSmallCnt</Name>
|
||||
<Type>UNSIGNED16</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x0D</Index>
|
||||
<Name>ShiftTimeTooSmallCnt</Name>
|
||||
<Type>UNSIGNED16</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x0E</Index>
|
||||
<Name>RxPDOToggleFailed</Name>
|
||||
<Type>UNSIGNED16</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x0F</Index>
|
||||
<Name>MinCycleDist</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x10</Index>
|
||||
<Name>MaxCycleDist</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x11</Index>
|
||||
<Name>MinSMSYNCDist</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x12</Index>
|
||||
<Name>MaxSMSYNCDist</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x14</Index>
|
||||
<Name>Dummy_x14</Name>
|
||||
<Type>UNSIGNED8</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x20</Index>
|
||||
<Name>SyncError</Name>
|
||||
<Type>UNSIGNED8</Type>
|
||||
<Access>RO</Access>
|
||||
</Member>
|
||||
</Manufacturer>
|
||||
<Manufacturer>
|
||||
<Index>0x10F1</Index>
|
||||
<Name>ErrorSettings</Name>
|
||||
<ObjectType>RECORD</ObjectType>
|
||||
<Member>
|
||||
<Index>0x01</Index>
|
||||
<Name>Dummy_x01</Name>
|
||||
<Type>UNSIGNED8</Type>
|
||||
</Member>
|
||||
<Member>
|
||||
<Index>0x02</Index>
|
||||
<Name>SyncErrorCounterLimit</Name>
|
||||
<Type>UNSIGNED16</Type>
|
||||
<DefaultValue>2</DefaultValue>
|
||||
<Access>RW</Access>
|
||||
</Member>
|
||||
</Manufacturer>
|
||||
</Slave>
|
|
@ -0,0 +1,64 @@
|
|||
#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);
|
||||
|
||||
/**
|
||||
* ISR for SM0/1, EEPROM and AL CONTROL events in a SM/DC
|
||||
* synchronization application
|
||||
*/
|
||||
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
|
@ -0,0 +1,218 @@
|
|||
#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
|
|
@ -0,0 +1,96 @@
|
|||
#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__ */
|
|
@ -41,17 +41,17 @@ static const XMC_GPIO_CONFIG_t gpio_config_led = {
|
|||
uint32_t encoder_scale;
|
||||
uint32_t encoder_scale_mirror;
|
||||
|
||||
volatile _ESCvar ESCvar;
|
||||
_MBX MBX[MBXBUFFERS];
|
||||
_MBXcontrol MBXcontrol[MBXBUFFERS];
|
||||
uint8_t MBXrun=0;
|
||||
uint16_t SM2_sml,SM3_sml;
|
||||
_Rbuffer Rb;
|
||||
_Wbuffer Wb;
|
||||
_Cbuffer Cb;
|
||||
_App App;
|
||||
uint16_t TXPDOsize,RXPDOsize;
|
||||
int wd_cnt = WD_RESET;
|
||||
/* 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;
|
||||
|
@ -59,6 +59,28 @@ 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.
|
||||
*
|
||||
|
@ -80,7 +102,7 @@ void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
|||
{
|
||||
rxpdomap = 0x1600;
|
||||
}
|
||||
RXPDOsize = SM2_sml = sizeRXPDO ();
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
break;
|
||||
}
|
||||
case 0x1c13:
|
||||
|
@ -94,7 +116,7 @@ void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
|||
{
|
||||
txpdomap = 0x1A00;
|
||||
}
|
||||
TXPDOsize = SM3_sml = sizeTXPDO ();
|
||||
ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
break;
|
||||
}
|
||||
case 0x7100:
|
||||
|
@ -137,13 +159,13 @@ void APP_safeoutput (void)
|
|||
*/
|
||||
void TXPDO_update (void)
|
||||
{
|
||||
ESC_write (SM3_sma, &Rb.button, TXPDOsize);
|
||||
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, RXPDOsize);
|
||||
ESC_read (SM2_sma, &Wb.LED, ESCvar.RXPDOsize);
|
||||
}
|
||||
|
||||
/** Mandatory: Function to update local I/O, call read ethercat outputs, call
|
||||
|
@ -156,7 +178,7 @@ void DIG_process (void)
|
|||
{
|
||||
wd_cnt--;
|
||||
}
|
||||
if (App.state & APPSTATE_OUTPUT)
|
||||
if (ESCvar.App.state & APPSTATE_OUTPUT)
|
||||
{
|
||||
/* SM2 trigger ? */
|
||||
if (ESCvar.ALevent & ESCREG_ALEVENT_SM2)
|
||||
|
@ -185,7 +207,7 @@ void DIG_process (void)
|
|||
{
|
||||
wd_cnt = WD_RESET;
|
||||
}
|
||||
if (App.state)
|
||||
if (ESCvar.App.state)
|
||||
{
|
||||
Rb.button = XMC_GPIO_GetInput(P_BTN);
|
||||
Cb.reset_counter++;
|
||||
|
@ -208,17 +230,38 @@ void soes_init (void)
|
|||
XMC_GPIO_Init(P_BTN, &gpio_config_btn);
|
||||
XMC_GPIO_Init(P_LED, &gpio_config_led);
|
||||
|
||||
TXPDOsize = SM3_sml = sizeTXPDO ();
|
||||
RXPDOsize = SM2_sml = sizeRXPDO ();
|
||||
ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
|
||||
/* Setup post config hooks */
|
||||
/* 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
|
||||
.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 ((esc_cfg_t *)&config);
|
||||
|
||||
ESC_config (&config);
|
||||
ESC_init (NULL);
|
||||
|
||||
/* wait until ESC is started up */
|
||||
|
@ -251,7 +294,9 @@ void soes_task (void)
|
|||
ESCvar.Time = etohl (ESCvar.Time);
|
||||
|
||||
/* Check the state machine */
|
||||
ESC_state ();
|
||||
ESC_state();
|
||||
/* Check the SM activation event */
|
||||
ESC_sm_act_event();
|
||||
|
||||
/* If else to two separate execution paths
|
||||
* If we're running BOOSTRAP
|
||||
|
|
150
soes/esc.c
150
soes/esc.c
|
@ -15,17 +15,6 @@
|
|||
*
|
||||
* State machine and mailbox support.
|
||||
*/
|
||||
/* Global variables used by the stack */
|
||||
esc_cfg_t * esc_cfg = NULL;
|
||||
size_t ESC_MBXSIZE;
|
||||
uint16_t ESC_MBX0_sma;
|
||||
uint16_t ESC_MBX0_sml;
|
||||
uint16_t ESC_MBX0_sme;
|
||||
uint8_t ESC_MBX0_smc;
|
||||
uint16_t ESC_MBX1_sma;
|
||||
uint16_t ESC_MBX1_sml;
|
||||
uint16_t ESC_MBX1_sme;
|
||||
uint8_t ESC_MBX1_smc;
|
||||
|
||||
/** Write AL Status Code to the ESC.
|
||||
*
|
||||
|
@ -246,7 +235,7 @@ uint16_t ESC_checkDC (void)
|
|||
{
|
||||
ret = ALERR_DCINVALIDSYNCCFG;
|
||||
}
|
||||
else if(COE_getSyncMgrPara(0x10F1, 0x2, &sync_counter_limit, DTYPE_UNSIGNED16) == 0)
|
||||
else if(COE_getSyncMgrPara(0x10F1, 0x2, &ESCvar.synccounterlimit, DTYPE_UNSIGNED16) == 0)
|
||||
{
|
||||
ret = ALERR_DCINVALIDSYNCCFG;
|
||||
}
|
||||
|
@ -272,14 +261,14 @@ uint16_t ESC_checkDC (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
dc_sync = 1;
|
||||
sync_counter = 0;
|
||||
ESCvar.dcsync = 1;
|
||||
ESCvar.synccounter = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_sync = 0;
|
||||
sync_counter = 0;
|
||||
ESCvar.dcsync = 0;
|
||||
ESCvar.synccounter = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -331,15 +320,10 @@ uint8_t ESC_checkmbx (uint8_t state)
|
|||
uint8_t ESC_startmbx (uint8_t state)
|
||||
{
|
||||
/* Assign SM settings */
|
||||
ESC_MBXSIZE = esc_cfg->mbxsize;
|
||||
ESC_MBX0_sma = esc_cfg->mb[0].cfg_sma;
|
||||
ESC_MBX0_sml = esc_cfg->mb[0].cfg_sml;
|
||||
ESC_MBX0_sme = esc_cfg->mb[0].cfg_sme;
|
||||
ESC_MBX0_smc = esc_cfg->mb[0].cfg_smc;
|
||||
ESC_MBX1_sma = esc_cfg->mb[1].cfg_sma;
|
||||
ESC_MBX1_sml = esc_cfg->mb[1].cfg_sml;
|
||||
ESC_MBX1_sme = esc_cfg->mb[1].cfg_sme;
|
||||
ESC_MBX1_smc = esc_cfg->mb[1].cfg_smc;
|
||||
ESCvar.activembxsize = ESCvar.mbxsize;
|
||||
ESCvar.activemb0 = &ESCvar.mb[0];
|
||||
ESCvar.activemb1 = &ESCvar.mb[1];
|
||||
|
||||
|
||||
ESC_SMenable (0);
|
||||
ESC_SMenable (1);
|
||||
|
@ -348,12 +332,12 @@ uint8_t ESC_startmbx (uint8_t state)
|
|||
if ((state = ESC_checkmbx (state)) & ESCerror)
|
||||
{
|
||||
ESC_ALerror (ALERR_INVALIDMBXCONFIG);
|
||||
MBXrun = 0;
|
||||
ESCvar.MBXrun = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESCvar.toggle = ESCvar.SM[1].ECrep; //sync repeat request toggle state
|
||||
MBXrun = 1;
|
||||
ESCvar.MBXrun = 1;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -370,15 +354,9 @@ uint8_t ESC_startmbx (uint8_t state)
|
|||
uint8_t ESC_startmbxboot (uint8_t state)
|
||||
{
|
||||
/* Assign SM settings */
|
||||
ESC_MBXSIZE = esc_cfg->mbxsizeboot;
|
||||
ESC_MBX0_sma = esc_cfg->mb_boot[0].cfg_sma;
|
||||
ESC_MBX0_sml = esc_cfg->mb_boot[0].cfg_sml;
|
||||
ESC_MBX0_sme = esc_cfg->mb_boot[0].cfg_sme;
|
||||
ESC_MBX0_smc = esc_cfg->mb_boot[0].cfg_smc;
|
||||
ESC_MBX1_sma = esc_cfg->mb_boot[1].cfg_sma;
|
||||
ESC_MBX1_sml = esc_cfg->mb_boot[1].cfg_sml;
|
||||
ESC_MBX1_sme = esc_cfg->mb_boot[1].cfg_sme;
|
||||
ESC_MBX1_smc = esc_cfg->mb_boot[1].cfg_smc;
|
||||
ESCvar.activembxsize = ESCvar.mbxsizeboot;
|
||||
ESCvar.activemb0 = &ESCvar.mbboot[0];
|
||||
ESCvar.activemb1 = &ESCvar.mbboot[1];
|
||||
|
||||
ESC_SMenable (0);
|
||||
ESC_SMenable (1);
|
||||
|
@ -387,12 +365,12 @@ uint8_t ESC_startmbxboot (uint8_t state)
|
|||
if ((state = ESC_checkmbx (state)) & ESCerror)
|
||||
{
|
||||
ESC_ALerror (ALERR_INVALIDBOOTMBXCONFIG);
|
||||
MBXrun = 0;
|
||||
ESCvar.MBXrun = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESCvar.toggle = ESCvar.SM[1].ECrep; //sync repeat request toggle state
|
||||
MBXrun = 1;
|
||||
ESCvar.MBXrun = 1;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -403,7 +381,7 @@ uint8_t ESC_startmbxboot (uint8_t state)
|
|||
void ESC_stopmbx (void)
|
||||
{
|
||||
uint8_t n;
|
||||
MBXrun = 0;
|
||||
ESCvar.MBXrun = 0;
|
||||
ESC_SMdisable (0);
|
||||
ESC_SMdisable (1);
|
||||
for (n = 0; n < ESC_MBXBUFFERS; n++)
|
||||
|
@ -500,7 +478,8 @@ uint8_t ESC_claimbuffer (void)
|
|||
{
|
||||
MBXcontrol[n].state = MBXstate_outclaim;
|
||||
MBh = (_MBXh *)&MBX[n * ESC_MBXSIZE];
|
||||
ESCvar.mbxcnt = (++ESCvar.mbxcnt) & 0x07;
|
||||
ESCvar.mbxcnt++;
|
||||
ESCvar.mbxcnt = (ESCvar.mbxcnt & 0x07);
|
||||
if (ESCvar.mbxcnt == 0)
|
||||
{
|
||||
ESCvar.mbxcnt = 1;
|
||||
|
@ -560,7 +539,7 @@ uint8_t ESC_mbxprocess (void)
|
|||
uint8_t mbxhandle = 0;
|
||||
_MBXh *MBh = (_MBXh *)&MBX[0];
|
||||
|
||||
if (!MBXrun)
|
||||
if (ESCvar.MBXrun == 0)
|
||||
{
|
||||
/* nothing to do */
|
||||
return 0;
|
||||
|
@ -676,11 +655,11 @@ uint8_t ESC_mbxprocess (void)
|
|||
void ESC_xoeprocess (void)
|
||||
{
|
||||
_MBXh *mbh;
|
||||
if (!MBXrun)
|
||||
if (ESCvar.MBXrun == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!ESCvar.xoe && (MBXcontrol[0].state == MBXstate_inclaim))
|
||||
if ((ESCvar.xoe == 0) && (MBXcontrol[0].state == MBXstate_inclaim))
|
||||
{
|
||||
mbh = (_MBXh *) &MBX[0];
|
||||
if ((mbh->mbxtype == 0) || (etohs (mbh->length) == 0))
|
||||
|
@ -707,7 +686,7 @@ uint8_t ESC_checkSM23 (uint8_t state)
|
|||
_ESCsm2 *SM;
|
||||
ESC_read (ESCREG_SM2, (void *) &ESCvar.SM[2], sizeof (ESCvar.SM[2]));
|
||||
SM = (_ESCsm2 *) & ESCvar.SM[2];
|
||||
if ((etohs (SM->PSA) != ESC_SM2_sma) || (etohs (SM->Length) != ESC_SM2_sml)
|
||||
if ((etohs (SM->PSA) != ESC_SM2_sma) || (etohs (SM->Length) != ESCvar.ESC_SM2_sml)
|
||||
|| (SM->Command != ESC_SM2_smc) || !(SM->ActESC & ESC_SM2_act))
|
||||
{
|
||||
ESCvar.SMtestresult = SMRESULT_ERRSM2;
|
||||
|
@ -716,7 +695,7 @@ uint8_t ESC_checkSM23 (uint8_t state)
|
|||
}
|
||||
ESC_read (ESCREG_SM3, (void *) &ESCvar.SM[3], sizeof (ESCvar.SM[3]));
|
||||
SM = (_ESCsm2 *) & ESCvar.SM[3];
|
||||
if ((etohs (SM->PSA) != ESC_SM3_sma) || (etohs (SM->Length) != ESC_SM3_sml)
|
||||
if ((etohs (SM->PSA) != ESC_SM3_sma) || (etohs (SM->Length) != ESCvar.ESC_SM3_sml)
|
||||
|| (SM->Command != ESC_SM3_smc) || !(SM->ActESC & ESC_SM3_act))
|
||||
{
|
||||
ESCvar.SMtestresult = SMRESULT_ERRSM3;
|
||||
|
@ -741,7 +720,7 @@ uint8_t ESC_startinput (uint8_t state)
|
|||
if (state != (ESCpreop | ESCerror))
|
||||
{
|
||||
ESC_SMenable (3);
|
||||
CC_ATOMIC_SET(App.state, APPSTATE_INPUT);
|
||||
CC_ATOMIC_SET(ESCvar.App.state, APPSTATE_INPUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -758,7 +737,7 @@ uint8_t ESC_startinput (uint8_t state)
|
|||
}
|
||||
|
||||
/* Exit here if polling */
|
||||
if (esc_cfg->use_interrupt == 0)
|
||||
if (ESCvar.use_interrupt == 0)
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
@ -774,19 +753,20 @@ uint8_t ESC_startinput (uint8_t state)
|
|||
|
||||
ESC_SMdisable (2);
|
||||
ESC_SMdisable (3);
|
||||
CC_ATOMIC_SET(App.state, APPSTATE_IDLE);
|
||||
CC_ATOMIC_SET(ESCvar.App.state, APPSTATE_IDLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (esc_cfg->esc_hw_interrupt_enable != NULL)
|
||||
if (ESCvar.esc_hw_interrupt_enable != NULL)
|
||||
{
|
||||
if(dc_sync > 0)
|
||||
if(ESCvar.dcsync > 0)
|
||||
{
|
||||
esc_cfg->esc_hw_interrupt_enable(ESCREG_ALEVENT_DC_SYNC0 | ESCREG_ALEVENT_SM2);
|
||||
ESCvar.esc_hw_interrupt_enable(ESCREG_ALEVENT_DC_SYNC0 |
|
||||
ESCREG_ALEVENT_SM2);
|
||||
}
|
||||
else
|
||||
{
|
||||
esc_cfg->esc_hw_interrupt_enable(ESCREG_ALEVENT_SM2);
|
||||
ESCvar.esc_hw_interrupt_enable(ESCREG_ALEVENT_SM2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -801,15 +781,16 @@ uint8_t ESC_startinput (uint8_t state)
|
|||
*/
|
||||
void ESC_stopinput (void)
|
||||
{
|
||||
CC_ATOMIC_SET(App.state, APPSTATE_IDLE);
|
||||
CC_ATOMIC_SET(ESCvar.App.state, APPSTATE_IDLE);
|
||||
ESC_SMdisable (3);
|
||||
ESC_SMdisable (2);
|
||||
|
||||
/* Call interrupt disable hook case it have been configured */
|
||||
if ((esc_cfg->use_interrupt != 0) &&
|
||||
(esc_cfg->esc_hw_interrupt_disable != NULL))
|
||||
if ((ESCvar.use_interrupt != 0) &&
|
||||
(ESCvar.esc_hw_interrupt_disable != NULL))
|
||||
{
|
||||
esc_cfg->esc_hw_interrupt_disable (ESCREG_ALEVENT_DC_SYNC0 | ESCREG_ALEVENT_SM2);
|
||||
ESCvar.esc_hw_interrupt_disable (ESCREG_ALEVENT_DC_SYNC0 |
|
||||
ESCREG_ALEVENT_SM2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -825,7 +806,7 @@ uint8_t ESC_startoutput (uint8_t state)
|
|||
{
|
||||
|
||||
ESC_SMenable (2);
|
||||
CC_ATOMIC_OR(App.state, APPSTATE_OUTPUT);
|
||||
CC_ATOMIC_OR(ESCvar.App.state, APPSTATE_OUTPUT);
|
||||
return state;
|
||||
|
||||
}
|
||||
|
@ -837,7 +818,7 @@ uint8_t ESC_startoutput (uint8_t state)
|
|||
*/
|
||||
void ESC_stopoutput (void)
|
||||
{
|
||||
CC_ATOMIC_AND(App.state, APPSTATE_INPUT);
|
||||
CC_ATOMIC_AND(ESCvar.App.state, APPSTATE_INPUT);
|
||||
ESC_SMdisable (2);
|
||||
APP_safeoutput ();
|
||||
}
|
||||
|
@ -871,7 +852,7 @@ void ESC_sm_act_event (void)
|
|||
* is up and running
|
||||
*/
|
||||
if ((as & ESCREG_AL_ALLBUTINITMASK) &&
|
||||
((as == ESCboot) == 0) && MBXrun)
|
||||
((as == ESCboot) == 0) && ESCvar.MBXrun)
|
||||
{
|
||||
/* Validate Sync Managers, reading the Activation register will
|
||||
* acknowledge the SyncManager Activation event making us enter
|
||||
|
@ -889,7 +870,7 @@ void ESC_sm_act_event (void)
|
|||
else if (ax == (ESCinit | ESCerror))
|
||||
{
|
||||
/* If we have activated Inputs and Outputs we need to disable them */
|
||||
if (CC_ATOMIC_GET(App.state))
|
||||
if (CC_ATOMIC_GET(ESCvar.App.state))
|
||||
{
|
||||
ESC_stopoutput ();
|
||||
ESC_stopinput ();
|
||||
|
@ -897,14 +878,14 @@ void ESC_sm_act_event (void)
|
|||
/* Stop mailboxes and update ALStatus code */
|
||||
ESC_stopmbx ();
|
||||
ESC_ALerror (ALERR_INVALIDMBXCONFIG);
|
||||
MBXrun = 0;
|
||||
ESCvar.MBXrun = 0;
|
||||
ESC_ALstatus (ax);
|
||||
return;
|
||||
}
|
||||
/* Have we been forced to step down to PREOP we will stop inputs
|
||||
* and outputs, update AL Status Code and exit ESC_state
|
||||
*/
|
||||
else if (CC_ATOMIC_GET(App.state) && (ax23 == (ESCpreop | ESCerror)))
|
||||
else if (CC_ATOMIC_GET(ESCvar.App.state) && (ax23 == (ESCpreop | ESCerror)))
|
||||
{
|
||||
ESC_stopoutput ();
|
||||
ESC_stopinput ();
|
||||
|
@ -972,9 +953,9 @@ void ESC_state (void)
|
|||
as = (ac << 4) | (as & 0x0f);
|
||||
|
||||
/* Call post state change hook case it have been configured */
|
||||
if (esc_cfg->pre_state_change_hook != NULL)
|
||||
if (ESCvar.pre_state_change_hook != NULL)
|
||||
{
|
||||
esc_cfg->pre_state_change_hook (&as, &an);
|
||||
ESCvar.pre_state_change_hook (&as, &an);
|
||||
}
|
||||
|
||||
/* Switch through the state change requested via AlControl from
|
||||
|
@ -1050,8 +1031,8 @@ void ESC_state (void)
|
|||
case PREOP_TO_SAFEOP:
|
||||
case SAFEOP_TO_SAFEOP:
|
||||
{
|
||||
ESC_SM2_sml = sizeOfPDO (RX_PDO_OBJIDX);
|
||||
ESC_SM3_sml = sizeOfPDO (TX_PDO_OBJIDX);
|
||||
ESCvar.ESC_SM2_sml = sizeOfPDO (RX_PDO_OBJIDX);
|
||||
ESCvar.ESC_SM3_sml = sizeOfPDO (TX_PDO_OBJIDX);
|
||||
an = ESC_startinput (ac);
|
||||
if (an == ac)
|
||||
{
|
||||
|
@ -1120,9 +1101,9 @@ void ESC_state (void)
|
|||
}
|
||||
|
||||
/* Call post state change hook case it have been configured */
|
||||
if (esc_cfg->post_state_change_hook != NULL)
|
||||
if (ESCvar.post_state_change_hook != NULL)
|
||||
{
|
||||
esc_cfg->post_state_change_hook (&as, &an);
|
||||
ESCvar.post_state_change_hook (&as, &an);
|
||||
}
|
||||
|
||||
if (!(an & ESCerror) && (ESCvar.ALerror))
|
||||
|
@ -1135,13 +1116,36 @@ void ESC_state (void)
|
|||
|
||||
}
|
||||
/** Function copying the application configuration variable
|
||||
* to the stack local pointer variable.
|
||||
* data to the stack local variable.
|
||||
*
|
||||
* @param[in] cfg = Pointer to by the Application static declared
|
||||
* configuration variable holding application specific details. Ex. post- and
|
||||
* pre state change hooks
|
||||
* @param[in] cfg = Pointer to the Application configuration variable
|
||||
* holding application specific details. Data is copied.
|
||||
*/
|
||||
void ESC_config (esc_cfg_t * cfg)
|
||||
{
|
||||
esc_cfg = cfg;
|
||||
/* Copy configuration data */
|
||||
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.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;
|
||||
ESCvar.safeoutput_override = cfg->safeoutput_override;
|
||||
ESCvar.pre_object_download_hook = cfg->pre_object_download_hook;
|
||||
ESCvar.post_object_download_hook = cfg->post_object_download_hook;
|
||||
ESCvar.rxpdo_override = cfg->rxpdo_override;
|
||||
ESCvar.txpdo_override = cfg->txpdo_override;
|
||||
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;
|
||||
}
|
||||
|
|
176
soes/esc.h
176
soes/esc.h
|
@ -206,6 +206,48 @@
|
|||
#define FOE_WAIT_FOR_FINAL_ACK 2
|
||||
#define FOE_WAIT_FOR_DATA 3
|
||||
|
||||
#define APPSTATE_IDLE 0x00
|
||||
#define APPSTATE_INPUT 0x01
|
||||
#define APPSTATE_OUTPUT 0x02
|
||||
|
||||
typedef struct sm_cfg
|
||||
{
|
||||
uint16_t cfg_sma;
|
||||
uint16_t cfg_sml;
|
||||
uint16_t cfg_sme;
|
||||
uint8_t cfg_smc;
|
||||
uint8_t cfg_smact;
|
||||
}sm_cfg_t;
|
||||
|
||||
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 (*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);
|
||||
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);
|
||||
} esc_cfg_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t state;
|
||||
} _App;
|
||||
|
||||
// Attention! this struct is always little-endian
|
||||
CC_PACKED_BEGIN
|
||||
typedef struct CC_PACKED
|
||||
|
@ -292,7 +334,35 @@ CC_PACKED_END
|
|||
CC_PACKED_BEGIN
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16_t ALevent;
|
||||
/* 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 (*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);
|
||||
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);
|
||||
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;
|
||||
uint16_t ALcontrol;
|
||||
uint16_t ALerror;
|
||||
|
@ -325,10 +395,14 @@ typedef struct CC_PACKED
|
|||
|
||||
uint8_t SMtestresult;
|
||||
int16_t temp;
|
||||
uint16_t wdcnt;
|
||||
uint32_t PrevTime;
|
||||
uint32_t Time;
|
||||
_ESCsm SM[4];
|
||||
/* Volatile since it may be read from ISR */
|
||||
volatile int watchdogcnt;
|
||||
volatile uint32_t Time;
|
||||
volatile uint16_t ALevent;
|
||||
volatile int8_t synccounter;
|
||||
volatile _App App;
|
||||
} _ESCvar;
|
||||
CC_PACKED_END
|
||||
|
||||
|
@ -481,58 +555,23 @@ typedef struct
|
|||
uint8_t state;
|
||||
} _MBXcontrol;
|
||||
|
||||
typedef struct sm_cfg
|
||||
{
|
||||
uint16_t cfg_sma;
|
||||
uint16_t cfg_sml;
|
||||
uint16_t cfg_sme;
|
||||
uint8_t cfg_smc;
|
||||
uint8_t cfg_smact;
|
||||
}sm_cfg_t;
|
||||
|
||||
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 (*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);
|
||||
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);
|
||||
} esc_cfg_t;
|
||||
|
||||
/* Stack reference to application configuration of the ESC */
|
||||
extern esc_cfg_t * esc_cfg;
|
||||
extern size_t ESC_MBXSIZE;
|
||||
extern uint16_t ESC_MBX0_sma;
|
||||
extern uint16_t ESC_MBX0_sml;
|
||||
extern uint16_t ESC_MBX0_sme;
|
||||
extern uint8_t ESC_MBX0_smc;
|
||||
extern uint16_t ESC_MBX1_sma;
|
||||
extern uint16_t ESC_MBX1_sml;
|
||||
extern uint16_t ESC_MBX1_sme;
|
||||
extern uint8_t ESC_MBX1_smc;
|
||||
|
||||
#define ESC_MBXBUFFERS (esc_cfg->mbxbuffers)
|
||||
#define ESC_SM2_sma (esc_cfg->pdosm[0].cfg_sma)
|
||||
#define ESC_SM2_smc (esc_cfg->pdosm[0].cfg_smc)
|
||||
#define ESC_SM2_act (esc_cfg->pdosm[0].cfg_smact)
|
||||
#define ESC_SM3_sma (esc_cfg->pdosm[1].cfg_sma)
|
||||
#define ESC_SM3_smc (esc_cfg->pdosm[1].cfg_smc)
|
||||
#define ESC_SM3_act (esc_cfg->pdosm[1].cfg_smact)
|
||||
#define ESC_MBXSIZE (ESCvar.activembxsize)
|
||||
#define ESC_MBX0_sma (ESCvar.activemb0->cfg_sma)
|
||||
#define ESC_MBX0_sml (ESCvar.activemb0->cfg_sml)
|
||||
#define ESC_MBX0_sme (ESCvar.activemb0->cfg_sme)
|
||||
#define ESC_MBX0_smc (ESCvar.activemb0->cfg_smc)
|
||||
#define ESC_MBX1_sma (ESCvar.activemb1->cfg_sma)
|
||||
#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_MBXHSIZE sizeof(_MBXh)
|
||||
#define ESC_MBXDSIZE (ESC_MBXSIZE - ESC_MBXHSIZE)
|
||||
|
@ -569,34 +608,9 @@ void ESC_reset (void);
|
|||
|
||||
/* From application */
|
||||
extern void APP_safeoutput ();
|
||||
extern volatile _ESCvar ESCvar;
|
||||
extern uint8_t MBX[];
|
||||
extern _ESCvar ESCvar;
|
||||
extern _MBXcontrol MBXcontrol[];
|
||||
extern uint8_t MBXrun;
|
||||
extern uint16_t ESC_SM2_sml, ESC_SM3_sml;
|
||||
extern uint8_t dc_sync;
|
||||
extern int8_t sync_counter;
|
||||
extern uint16_t sync_counter_limit;
|
||||
extern uint16_t TXPDOsize;
|
||||
extern uint16_t RXPDOsize;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t state;
|
||||
} _App;
|
||||
|
||||
#define APPSTATE_IDLE 0x00
|
||||
#define APPSTATE_INPUT 0x01
|
||||
#define APPSTATE_OUTPUT 0x02
|
||||
|
||||
extern _App App;
|
||||
|
||||
void DIG_process (uint8_t flags);
|
||||
|
||||
#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
|
||||
extern uint8_t MBX[];
|
||||
|
||||
/* ATOMIC operations are used when running interrupt driven */
|
||||
#ifndef CC_ATOMIC_SET
|
||||
|
|
|
@ -850,7 +850,7 @@ void ESC_coeprocess (void)
|
|||
_COEsdo *coesdo;
|
||||
_COEobjdesc *coeobjdesc;
|
||||
uint8_t service;
|
||||
if (!MBXrun)
|
||||
if (ESCvar.MBXrun == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -563,7 +563,7 @@ void ESC_foeprocess (void)
|
|||
_MBXh *mbh;
|
||||
_FOE *foembx;
|
||||
|
||||
if (!MBXrun)
|
||||
if (ESCvar.MBXrun == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* Function to read and write commands to the ESC. Used to read/write ESC
|
||||
* registers and memory.
|
||||
*/
|
||||
#include "utypes.h"
|
||||
#include "esc.h"
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -426,10 +425,10 @@ void ESC_reset (void)
|
|||
|
||||
}
|
||||
|
||||
void ESC_init (const void * arg)
|
||||
void ESC_init (const esc_cfg_t * config)
|
||||
{
|
||||
uint32_t value;
|
||||
const char * spi_name = (char *)arg;
|
||||
const char * spi_name = (char *)config->user_arg;
|
||||
lan9252 = open (spi_name, O_RDWR, 0);
|
||||
|
||||
/* Reset the ecat core here due to evb-lan9252-digio not having any GPIO
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
* registers and memory.
|
||||
*/
|
||||
|
||||
#include "utypes.h"
|
||||
#include "esc.h"
|
||||
#include <spi/spi.h>
|
||||
#include <string.h>
|
||||
|
@ -390,10 +389,10 @@ void ESC_reset (void)
|
|||
|
||||
}
|
||||
|
||||
void ESC_init (const void * arg)
|
||||
void ESC_init (const esc_cfg_t * config)
|
||||
{
|
||||
uint32_t value;
|
||||
const char * spi_name = (char *)arg;
|
||||
const char * spi_name = (char *)config->user_arg;
|
||||
lan9252 = open (spi_name, O_RDWR, 0);
|
||||
|
||||
/* Reset the ecat core here due to evb-lan9252-digio not having any GPIO
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
* registers and memory.
|
||||
*/
|
||||
|
||||
#include "utypes.h"
|
||||
#include "../../esc.h"
|
||||
#include <spi/spi.h>
|
||||
#include <string.h>
|
||||
|
@ -119,9 +118,9 @@ void ESC_reset (void)
|
|||
DPRINT("esc_reset_ended\n");
|
||||
}
|
||||
|
||||
void ESC_init (const void * arg)
|
||||
void ESC_init (const esc_cfg_t * config)
|
||||
{
|
||||
const char * spi_name = (char *)arg;
|
||||
const char * spi_name = (char *)config->user_arg;
|
||||
et1100 = open (spi_name, O_RDWR, 0);
|
||||
read_termination[sizeof(read_termination) - 1] = 0xFF;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ static void ecat_isr (void * arg)
|
|||
|
||||
if(ESCvar.ALevent & ESCREG_ALEVENT_SM2)
|
||||
{
|
||||
if(dc_sync == 0)
|
||||
if(ESCvar.dcsync == 0)
|
||||
{
|
||||
DIG_process(DIG_PROCESS_OUTPUTS_FLAG | DIG_PROCESS_APP_HOOK_FLAG |
|
||||
DIG_PROCESS_INPUTS_FLAG);
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* Licensed under the GNU General Public License version 2 with exceptions. See
|
||||
* LICENSE file in the project root for full license information
|
||||
*/
|
||||
|
||||
#ifndef CC_H
|
||||
#define CC_H
|
||||
|
||||
|
@ -8,6 +13,8 @@ extern "C"
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/param.h>
|
||||
#ifdef __linux__
|
||||
#include <endian.h>
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue