Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions soes/esc.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ CC_STATIC_ASSERT((MBXSIZE > ESC_MBXHSIZE) && (MBXSIZEBOOT > ESC_MBXHSIZE), "Mail
* State machine and mailbox support.
*/

/** Update and set cnt value for a desired mailbox out buffer.
*
* @param[in] n = Index of mailbox buffer.
*/
static void setmbxoutcnt (uint8_t const n)
{
ESCvar.mbxcnt = (ESCvar.mbxcnt + 1U) & 0x07U;
if (ESCvar.mbxcnt == 0U)
{
ESCvar.mbxcnt = 1U;
}
((_MBXh*)&MBX[n * ESC_MBXSIZE])->mbxcnt = ESCvar.mbxcnt;
}

/** Write AL Status Code to the ESC.
*
* @param[in] errornumber = Write an by EtherCAT specified Error number register 0x134 AL Status Code
Expand Down Expand Up @@ -416,6 +430,7 @@ void ESC_stopmbx (void)
ESCvar.xoe = 0;
ESCvar.mbxfree = 1;
ESCvar.toggle = 0;
ESCvar.mbxcnt = 0;
ESCvar.mbxincnt = 0;
ESCvar.segmented = 0;
ESCvar.frags = 0;
Expand Down Expand Up @@ -488,7 +503,7 @@ void ESC_ackmbxread (void)

/** Allocate and prepare a mailbox buffer. Take the first Idle buffer from the End.
* Set Mailbox control state to be used for outbox and fill the mailbox buffer with
* address master and mailbox next CNT value between 1-7.
* address master.
*
* @return The index of Mailbox buffer prepared for outbox. IF no buffer is available return 0.
*/
Expand All @@ -504,16 +519,10 @@ uint8_t ESC_claimbuffer (void)
{
MBXcontrol[n].state = MBXstate_outclaim;
MBh = (_MBXh *)&MBX[n * ESC_MBXSIZE];
ESCvar.mbxcnt++;
ESCvar.mbxcnt = (ESCvar.mbxcnt & 0x07);
if (ESCvar.mbxcnt == 0)
{
ESCvar.mbxcnt = 1;
}
MBh->address = htoes (0x0000); // destination is master
MBh->channel = 0;
MBh->priority = 0;
MBh->mbxcnt = ESCvar.mbxcnt & 0xFU;
MBh->reserved = 0;
ESCvar.txcue++;
}
return n;
Expand All @@ -532,6 +541,7 @@ uint8_t ESC_outreqbuffer (void)
}
return n;
}

/** Allocate and prepare a mailbox buffer for sending an error message. Take the first Idle
* buffer from the end. Set Mailbox control state to be used for outbox and fill the mailbox
* buffer with error information.
Expand Down Expand Up @@ -641,6 +651,7 @@ uint8_t ESC_mbxprocess (void)
/* outmbx empty and outreq mbx available */
if (mbxhandle)
{
setmbxoutcnt (mbxhandle);
ESC_writembx (mbxhandle);
/* Refresh SM status */
ESC_SMstatus (1);
Expand Down
6 changes: 4 additions & 2 deletions soes/esc.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,16 @@ typedef struct CC_PACKED
uint8_t priority:2;

uint8_t mbxtype:4;
uint8_t mbxcnt:4;
uint8_t mbxcnt:3;
uint8_t reserved:1;
#endif

#if defined(EC_BIG_ENDIAN)
uint8_t priority:2;
uint8_t channel:6;

uint8_t mbxcnt:4;
uint8_t reserved:1;
uint8_t mbxcnt:3;
uint8_t mbxtype:4;
#endif
} _MBXh;
Expand Down
6 changes: 6 additions & 0 deletions soes/esc_coe.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define __esc_coe__

#include <cc.h>
#include "options.h"


typedef struct
Expand Down Expand Up @@ -133,6 +134,11 @@ extern uint32_t ESC_upload_pre_objecthandler (uint16_t index,
size_t *size,
uint16_t flags);
extern uint32_t ESC_upload_post_objecthandler (uint16_t index, uint8_t subindex, uint16_t flags);

#if USE_CONST_OBJECTLIST
extern const _objectlist SDOobjects[];
#else
extern _objectlist SDOobjects[];
#endif

#endif
5 changes: 5 additions & 0 deletions soes/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
/* User-defined options, Options defined here will override default values */
#include "ecat_options.h"

/* SDOobjects to be provided as const */
#ifndef USE_CONST_OBJECTLIST
#define USE_CONST_OBJECTLIST 1
#endif

/* FoE support */
#ifndef USE_FOE
#define USE_FOE 1
Expand Down
Loading