MTB XMC ECAT Library
API Prototypes

General Description

Macros

#define HW_EscReadDWord(DWordValue, Address)   ((DWordValue) = (UINT32)(((volatile UINT32 *)pEsc)[((Address)>>2)]))
 32Bit ESC read access.
 
#define HW_EscReadDWordIsr(DWordValue, Address)   HW_EscReadDWord(DWordValue, Address)
 Interrupt specific 32Bit ESC read access.
 
#define HW_EscReadWord(WordValue, Address)   ((WordValue) = (((volatile UINT16 *)pEsc)[((Address)>>1)]))
 16Bit ESC read access.
 
#define HW_EscReadWordIsr(WordValue, Address)   HW_EscReadWord(WordValue, Address)
 Interrupt specific 16Bit ESC read access.
 
#define HW_EscReadByte(ByteValue, Address)   ((ByteValue) = (((volatile UINT8 *)pEsc)[(Address)]))
 8Bit ESC read access.
 
#define HW_EscReadByteIsr(ByteValue, Address)   HW_EscReadByte(ByteValue, Address)
 Interrupt specific 8Bit ESC read access.
 
#define HW_EscWriteDWord(DWordValue, Address)   ((((volatile UINT32 *)pEsc)[(Address>>2)]) = (DWordValue))
 16Bit ESC write access.
 
#define HW_EscWriteDWordIsr(DWordValue, Address)   HW_EscWriteWord(DWordValue, Address)
 Interrupt specific 32Bit ESC write access.
 
#define HW_EscWriteWord(WordValue, Address)   ((((volatile UINT16 *)pEsc)[((Address)>>1)]) = (WordValue))
 16Bit ESC write access.
 
#define HW_EscWriteWordIsr(WordValue, Address)   HW_EscWriteWord(WordValue, Address)
 Interrupt specific 16Bit ESC write access.
 
#define HW_EscWriteByte(ByteValue, Address)   ((((volatile UINT8 *)pEsc)[(Address)]) = (ByteValue))
 8Bit ESC write access.
 
#define HW_EscWriteByteIsr(ByteValue, Address)   HW_EscWriteByte(ByteValue, Address)
 Interrupt specific 8Bit ESC write access.
 

Functions

void mtb_xmc_ecat_timer_stop_reset (void)
 
void mtb_xmc_ecat_timer_start (void)
 
E_EEPROM_XMC4_STATUS_t mtb_xmc_ecat_eeprom_init (void)
 
uint32_t mtb_xmc_ecat_init (void)
 
__STATIC_INLINE void HW_EscRead (MEM_ADDR *pData, UINT16 Address, UINT16 Len)
 
__STATIC_INLINE void HW_EscReadIsr (MEM_ADDR *pData, UINT16 Address, UINT16 Len)
 
__STATIC_INLINE void HW_EscReadMbxMem (MEM_ADDR *pData, UINT16 Address, UINT16 Len)
 
__STATIC_INLINE void HW_EscWrite (MEM_ADDR *pData, UINT16 Address, UINT16 Len)
 
__STATIC_INLINE void HW_EscWriteIsr (MEM_ADDR *pData, UINT16 Address, UINT16 Len)
 
__STATIC_INLINE void HW_EscWriteMbxMem (MEM_ADDR *pData, UINT16 Address, UINT16 Len)
 
__STATIC_INLINE UINT16 HW_GetALEventRegister (void)
 
__STATIC_INLINE UINT16 HW_GetALEventRegister_Isr (void)
 
void ENABLE_ESC_INT (void)
 
void DISABLE_ESC_INT (void)
 
void mtb_xmc_enable_user_int (void)
 
void mtb_xmc_disable_user_int (void)
 
UINT32 HW_GetTimer (void)
 
void HW_ClearTimer (void)
 
UINT16 HW_Init (void)
 
void HW_Release (void)
 
void HW_RestartTarget (void)
 
UINT16 HW_EepromRead (UINT32 wordaddr)
 
UINT16 HW_EepromWrite (UINT32 wordaddr)
 
UINT16 HW_EepromReload (void)
 

Function Documentation

◆ mtb_xmc_ecat_timer_stop_reset()

void mtb_xmc_ecat_timer_stop_reset ( void  )
Parameters
None
Returns
None
Description:
This function stops and resets a timer for the EtherCAT.

◆ mtb_xmc_ecat_timer_start()

void mtb_xmc_ecat_timer_start ( void  )
Parameters
None
Returns
None
Description:
This function starts a timer for the EtherCAT.

◆ mtb_xmc_ecat_eeprom_init()

E_EEPROM_XMC4_STATUS_t mtb_xmc_ecat_eeprom_init ( void  )
Parameters
None
Returns
E_EEPROM_XMC4_STATUS_t
Description:
This function initializes an EEPROM for the EtherCAT.

◆ mtb_xmc_ecat_init()

uint32_t mtb_xmc_ecat_init ( void  )
Parameters
None
Returns
Status 0, if the operation was successful.
greater than 0, an error has occurred.
Description:
This function initializes the EtherCAT using EEPROM, timer, ECAT slave hardware, and generic slave stack initialization functions.

◆ HW_EscRead()

__STATIC_INLINE void HW_EscRead ( MEM_ADDR *  pData,
UINT16  Address,
UINT16  Len 
)
Parameters
pDataPointer to local destination buffer.
AddressEtherCAT Slave Controller address. Specifies the offset within the ESC memory area in Bytes.
LenAccess size in Bytes
Returns
None
Description:
16Bit ESC read access. Reads from the EtherCAT Slave Controller. This function is used to access ESC registers and the DPRAM area.

◆ HW_EscReadIsr()

__STATIC_INLINE void HW_EscReadIsr ( MEM_ADDR *  pData,
UINT16  Address,
UINT16  Len 
)
Parameters
pDataPointer to local destination buffer.
AddressEtherCAT Slave Controller address. Specifies the offset within the ESC memory area in Bytes.
LenAccess size in Bytes
Returns
None
Description:
Interrupt specific 16Bit ESC read access. Reads from the EtherCAT Slave Controller. This function is used to access ESC registers and the DPRAM area.

◆ HW_EscReadMbxMem()

__STATIC_INLINE void HW_EscReadMbxMem ( MEM_ADDR *  pData,
UINT16  Address,
UINT16  Len 
)
Parameters
pDataPointer to local destination mailbox buffer.
AddressEtherCAT Slave Controller address. Specifies the offset within the ESC memory area in Bytes.
LenAccess size in Bytes
Returns
None
Description:
Reads data from the ESC and copies to slave mailbox memory. If the local mailbox memory is also located in the application memory this function is equal to HW_EscRead.

◆ HW_EscWrite()

__STATIC_INLINE void HW_EscWrite ( MEM_ADDR *  pData,
UINT16  Address,
UINT16  Len 
)
Parameters
pDataPointer to local source buffer.
AddressEtherCAT Slave Controller address. Specifies the offset within the ESC memory area in Bytes.
LenAccess size in Bytes
Returns
None
Description:
16Bit ESC write access. Writes from the EtherCAT Slave Controller. This function is used to access ESC registers and the DPRAM area.

◆ HW_EscWriteIsr()

__STATIC_INLINE void HW_EscWriteIsr ( MEM_ADDR *  pData,
UINT16  Address,
UINT16  Len 
)
Parameters
pDataPointer to local source buffer.
AddressEtherCAT Slave Controller address. Specifies the offset within the ESC memory area in Bytes.
LenAccess size in Bytes
Returns
None
Description:
Interrupt specific 16Bit ESC write access. Writes from the EtherCAT Slave Controller. This function is used to access ESC registers and the DPRAM area.

◆ HW_EscWriteMbxMem()

__STATIC_INLINE void HW_EscWriteMbxMem ( MEM_ADDR *  pData,
UINT16  Address,
UINT16  Len 
)
Parameters
pDataPointer to local source mailbox buffer.
AddressEtherCAT Slave Controller address. Specifies the offset within the ESC memory area in Bytes.
LenAccess size in Bytes
Returns
None
Description:
Writes data from the slave mailbox memory to ESC memory. If the local mailbox memory is also located in the application memory this function is equal to HW_EscWrite.

◆ HW_GetALEventRegister()

__STATIC_INLINE UINT16 HW_GetALEventRegister ( void  )
Parameters
None
Returns
Content of register 0x220-0x221
Description:
Get the first two bytes of the AL Event register.

◆ HW_GetALEventRegister_Isr()

__STATIC_INLINE UINT16 HW_GetALEventRegister_Isr ( void  )
Parameters
None
Returns
None
Description:
Get the first two bytes of the AL Event register from ISR. Special function for ESC access from interrupt service routines if required, otherwise this function is defined as HW_GetALEventRegister.

◆ ENABLE_ESC_INT()

void ENABLE_ESC_INT ( void  )
Parameters
None
Returns
None
Description:
Function to enable the XMC EtherCAT slave controller interrupt.

◆ DISABLE_ESC_INT()

void DISABLE_ESC_INT ( void  )
Parameters
None
Returns
None
Description:
Function to disable the XMC EtherCAT slave controller interrupt.

◆ mtb_xmc_enable_user_int()

void mtb_xmc_enable_user_int ( void  )
Parameters
None
Returns
None
Description:
This routine is called from ECAT_APP on request of SSC stack once specific EtherCAT interrupts (sync1/sync0) need to be enabled.

◆ mtb_xmc_disable_user_int()

void mtb_xmc_disable_user_int ( void  )
Parameters
None
Returns
None
Description:
This routine is called from ECAT_APP on request of SSC stack once specific EtherCAT interrupts (sync1/sync0) need to be disabled.

◆ HW_GetTimer()

UINT32 HW_GetTimer ( void  )
Parameters
None
Returns
Current timer value
Description:
Reads the hardware timer value in ticks. The timer ticks value (increments / ms) is defined in ECAT_TIMER_INC_P_MS. This function is required, if no timer interrupt is supported (ECAT_TIMER_INT = 0) and to calculate the bus cycle time.

◆ HW_ClearTimer()

void HW_ClearTimer ( void  )
Parameters
None
Returns
None
Description:
Clears the hardware timer value.

◆ HW_Init()

UINT16 HW_Init ( void  )
Parameters
None
Returns
0 if initialization was successful,
Else, if error has occurred while initialization
Description:
Initializes the host controller, process data interface (PDI) and allocates resources which are required for hardware access.

◆ HW_Release()

void HW_Release ( void  )
Parameters
None
Returns
None
Description:
Release allocated reserved resources.

◆ HW_RestartTarget()

void HW_RestartTarget ( void  )
Parameters
None
Returns
None
Description:
Resets the hardware. This function is only required if BOOTSTRAPMODE_SUPPORTED is set.

◆ HW_EepromRead()

UINT16 HW_EepromRead ( UINT32  wordaddr)
Parameters
wordaddrstart word address within the EEPROM memory
Returns
0, if the operation was successful.
greater than 0, an error has occurred.
Description:
Copies EEPROM data to the ESC EEPROM data register. This is only required if EEPROM_EMULATION is enabled and no EEPROM content is created (CREATE_EEPROM_CONTENT== 0). This function shall copy EEPROM data to the ESC EEPROM data register (0x508:0x50F/0x50B).The EEPROM data starting at the specified word address and the length specified with "EEPROM_READ_SIZE". The data shall be copied to the ESC EEPROM buffer (ESC offset 0x508).

◆ HW_EepromWrite()

UINT16 HW_EepromWrite ( UINT32  wordaddr)
Parameters
wordaddrstart word address within the EEPROM memory
Returns
0, if the operation was successful.
greater than 0, an error has occurred.
Description:
Writes the EEPROM configuration information from ESC data register to EEPROM. This is only required if EEPROM_EMULATION is enabled and no EEPROM content is created (CREATE_EEPROM_CONTENT== 0). This function shall copy data from the ESC EEPROM data register (0x508:0x50F/0x50B).The EEPROM data starting at the specified word address and the length specified with "EEPROM_WRITE_SIZE".

◆ HW_EepromReload()

UINT16 HW_EepromReload ( void  )
Parameters
None
Returns
0, if the operation was successful.
greater than 0, an error has occurred.
Description:
Reloads the EEPROM configuration information to ESC data registers. This is only required if EEPROM_EMULATION is enabled and no EEPROM content is created (CREATE_EEPROM_CONTENT== 0). This function shall copy the EEPROM reload information to the ESC EEPROM data register (0x508:0x50F/0x50B).