commit
4bf6be795b
|
@ -0,0 +1,35 @@
|
|||
#ifndef __CONFIG_H__
|
||||
#define __CONFIG_H__
|
||||
|
||||
#include <cc.h>
|
||||
|
||||
#define MBXSIZE 128
|
||||
#define MBXSIZEBOOT 128
|
||||
#define MBXBUFFERS 3
|
||||
|
||||
#define MBX0_sma 0x1000
|
||||
#define MBX0_sml MBXSIZE
|
||||
#define MBX0_sme MBX0_sma+MBX0_sml-1
|
||||
#define MBX0_smc 0x26
|
||||
#define MBX1_sma MBX0_sma+MBX0_sml
|
||||
#define MBX1_sml MBXSIZE
|
||||
#define MBX1_sme MBX1_sma+MBX1_sml-1
|
||||
#define MBX1_smc 0x22
|
||||
|
||||
#define MBX0_sma_b 0x1000
|
||||
#define MBX0_sml_b MBXSIZEBOOT
|
||||
#define MBX0_sme_b MBX0_sma_b+MBX0_sml_b-1
|
||||
#define MBX0_smc_b 0x26
|
||||
#define MBX1_sma_b MBX0_sma_b+MBX0_sml_b
|
||||
#define MBX1_sml_b MBXSIZEBOOT
|
||||
#define MBX1_sme_b MBX1_sma_b+MBX1_sml_b-1
|
||||
#define MBX1_smc_b 0x22
|
||||
|
||||
#define SM2_sma 0x1100
|
||||
#define SM2_smc 0x24
|
||||
#define SM2_act 1
|
||||
#define SM3_sma 0x1180
|
||||
#define SM3_smc 0x20
|
||||
#define SM3_act 1
|
||||
|
||||
#endif /* __CONFIG_H__ */
|
Binary file not shown.
|
@ -0,0 +1,326 @@
|
|||
#ifndef SOES_V1
|
||||
#include <stddef.h>
|
||||
#include "utypes.h"
|
||||
#include "esc.h"
|
||||
#include "esc_coe.h"
|
||||
#include "esc_foe.h"
|
||||
#include "config.h"
|
||||
#include "k2gice.h"
|
||||
|
||||
/* Global variables used by the stack */
|
||||
uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)];
|
||||
_MBXcontrol MBXcontrol[MBXBUFFERS];
|
||||
_ESCvar ESCvar;
|
||||
|
||||
/* Application variables */
|
||||
_Rbuffer Rb;
|
||||
_Wbuffer Wb;
|
||||
_Cbuffer Cb;
|
||||
_Mbuffer Mb;
|
||||
|
||||
/* Private variables */
|
||||
static volatile int watchdog;
|
||||
|
||||
/** Mandatory: Function to pre-qualify the incoming SDO download.
|
||||
*
|
||||
* @param[in] index = index of SDO download request to check
|
||||
* @param[in] sub-index = sub-index of SDO download request to check
|
||||
* @return 1 if the SDO Download is correct. 0 If not correct.
|
||||
*/
|
||||
int ESC_pre_objecthandler (uint16_t index, uint8_t subindex)
|
||||
{
|
||||
int result = 1;
|
||||
|
||||
if(ESCvar.pre_object_download_hook)
|
||||
{
|
||||
result = (ESCvar.pre_object_download_hook)(index, subindex);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Mandatory: Hook called from the slave stack SDO Download handler to act on
|
||||
* user specified Index and Sub-index.
|
||||
*
|
||||
* @param[in] index = index of SDO download request to handle
|
||||
* @param[in] sub-index = sub-index of SDO download request to handle
|
||||
*/
|
||||
void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
/* Handle post-write of parameter values */
|
||||
default:
|
||||
{
|
||||
if(ESCvar.post_object_download_hook != NULL)
|
||||
{
|
||||
(ESCvar.post_object_download_hook)(index, subindex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Mandatory: Hook called from the slave stack ESC_stopoutputs to act on state changes
|
||||
* forcing us to stop outputs. Here we can set them to a safe state.
|
||||
* set
|
||||
*/
|
||||
void APP_safeoutput (void)
|
||||
{
|
||||
DPRINT ("APP_safeoutput\n");
|
||||
|
||||
if(ESCvar.safeoutput_override != NULL)
|
||||
{
|
||||
(ESCvar.safeoutput_override)();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set safe values for Wb.LED
|
||||
Wb.LED = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Mandatory: Write local process data to Sync Manager 3, Master Inputs.
|
||||
*/
|
||||
void TXPDO_update (void)
|
||||
{
|
||||
if(ESCvar.txpdo_override != NULL)
|
||||
{
|
||||
(ESCvar.txpdo_override)();
|
||||
}
|
||||
else
|
||||
{
|
||||
ESC_write (SM3_sma, &Rb, ESCvar.TXPDOsize);
|
||||
}
|
||||
}
|
||||
|
||||
/** Mandatory: Read Sync Manager 2 to local process data, Master Outputs.
|
||||
*/
|
||||
void RXPDO_update (void)
|
||||
{
|
||||
if(ESCvar.rxpdo_override != NULL)
|
||||
{
|
||||
(ESCvar.rxpdo_override)();
|
||||
}
|
||||
else
|
||||
{
|
||||
ESC_read (SM2_sma, &Wb, ESCvar.RXPDOsize);
|
||||
}
|
||||
}
|
||||
|
||||
/** Mandatory: Function to update local I/O, call read ethercat outputs, call
|
||||
* write ethercat inputs. Implement watch-dog counter to count-out if we have
|
||||
* made state change affecting the App.state.
|
||||
*/
|
||||
void DIG_process (uint8_t flags)
|
||||
{
|
||||
/* Handle watchdog */
|
||||
if((flags & DIG_PROCESS_WD_FLAG) > 0)
|
||||
{
|
||||
|
||||
if (CC_ATOMIC_GET(watchdog) > 0)
|
||||
{
|
||||
CC_ATOMIC_SUB(watchdog, 1);
|
||||
}
|
||||
|
||||
if ((CC_ATOMIC_GET(watchdog) <= 0) &&
|
||||
((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0))
|
||||
{
|
||||
DPRINT("DIG_process watchdog expired\n");
|
||||
ESC_stopoutput();
|
||||
/* watchdog, invalid outputs */
|
||||
ESC_ALerror (ALERR_WATCHDOG);
|
||||
/* goto safe-op with error bit set */
|
||||
ESC_ALstatus (ESCsafeop | ESCerror);
|
||||
}
|
||||
else if(((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) == 0))
|
||||
{
|
||||
CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle Outputs */
|
||||
if ((flags & DIG_PROCESS_OUTPUTS_FLAG) > 0)
|
||||
{
|
||||
if(((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0) &&
|
||||
(ESCvar.ALevent & ESCREG_ALEVENT_SM2))
|
||||
{
|
||||
RXPDO_update();
|
||||
CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt);
|
||||
if(ESCvar.dcsync > 0)
|
||||
{
|
||||
CC_ATOMIC_ADD(ESCvar.synccounter, 1);
|
||||
}
|
||||
/* Set outputs */
|
||||
cb_set_LED();
|
||||
}
|
||||
else if (ESCvar.ALevent & ESCREG_ALEVENT_SM2)
|
||||
{
|
||||
RXPDO_update();
|
||||
}
|
||||
}
|
||||
|
||||
/* Call application */
|
||||
if ((flags & DIG_PROCESS_APP_HOOK_FLAG) > 0)
|
||||
{
|
||||
|
||||
if((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0)
|
||||
{
|
||||
CC_ATOMIC_SUB(ESCvar.synccounter, 1);
|
||||
}
|
||||
|
||||
if((ESCvar.dcsync > 0) &&
|
||||
((CC_ATOMIC_GET(ESCvar.synccounter) < -ESCvar.synccounterlimit) ||
|
||||
(CC_ATOMIC_GET(ESCvar.synccounter) > ESCvar.synccounterlimit)))
|
||||
{
|
||||
if((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0)
|
||||
{
|
||||
DPRINT("sync error = %d\n", ESCvar.synccounter);
|
||||
ESC_stopoutput();
|
||||
/* Sync error */
|
||||
ESC_ALerror (ALERR_SYNCERROR);
|
||||
/* goto safe-op with error bit set */
|
||||
ESC_ALstatus (ESCsafeop | ESCerror);
|
||||
CC_ATOMIC_SET(ESCvar.synccounter, 0);
|
||||
}
|
||||
}
|
||||
/* Call application callback if set */
|
||||
if (ESCvar.application_hook != NULL)
|
||||
{
|
||||
(ESCvar.application_hook)();
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle Inputs */
|
||||
if ((flags & DIG_PROCESS_INPUTS_FLAG) > 0)
|
||||
{
|
||||
if(CC_ATOMIC_GET(ESCvar.App.state) > 0)
|
||||
{
|
||||
/* Update inputs */
|
||||
cb_get_BUTTON();
|
||||
TXPDO_update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application
|
||||
* control what interrupts that should be served and re-activated with
|
||||
* event mask argument
|
||||
*/
|
||||
void ecat_slv_worker (uint32_t event_mask)
|
||||
{
|
||||
do
|
||||
{
|
||||
/* Check the state machine */
|
||||
ESC_state();
|
||||
/* Check the SM activation event */
|
||||
ESC_sm_act_event();
|
||||
|
||||
/* Check mailboxes */
|
||||
while ((ESC_mbxprocess() > 0) || (ESCvar.txcue > 0))
|
||||
{
|
||||
ESC_coeprocess();
|
||||
ESC_foeprocess();
|
||||
ESC_xoeprocess();
|
||||
}
|
||||
|
||||
/* Call emulated eeprom handler if set */
|
||||
if (ESCvar.esc_hw_eep_handler != NULL)
|
||||
{
|
||||
(ESCvar.esc_hw_eep_handler)();
|
||||
}
|
||||
|
||||
CC_ATOMIC_SET(ESCvar.ALevent, ESC_ALeventread());
|
||||
|
||||
}while(ESCvar.ALevent & event_mask);
|
||||
|
||||
ESC_ALeventmaskwrite(ESC_ALeventmaskread() | event_mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* ISR function. It should be called from ISR for applications entirely driven by
|
||||
* interrupts.
|
||||
* Read and handle events for the EtherCAT state, status, mailbox and eeprom.
|
||||
*/
|
||||
void ecat_slv_isr (void)
|
||||
{
|
||||
ecat_slv_worker(ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SMCHANGE
|
||||
| ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1 | ESCREG_ALEVENT_EEP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Polling function. It should be called periodically for an application
|
||||
* when only SM2/DC interrupt is active.
|
||||
* Read and handle events for the EtherCAT state, status, mailbox and eeprom.
|
||||
*/
|
||||
void ecat_slv_poll (void)
|
||||
{
|
||||
/* Read local time from ESC*/
|
||||
ESC_read (ESCREG_LOCALTIME, (void *) &ESCvar.Time, sizeof (ESCvar.Time));
|
||||
ESCvar.Time = etohl (ESCvar.Time);
|
||||
|
||||
/* Check the state machine */
|
||||
ESC_state();
|
||||
/* Check the SM activation event */
|
||||
ESC_sm_act_event();
|
||||
|
||||
/* Check mailboxes */
|
||||
if (ESC_mbxprocess())
|
||||
{
|
||||
ESC_coeprocess();
|
||||
ESC_foeprocess();
|
||||
ESC_xoeprocess();
|
||||
}
|
||||
|
||||
/* Call emulated eeprom handler if set */
|
||||
if (ESCvar.esc_hw_eep_handler != NULL)
|
||||
{
|
||||
(ESCvar.esc_hw_eep_handler)();
|
||||
}
|
||||
}
|
||||
|
||||
void ecat_slv (void)
|
||||
{
|
||||
ecat_slv_poll();
|
||||
DIG_process(DIG_PROCESS_WD_FLAG | DIG_PROCESS_OUTPUTS_FLAG |
|
||||
DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the slave stack.
|
||||
*/
|
||||
void ecat_slv_init (esc_cfg_t * config)
|
||||
{
|
||||
DPRINT ("Slave stack init started\n");
|
||||
|
||||
ESCvar.TXPDOsize = ESCvar.ESC_SM3_sml = sizeOfPDO(TX_PDO_OBJIDX);
|
||||
ESCvar.RXPDOsize = ESCvar.ESC_SM2_sml = sizeOfPDO(RX_PDO_OBJIDX);
|
||||
|
||||
/* Init watchdog */
|
||||
watchdog = config->watchdog_cnt;
|
||||
|
||||
/* Call stack configuration */
|
||||
ESC_config (config);
|
||||
/* Call HW init */
|
||||
ESC_init (config);
|
||||
|
||||
/* wait until ESC is started up */
|
||||
while ((ESCvar.DLstatus & 0x0001) == 0)
|
||||
{
|
||||
ESC_read (ESCREG_DLSTATUS, (void *) &ESCvar.DLstatus,
|
||||
sizeof (ESCvar.DLstatus));
|
||||
ESCvar.DLstatus = etohs (ESCvar.DLstatus);
|
||||
}
|
||||
|
||||
/* Init FoE */
|
||||
FOE_init();
|
||||
|
||||
/* reset ESC to init state */
|
||||
ESC_ALstatus (ESCinit);
|
||||
ESC_ALerror (ALERR_NONE);
|
||||
ESC_stopmbx();
|
||||
ESC_stopinput();
|
||||
ESC_stopoutput();
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,242 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Slave fileVersion="1" id="k2gice" productCode="0x1234">
|
||||
<Name>k2gice</Name>
|
||||
<Vendor>
|
||||
<Id>0x1337</Id>
|
||||
<Name>rt-labs</Name>
|
||||
</Vendor>
|
||||
<Group>
|
||||
<Type>k2gice_t</Type>
|
||||
<Name>k2gice_n</Name>
|
||||
</Group>
|
||||
<Fmmu>Outputs</Fmmu>
|
||||
<Fmmu>Inputs</Fmmu>
|
||||
<Fmmu>MBoxState</Fmmu>
|
||||
<Sm ControlByte="0x26" DefaultSize="128" StartAddress="0x1000">MBoxOut</Sm>
|
||||
<Sm ControlByte="0x22" DefaultSize="128" StartAddress="0x1080">MBoxIn</Sm>
|
||||
<Sm ControlByte="0x24" DefaultSize="0" StartAddress="0x1100">Outputs</Sm>
|
||||
<Sm ControlByte="0x20" DefaultSize="0" StartAddress="0x1180">Inputs</Sm>
|
||||
<Mailbox CoE="true">
|
||||
<Bootstrap Length="128" Start="0x1000"/>
|
||||
<Standard Length="128" Start="0x1000"/>
|
||||
</Mailbox>
|
||||
<Eeprom>
|
||||
<ByteSize>2048</ByteSize>
|
||||
<ConfigData>800CE08800000000</ConfigData>
|
||||
<BootStrap>0010800080108000</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>k2gice</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>0x1234</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>LED</Name>
|
||||
<Index>0x1600</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>LED</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0x70000020</DefaultValue>
|
||||
</SubItem>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>BUTTON</Name>
|
||||
<Index>0x1A00</Index>
|
||||
<DataType>RECORD</DataType>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Index>0x00</Index>
|
||||
<DataType>UNSIGNED8</DataType>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>BUTTON</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0x60000020</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>1</DefaultValue>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>PDO Mapping</Name>
|
||||
<Index>0x01</Index>
|
||||
<DataType>UNSIGNED16</DataType>
|
||||
<DefaultValue>0x1600</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>BUTTON</Name>
|
||||
<Index>0x6000</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>BUTTON</Variable>
|
||||
<VariableType>Input</VariableType>
|
||||
</Item>
|
||||
<Item Managed="true">
|
||||
<Name>LED</Name>
|
||||
<Index>0x7000</Index>
|
||||
<DataType>UNSIGNED32</DataType>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
<Access>RO</Access>
|
||||
<Variable>LED</Variable>
|
||||
<VariableType>Output</VariableType>
|
||||
</Item>
|
||||
</Dictionary>
|
||||
<RxPdo>
|
||||
<Index>0x1600</Index>
|
||||
<Container>LED</Container>
|
||||
<Name>LED</Name>
|
||||
<Entry>
|
||||
<Index>0x7000</Index>
|
||||
<SubIndex>0</SubIndex>
|
||||
<Variable>LED</Variable>
|
||||
</Entry>
|
||||
</RxPdo>
|
||||
<TxPdo>
|
||||
<Index>0x1A00</Index>
|
||||
<Container>BUTTON</Container>
|
||||
<Name>BUTTON</Name>
|
||||
<Entry>
|
||||
<Index>0x6000</Index>
|
||||
<SubIndex>0</SubIndex>
|
||||
<Variable>BUTTON</Variable>
|
||||
</Entry>
|
||||
</TxPdo>
|
||||
<Input>
|
||||
<Index>0x6000</Index>
|
||||
<Name>BUTTON</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
<ObjectType>VAR</ObjectType>
|
||||
</Input>
|
||||
<Output>
|
||||
<Index>0x7000</Index>
|
||||
<Name>LED</Name>
|
||||
<Type>UNSIGNED32</Type>
|
||||
<ObjectType>VAR</ObjectType>
|
||||
</Output>
|
||||
</Slave>
|
|
@ -0,0 +1,64 @@
|
|||
#ifndef __K2GICE_H__
|
||||
#define __K2GICE_H__
|
||||
|
||||
#include "utypes.h"
|
||||
#include "esc.h"
|
||||
|
||||
/**
|
||||
* This function gets input values and updates Rb.BUTTON
|
||||
*/
|
||||
void cb_get_BUTTON();
|
||||
|
||||
/**
|
||||
* This function sets output values according to Wb.LED
|
||||
*/
|
||||
void cb_set_LED();
|
||||
|
||||
#define DIG_PROCESS_INPUTS_FLAG 0x01
|
||||
#define DIG_PROCESS_OUTPUTS_FLAG 0x02
|
||||
#define DIG_PROCESS_WD_FLAG 0x04
|
||||
#define DIG_PROCESS_APP_HOOK_FLAG 0x08
|
||||
/** Implements the watch-dog counter to count if we should make a state change
|
||||
* due to missing incoming SM2 events. Updates local I/O and run the application
|
||||
* in the following order, call read EtherCAT outputs, execute user provided
|
||||
* application hook and call write EtherCAT inputs.
|
||||
*
|
||||
* @param[in] flags = User input what to execute
|
||||
*/
|
||||
void DIG_process (uint8_t flags);
|
||||
|
||||
/**
|
||||
* Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application
|
||||
* control what interrupts that should be served and re-activated with
|
||||
* event mask argument
|
||||
*
|
||||
* @param[in] event_mask = Event mask for interrupts to serve and re-activate
|
||||
* after served
|
||||
*/
|
||||
void ecat_slv_worker (uint32_t event_mask);
|
||||
|
||||
/**
|
||||
* ISR for SM0/1, EEPROM and AL CONTROL events in a SM/DC
|
||||
* synchronization application
|
||||
*/
|
||||
CC_DEPRECATED void ecat_slv_isr (void);
|
||||
|
||||
/**
|
||||
* Poll SM0/1, EEPROM and AL CONTROL events in a SM/DC synchronization
|
||||
* application
|
||||
*/
|
||||
void ecat_slv_poll (void);
|
||||
|
||||
/**
|
||||
* Poll all events in a free-run application
|
||||
*/
|
||||
void ecat_slv (void);
|
||||
|
||||
/**
|
||||
* Initialize the slave stack
|
||||
*
|
||||
* @param[in] config = User input how to configure the stack
|
||||
*/
|
||||
void ecat_slv_init (esc_cfg_t * config);
|
||||
|
||||
#endif /* __K2GICE_H__ */
|
|
@ -0,0 +1,535 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EtherCATInfo>
|
||||
<Vendor>
|
||||
<Id>#x1337</Id>
|
||||
<Name LcId="1033">rt-labs</Name>
|
||||
</Vendor>
|
||||
<Descriptions>
|
||||
<Groups>
|
||||
<Group>
|
||||
<Type>k2gice_t</Type>
|
||||
<Name LcId="1033">k2gice_n</Name>
|
||||
</Group>
|
||||
</Groups>
|
||||
<Devices>
|
||||
<Device Physics="YY">
|
||||
<Type ProductCode="#x1234" RevisionNo="0">k2gice</Type>
|
||||
<Name LcId="1033">k2gice</Name>
|
||||
<GroupType>k2gice_t</GroupType>
|
||||
<Profile>
|
||||
<ProfileNo>5001</ProfileNo>
|
||||
<AddInfo>0</AddInfo>
|
||||
<Dictionary>
|
||||
<DataTypes>
|
||||
<DataType>
|
||||
<Name>DT1018</Name>
|
||||
<BitSize>144</BitSize>
|
||||
<SubItem>
|
||||
<SubIdx>0</SubIdx>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Type>USINT</Type>
|
||||
<BitSize>8</BitSize>
|
||||
<BitOffs>0</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<SubIdx>1</SubIdx>
|
||||
<Name>Vendor ID</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<BitOffs>16</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<SubIdx>2</SubIdx>
|
||||
<Name>Product Code</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<BitOffs>48</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<SubIdx>3</SubIdx>
|
||||
<Name>Revision Number</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<BitOffs>80</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<SubIdx>4</SubIdx>
|
||||
<Name>Serial Number</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<BitOffs>112</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>DT1600</Name>
|
||||
<BitSize>48</BitSize>
|
||||
<SubItem>
|
||||
<SubIdx>0</SubIdx>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Type>USINT</Type>
|
||||
<BitSize>8</BitSize>
|
||||
<BitOffs>0</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<SubIdx>1</SubIdx>
|
||||
<Name>LED</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<BitOffs>16</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>DT1A00</Name>
|
||||
<BitSize>48</BitSize>
|
||||
<SubItem>
|
||||
<SubIdx>0</SubIdx>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Type>USINT</Type>
|
||||
<BitSize>8</BitSize>
|
||||
<BitOffs>0</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<SubIdx>1</SubIdx>
|
||||
<Name>BUTTON</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<BitOffs>16</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>DT1C00ARR</Name>
|
||||
<BaseType>USINT</BaseType>
|
||||
<BitSize>32</BitSize>
|
||||
<ArrayInfo>
|
||||
<LBound>1</LBound>
|
||||
<Elements>4</Elements>
|
||||
</ArrayInfo>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>DT1C00</Name>
|
||||
<BitSize>48</BitSize>
|
||||
<SubItem>
|
||||
<SubIdx>0</SubIdx>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Type>USINT</Type>
|
||||
<BitSize>8</BitSize>
|
||||
<BitOffs>0</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Elements</Name>
|
||||
<Type>DT1C00ARR</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<BitOffs>16</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>DT1C12ARR</Name>
|
||||
<BaseType>UINT</BaseType>
|
||||
<BitSize>16</BitSize>
|
||||
<ArrayInfo>
|
||||
<LBound>1</LBound>
|
||||
<Elements>1</Elements>
|
||||
</ArrayInfo>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>DT1C12</Name>
|
||||
<BitSize>32</BitSize>
|
||||
<SubItem>
|
||||
<SubIdx>0</SubIdx>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Type>USINT</Type>
|
||||
<BitSize>8</BitSize>
|
||||
<BitOffs>0</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Elements</Name>
|
||||
<Type>DT1C12ARR</Type>
|
||||
<BitSize>16</BitSize>
|
||||
<BitOffs>16</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>DT1C13ARR</Name>
|
||||
<BaseType>UINT</BaseType>
|
||||
<BitSize>16</BitSize>
|
||||
<ArrayInfo>
|
||||
<LBound>1</LBound>
|
||||
<Elements>1</Elements>
|
||||
</ArrayInfo>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>DT1C13</Name>
|
||||
<BitSize>32</BitSize>
|
||||
<SubItem>
|
||||
<SubIdx>0</SubIdx>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Type>USINT</Type>
|
||||
<BitSize>8</BitSize>
|
||||
<BitOffs>0</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Elements</Name>
|
||||
<Type>DT1C13ARR</Type>
|
||||
<BitSize>16</BitSize>
|
||||
<BitOffs>16</BitOffs>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</SubItem>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>STRING(6)</Name>
|
||||
<BitSize>48</BitSize>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>STRING(3)</Name>
|
||||
<BitSize>24</BitSize>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>UDINT</Name>
|
||||
<BitSize>32</BitSize>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>UINT</Name>
|
||||
<BitSize>16</BitSize>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name>USINT</Name>
|
||||
<BitSize>8</BitSize>
|
||||
</DataType>
|
||||
</DataTypes>
|
||||
<Objects>
|
||||
<Object>
|
||||
<Index>#x1000</Index>
|
||||
<Name>Device Type</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<Info>
|
||||
<DefaultValue>#x00001389</DefaultValue>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
<Category>m</Category>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x1008</Index>
|
||||
<Name>Device Name</Name>
|
||||
<Type>STRING(6)</Type>
|
||||
<BitSize>48</BitSize>
|
||||
<Info>
|
||||
<DefaultString>k2gice</DefaultString>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x1009</Index>
|
||||
<Name>Hardware Version</Name>
|
||||
<Type>STRING(3)</Type>
|
||||
<BitSize>24</BitSize>
|
||||
<Info>
|
||||
<DefaultString>1.0</DefaultString>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
<Category>o</Category>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x100A</Index>
|
||||
<Name>Software Version</Name>
|
||||
<Type>STRING(3)</Type>
|
||||
<BitSize>24</BitSize>
|
||||
<Info>
|
||||
<DefaultString>1.0</DefaultString>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x1018</Index>
|
||||
<Name>Identity Object</Name>
|
||||
<Type>DT1018</Type>
|
||||
<BitSize>144</BitSize>
|
||||
<Info>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Info>
|
||||
<DefaultValue>4</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Vendor ID</Name>
|
||||
<Info>
|
||||
<DefaultValue>#x1337</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Product Code</Name>
|
||||
<Info>
|
||||
<DefaultValue>#x1234</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Revision Number</Name>
|
||||
<Info>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Serial Number</Name>
|
||||
<Info>
|
||||
<DefaultValue>#x00000000</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x1600</Index>
|
||||
<Name>LED</Name>
|
||||
<Type>DT1600</Type>
|
||||
<BitSize>48</BitSize>
|
||||
<Info>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Info>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>LED</Name>
|
||||
<Info>
|
||||
<DefaultValue>#x70000020</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x1A00</Index>
|
||||
<Name>BUTTON</Name>
|
||||
<Type>DT1A00</Type>
|
||||
<BitSize>48</BitSize>
|
||||
<Info>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Info>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>BUTTON</Name>
|
||||
<Info>
|
||||
<DefaultValue>#x60000020</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x1C00</Index>
|
||||
<Name>Sync Manager Communication Type</Name>
|
||||
<Type>DT1C00</Type>
|
||||
<BitSize>48</BitSize>
|
||||
<Info>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Info>
|
||||
<DefaultValue>4</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Communications Type SM0</Name>
|
||||
<Info>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Communications Type SM1</Name>
|
||||
<Info>
|
||||
<DefaultValue>2</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Communications Type SM2</Name>
|
||||
<Info>
|
||||
<DefaultValue>3</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>Communications Type SM3</Name>
|
||||
<Info>
|
||||
<DefaultValue>4</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x1C12</Index>
|
||||
<Name>Sync Manager 2 PDO Assignment</Name>
|
||||
<Type>DT1C12</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<Info>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Info>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>PDO Mapping</Name>
|
||||
<Info>
|
||||
<DefaultValue>#x1600</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x1C13</Index>
|
||||
<Name>Sync Manager 3 PDO Assignment</Name>
|
||||
<Type>DT1C13</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<Info>
|
||||
<SubItem>
|
||||
<Name>Max SubIndex</Name>
|
||||
<Info>
|
||||
<DefaultValue>1</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
<SubItem>
|
||||
<Name>PDO Mapping</Name>
|
||||
<Info>
|
||||
<DefaultValue>#x1A00</DefaultValue>
|
||||
</Info>
|
||||
</SubItem>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x6000</Index>
|
||||
<Name>BUTTON</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<Info>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
<Object>
|
||||
<Index>#x7000</Index>
|
||||
<Name>LED</Name>
|
||||
<Type>UDINT</Type>
|
||||
<BitSize>32</BitSize>
|
||||
<Info>
|
||||
<DefaultValue>0</DefaultValue>
|
||||
</Info>
|
||||
<Flags>
|
||||
<Access>ro</Access>
|
||||
</Flags>
|
||||
</Object>
|
||||
</Objects>
|
||||
</Dictionary>
|
||||
</Profile>
|
||||
<Fmmu>Outputs</Fmmu>
|
||||
<Fmmu>Inputs</Fmmu>
|
||||
<Fmmu>MBoxState</Fmmu>
|
||||
<Sm ControlByte="#x26" DefaultSize="128" Enable="1" StartAddress="#x1000">MBoxOut</Sm>
|
||||
<Sm ControlByte="#x22" DefaultSize="128" Enable="1" StartAddress="#x1080">MBoxIn</Sm>
|
||||
<Sm ControlByte="#x24" Enable="1" StartAddress="#x1100">Outputs</Sm>
|
||||
<Sm ControlByte="#x20" Enable="1" StartAddress="#x1180">Inputs</Sm>
|
||||
<RxPdo Fixed="true" Mandatory="true" Sm="2">
|
||||
<Index>#x1600</Index>
|
||||
<Name>LED</Name>
|
||||
<Entry>
|
||||
<Index>#x7000</Index>
|
||||
<SubIndex>0</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>LED</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
</RxPdo>
|
||||
<TxPdo Fixed="true" Mandatory="true" Sm="3">
|
||||
<Index>#x1A00</Index>
|
||||
<Name>BUTTON</Name>
|
||||
<Entry>
|
||||
<Index>#x6000</Index>
|
||||
<SubIndex>0</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>BUTTON</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
</TxPdo>
|
||||
<Mailbox DataLinkLayer="true">
|
||||
<CoE CompleteAccess="false" PdoUpload="true" SdoInfo="true"/>
|
||||
</Mailbox>
|
||||
<Eeprom>
|
||||
<ByteSize>2048</ByteSize>
|
||||
<ConfigData>800CE08800000000</ConfigData>
|
||||
<BootStrap>0010800080108000</BootStrap>
|
||||
</Eeprom>
|
||||
</Device>
|
||||
</Devices>
|
||||
</Descriptions>
|
||||
</EtherCATInfo>
|
|
@ -0,0 +1,128 @@
|
|||
#ifndef SOES_V1
|
||||
#include "esc_coe.h"
|
||||
#include "utypes.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef HW_REV
|
||||
#define HW_REV "1.0"
|
||||
#endif
|
||||
|
||||
#ifndef SW_REV
|
||||
#define SW_REV "1.0"
|
||||
#endif
|
||||
|
||||
static const char acName1000[] = "Device Type";
|
||||
static const char acName1000_0[] = "Device Type";
|
||||
static const char acName1008[] = "Device Name";
|
||||
static const char acName1008_0[] = "Device Name";
|
||||
static const char acName1009[] = "Hardware Version";
|
||||
static const char acName1009_0[] = "Hardware Version";
|
||||
static const char acName100A[] = "Software Version";
|
||||
static const char acName100A_0[] = "Software Version";
|
||||
static const char acName1018[] = "Identity Object";
|
||||
static const char acName1018_00[] = "Max SubIndex";
|
||||
static const char acName1018_01[] = "Vendor ID";
|
||||
static const char acName1018_02[] = "Product Code";
|
||||
static const char acName1018_03[] = "Revision Number";
|
||||
static const char acName1018_04[] = "Serial Number";
|
||||
static const char acName1600[] = "LED";
|
||||
static const char acName1600_00[] = "Max SubIndex";
|
||||
static const char acName1600_01[] = "LED";
|
||||
static const char acName1A00[] = "BUTTON";
|
||||
static const char acName1A00_00[] = "Max SubIndex";
|
||||
static const char acName1A00_01[] = "BUTTON";
|
||||
static const char acName1C00[] = "Sync Manager Communication Type";
|
||||
static const char acName1C00_00[] = "Max SubIndex";
|
||||
static const char acName1C00_01[] = "Communications Type SM0";
|
||||
static const char acName1C00_02[] = "Communications Type SM1";
|
||||
static const char acName1C00_03[] = "Communications Type SM2";
|
||||
static const char acName1C00_04[] = "Communications Type SM3";
|
||||
static const char acName1C12[] = "Sync Manager 2 PDO Assignment";
|
||||
static const char acName1C12_00[] = "Max SubIndex";
|
||||
static const char acName1C12_01[] = "PDO Mapping";
|
||||
static const char acName1C13[] = "Sync Manager 3 PDO Assignment";
|
||||
static const char acName1C13_00[] = "Max SubIndex";
|
||||
static const char acName1C13_01[] = "PDO Mapping";
|
||||
static const char acName6000[] = "BUTTON";
|
||||
static const char acName6000_0[] = "BUTTON";
|
||||
static const char acName7000[] = "LED";
|
||||
static const char acName7000_0[] = "LED";
|
||||
|
||||
const _objd SDO1000[] =
|
||||
{
|
||||
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000_0, 0x00001389, NULL},
|
||||
};
|
||||
const _objd SDO1008[] =
|
||||
{
|
||||
{0x0, DTYPE_VISIBLE_STRING, 48, ATYPE_RO, acName1008_0, 0, "k2gice"},
|
||||
};
|
||||
const _objd SDO1009[] =
|
||||
{
|
||||
{0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName1009_0, 0, HW_REV},
|
||||
};
|
||||
const _objd SDO100A[] =
|
||||
{
|
||||
{0x0, DTYPE_VISIBLE_STRING, 24, ATYPE_RO, acName100A_0, 0, SW_REV},
|
||||
};
|
||||
const _objd SDO1018[] =
|
||||
{
|
||||
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1018_00, 4, NULL},
|
||||
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_01, 0x1337, NULL},
|
||||
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_02, 0x1234, NULL},
|
||||
{0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_03, 0, NULL},
|
||||
{0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_04, 0x00000000, NULL},
|
||||
};
|
||||
const _objd SDO1600[] =
|
||||
{
|
||||
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1600_00, 1, NULL},
|
||||
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70000020, NULL},
|
||||
};
|
||||
const _objd SDO1A00[] =
|
||||
{
|
||||
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL},
|
||||
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60000020, NULL},
|
||||
};
|
||||
const _objd SDO1C00[] =
|
||||
{
|
||||
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_00, 4, NULL},
|
||||
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_01, 1, NULL},
|
||||
{0x02, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_02, 2, NULL},
|
||||
{0x03, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_03, 3, NULL},
|
||||
{0x04, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_04, 4, NULL},
|
||||
};
|
||||
const _objd SDO1C12[] =
|
||||
{
|
||||
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 1, NULL},
|
||||
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_01, 0x1600, NULL},
|
||||
};
|
||||
const _objd SDO1C13[] =
|
||||
{
|
||||
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 1, NULL},
|
||||
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_01, 0x1A00, NULL},
|
||||
};
|
||||
const _objd SDO6000[] =
|
||||
{
|
||||
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName6000_0, 0, &Rb.BUTTON},
|
||||
};
|
||||
const _objd SDO7000[] =
|
||||
{
|
||||
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName7000_0, 0, &Wb.LED},
|
||||
};
|
||||
|
||||
const _objectlist SDOobjects[] =
|
||||
{
|
||||
{0x1000, OTYPE_VAR, 0, 0, acName1000, SDO1000},
|
||||
{0x1008, OTYPE_VAR, 0, 0, acName1008, SDO1008},
|
||||
{0x1009, OTYPE_VAR, 0, 0, acName1009, SDO1009},
|
||||
{0x100A, OTYPE_VAR, 0, 0, acName100A, SDO100A},
|
||||
{0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018},
|
||||
{0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600},
|
||||
{0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00},
|
||||
{0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00},
|
||||
{0x1C12, OTYPE_ARRAY, 1, 0, acName1C12, SDO1C12},
|
||||
{0x1C13, OTYPE_ARRAY, 1, 0, acName1C13, SDO1C13},
|
||||
{0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000},
|
||||
{0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000},
|
||||
{0xffff, 0xff, 0xff, 0xff, NULL, NULL}
|
||||
};
|
||||
#endif
|
|
@ -0,0 +1,86 @@
|
|||
#include "k2gice.h"
|
||||
#include "esc_hw.h"
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include "tiescutils.h"
|
||||
#include <examples/board/include/board_i2cLed.h>
|
||||
#include <examples/board/include/board_rotary_switch.h>
|
||||
|
||||
/**
|
||||
* This function reads physical input values and assigns the corresponding members
|
||||
* of Rb.Buttons
|
||||
*/
|
||||
void cb_get_BUTTON()
|
||||
{
|
||||
volatile uint8_t io_input;
|
||||
Board_readRotarySwitch(&io_input);
|
||||
Rb.BUTTON = io_input;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function writes physical output values from the corresponding members of
|
||||
* Wb.LEDs
|
||||
*/
|
||||
void cb_set_LED()
|
||||
{
|
||||
volatile uint8_t io_output;
|
||||
io_output = Wb.LED;
|
||||
Board_setDigOutput(io_output);
|
||||
}
|
||||
|
||||
|
||||
/* Called from stack when stopping outputs */
|
||||
void user_safeoutput (void)
|
||||
{
|
||||
memset(&Wb, 0, (sizeof(Wb)));
|
||||
Board_setDigOutput(0);
|
||||
}
|
||||
|
||||
/* Configuration parameters for SOES
|
||||
* SM and Mailbox parameters comes from the
|
||||
* generated config.h
|
||||
*/
|
||||
static esc_cfg_t config =
|
||||
{
|
||||
.user_arg = NULL,
|
||||
.use_interrupt = 1,
|
||||
.watchdog_cnt = 9999,
|
||||
.mbxsize = MBXSIZE,
|
||||
.mbxsizeboot = MBXSIZEBOOT,
|
||||
.mbxbuffers = MBXBUFFERS,
|
||||
.mb[0] = {MBX0_sma, MBX0_sml, MBX0_sme, MBX0_smc, 0},
|
||||
.mb[1] = {MBX1_sma, MBX1_sml, MBX1_sme, MBX1_smc, 0},
|
||||
.mb_boot[0] = {MBX0_sma_b, MBX0_sml_b, MBX0_sme_b, MBX0_smc_b, 0},
|
||||
.mb_boot[1] = {MBX1_sma_b, MBX1_sml_b, MBX1_sme_b, MBX1_smc_b, 0},
|
||||
.pdosm[0] = {SM2_sma, 0, 0, SM2_smc, SM2_act},
|
||||
.pdosm[1] = {SM3_sma, 0, 0, SM3_smc, SM3_act},
|
||||
.pre_state_change_hook = NULL,
|
||||
.post_state_change_hook = NULL,
|
||||
.application_hook = NULL,
|
||||
.safeoutput_override = user_safeoutput,
|
||||
.pre_object_download_hook = NULL,
|
||||
.post_object_download_hook = NULL,
|
||||
.rxpdo_override = NULL,
|
||||
.txpdo_override = NULL,
|
||||
.esc_hw_interrupt_enable = ESC_interrupt_enable,
|
||||
.esc_hw_interrupt_disable = ESC_interrupt_disable,
|
||||
.esc_hw_eep_handler = ESC_eep_handler
|
||||
};
|
||||
|
||||
int MainInit(void)
|
||||
{
|
||||
ecat_slv_init(&config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MainLoop(void)
|
||||
{
|
||||
ecat_slv_poll();
|
||||
DIG_process(DIG_PROCESS_WD_FLAG);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
common_main();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef __UTYPES_H__
|
||||
#define __UTYPES_H__
|
||||
|
||||
#include <cc.h>
|
||||
|
||||
/* Inputs */
|
||||
CC_PACKED_BEGIN
|
||||
typedef struct
|
||||
{
|
||||
uint32_t BUTTON;
|
||||
} CC_PACKED _Rbuffer;
|
||||
CC_PACKED_END
|
||||
|
||||
/* Outputs */
|
||||
CC_PACKED_BEGIN
|
||||
typedef struct
|
||||
{
|
||||
uint32_t LED;
|
||||
} CC_PACKED _Wbuffer;
|
||||
CC_PACKED_END
|
||||
|
||||
/* Parameters */
|
||||
CC_PACKED_BEGIN
|
||||
typedef struct
|
||||
{
|
||||
} CC_PACKED _Cbuffer;
|
||||
CC_PACKED_END
|
||||
|
||||
/* Manufacturer specific data */
|
||||
CC_PACKED_BEGIN
|
||||
typedef struct
|
||||
{
|
||||
} CC_PACKED _Mbuffer;
|
||||
CC_PACKED_END
|
||||
|
||||
extern _Rbuffer Rb;
|
||||
extern _Wbuffer Wb;
|
||||
extern _Cbuffer Cb;
|
||||
extern _Mbuffer Mb;
|
||||
|
||||
#endif /* __UTYPES_H__ */
|
|
@ -543,7 +543,7 @@ uint8_t ESC_mbxprocess (void)
|
|||
}
|
||||
|
||||
/* outmbx read by master */
|
||||
if (ESCvar.mbxoutpost && ESCvar.SM[1].IntR)
|
||||
if (ESCvar.mbxoutpost && (ESCvar.ALevent & ESCREG_ALEVENT_SM1))
|
||||
{
|
||||
ESC_ackmbxread ();
|
||||
/* dispose old backup */
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef _APPLINTERFACE_H_
|
||||
#define _APPLINTERFACE_H_
|
||||
|
||||
/* Not used, to be removed */
|
||||
|
||||
#endif /*_APPLINTERFACE_H_ */
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef __ECAT_DEF_H__
|
||||
#define __ECAT_DEF_H__
|
||||
|
||||
#define ESC_DC_SYNC0_CYCLETIME_OFFSET 0x09A0
|
||||
#define ESC_SYSTEMTIME_OFFSET 0x0910
|
||||
#define ESC_DC_SYNC_ACTIVATION_OFFSET 0x0981
|
||||
|
||||
#define STATE_INIT ((uint8_t)0x01)
|
||||
|
||||
#ifndef SOES
|
||||
#define SOES 1
|
||||
#endif
|
||||
|
||||
#ifndef VARVOLATILE
|
||||
#define VARVOLATILE volatile
|
||||
#endif
|
||||
|
||||
#ifndef AL_EVENT_ENABLED
|
||||
#define AL_EVENT_ENABLED 1
|
||||
#endif
|
||||
|
||||
|
||||
int MainInit(void);
|
||||
void MainLoop(void);
|
||||
|
||||
extern const unsigned char * tiesc_eeprom;
|
||||
extern int bRunApplication;
|
||||
|
||||
#endif /* __ECAT_DEF_H__ */
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef _ECATSLV_H_
|
||||
#define _ECATSLV_H_
|
||||
|
||||
/* Not used, to be removed */
|
||||
|
||||
#endif /*_ECATSLV_H_ */
|
|
@ -0,0 +1,327 @@
|
|||
/*
|
||||
* Licensed under the GNU General Public License version 2 with exceptions. See
|
||||
* LICENSE file in the project root for full license information
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief
|
||||
* ESC hardware layer functions.
|
||||
*
|
||||
* Function to read and write commands to the ESC. Used to read/write ESC
|
||||
* registers and memory.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "cc.h"
|
||||
#include "esc_hw.h"
|
||||
#include "esc_eep.h"
|
||||
#include "k2gice.h"
|
||||
#include "tiescbsp.h"
|
||||
#include "tieschw.h"
|
||||
#include "config.h"
|
||||
|
||||
extern PRUICSS_Handle pruIcss1Handle;
|
||||
extern uint32_t pd_read_addr_err, pd_write_addr_err;
|
||||
extern uint32_t pdi_read_fail_cnt, pdi_write_fail_cnt;
|
||||
|
||||
static PRUICSS_Handle escHwPruIcssHandle;
|
||||
|
||||
int bRunApplication;
|
||||
|
||||
static void Esc_readmbx(uint8_t *pData, uint16_t Address, uint16_t Len)
|
||||
{
|
||||
bsp_pdi_mbx_read_start(escHwPruIcssHandle);
|
||||
bsp_read(escHwPruIcssHandle, pData, Address, Len);
|
||||
|
||||
if(Len >= MBX0_sml - 2)
|
||||
{
|
||||
bsp_pdi_mbx_read_complete(escHwPruIcssHandle);
|
||||
}
|
||||
}
|
||||
|
||||
static void ESC_readRXPDO(uint8_t *pData, uint16_t Address, uint16_t Len)
|
||||
{
|
||||
int16_t sm_index;
|
||||
uint16_t ActAddress = bsp_get_process_data_address(escHwPruIcssHandle, Address, Len,
|
||||
&sm_index);
|
||||
|
||||
if(ActAddress < ESC_ADDR_MEMORY)
|
||||
{
|
||||
pd_read_addr_err++;
|
||||
return;
|
||||
}
|
||||
|
||||
bsp_read(escHwPruIcssHandle, pData, ActAddress, Len);
|
||||
bsp_process_data_access_complete(escHwPruIcssHandle, Address, Len, sm_index);
|
||||
}
|
||||
|
||||
static void ESC_writembox(uint8_t *pData, uint16_t Address, uint16_t Len)
|
||||
{
|
||||
|
||||
//Do not write to mailbox if already full
|
||||
if((bsp_read_byte(escHwPruIcssHandle,
|
||||
ESC_ADDR_SM1_STATUS) & SM_STATUS_MBX_FULL))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bsp_pdi_mbx_write_start(escHwPruIcssHandle);
|
||||
bsp_write(escHwPruIcssHandle, pData, Address, Len);
|
||||
|
||||
if(Len >= MBX1_sml - 2)
|
||||
{
|
||||
bsp_pdi_mbx_write_complete(escHwPruIcssHandle);
|
||||
}
|
||||
}
|
||||
|
||||
static void ESC_writeTXPDO(uint8_t *pData, uint16_t Address, uint16_t Len)
|
||||
{
|
||||
int16_t sm_index;
|
||||
uint16_t ActualAddr = bsp_get_process_data_address(escHwPruIcssHandle, Address, Len,
|
||||
&sm_index);
|
||||
|
||||
if(ActualAddr < ESC_ADDR_MEMORY)
|
||||
{
|
||||
pd_write_addr_err++;
|
||||
return;
|
||||
}
|
||||
|
||||
bsp_write(escHwPruIcssHandle, pData, ActualAddr, Len);
|
||||
bsp_process_data_access_complete(escHwPruIcssHandle, Address, Len, sm_index);
|
||||
}
|
||||
|
||||
|
||||
/** ESC read function used by the Slave stack.
|
||||
*
|
||||
* @param[in] address = address of ESC register to read
|
||||
* @param[out] buf = pointer to buffer to read in
|
||||
* @param[in] len = number of bytes to read
|
||||
*/
|
||||
void ESC_read (uint16_t address, void *buf, uint16_t len)
|
||||
{
|
||||
uint16_t alevent;
|
||||
|
||||
switch(address)
|
||||
{
|
||||
case MBX0_sma:
|
||||
/* TODO *//*case MBX0_sma_b:*/
|
||||
{
|
||||
Esc_readmbx(buf, address, len);
|
||||
break;
|
||||
}
|
||||
case SM2_sma:
|
||||
{
|
||||
ESC_readRXPDO(buf, address, len);
|
||||
break;
|
||||
}
|
||||
case ESCREG_SM0:
|
||||
case ESCREG_SM1:
|
||||
case ESCREG_SM2:
|
||||
case ESCREG_SM3:
|
||||
{
|
||||
bsp_read(escHwPruIcssHandle, buf, address, len);
|
||||
/* Handle special case when SOES batch read SM settings,
|
||||
* indicate that SM ACTIVATE is read
|
||||
*/
|
||||
if(len > 5)
|
||||
{
|
||||
uint8_t n = (address - ESC_ADDR_SYNCMAN) >> 3;
|
||||
bsp_pdi_post_read_indication(escHwPruIcssHandle, ESCREG_SM0ACTIVATE + (n << 3));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
switch(len)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
uint8_t *p = buf;
|
||||
*p = bsp_read_byte(escHwPruIcssHandle, address);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
uint16_t *p = buf;
|
||||
*p = bsp_read_word(escHwPruIcssHandle, address);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
uint32_t *p = buf;
|
||||
*p = bsp_read_dword(escHwPruIcssHandle, address);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
bsp_read(escHwPruIcssHandle, buf, address, len);
|
||||
bsp_pdi_post_read_indication(escHwPruIcssHandle, address);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
alevent = bsp_read_word_isr(escHwPruIcssHandle, ESCREG_ALEVENT);
|
||||
CC_ATOMIC_SET(ESCvar.ALevent, (etohs(alevent)));
|
||||
}
|
||||
|
||||
/** ESC write function used by the Slave stack.
|
||||
*
|
||||
* @param[in] address = address of ESC register to write
|
||||
* @param[out] buf = pointer to buffer to write from
|
||||
* @param[in] len = number of bytes to write
|
||||
*/
|
||||
void ESC_write (uint16_t address, void *buf, uint16_t len)
|
||||
{
|
||||
uint16_t alevent;
|
||||
|
||||
switch(address)
|
||||
{
|
||||
case MBX1_sma:
|
||||
/* TODO *//*case MBX1_sma_b:*/
|
||||
{
|
||||
if(len != 1)
|
||||
{
|
||||
ESC_writembox(buf, address, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsp_pdi_mbx_write_start(escHwPruIcssHandle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (MBX1_sma + MBX1_sml - 1):
|
||||
{
|
||||
/* Handle SM end byte is written */
|
||||
uint8_t * p = buf;
|
||||
bsp_write_byte(escHwPruIcssHandle, *p, address);
|
||||
bsp_pdi_mbx_write_complete(escHwPruIcssHandle);
|
||||
break;
|
||||
}
|
||||
case SM3_sma:
|
||||
{
|
||||
ESC_writeTXPDO(buf, address, len);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
switch(len)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
uint8_t * p = buf;
|
||||
bsp_write_byte(escHwPruIcssHandle, *p, address);
|
||||
bsp_pdi_write_indication(escHwPruIcssHandle, address, *p);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
uint16_t * p = buf;
|
||||
bsp_write_word(escHwPruIcssHandle, *p, address);
|
||||
bsp_pdi_write_indication(escHwPruIcssHandle, address, *p);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
uint32_t * p = buf;
|
||||
bsp_write_dword(escHwPruIcssHandle, *p, address);
|
||||
bsp_pdi_write_indication(escHwPruIcssHandle, address, *p);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
bsp_write(escHwPruIcssHandle, buf, address, len);
|
||||
bsp_pdi_write_indication(escHwPruIcssHandle, address, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
alevent = bsp_read_word_isr(escHwPruIcssHandle, ESCREG_ALEVENT);
|
||||
CC_ATOMIC_SET(ESCvar.ALevent, (etohs(alevent)));
|
||||
}
|
||||
|
||||
/** ESC interrupt enable function by the Slave stack in IRQ mode.
|
||||
*
|
||||
* @param[in] mask = of interrupts to enable
|
||||
*/
|
||||
void ESC_interrupt_enable (uint32_t mask)
|
||||
{
|
||||
uint32_t readmask;
|
||||
readmask = bsp_read_dword_isr(escHwPruIcssHandle,ESCREG_ALEVENTMASK);
|
||||
bsp_write_dword(escHwPruIcssHandle, (mask | readmask), ESCREG_ALEVENTMASK);
|
||||
}
|
||||
|
||||
/** ESC interrupt disable function by the Slave stack in IRQ mode.
|
||||
*
|
||||
* @param[in] mask = interrupts to disable
|
||||
*/
|
||||
void ESC_interrupt_disable (uint32_t mask)
|
||||
{
|
||||
uint32_t readmask;
|
||||
readmask = bsp_read_dword_isr(escHwPruIcssHandle,ESCREG_ALEVENTMASK);
|
||||
bsp_write_dword(escHwPruIcssHandle, (~mask & readmask), ESCREG_ALEVENTMASK);
|
||||
}
|
||||
|
||||
/** ESC emulated EEPROM handler
|
||||
*/
|
||||
void ESC_eep_handler(void)
|
||||
{
|
||||
EEP_process ();
|
||||
EEP_hw_process();
|
||||
}
|
||||
|
||||
/** SYNC0 ISR handler
|
||||
*
|
||||
* @param[in] arg = NOT USED
|
||||
*/
|
||||
void Sync0_Isr (void)
|
||||
{
|
||||
}
|
||||
|
||||
/** SYNC1 ISR handler
|
||||
*
|
||||
* @param[in] arg = NOT USED
|
||||
*/
|
||||
void Sync1_Isr (void)
|
||||
{
|
||||
}
|
||||
|
||||
/** PDI ISR handler
|
||||
*
|
||||
* @param[in] arg = NOT USED
|
||||
*/
|
||||
void PDI_Isr(void)
|
||||
{
|
||||
uint16_t alevent;
|
||||
|
||||
alevent = bsp_read_word_isr(escHwPruIcssHandle,ESCREG_ALEVENT);
|
||||
CC_ATOMIC_SET(ESCvar.ALevent, etohs(alevent));
|
||||
|
||||
if(ESCvar.ALevent & ESCREG_ALEVENT_SM2)
|
||||
{
|
||||
DIG_process(DIG_PROCESS_OUTPUTS_FLAG | DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** ESC and CPU related HW init
|
||||
*
|
||||
* @param[in] arg = esc_cfg provided by the application
|
||||
*/
|
||||
void ESC_init (const esc_cfg_t * config)
|
||||
{
|
||||
escHwPruIcssHandle = pruIcss1Handle;
|
||||
bsp_set_sm_properties(escHwPruIcssHandle, 0, MBX0_sma, MBX0_sml);
|
||||
bsp_set_sm_properties(escHwPruIcssHandle, 1, MBX1_sma, MBX1_sml);
|
||||
bsp_set_sm_properties(escHwPruIcssHandle, 2, SM2_sma, ESCvar.RXPDOsize);
|
||||
bsp_set_sm_properties(escHwPruIcssHandle, 3, SM3_sma, ESCvar.TXPDOsize);
|
||||
|
||||
bsp_write_dword(escHwPruIcssHandle, 0 , ESCREG_ALEVENTMASK);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Licensed under the GNU General Public License version 2 with exceptions. See
|
||||
* LICENSE file in the project root for full license information
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief
|
||||
* ESC hardware specifoc EEPROM emulation functions.
|
||||
*/
|
||||
|
||||
#ifndef __esc_hw__
|
||||
#define __esc_hw__
|
||||
|
||||
#include <cc.h>
|
||||
|
||||
void EEP_hw_process (void);
|
||||
void ESC_eep_handler(void);
|
||||
void ESC_interrupt_enable (uint32_t mask);
|
||||
void ESC_interrupt_disable (uint32_t mask);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Licensed under the GNU General Public License version 2 with exceptions. See
|
||||
* LICENSE file in the project root for full license information
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief
|
||||
* ESC hardware specific EEPROM emulation functions.
|
||||
*/
|
||||
|
||||
#include <cc.h>
|
||||
#include <string.h>
|
||||
#include "esc.h"
|
||||
#include "esc_hw_eep.h"
|
||||
#include "tieschw.h"
|
||||
|
||||
extern const uint8_t _binary_sii_eeprom_bin_start;
|
||||
const unsigned char * tiesc_eeprom = &_binary_sii_eeprom_bin_start;
|
||||
extern uint8_t eeprom_cache[TIESC_EEPROM_SIZE];
|
||||
|
||||
/** Initialize EEPROM emulation (load default data, validate checksums, ...).
|
||||
*
|
||||
*/
|
||||
void EEP_init (void)
|
||||
{
|
||||
}
|
||||
|
||||
/** EEPROM emulation controller side periodic task.
|
||||
*
|
||||
*/
|
||||
void EEP_hw_process (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/** EEPROM read function
|
||||
*
|
||||
* @param[in] addr = EEPROM byte address
|
||||
* @param[out] data = pointer to buffer of output data
|
||||
* @param[in] count = number of bytes to read
|
||||
* @return 0 on OK, 1 on error
|
||||
*/
|
||||
int8_t EEP_read (uint32_t addr, uint8_t *data, uint16_t count)
|
||||
{
|
||||
if (addr >= TIESC_EEPROM_SIZE) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* read data from ram buffer */
|
||||
memcpy(data, eeprom_cache + addr, count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** EEPROM write function
|
||||
*
|
||||
* @param[in] addr = EEPROM byte address
|
||||
* @param[out] data = pointer to buffer of input data
|
||||
* @param[in] count = number of bytes to write
|
||||
* @return 0 on OK, 1 on error
|
||||
*/
|
||||
int8_t EEP_write (uint32_t addr, uint8_t *data, uint16_t count)
|
||||
{
|
||||
|
||||
/* write data to ram buffer */
|
||||
memcpy(eeprom_cache + addr, data, count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed under the GNU General Public License version 2 with exceptions. See
|
||||
* LICENSE file in the project root for full license information
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief
|
||||
* ESC hardware specifoc EEPROM emulation functions.
|
||||
*/
|
||||
|
||||
#ifndef __esc_hw_eep__
|
||||
#define __esc_hw_eep__
|
||||
|
||||
#include <cc.h>
|
||||
#include "esc_eep.h"
|
||||
|
||||
|
||||
/* periodic task */
|
||||
void EEP_hw_process (void);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue