Add device emulation support
parent
7605acd3af
commit
e166eaa9e6
|
@ -5,6 +5,7 @@
|
|||
|
||||
#define DYN_PDO_MAPPING 0
|
||||
|
||||
#define USE_EMU 1
|
||||
#define USE_MBX 0
|
||||
#define USE_FOE 0
|
||||
#define USE_EOE 0
|
||||
|
|
13
soes/esc.c
13
soes/esc.c
|
@ -35,10 +35,12 @@ void ESC_ALerror (uint16_t errornumber)
|
|||
*/
|
||||
void ESC_ALstatus (uint8_t status)
|
||||
{
|
||||
#if !(USE_EMU)
|
||||
uint16_t dummy;
|
||||
ESCvar.ALstatus = status;
|
||||
dummy = htoes ((uint16_t) status);
|
||||
ESC_write (ESCREG_ALSTATUS, &dummy, sizeof (dummy));
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Write AL Status and AL Status code to the ESC.
|
||||
|
@ -940,6 +942,13 @@ void ESC_state (void)
|
|||
uint8_t ac, an, as;
|
||||
|
||||
/* Do we have a state change request pending */
|
||||
#if USE_EMU
|
||||
uint16_t ALstate;
|
||||
ESC_read (ESCREG_ALCONTROL, (void *) &ALstate,
|
||||
sizeof (ALstate));
|
||||
ALstate = etohs (ALstate);
|
||||
if (ALstate == ESCvar.ALcontrol)
|
||||
#else
|
||||
if (ESCvar.ALevent & ESCREG_ALEVENT_CONTROL)
|
||||
{
|
||||
ESC_read (ESCREG_ALCONTROL, (void *) &ESCvar.ALcontrol,
|
||||
|
@ -947,6 +956,7 @@ void ESC_state (void)
|
|||
ESCvar.ALcontrol = etohs (ESCvar.ALcontrol);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* nothing to do */
|
||||
return;
|
||||
|
@ -1163,6 +1173,9 @@ void ESC_state (void)
|
|||
}
|
||||
|
||||
ESC_ALstatus (an);
|
||||
#if USE_EMU
|
||||
ESCvar.ALcontrol = ALstate;
|
||||
#endif
|
||||
DPRINT ("state %x\n", an);
|
||||
}
|
||||
/** Function copying the application configuration variable
|
||||
|
|
|
@ -524,9 +524,6 @@ void ESC_init (const esc_cfg_t * config)
|
|||
// Read the chip identification and revision
|
||||
value = bcm2835_spi_read_32(ESC_CMD_ID_REV);
|
||||
DPRINT("Detected chip %x Rev %u \n", ((value >> 16) & 0xFFFF), (value & 0xFFFF));
|
||||
|
||||
// Disable device simulation to let application set AL status
|
||||
ESC_emulation_disable ();
|
||||
|
||||
// Set AL event mask
|
||||
value = (ESCREG_ALEVENT_CONTROL |
|
||||
|
@ -534,7 +531,6 @@ void ESC_init (const esc_cfg_t * config)
|
|||
ESCREG_ALEVENT_SM0 |
|
||||
ESCREG_ALEVENT_SM1 );
|
||||
ESC_ALeventmaskwrite(value);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -591,35 +587,3 @@ void ESC_interrupt_disable (uint32_t mask)
|
|||
// Disable LAN9252 interrupt
|
||||
bcm2835_spi_write_32(ESC_CMD_INT_EN, 0x00000000);
|
||||
}
|
||||
|
||||
void ESC_emulation_enable (void)
|
||||
{
|
||||
uint32_t config;
|
||||
|
||||
// Read current register configuration
|
||||
ESC_read_csr(ESCREG_ALCONFIG,&config,sizeof(config));
|
||||
config = htoel(config);
|
||||
|
||||
// Enable device emulation (AL status register will be set to value written to AL control register)
|
||||
config |= 0x00000001;
|
||||
|
||||
// Write updated register configuration
|
||||
config = htoel(config);
|
||||
ESC_write_csr(ESCREG_ALCONFIG,&config,sizeof(config));
|
||||
}
|
||||
|
||||
void ESC_emulation_disable (void)
|
||||
{
|
||||
uint32_t config;
|
||||
|
||||
// Read current register configuration
|
||||
ESC_read_csr(ESCREG_ALCONFIG,&config,sizeof(config));
|
||||
config = htoel(config);
|
||||
|
||||
// Disable device emulation (AL status register has to be set by PDI)
|
||||
config &= ~(0x00000001);
|
||||
|
||||
// Write updated register configuration
|
||||
config = htoel(config);
|
||||
ESC_write_csr(ESCREG_ALCONFIG,&config,sizeof(config));
|
||||
}
|
|
@ -13,8 +13,6 @@
|
|||
|
||||
void ESC_interrupt_enable (uint32_t mask);
|
||||
void ESC_interrupt_disable (uint32_t mask);
|
||||
void ESC_emulation_denable (void);
|
||||
void ESC_emulation_disable (void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
/* User-defined options, Options defined here will override default values */
|
||||
#include "ecat_options.h"
|
||||
|
||||
/* Device emulation support */
|
||||
#ifndef USE_EMU
|
||||
#define USE_EMU 0
|
||||
#endif
|
||||
|
||||
/* Mailbox support */
|
||||
/* If disabled SM2 --> SM0, and SM3 --> SM1 */
|
||||
#ifndef USE_MBX
|
||||
|
|
Loading…
Reference in New Issue