use C99 types
parent
fa7a68381e
commit
1dd230f742
|
@ -70,10 +70,10 @@ void boot_inithook (void)
|
|||
}
|
||||
}
|
||||
|
||||
uint32 flash_foe_buffer (foe_writefile_cfg_t * self, uint8 * data)
|
||||
uint32_t flash_foe_buffer (foe_writefile_cfg_t * self, uint8_t * data)
|
||||
{
|
||||
uint32 flash_cmd_failed = 0;
|
||||
uint32 calculated_address = self->dest_start_address + self->address_offset;
|
||||
uint32_t flash_cmd_failed = 0;
|
||||
uint32_t calculated_address = self->dest_start_address + self->address_offset;
|
||||
|
||||
/* This part is Cortex M4 Kinetis specific therefore placed in Hooks*/
|
||||
/* Erase every new sector we enter by looking at modulo sector size */
|
||||
|
@ -137,11 +137,11 @@ void bootstrap_foe_init (void)
|
|||
},
|
||||
};
|
||||
|
||||
static uint8 fbuf[FLASH_WRITE_BLOCK_SIZE];
|
||||
static uint8_t fbuf[FLASH_WRITE_BLOCK_SIZE];
|
||||
static foe_cfg_t config =
|
||||
{
|
||||
.buffer_size = FLASH_WRITE_BLOCK_SIZE, /* Buffer size before we flush to destination */
|
||||
.fbuffer = (uint8 *)&fbuf,
|
||||
.fbuffer = (uint8_t *)&fbuf,
|
||||
.empty_write = 0xFF,
|
||||
.n_files = NELEMENTS (files),
|
||||
.files = files
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
extern _Rbuffer Rb;
|
||||
extern _Wbuffer Wb;
|
||||
extern _Cbuffer Cb;
|
||||
extern uint32 encoder_scale;
|
||||
extern uint32 encoder_scale_mirror;
|
||||
extern uint32_t encoder_scale;
|
||||
extern uint32_t encoder_scale_mirror;
|
||||
|
||||
static const char acName1000[] = "Device Type";
|
||||
static const char acName1008[] = "Manufacturer Device Name";
|
||||
|
|
|
@ -48,26 +48,26 @@
|
|||
#define DEFAULTTXPDOITEMS 1
|
||||
#define DEFAULTRXPDOITEMS 1
|
||||
|
||||
uint32 encoder_scale;
|
||||
uint32 encoder_scale_mirror;
|
||||
uint32_t encoder_scale;
|
||||
uint32_t encoder_scale_mirror;
|
||||
|
||||
volatile _ESCvar ESCvar;
|
||||
_MBX MBX[MBXBUFFERS];
|
||||
_MBXcontrol MBXcontrol[MBXBUFFERS];
|
||||
uint8 MBXrun=0;
|
||||
uint16 SM2_sml,SM3_sml;
|
||||
uint8_t MBXrun=0;
|
||||
uint16_t SM2_sml,SM3_sml;
|
||||
_Rbuffer Rb;
|
||||
_Wbuffer Wb;
|
||||
_Cbuffer Cb;
|
||||
_App App;
|
||||
uint16 TXPDOsize,RXPDOsize;
|
||||
uint16_t TXPDOsize,RXPDOsize;
|
||||
int wd_cnt = WD_RESET;
|
||||
volatile uint8 digoutput;
|
||||
volatile uint8 diginput;
|
||||
uint16 txpdomap = DEFAULTTXPDOMAP;
|
||||
uint16 rxpdomap = DEFAULTRXPDOMAP;
|
||||
uint8 txpdoitems = DEFAULTTXPDOITEMS;
|
||||
uint8 rxpdoitems = DEFAULTTXPDOITEMS;
|
||||
volatile uint8_t digoutput;
|
||||
volatile uint8_t diginput;
|
||||
uint16_t txpdomap = DEFAULTTXPDOMAP;
|
||||
uint16_t rxpdomap = DEFAULTRXPDOMAP;
|
||||
uint8_t txpdoitems = DEFAULTTXPDOITEMS;
|
||||
uint8_t rxpdoitems = DEFAULTTXPDOITEMS;
|
||||
|
||||
|
||||
extern uint32_t local_boot_state;
|
||||
|
@ -80,7 +80,7 @@ static const char *spi_name = "/spi0/et1100";
|
|||
* @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 index, uint8 subindex)
|
||||
void ESC_objecthandler (uint16_t index, uint8_t subindex)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
|
@ -209,7 +209,7 @@ void DIG_process (void)
|
|||
/** Optional: Hook called after state change for application specific
|
||||
* actions for specific state changes.
|
||||
*/
|
||||
void post_state_change_hook (uint8 * as, uint8 * an)
|
||||
void post_state_change_hook (uint8_t * as, uint8_t * an)
|
||||
{
|
||||
|
||||
/* Add specific step change hooks here */
|
||||
|
|
|
@ -41,19 +41,19 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
uint8 state;
|
||||
uint8 button;
|
||||
uint32 encoder;
|
||||
uint8_t state;
|
||||
uint8_t button;
|
||||
uint32_t encoder;
|
||||
} _Rbuffer;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 LED;
|
||||
uint8_t LED;
|
||||
} _Wbuffer;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 reset_counter;
|
||||
uint32_t reset_counter;
|
||||
} _Cbuffer;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,13 +9,6 @@ extern "C"
|
|||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint8_t uint8;
|
||||
typedef int8_t int8;
|
||||
typedef uint16_t uint16;
|
||||
typedef int16_t int16;
|
||||
typedef uint32_t uint32;
|
||||
typedef int32_t int32;
|
||||
|
||||
#define CC_PACKED_BEGIN
|
||||
#define CC_PACKED_END
|
||||
#define CC_PACKED __attribute__((packed))
|
||||
|
|
|
@ -51,18 +51,18 @@
|
|||
#define ESC_NEXT 0x00
|
||||
|
||||
static int et1100 = -1;
|
||||
static uint8 read_termination[128] = { 0 };
|
||||
static uint8_t read_termination[128] = { 0 };
|
||||
|
||||
#define GPIO_ECAT_RESET 1 /* specific function to hold ESC reset on startup
|
||||
* when emulating EEPROM
|
||||
*/
|
||||
|
||||
static void esc_address (uint16 address, uint8 command, uint16 * al_event)
|
||||
static void esc_address (uint16_t address, uint8_t command, uint16_t * al_event)
|
||||
{
|
||||
/* Device is selected already.
|
||||
* We use 2 bytes addressing.
|
||||
*/
|
||||
uint8 data[2];
|
||||
uint8_t data[2];
|
||||
|
||||
/* address 12:5 */
|
||||
data[0] = (address >> 5);
|
||||
|
@ -70,7 +70,7 @@ static void esc_address (uint16 address, uint8 command, uint16 * al_event)
|
|||
data[1] = ((address & 0x1F) << 3) | command;
|
||||
|
||||
/* Write (and read AL interrupt register) */
|
||||
spi_bidirectionally_transfer (et1100, (uint8 *) al_event, data,
|
||||
spi_bidirectionally_transfer (et1100, (uint8_t *) al_event, data,
|
||||
sizeof (data));
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ static void esc_address (uint16 address, uint8 command, uint16 * al_event)
|
|||
* @param[out] tALevent = on every read we refresh the AL event register
|
||||
* @return 0 as default, the stack don't rely on any result
|
||||
*/
|
||||
uint8 ESC_read (uint16 address, void *buf, uint16 len, void *tALevent)
|
||||
uint8_t ESC_read (uint16_t address, void *buf, uint16_t len, void *tALevent)
|
||||
{
|
||||
/* Select device. */
|
||||
spi_select (et1100);
|
||||
|
@ -111,7 +111,7 @@ uint8 ESC_read (uint16 address, void *buf, uint16 len, void *tALevent)
|
|||
* @param[out] tALevent = on every read we refresh the AL event register
|
||||
* @return 0 as default, the stack don't rely on any result
|
||||
*/
|
||||
uint8 ESC_write (uint16 address, void *buf, uint16 len, void *tALevent)
|
||||
uint8_t ESC_write (uint16_t address, void *buf, uint16_t len, void *tALevent)
|
||||
{
|
||||
/* Select device. */
|
||||
spi_select (et1100);
|
||||
|
|
86
soes/esc.c
86
soes/esc.c
|
@ -45,9 +45,9 @@ static esc_cfg_t * esc_cfg = NULL;
|
|||
*
|
||||
* @param[in] errornumber = Write an by EtherCAT specified Error number register 0x134 AL Status Code
|
||||
*/
|
||||
void ESC_ALerror (uint16 errornumber)
|
||||
void ESC_ALerror (uint16_t errornumber)
|
||||
{
|
||||
uint16 dummy;
|
||||
uint16_t dummy;
|
||||
ESCvar.ALerror = errornumber;
|
||||
dummy = htoes (errornumber);
|
||||
ESC_write (ESCREG_ALERROR, &dummy, sizeof (dummy), (void *) &ESCvar.ALevent);
|
||||
|
@ -57,11 +57,11 @@ void ESC_ALerror (uint16 errornumber)
|
|||
* @param[in] status = Write current slave status to register 0x130 AL Status
|
||||
* reflecting actual state and error indication if present
|
||||
*/
|
||||
void ESC_ALstatus (uint8 status)
|
||||
void ESC_ALstatus (uint8_t status)
|
||||
{
|
||||
uint16 dummy;
|
||||
uint16_t dummy;
|
||||
ESCvar.ALstatus = status;
|
||||
dummy = htoes ((uint16) status);
|
||||
dummy = htoes ((uint16_t) status);
|
||||
ESC_write (ESCREG_ALSTATUS, &dummy, sizeof (dummy),
|
||||
(void *) &ESCvar.ALevent);
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ void ESC_ALstatus (uint8 status)
|
|||
*
|
||||
* @param[in] n = Read Sync Manager no. n
|
||||
*/
|
||||
void ESC_SMack (uint8 n)
|
||||
void ESC_SMack (uint8_t n)
|
||||
{
|
||||
uint16 dummy;
|
||||
uint16_t dummy;
|
||||
ESC_read (ESCREG_SM0STATUS + (n << 3), &dummy, 2, (void *) &ESCvar.ALevent);
|
||||
}
|
||||
|
||||
|
@ -82,10 +82,10 @@ void ESC_SMack (uint8 n)
|
|||
*
|
||||
* @param[in] n = Read Sync Manager no. n
|
||||
*/
|
||||
void ESC_SMstatus (uint8 n)
|
||||
void ESC_SMstatus (uint8_t n)
|
||||
{
|
||||
_ESCsm2 *sm;
|
||||
uint16 temp;
|
||||
uint16_t temp;
|
||||
sm = (_ESCsm2 *) & ESCvar.SM[n];
|
||||
ESC_read (ESCREG_SM0STATUS + (n << 3), &temp, 2, (void *) &ESCvar.ALevent);
|
||||
#if defined(EC_LITTLE_ENDIAN)
|
||||
|
@ -103,7 +103,7 @@ void ESC_SMstatus (uint8 n)
|
|||
*
|
||||
* @param[in] n = Write to Sync Manager no. n
|
||||
*/
|
||||
void ESC_SMwritepdi (uint8 n)
|
||||
void ESC_SMwritepdi (uint8_t n)
|
||||
{
|
||||
_ESCsm2 *sm;
|
||||
sm = (_ESCsm2 *) & ESCvar.SM[n];
|
||||
|
@ -115,7 +115,7 @@ void ESC_SMwritepdi (uint8 n)
|
|||
*
|
||||
* @param[in] n = Write to Sync Manager no. n
|
||||
*/
|
||||
void ESC_SMenable (uint8 n)
|
||||
void ESC_SMenable (uint8_t n)
|
||||
{
|
||||
_ESCsm2 *sm;
|
||||
sm = (_ESCsm2 *) & ESCvar.SM[n];
|
||||
|
@ -126,7 +126,7 @@ void ESC_SMenable (uint8 n)
|
|||
*
|
||||
* @param[in] n = Write to Sync Manager no. n
|
||||
*/
|
||||
void ESC_SMdisable (uint8 n)
|
||||
void ESC_SMdisable (uint8_t n)
|
||||
{
|
||||
_ESCsm2 *sm;
|
||||
sm = (_ESCsm2 *) & ESCvar.SM[n];
|
||||
|
@ -147,12 +147,12 @@ void ESC_address (void)
|
|||
*
|
||||
* @return value of register Watchdog Status.
|
||||
*/
|
||||
uint8 ESC_WDstatus (void)
|
||||
uint8_t ESC_WDstatus (void)
|
||||
{
|
||||
uint16 wdstatus;
|
||||
uint16_t wdstatus;
|
||||
ESC_read (ESCREG_WDSTATUS, &wdstatus, 2, (void *) &ESCvar.ALevent);
|
||||
wdstatus = etohs (wdstatus);
|
||||
return (uint8) wdstatus;
|
||||
return (uint8_t) wdstatus;
|
||||
}
|
||||
|
||||
/** Check mailbox status by reading all SyncManager 0 and 1 data. The read values
|
||||
|
@ -164,7 +164,7 @@ uint8 ESC_WDstatus (void)
|
|||
* @return if all Mailbox values is correct we return incoming state request, otherwise
|
||||
* we return state Init with Error flag set.
|
||||
*/
|
||||
uint8 ESC_checkmbx (uint8 state)
|
||||
uint8_t ESC_checkmbx (uint8_t state)
|
||||
{
|
||||
_ESCsm2 *SM;
|
||||
ESC_read (ESCREG_SM0, (void *) &ESCvar.SM[0], sizeof (ESCvar.SM[0]),
|
||||
|
@ -178,7 +178,7 @@ uint8 ESC_checkmbx (uint8 state)
|
|||
ESCvar.SMtestresult = SMRESULT_ERRSM0;
|
||||
ESC_SMdisable (0);
|
||||
ESC_SMdisable (1);
|
||||
return (uint8) (ESCinit | ESCerror); //fail state change
|
||||
return (uint8_t) (ESCinit | ESCerror); //fail state change
|
||||
}
|
||||
SM = (_ESCsm2 *) & ESCvar.SM[1];
|
||||
if ((etohs (SM->PSA) != MBX1_sma) || (etohs (SM->Length) != MBX1_sml)
|
||||
|
@ -200,7 +200,7 @@ uint8 ESC_checkmbx (uint8 state)
|
|||
* @return if all Mailbox values is correct we return incoming state, otherwise
|
||||
* we return state Init with Error flag set.
|
||||
*/
|
||||
uint8 ESC_startmbx (uint8 state)
|
||||
uint8_t ESC_startmbx (uint8_t state)
|
||||
{
|
||||
ESC_SMenable (0);
|
||||
ESC_SMenable (1);
|
||||
|
@ -227,7 +227,7 @@ uint8 ESC_startmbx (uint8 state)
|
|||
* @return if all Mailbox values is correct we return incoming state request, otherwise
|
||||
* we return state Init with Error flag set.
|
||||
*/
|
||||
uint8 ESC_checkmbxboot (uint8 state)
|
||||
uint8_t ESC_checkmbxboot (uint8_t state)
|
||||
{
|
||||
_ESCsm2 *SM;
|
||||
ESC_read (ESCREG_SM0, (void *) &ESCvar.SM[0], sizeof (ESCvar.SM[0]),
|
||||
|
@ -241,7 +241,7 @@ uint8 ESC_checkmbxboot (uint8 state)
|
|||
ESCvar.SMtestresult = SMRESULT_ERRSM0;
|
||||
ESC_SMdisable (0);
|
||||
ESC_SMdisable (1);
|
||||
return (uint8) (ESCinit | ESCerror); //fail state change
|
||||
return (uint8_t) (ESCinit | ESCerror); //fail state change
|
||||
}
|
||||
SM = (_ESCsm2 *) & ESCvar.SM[1];
|
||||
if ((etohs (SM->PSA) != MBX1_sma_b) || (etohs (SM->Length) != MBX1_sml_b)
|
||||
|
@ -250,7 +250,7 @@ uint8 ESC_checkmbxboot (uint8 state)
|
|||
ESCvar.SMtestresult = SMRESULT_ERRSM1;
|
||||
ESC_SMdisable (0);
|
||||
ESC_SMdisable (1);
|
||||
return (uint8) (ESCinit | ESCerror); //fail state change
|
||||
return (uint8_t) (ESCinit | ESCerror); //fail state change
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ uint8 ESC_checkmbxboot (uint8 state)
|
|||
* @return if all Mailbox values is correct we return incoming state, otherwise
|
||||
* we return state Init with Error flag set.
|
||||
*/
|
||||
uint8 ESC_startmbxboot (uint8 state)
|
||||
uint8_t ESC_startmbxboot (uint8_t state)
|
||||
{
|
||||
ESC_SMenable (0);
|
||||
ESC_SMenable (1);
|
||||
|
@ -288,7 +288,7 @@ uint8 ESC_startmbxboot (uint8 state)
|
|||
*/
|
||||
void ESC_stopmbx (void)
|
||||
{
|
||||
uint8 n;
|
||||
uint8_t n;
|
||||
MBXrun = 0;
|
||||
ESC_SMdisable (0);
|
||||
ESC_SMdisable (1);
|
||||
|
@ -315,7 +315,7 @@ void ESC_stopmbx (void)
|
|||
void ESC_readmbx (void)
|
||||
{
|
||||
_MBX *MB = &MBX[0];
|
||||
uint16 length;
|
||||
uint16_t length;
|
||||
|
||||
if (ESCvar.ALstatus == ESCboot)
|
||||
{
|
||||
|
@ -357,11 +357,11 @@ void ESC_readmbx (void)
|
|||
*
|
||||
* @param[in] n = Which local mailbox buffer n to send.
|
||||
*/
|
||||
void ESC_writembx (uint8 n)
|
||||
void ESC_writembx (uint8_t n)
|
||||
{
|
||||
_MBX *MB = &MBX[n];
|
||||
uint8 dummy = 0;
|
||||
uint16 length;
|
||||
uint8_t dummy = 0;
|
||||
uint16_t length;
|
||||
length = etohs (MB->header.length);
|
||||
if (ESCvar.ALstatus == ESCboot)
|
||||
{
|
||||
|
@ -394,7 +394,7 @@ void ESC_writembx (uint8 n)
|
|||
*/
|
||||
void ESC_ackmbxread (void)
|
||||
{
|
||||
uint8 dummy = 0;
|
||||
uint8_t dummy = 0;
|
||||
if (ESCvar.ALstatus == ESCboot)
|
||||
{
|
||||
ESC_write (MBX1_sma_b, &dummy, 1, (void *) &ESCvar.ALevent);
|
||||
|
@ -412,10 +412,10 @@ void ESC_ackmbxread (void)
|
|||
*
|
||||
* @return The index of Mailbox buffer prepared for outbox. IF no buffer is available return 0.
|
||||
*/
|
||||
uint8 ESC_claimbuffer (void)
|
||||
uint8_t ESC_claimbuffer (void)
|
||||
{
|
||||
_MBX *MB;
|
||||
uint8 n = MBXBUFFERS - 1;
|
||||
uint8_t n = MBXBUFFERS - 1;
|
||||
while ((n > 0) && (MBXcontrol[n].state))
|
||||
{
|
||||
n--;
|
||||
|
@ -442,9 +442,9 @@ uint8 ESC_claimbuffer (void)
|
|||
*
|
||||
* @return the index of Mailbox buffer ready to be posted.
|
||||
*/
|
||||
uint8 ESC_outreqbuffer (void)
|
||||
uint8_t ESC_outreqbuffer (void)
|
||||
{
|
||||
uint8 n = MBXBUFFERS - 1;
|
||||
uint8_t n = MBXBUFFERS - 1;
|
||||
while ((n > 0) && (MBXcontrol[n].state != MBXstate_outreq))
|
||||
{
|
||||
n--;
|
||||
|
@ -457,17 +457,17 @@ uint8 ESC_outreqbuffer (void)
|
|||
*
|
||||
* @param[in] n = Error number to be sent in mailbox error message.
|
||||
*/
|
||||
void MBX_error (uint16 error)
|
||||
void MBX_error (uint16_t error)
|
||||
{
|
||||
uint8 MBXout;
|
||||
uint8_t MBXout;
|
||||
_MBXerr *mbxerr;
|
||||
MBXout = ESC_claimbuffer ();
|
||||
if (MBXout)
|
||||
{
|
||||
mbxerr = (_MBXerr *) & MBX[MBXout];
|
||||
mbxerr->mbxheader.length = htoes ((uint16) 0x04);
|
||||
mbxerr->mbxheader.length = htoes ((uint16_t) 0x04);
|
||||
mbxerr->mbxheader.mbxtype = MBXERR;
|
||||
mbxerr->type = htoes ((uint16) 0x01);
|
||||
mbxerr->type = htoes ((uint16_t) 0x01);
|
||||
mbxerr->detail = htoes (error);
|
||||
MBXcontrol[MBXout].state = MBXstate_outreq;
|
||||
}
|
||||
|
@ -479,9 +479,9 @@ void MBX_error (uint16 error)
|
|||
*
|
||||
* @return =0 if nothing to do. =1 if something to be handled by mailbox protocols.
|
||||
*/
|
||||
uint8 ESC_mbxprocess (void)
|
||||
uint8_t ESC_mbxprocess (void)
|
||||
{
|
||||
uint8 mbxhandle = 0;
|
||||
uint8_t mbxhandle = 0;
|
||||
_MBX *MB = &MBX[0];
|
||||
|
||||
if (!MBXrun)
|
||||
|
@ -637,7 +637,7 @@ void ESC_xoeprocess (void)
|
|||
* @param[in] state = Requested state.
|
||||
* @return = incoming state request if every thing checks out OK. = state (PREOP | ERROR) if something isn't correct.
|
||||
*/
|
||||
uint8 ESC_checkSM23 (uint8 state)
|
||||
uint8_t ESC_checkSM23 (uint8_t state)
|
||||
{
|
||||
_ESCsm2 *SM;
|
||||
ESC_read (ESCREG_SM2, (void *) &ESCvar.SM[2], sizeof (ESCvar.SM[2]),
|
||||
|
@ -670,7 +670,7 @@ uint8 ESC_checkSM23 (uint8 state)
|
|||
* @param[in] state = Requested state.
|
||||
* @return = state, incoming state request if every thing checks out OK. =state (PREOP | ERROR) if something isn't correct.
|
||||
*/
|
||||
uint8 ESC_startinput (uint8 state)
|
||||
uint8_t ESC_startinput (uint8_t state)
|
||||
{
|
||||
state = ESC_checkSM23 (state);
|
||||
if (state != (ESCpreop | ESCerror))
|
||||
|
@ -713,7 +713,7 @@ void ESC_stopinput (void)
|
|||
* @return = state unchanged.
|
||||
*
|
||||
*/
|
||||
uint8 ESC_startoutput (uint8 state)
|
||||
uint8_t ESC_startoutput (uint8_t state)
|
||||
{
|
||||
ESC_SMenable (2);
|
||||
App.state |= APPSTATE_OUTPUT;
|
||||
|
@ -737,8 +737,8 @@ void ESC_stopoutput (void)
|
|||
*/
|
||||
void ESC_state (void)
|
||||
{
|
||||
uint8 ac, an, as, ax, ax23;
|
||||
uint8 handle_smchanged = 0;
|
||||
uint8_t ac, an, as, ax, ax23;
|
||||
uint8_t handle_smchanged = 0;
|
||||
|
||||
/* Do we have a state change request pending */
|
||||
if (ESCvar.ALevent & ESCREG_ALEVENT_CONTROL)
|
||||
|
|
274
soes/esc.h
274
soes/esc.h
|
@ -209,185 +209,185 @@
|
|||
// Attention! this struct is always little-endian
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16 PSA;
|
||||
uint16 Length;
|
||||
uint16_t PSA;
|
||||
uint16_t Length;
|
||||
|
||||
#if defined(EC_LITTLE_ENDIAN)
|
||||
uint8 Mode:2;
|
||||
uint8 Direction:2;
|
||||
uint8 IntECAT:1;
|
||||
uint8 IntPDI:1;
|
||||
uint8 WTE:1;
|
||||
uint8 R1:1;
|
||||
uint8_t Mode:2;
|
||||
uint8_t Direction:2;
|
||||
uint8_t IntECAT:1;
|
||||
uint8_t IntPDI:1;
|
||||
uint8_t WTE:1;
|
||||
uint8_t R1:1;
|
||||
|
||||
uint8 IntW:1;
|
||||
uint8 IntR:1;
|
||||
uint8 R2:1;
|
||||
uint8 MBXstat:1;
|
||||
uint8 BUFstat:2;
|
||||
uint8 R3:2;
|
||||
uint8_t IntW:1;
|
||||
uint8_t IntR:1;
|
||||
uint8_t R2:1;
|
||||
uint8_t MBXstat:1;
|
||||
uint8_t BUFstat:2;
|
||||
uint8_t R3:2;
|
||||
|
||||
uint8 ECsm:1;
|
||||
uint8 ECrep:1;
|
||||
uint8 ECr4:4;
|
||||
uint8 EClatchEC:1;
|
||||
uint8 EClatchPDI:1;
|
||||
uint8_t ECsm:1;
|
||||
uint8_t ECrep:1;
|
||||
uint8_t ECr4:4;
|
||||
uint8_t EClatchEC:1;
|
||||
uint8_t EClatchPDI:1;
|
||||
|
||||
uint8 PDIsm:1;
|
||||
uint8 PDIrep:1;
|
||||
uint8 PDIr5:6;
|
||||
uint8_t PDIsm:1;
|
||||
uint8_t PDIrep:1;
|
||||
uint8_t PDIr5:6;
|
||||
#endif
|
||||
|
||||
#if defined(EC_BIG_ENDIAN)
|
||||
uint8 R1:1;
|
||||
uint8 WTE:1;
|
||||
uint8 IntPDI:1;
|
||||
uint8 IntECAT:1;
|
||||
uint8 Direction:2;
|
||||
uint8 Mode:2;
|
||||
uint8_t R1:1;
|
||||
uint8_t WTE:1;
|
||||
uint8_t IntPDI:1;
|
||||
uint8_t IntECAT:1;
|
||||
uint8_t Direction:2;
|
||||
uint8_t Mode:2;
|
||||
|
||||
uint8 R3:2;
|
||||
uint8 BUFstat:2;
|
||||
uint8 MBXstat:1;
|
||||
uint8 R2:1;
|
||||
uint8 IntR:1;
|
||||
uint8 IntW:1;
|
||||
uint8_t R3:2;
|
||||
uint8_t BUFstat:2;
|
||||
uint8_t MBXstat:1;
|
||||
uint8_t R2:1;
|
||||
uint8_t IntR:1;
|
||||
uint8_t IntW:1;
|
||||
|
||||
uint8 EClatchPDI:1;
|
||||
uint8 EClatchEC:1;
|
||||
uint8 ECr4:4;
|
||||
uint8 ECrep:1;
|
||||
uint8 ECsm:1;
|
||||
uint8_t EClatchPDI:1;
|
||||
uint8_t EClatchEC:1;
|
||||
uint8_t ECr4:4;
|
||||
uint8_t ECrep:1;
|
||||
uint8_t ECsm:1;
|
||||
|
||||
uint8 PDIr5:6;
|
||||
uint8 PDIrep:1;
|
||||
uint8 PDIsm:1;
|
||||
uint8_t PDIr5:6;
|
||||
uint8_t PDIrep:1;
|
||||
uint8_t PDIsm:1;
|
||||
#endif
|
||||
} _ESCsm;
|
||||
|
||||
/* Attention! this struct is always little-endian */
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16 PSA;
|
||||
uint16 Length;
|
||||
uint8 Command;
|
||||
uint8 Status;
|
||||
uint8 ActESC;
|
||||
uint8 ActPDI;
|
||||
uint16_t PSA;
|
||||
uint16_t Length;
|
||||
uint8_t Command;
|
||||
uint8_t Status;
|
||||
uint8_t ActESC;
|
||||
uint8_t ActPDI;
|
||||
} _ESCsm2;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16 PSA;
|
||||
uint16 Length;
|
||||
uint8 Command;
|
||||
uint16_t PSA;
|
||||
uint16_t Length;
|
||||
uint8_t Command;
|
||||
} _ESCsmCompact;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16 ALevent;
|
||||
uint16 ALstatus;
|
||||
uint16 ALcontrol;
|
||||
uint16 ALerror;
|
||||
uint16 DLstatus;
|
||||
uint16 address;
|
||||
uint8 mbxcnt;
|
||||
uint8 mbxincnt;
|
||||
uint8 mbxoutpost;
|
||||
uint8 mbxbackup;
|
||||
uint8 xoe;
|
||||
uint8 txcue;
|
||||
uint8 mbxfree;
|
||||
uint8 segmented;
|
||||
uint16_t ALevent;
|
||||
uint16_t ALstatus;
|
||||
uint16_t ALcontrol;
|
||||
uint16_t ALerror;
|
||||
uint16_t DLstatus;
|
||||
uint16_t address;
|
||||
uint8_t mbxcnt;
|
||||
uint8_t mbxincnt;
|
||||
uint8_t mbxoutpost;
|
||||
uint8_t mbxbackup;
|
||||
uint8_t xoe;
|
||||
uint8_t txcue;
|
||||
uint8_t mbxfree;
|
||||
uint8_t segmented;
|
||||
void *data;
|
||||
uint16 entries;
|
||||
uint16 frags;
|
||||
uint16 fragsleft;
|
||||
uint16_t entries;
|
||||
uint16_t frags;
|
||||
uint16_t fragsleft;
|
||||
|
||||
#if defined(EC_LITTLE_ENDIAN)
|
||||
uint8 r1:1;
|
||||
uint8 toggle:1;
|
||||
uint8 r2:6;
|
||||
uint8_t r1:1;
|
||||
uint8_t toggle:1;
|
||||
uint8_t r2:6;
|
||||
#endif
|
||||
|
||||
#if defined(EC_BIG_ENDIAN)
|
||||
uint8 r2:6;
|
||||
uint8 toggle:1;
|
||||
uint8 r1:1;
|
||||
uint8_t r2:6;
|
||||
uint8_t toggle:1;
|
||||
uint8_t r1:1;
|
||||
#endif
|
||||
|
||||
uint8 SMtestresult;
|
||||
int16 temp;
|
||||
uint16 wdcnt;
|
||||
uint32 PrevTime;
|
||||
uint32 Time;
|
||||
uint8_t SMtestresult;
|
||||
int16_t temp;
|
||||
uint16_t wdcnt;
|
||||
uint32_t PrevTime;
|
||||
uint32_t Time;
|
||||
_ESCsm SM[4];
|
||||
} _ESCvar;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16 length;
|
||||
uint16 address;
|
||||
uint16_t length;
|
||||
uint16_t address;
|
||||
|
||||
#if defined(EC_LITTLE_ENDIAN)
|
||||
uint8 channel:6;
|
||||
uint8 priority:2;
|
||||
uint8_t channel:6;
|
||||
uint8_t priority:2;
|
||||
|
||||
uint8 mbxtype:4;
|
||||
uint8 mbxcnt:4;
|
||||
uint8_t mbxtype:4;
|
||||
uint8_t mbxcnt:4;
|
||||
#endif
|
||||
|
||||
#if defined(EC_BIG_ENDIAN)
|
||||
uint8 priority:2;
|
||||
uint8 channel:6;
|
||||
uint8_t priority:2;
|
||||
uint8_t channel:6;
|
||||
|
||||
uint8 mbxcnt:4;
|
||||
uint8 mbxtype:4;
|
||||
uint8_t mbxcnt:4;
|
||||
uint8_t mbxtype:4;
|
||||
#endif
|
||||
} _MBXh;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
_MBXh header;
|
||||
uint8 b[MBXDSIZE];
|
||||
uint8_t b[MBXDSIZE];
|
||||
} _MBX;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16 numberservice;
|
||||
uint16_t numberservice;
|
||||
} _COEh;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
#if defined(EC_LITTLE_ENDIAN)
|
||||
uint8 opcode:7;
|
||||
uint8 incomplete:1;
|
||||
uint8_t opcode:7;
|
||||
uint8_t incomplete:1;
|
||||
#endif
|
||||
|
||||
#if defined(EC_BIG_ENDIAN)
|
||||
uint8 incomplete:1;
|
||||
uint8 opcode:7;
|
||||
uint8_t incomplete:1;
|
||||
uint8_t opcode:7;
|
||||
#endif
|
||||
|
||||
uint8 reserved;
|
||||
uint16 fragmentsleft;
|
||||
uint8_t reserved;
|
||||
uint16_t fragmentsleft;
|
||||
} _INFOh;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
_MBXh mbxheader;
|
||||
uint16 type;
|
||||
uint16 detail;
|
||||
uint16_t type;
|
||||
uint16_t detail;
|
||||
} _MBXerr;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
_MBXh mbxheader;
|
||||
_COEh coeheader;
|
||||
uint8 command;
|
||||
uint16 index;
|
||||
uint8 subindex;
|
||||
uint32 size;
|
||||
uint8_t command;
|
||||
uint16_t index;
|
||||
uint8_t subindex;
|
||||
uint32_t size;
|
||||
} _COEsdo;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
|
@ -395,10 +395,10 @@ typedef struct CC_PACKED
|
|||
_MBXh mbxheader;
|
||||
_COEh coeheader;
|
||||
_INFOh infoheader;
|
||||
uint16 index;
|
||||
uint16 datatype;
|
||||
uint8 maxsub;
|
||||
uint8 objectcode;
|
||||
uint16_t index;
|
||||
uint16_t datatype;
|
||||
uint8_t maxsub;
|
||||
uint8_t objectcode;
|
||||
char name;
|
||||
} _COEobjdesc;
|
||||
|
||||
|
@ -407,24 +407,24 @@ typedef struct CC_PACKED
|
|||
_MBXh mbxheader;
|
||||
_COEh coeheader;
|
||||
_INFOh infoheader;
|
||||
uint16 index;
|
||||
uint8 subindex;
|
||||
uint8 valueinfo;
|
||||
uint16 datatype;
|
||||
uint16 bitlength;
|
||||
uint16 access;
|
||||
uint16_t index;
|
||||
uint8_t subindex;
|
||||
uint8_t valueinfo;
|
||||
uint16_t datatype;
|
||||
uint16_t bitlength;
|
||||
uint16_t access;
|
||||
char name;
|
||||
} _COEentdesc;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint8 opcode;
|
||||
uint8 reserved;
|
||||
uint8_t opcode;
|
||||
uint8_t reserved;
|
||||
union
|
||||
{
|
||||
uint32 password;
|
||||
uint32 packetnumber;
|
||||
uint32 errorcode;
|
||||
uint32_t password;
|
||||
uint32_t packetnumber;
|
||||
uint32_t errorcode;
|
||||
};
|
||||
} _FOEh;
|
||||
|
||||
|
@ -438,7 +438,7 @@ typedef struct CC_PACKED
|
|||
union
|
||||
{
|
||||
char filename[FOE_DATA_SIZE];
|
||||
uint8 data[FOE_DATA_SIZE];
|
||||
uint8_t data[FOE_DATA_SIZE];
|
||||
char errortext[FOE_DATA_SIZE];
|
||||
};
|
||||
} _FOE;
|
||||
|
@ -454,36 +454,36 @@ typedef struct CC_PACKED
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8 state;
|
||||
uint8_t state;
|
||||
} _MBXcontrol;
|
||||
|
||||
typedef struct esc_cfg
|
||||
{
|
||||
void (*pre_state_change_hook) (uint8 * as, uint8 * an);
|
||||
void (*post_state_change_hook) (uint8 * as, uint8 * an);
|
||||
void (*pre_state_change_hook) (uint8_t * as, uint8_t * an);
|
||||
void (*post_state_change_hook) (uint8_t * as, uint8_t * an);
|
||||
} esc_cfg_t;
|
||||
|
||||
void ESC_config (esc_cfg_t * cfg);
|
||||
void ESC_ALerror (uint16 errornumber);
|
||||
void ESC_ALstatus (uint8 status);
|
||||
void ESC_SMstatus (uint8 n);
|
||||
uint8 ESC_WDstatus (void);
|
||||
uint8 ESC_claimbuffer (void);
|
||||
uint8 ESC_startmbx (uint8 state);
|
||||
void ESC_ALerror (uint16_t errornumber);
|
||||
void ESC_ALstatus (uint8_t status);
|
||||
void ESC_SMstatus (uint8_t n);
|
||||
uint8_t ESC_WDstatus (void);
|
||||
uint8_t ESC_claimbuffer (void);
|
||||
uint8_t ESC_startmbx (uint8_t state);
|
||||
void ESC_stopmbx (void);
|
||||
void MBX_error (uint16 error);
|
||||
uint8 ESC_mbxprocess (void);
|
||||
void MBX_error (uint16_t error);
|
||||
uint8_t ESC_mbxprocess (void);
|
||||
void ESC_xoeprocess (void);
|
||||
uint8 ESC_startinput (uint8 state);
|
||||
uint8_t ESC_startinput (uint8_t state);
|
||||
void ESC_stopinput (void);
|
||||
uint8 ESC_startoutput (uint8 state);
|
||||
uint8_t ESC_startoutput (uint8_t state);
|
||||
void ESC_stopoutput (void);
|
||||
void ESC_ALevent (void);
|
||||
void ESC_state (void);
|
||||
|
||||
/* From hardware file */
|
||||
uint8 ESC_read (uint16 address, void *buf, uint16 len, void *tALevent);
|
||||
uint8 ESC_write (uint16 address, void *buf, uint16 len, void *tALevent);
|
||||
uint8_t ESC_read (uint16_t address, void *buf, uint16_t len, void *tALevent);
|
||||
uint8_t ESC_write (uint16_t address, void *buf, uint16_t len, void *tALevent);
|
||||
void ESC_init (const void * arg);
|
||||
void ESC_reset (void);
|
||||
|
||||
|
@ -493,12 +493,12 @@ extern void APP_safeoutput ();
|
|||
extern volatile _ESCvar ESCvar;
|
||||
extern _MBX MBX[MBXBUFFERS];
|
||||
extern _MBXcontrol MBXcontrol[MBXBUFFERS];
|
||||
extern uint8 MBXrun;
|
||||
extern uint16 SM2_sml, SM3_sml;
|
||||
extern uint8_t MBXrun;
|
||||
extern uint16_t SM2_sml, SM3_sml;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 state;
|
||||
uint8_t state;
|
||||
} _App;
|
||||
|
||||
#define APPSTATE_IDLE 0x00
|
||||
|
|
160
soes/esc_coe.c
160
soes/esc_coe.c
|
@ -41,17 +41,17 @@
|
|||
|
||||
#define BITS2BYTES(b) ((b + 7) >> 3)
|
||||
|
||||
extern uint8 txpdoitems;
|
||||
extern uint8 rxpdoitems;
|
||||
extern uint8_t txpdoitems;
|
||||
extern uint8_t rxpdoitems;
|
||||
|
||||
/** Search for an object index matching the wanted value in the Object List.
|
||||
*
|
||||
* @param[in] index = value on index of object we want to locate
|
||||
* @return local array index if we succeed, -1 if we didn't find the index.
|
||||
*/
|
||||
int32 SDO_findobject (uint16 index)
|
||||
int32_t SDO_findobject (uint16_t index)
|
||||
{
|
||||
int32 n = 0;
|
||||
int32_t n = 0;
|
||||
while (SDOobjects[n].index < index)
|
||||
{
|
||||
n++;
|
||||
|
@ -68,20 +68,20 @@ int32 SDO_findobject (uint16 index)
|
|||
*
|
||||
* @return size of TxPDOs in Bytes.
|
||||
*/
|
||||
uint16 sizeTXPDO (void)
|
||||
uint16_t sizeTXPDO (void)
|
||||
{
|
||||
uint8 c, l, si, sic;
|
||||
uint16 size = 0, hobj;
|
||||
int16 nidx;
|
||||
uint8_t c, l, si, sic;
|
||||
uint16_t size = 0, hobj;
|
||||
int16_t nidx;
|
||||
const _objd *objd;
|
||||
|
||||
if (SDO1C13[0].data)
|
||||
{
|
||||
si = *((uint8 *) SDO1C13[0].data);
|
||||
si = *((uint8_t *) SDO1C13[0].data);
|
||||
}
|
||||
else
|
||||
{
|
||||
si = (uint8) SDO1C13[0].value;
|
||||
si = (uint8_t) SDO1C13[0].value;
|
||||
}
|
||||
if (si)
|
||||
{
|
||||
|
@ -89,17 +89,17 @@ uint16 sizeTXPDO (void)
|
|||
{
|
||||
if (SDO1C13[sic].data)
|
||||
{
|
||||
hobj = *((uint16 *) SDO1C13[sic].data);
|
||||
hobj = *((uint16_t *) SDO1C13[sic].data);
|
||||
}
|
||||
else
|
||||
{
|
||||
hobj = (uint16) SDO1C13[sic].value;
|
||||
hobj = (uint16_t) SDO1C13[sic].value;
|
||||
}
|
||||
nidx = SDO_findobject (hobj);
|
||||
if (nidx > 0)
|
||||
{
|
||||
objd = SDOobjects[nidx].objdesc;
|
||||
l = (uint8) objd->value;
|
||||
l = (uint8_t) objd->value;
|
||||
for (c = 1; c <= l; c++)
|
||||
{
|
||||
size += ((objd + c)->value & 0xff);
|
||||
|
@ -115,37 +115,37 @@ uint16 sizeTXPDO (void)
|
|||
*
|
||||
* @return size of RxPDOs in Bytes.
|
||||
*/
|
||||
uint16 sizeRXPDO (void)
|
||||
uint16_t sizeRXPDO (void)
|
||||
{
|
||||
uint8 c, l, si, sic;
|
||||
uint16 size = 0, hobj;
|
||||
int16 nidx;
|
||||
uint8_t c, l, si, sic;
|
||||
uint16_t size = 0, hobj;
|
||||
int16_t nidx;
|
||||
const _objd *objd;
|
||||
|
||||
if (SDO1C12[0].data)
|
||||
{
|
||||
si = *((uint8 *) SDO1C12[0].data);
|
||||
si = *((uint8_t *) SDO1C12[0].data);
|
||||
}
|
||||
else
|
||||
{
|
||||
si = (uint8) SDO1C12[0].value;
|
||||
si = (uint8_t) SDO1C12[0].value;
|
||||
}if (si)
|
||||
{
|
||||
for (sic = 1; sic <= si; sic++)
|
||||
{
|
||||
if (SDO1C12[sic].data)
|
||||
{
|
||||
hobj = *((uint16 *) SDO1C12[sic].data);
|
||||
hobj = *((uint16_t *) SDO1C12[sic].data);
|
||||
}
|
||||
else
|
||||
{
|
||||
hobj = (uint16) SDO1C12[sic].value;
|
||||
hobj = (uint16_t) SDO1C12[sic].value;
|
||||
}
|
||||
nidx = SDO_findobject (hobj);
|
||||
if (nidx > 0)
|
||||
{
|
||||
objd = SDOobjects[nidx].objdesc;
|
||||
l = (uint8) objd->value;
|
||||
l = (uint8_t) objd->value;
|
||||
for (c = 1; c <= l; c++)
|
||||
{
|
||||
size += ((objd + c)->value & 0xff);
|
||||
|
@ -162,11 +162,11 @@ uint16 sizeRXPDO (void)
|
|||
* @param[in] subindex = value on sub-index of object we want to locate
|
||||
* @return local array index if we succeed, -1 if we didn't find the index.
|
||||
*/
|
||||
int16 SDO_findsubindex (int16 nidx, uint8 subindex)
|
||||
int16_t SDO_findsubindex (int16_t nidx, uint8_t subindex)
|
||||
{
|
||||
const _objd *objd;
|
||||
int16 n = 0;
|
||||
uint8 maxsub;
|
||||
int16_t n = 0;
|
||||
uint8_t maxsub;
|
||||
objd = SDOobjects[nidx].objdesc;
|
||||
maxsub = SDOobjects[nidx].maxsub;
|
||||
while (((objd + n)->subindex < subindex) && (n < maxsub))
|
||||
|
@ -186,7 +186,7 @@ int16 SDO_findsubindex (int16 nidx, uint8 subindex)
|
|||
* @param[in] dest = pointer to destination
|
||||
* @param[in] size = Size to copy
|
||||
*/
|
||||
void copy2mbx (void *source, void *dest, uint16 size)
|
||||
void copy2mbx (void *source, void *dest, uint16_t size)
|
||||
{
|
||||
memcpy (dest, source, size);
|
||||
}
|
||||
|
@ -197,9 +197,9 @@ void copy2mbx (void *source, void *dest, uint16 size)
|
|||
* @param[in] sub-index = sub-index of object causing abort reply
|
||||
* @param[in] abortcode = abort code to send in reply
|
||||
*/
|
||||
void SDO_abort (uint16 index, uint8 subindex, uint32 abortcode)
|
||||
void SDO_abort (uint16_t index, uint8_t subindex, uint32_t abortcode)
|
||||
{
|
||||
uint8 MBXout;
|
||||
uint8_t MBXout;
|
||||
_COEsdo *coeres;
|
||||
MBXout = ESC_claimbuffer ();
|
||||
if (MBXout)
|
||||
|
@ -224,12 +224,12 @@ void SDO_abort (uint16 index, uint8 subindex, uint32 abortcode)
|
|||
void SDO_upload (void)
|
||||
{
|
||||
_COEsdo *coesdo, *coeres;
|
||||
uint16 index;
|
||||
uint8 subindex;
|
||||
int16 nidx, nsub;
|
||||
uint8 MBXout;
|
||||
uint32 size;
|
||||
uint8 dss;
|
||||
uint16_t index;
|
||||
uint8_t subindex;
|
||||
int16_t nidx, nsub;
|
||||
uint8_t MBXout;
|
||||
uint32_t size;
|
||||
uint8_t dss;
|
||||
const _objd *objd;
|
||||
coesdo = (_COEsdo *) &MBX[0];
|
||||
index = etohs (coesdo->index);
|
||||
|
@ -336,8 +336,8 @@ void SDO_upload (void)
|
|||
void SDO_uploadsegment (void)
|
||||
{
|
||||
_COEsdo *coesdo, *coeres;
|
||||
uint8 MBXout;
|
||||
uint32 size, offset;
|
||||
uint8_t MBXout;
|
||||
uint32_t size, offset;
|
||||
coesdo = (_COEsdo *) &MBX[0];
|
||||
MBXout = ESC_claimbuffer ();
|
||||
if (MBXout)
|
||||
|
@ -375,7 +375,7 @@ void SDO_uploadsegment (void)
|
|||
coeres->mbxheader.length = htoes (COE_DEFAULTLENGTH);
|
||||
}
|
||||
}
|
||||
copy2mbx ((uint8 *) ESCvar.data + offset, (&(coeres->command)) + 1, size); //copy to mailbox
|
||||
copy2mbx ((uint8_t *) ESCvar.data + offset, (&(coeres->command)) + 1, size); //copy to mailbox
|
||||
|
||||
MBXcontrol[MBXout].state = MBXstate_outreq;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ void SDO_uploadsegment (void)
|
|||
* @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 index, uint8 subindex)
|
||||
int ESC_pre_objecthandler (uint16_t index, uint8_t subindex)
|
||||
{
|
||||
if ((index == 0x1c12) && (subindex > 0) && (rxpdoitems != 0))
|
||||
{
|
||||
|
@ -410,13 +410,13 @@ int ESC_pre_objecthandler (uint16 index, uint8 subindex)
|
|||
void SDO_download (void)
|
||||
{
|
||||
_COEsdo *coesdo, *coeres;
|
||||
uint16 index;
|
||||
uint8 subindex;
|
||||
int16 nidx, nsub;
|
||||
uint8 MBXout;
|
||||
uint16 size, actsize;
|
||||
uint16_t index;
|
||||
uint8_t subindex;
|
||||
int16_t nidx, nsub;
|
||||
uint8_t MBXout;
|
||||
uint16_t size, actsize;
|
||||
const _objd *objd;
|
||||
uint32 *mbxdata;
|
||||
uint32_t *mbxdata;
|
||||
coesdo = (_COEsdo *) &MBX[0];
|
||||
index = etohs (coesdo->index);
|
||||
subindex = coesdo->subindex;
|
||||
|
@ -501,15 +501,15 @@ void SDO_download (void)
|
|||
*
|
||||
* @param[in] abortcode = = abort code to send in reply
|
||||
*/
|
||||
void SDO_infoerror (uint32 abortcode)
|
||||
void SDO_infoerror (uint32_t abortcode)
|
||||
{
|
||||
uint8 MBXout;
|
||||
uint8_t MBXout;
|
||||
_COEobjdesc *coeres;
|
||||
MBXout = ESC_claimbuffer ();
|
||||
if (MBXout)
|
||||
{
|
||||
coeres = (_COEobjdesc *) &MBX[MBXout];
|
||||
coeres->mbxheader.length = htoes ((uint16) 0x0a);
|
||||
coeres->mbxheader.length = htoes ((uint16_t) 0x0a);
|
||||
coeres->mbxheader.mbxtype = MBXCOE;
|
||||
coeres->coeheader.numberservice =
|
||||
htoes ((0 & 0x01f) | (COE_SDOINFORMATION << 12));
|
||||
|
@ -530,11 +530,11 @@ void SDO_infoerror (uint32 abortcode)
|
|||
*/
|
||||
void SDO_getodlist (void)
|
||||
{
|
||||
uint16 frags;
|
||||
uint8 MBXout = 0;
|
||||
uint16 entries = 0;
|
||||
uint16 i, n;
|
||||
uint16 *p;
|
||||
uint16_t frags;
|
||||
uint8_t MBXout = 0;
|
||||
uint16_t entries = 0;
|
||||
uint16_t i, n;
|
||||
uint16_t *p;
|
||||
_COEobjdesc *coel, *coer;
|
||||
|
||||
while (SDOobjects[entries].index != 0xffff)
|
||||
|
@ -564,10 +564,10 @@ void SDO_getodlist (void)
|
|||
/* number of objects request */
|
||||
if (etohs (coer->index) == 0x00)
|
||||
{
|
||||
coel->index = htoes ((uint16) 0x00);
|
||||
coel->index = htoes ((uint16_t) 0x00);
|
||||
coel->infoheader.incomplete = 0;
|
||||
coel->infoheader.reserved = 0x00;
|
||||
coel->infoheader.fragmentsleft = htoes ((uint16) 0);
|
||||
coel->infoheader.fragmentsleft = htoes ((uint16_t) 0);
|
||||
MBXcontrol[0].state = MBXstate_idle;
|
||||
ESCvar.xoe = 0;
|
||||
ESCvar.frags = frags;
|
||||
|
@ -604,7 +604,7 @@ void SDO_getodlist (void)
|
|||
ESCvar.frags = frags;
|
||||
ESCvar.fragsleft = frags - 1;
|
||||
coel->infoheader.fragmentsleft = htoes (ESCvar.fragsleft);
|
||||
coel->index = htoes ((uint16) 0x01);
|
||||
coel->index = htoes ((uint16_t) 0x01);
|
||||
|
||||
p = &(coel->datatype);
|
||||
for (i = 0; i < n; i++)
|
||||
|
@ -624,9 +624,9 @@ void SDO_getodlist (void)
|
|||
*/
|
||||
void SDO_getodlistcont (void)
|
||||
{
|
||||
uint8 MBXout;
|
||||
uint16 i, n, s;
|
||||
uint16 *p;
|
||||
uint8_t MBXout;
|
||||
uint16_t i, n, s;
|
||||
uint16_t *p;
|
||||
_COEobjdesc *coel;
|
||||
|
||||
MBXout = ESC_claimbuffer ();
|
||||
|
@ -671,12 +671,12 @@ void SDO_getodlistcont (void)
|
|||
*/
|
||||
void SDO_getod (void)
|
||||
{
|
||||
uint8 MBXout;
|
||||
uint16 index;
|
||||
int32 nidx;
|
||||
uint8 *d;
|
||||
const uint8 *s;
|
||||
uint8 n = 0;
|
||||
uint8_t MBXout;
|
||||
uint16_t index;
|
||||
int32_t nidx;
|
||||
uint8_t *d;
|
||||
const uint8_t *s;
|
||||
uint8_t n = 0;
|
||||
_COEobjdesc *coer, *coel;
|
||||
coer = (_COEobjdesc *) &MBX[0];
|
||||
index = etohs (coer->index);
|
||||
|
@ -697,7 +697,7 @@ void SDO_getod (void)
|
|||
coel->index = htoes (index);
|
||||
if (SDOobjects[nidx].objtype == OTYPE_VAR)
|
||||
{
|
||||
int32 nsub = SDO_findsubindex (nidx, 0);
|
||||
int32_t nsub = SDO_findsubindex (nidx, 0);
|
||||
const _objd *objd = SDOobjects[nidx].objdesc;
|
||||
coel->datatype = htoes ((objd + nsub)->datatype);
|
||||
}
|
||||
|
@ -707,8 +707,8 @@ void SDO_getod (void)
|
|||
}
|
||||
coel->maxsub = SDOobjects[nidx].maxsub;
|
||||
coel->objectcode = SDOobjects[nidx].objtype;
|
||||
s = (uint8 *) SDOobjects[nidx].name;
|
||||
d = (uint8 *) &(coel->name);
|
||||
s = (uint8_t *) SDOobjects[nidx].name;
|
||||
d = (uint8_t *) &(coel->name);
|
||||
while (*s && (n < (MBXDSIZE - 0x0c)))
|
||||
{
|
||||
*d = *s;
|
||||
|
@ -717,7 +717,7 @@ void SDO_getod (void)
|
|||
d++;
|
||||
}
|
||||
*d = *s;
|
||||
coel->mbxheader.length = htoes ((uint16) 0x0c + n);
|
||||
coel->mbxheader.length = htoes ((uint16_t) 0x0c + n);
|
||||
MBXcontrol[MBXout].state = MBXstate_outreq;
|
||||
MBXcontrol[0].state = MBXstate_idle;
|
||||
ESCvar.xoe = 0;
|
||||
|
@ -735,14 +735,14 @@ void SDO_getod (void)
|
|||
*/
|
||||
void SDO_geted (void)
|
||||
{
|
||||
uint8 MBXout;
|
||||
uint16 index;
|
||||
int32 nidx, nsub;
|
||||
uint8 subindex;
|
||||
uint8 *d;
|
||||
const uint8 *s;
|
||||
uint8_t MBXout;
|
||||
uint16_t index;
|
||||
int32_t nidx, nsub;
|
||||
uint8_t subindex;
|
||||
uint8_t *d;
|
||||
const uint8_t *s;
|
||||
const _objd *objd;
|
||||
uint8 n = 0;
|
||||
uint8_t n = 0;
|
||||
_COEentdesc *coer, *coel;
|
||||
coer = (_COEentdesc *) &MBX[0];
|
||||
index = etohs (coer->index);
|
||||
|
@ -764,7 +764,7 @@ void SDO_geted (void)
|
|||
coel->infoheader.opcode = COE_ENTRYDESCRIPTIONRESPONSE;
|
||||
coel->infoheader.incomplete = 0;
|
||||
coel->infoheader.reserved = 0x00;
|
||||
coel->infoheader.fragmentsleft = htoes ((uint16) 0);
|
||||
coel->infoheader.fragmentsleft = htoes ((uint16_t) 0);
|
||||
coel->index = htoes (index);
|
||||
coel->subindex = subindex;
|
||||
coel->valueinfo = COE_VALUEINFO_ACCESS +
|
||||
|
@ -772,8 +772,8 @@ void SDO_geted (void)
|
|||
coel->datatype = htoes ((objd + nsub)->datatype);
|
||||
coel->bitlength = htoes ((objd + nsub)->bitlength);
|
||||
coel->access = htoes ((objd + nsub)->access);
|
||||
s = (uint8 *) (objd + nsub)->name;
|
||||
d = (uint8 *) &(coel->name);
|
||||
s = (uint8_t *) (objd + nsub)->name;
|
||||
d = (uint8_t *) &(coel->name);
|
||||
while (*s && (n < (MBXDSIZE - 0x10)))
|
||||
{
|
||||
*d = *s;
|
||||
|
@ -782,7 +782,7 @@ void SDO_geted (void)
|
|||
d++;
|
||||
}
|
||||
*d = *s;
|
||||
coel->mbxheader.length = htoes ((uint16) 0x10 + n);
|
||||
coel->mbxheader.length = htoes ((uint16_t) 0x10 + n);
|
||||
MBXcontrol[MBXout].state = MBXstate_outreq;
|
||||
MBXcontrol[0].state = MBXstate_idle;
|
||||
ESCvar.xoe = 0;
|
||||
|
@ -808,7 +808,7 @@ void ESC_coeprocess (void)
|
|||
_MBXh *mbh;
|
||||
_COEsdo *coesdo;
|
||||
_COEobjdesc *coeobjdesc;
|
||||
uint8 service;
|
||||
uint8_t service;
|
||||
if (!MBXrun)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -38,21 +38,21 @@
|
|||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16 subindex;
|
||||
uint16 datatype;
|
||||
uint16 bitlength;
|
||||
uint16 access;
|
||||
uint16_t subindex;
|
||||
uint16_t datatype;
|
||||
uint16_t bitlength;
|
||||
uint16_t access;
|
||||
const char *name;
|
||||
uint32 value;
|
||||
uint32_t value;
|
||||
void *data;
|
||||
} _objd;
|
||||
|
||||
typedef struct CC_PACKED
|
||||
{
|
||||
uint16 index;
|
||||
uint16 objtype;
|
||||
uint8 maxsub;
|
||||
uint8 pad1;
|
||||
uint16_t index;
|
||||
uint16_t objtype;
|
||||
uint8_t maxsub;
|
||||
uint8_t pad1;
|
||||
const char *name;
|
||||
const _objd *objdesc;
|
||||
} _objectlist;
|
||||
|
@ -101,10 +101,10 @@ typedef struct CC_PACKED
|
|||
#define ATYPE_TXPDO 0x80
|
||||
|
||||
void ESC_coeprocess (void);
|
||||
uint16 sizeTXPDO (void);
|
||||
uint16 sizeRXPDO (void);
|
||||
uint16_t sizeTXPDO (void);
|
||||
uint16_t sizeRXPDO (void);
|
||||
|
||||
extern void ESC_objecthandler (uint16 index, uint8 subindex);
|
||||
extern void ESC_objecthandler (uint16_t index, uint8_t subindex);
|
||||
extern const _objectlist SDOobjects[];
|
||||
extern const _objd SDO1C12[];
|
||||
extern const _objd SDO1C13[];
|
||||
|
|
|
@ -79,9 +79,9 @@ static _FOEvar FOEvar;
|
|||
* @return 0= if we succeed, FOE_ERR_NOTFOUND something wrong with filename or
|
||||
* password
|
||||
*/
|
||||
int FOE_fopen (char *name, uint8 num_chars, uint32 pass, uint8 op)
|
||||
int FOE_fopen (char *name, uint8_t num_chars, uint32_t pass, uint8_t op)
|
||||
{
|
||||
uint32 i;
|
||||
uint32_t i;
|
||||
|
||||
/* Unpack the file name into characters we can look at. */
|
||||
if (num_chars > FOE_FN_MAX)
|
||||
|
@ -135,9 +135,9 @@ int FOE_fopen (char *name, uint8 num_chars, uint32 pass, uint8 op)
|
|||
|
||||
* @return Number of copied bytes.
|
||||
*/
|
||||
uint16 FOE_fread (uint8 * data, uint16 maxlength)
|
||||
uint16_t FOE_fread (uint8_t * data, uint16_t maxlength)
|
||||
{
|
||||
uint16 ncopied = 0;
|
||||
uint16_t ncopied = 0;
|
||||
|
||||
while (maxlength && (FOEvar.fend - FOEvar.fposition))
|
||||
{
|
||||
|
@ -161,10 +161,10 @@ uint16 FOE_fread (uint8 * data, uint16 maxlength)
|
|||
|
||||
* @return Number of copied bytes.
|
||||
*/
|
||||
uint16 FOE_fwrite (uint8 *data, uint16 length)
|
||||
uint16_t FOE_fwrite (uint8_t *data, uint16_t length)
|
||||
{
|
||||
uint16 ncopied = 0;
|
||||
uint32 failed = 0;
|
||||
uint16_t ncopied = 0;
|
||||
uint32_t failed = 0;
|
||||
|
||||
DPRINT("FOE_fwrite\n");
|
||||
FOEvar.fprevposition = FOEvar.fposition;
|
||||
|
@ -194,8 +194,8 @@ uint16 FOE_fwrite (uint8 *data, uint16 length)
|
|||
*/
|
||||
uint32_t FOE_fclose (void)
|
||||
{
|
||||
uint32 i;
|
||||
uint32 failed = 0;
|
||||
uint32_t i;
|
||||
uint32_t failed = 0;
|
||||
|
||||
DPRINT("FOE_fclose\n");
|
||||
if (FOEvar.fbufposition)
|
||||
|
@ -231,10 +231,10 @@ void FOE_init ()
|
|||
*
|
||||
* @param[in] code = abort code
|
||||
*/
|
||||
void FOE_abort (uint32 code)
|
||||
void FOE_abort (uint32_t code)
|
||||
{
|
||||
_FOE *foembx;
|
||||
uint8 mbxhandle;
|
||||
uint8_t mbxhandle;
|
||||
|
||||
if (code)
|
||||
{
|
||||
|
@ -269,8 +269,8 @@ void FOE_abort (uint32 code)
|
|||
int FOE_send_data_packet ()
|
||||
{
|
||||
_FOE *foembx;
|
||||
uint16 data_len;
|
||||
uint8 mbxhandle;
|
||||
uint16_t data_len;
|
||||
uint8_t mbxhandle;
|
||||
|
||||
mbxhandle = ESC_claimbuffer ();
|
||||
if (mbxhandle)
|
||||
|
@ -300,7 +300,7 @@ int FOE_send_data_packet ()
|
|||
int FOE_send_ack ()
|
||||
{
|
||||
_FOE *foembx;
|
||||
uint8 mbxhandle;
|
||||
uint8_t mbxhandle;
|
||||
|
||||
mbxhandle = ESC_claimbuffer ();
|
||||
if (mbxhandle)
|
||||
|
@ -333,8 +333,8 @@ int FOE_send_ack ()
|
|||
void FOE_read ()
|
||||
{
|
||||
_FOE *foembx;
|
||||
uint32 data_len;
|
||||
uint32 password;
|
||||
uint32_t data_len;
|
||||
uint32_t password;
|
||||
int res;
|
||||
|
||||
if (FOEvar.foestate != FOE_READY)
|
||||
|
@ -417,8 +417,8 @@ void FOE_ack ()
|
|||
void FOE_write ()
|
||||
{
|
||||
_FOE *foembx;
|
||||
uint32 data_len;
|
||||
uint32 password;
|
||||
uint32_t data_len;
|
||||
uint32_t password;
|
||||
int res;
|
||||
|
||||
if (FOEvar.foestate != FOE_READY)
|
||||
|
@ -459,8 +459,8 @@ void FOE_write ()
|
|||
void FOE_data ()
|
||||
{
|
||||
_FOE *foembx;
|
||||
uint32 packet;
|
||||
uint16 data_len, ncopied;
|
||||
uint32_t packet;
|
||||
uint16_t data_len, ncopied;
|
||||
int res;
|
||||
|
||||
if(FOEvar.foestate != FOE_WAIT_FOR_DATA)
|
||||
|
|
|
@ -47,27 +47,27 @@ struct foe_writefile_cfg
|
|||
/** Name of file to receive from master */
|
||||
const char * name;
|
||||
/** Size of file,sizeof data we can recv */
|
||||
uint32 max_data;
|
||||
uint32_t max_data;
|
||||
/** Where to store the data initially */
|
||||
uint32 dest_start_address;
|
||||
uint32_t dest_start_address;
|
||||
/** Current address during write of file */
|
||||
uint32 address_offset;
|
||||
uint32_t address_offset;
|
||||
/* FoE password */
|
||||
uint32 filepass;
|
||||
uint32_t filepass;
|
||||
/* Pointer to application foe write function */
|
||||
uint32 (*write_function) (foe_writefile_cfg_t * self, uint8 * data);
|
||||
uint32_t (*write_function) (foe_writefile_cfg_t * self, uint8_t * data);
|
||||
};
|
||||
|
||||
typedef struct foe_cfg
|
||||
{
|
||||
/** Allocate static in caller func to fit buffer_size */
|
||||
uint8 * fbuffer;
|
||||
uint8_t * fbuffer;
|
||||
/** Write this to fill-up, ex. 0xFF for "non write" */
|
||||
uint8 empty_write;
|
||||
uint8_t empty_write;
|
||||
/** Buffer size before we flush to destination */
|
||||
uint32 buffer_size;
|
||||
uint32_t buffer_size;
|
||||
/** Number of files used in firmware update */
|
||||
uint32 n_files;
|
||||
uint32_t n_files;
|
||||
/** Pointer to files configured to be used by FoE */
|
||||
foe_writefile_cfg_t * files;
|
||||
} foe_cfg_t;
|
||||
|
@ -75,19 +75,19 @@ typedef struct foe_cfg
|
|||
typedef struct CC_PACKED
|
||||
{
|
||||
/** Current FoE state, ex. Waiting for ACK, Waiting for DATA */
|
||||
uint8 foestate;
|
||||
uint8_t foestate;
|
||||
/** Current file buffer position, evaluated against foe file buffer size
|
||||
* when to flush
|
||||
*/
|
||||
uint16 fbufposition;
|
||||
uint16_t fbufposition;
|
||||
/** Frame number in read or write sequence */
|
||||
uint32 foepacket;
|
||||
uint32_t foepacket;
|
||||
/** Current position in file to be handled by FoE request */
|
||||
uint32 fposition;
|
||||
uint32_t fposition;
|
||||
/** Previous position in file to be handled by FoE request */
|
||||
uint32 fprevposition;
|
||||
uint32_t fprevposition;
|
||||
/** End position of allocated disk space for FoE requested file */
|
||||
uint32 fend;
|
||||
uint32_t fend;
|
||||
} _FOEvar;
|
||||
|
||||
/* Initializes FoE state. */
|
||||
|
|
Loading…
Reference in New Issue