Preparation
Include Files
Include following header file into your C code:
#include <eray_commands.h>
Variables
volatile unsigned receivedDataCounter;
Defines
#define NUMBER_ERAY_COMM_CYCLES 8
Interrupt Handler Installation
Define priorities for the Interrrupt handler. This is normally done in the Ifx_IntPrioDef.h file:
#define IFX_ERAY_INT0_PRIO 1
#define IFX_ERAY_INT1_PRIO 2
#define IFX_ERAY_NDAT0_PRIO 3
#define IFX_ERAY_NDAT1_PRIO 4
#define IFX_ERAY_MBSC0_PRIO 5
#define IFX_ERAY_MBSC1_PRIO 6
Add the interrupt service routine to your C code. It has to call the ERAY interrupt handler:
void ERAY_irqInt0Handler();
void ERAY_irqInt1Handler();
void ERAY_irqNdat0Handler();
void ERAY_irqNdat1Handler();
void ERAY_irqMbsc0Handler();
void ERAY_irqMbsc1Handler();
{
ERAY_irqInt0Handler();
}
{
ERAY_irqInt1Handler();
}
{
ERAY_irqNdat0Handler();
}
{
ERAY_irqNdat1Handler();
}
{
ERAY_irqMbsc0Handler();
}
{
ERAY_irqMbsc1Handler();
}
Finally install the interrupt handlers in your initialisation function:
IfxCpu_Irq_installInterruptHandler(&eray0Int0ISR, IFX_ERAY_INT0_PRIO);
IfxCpu_Irq_installInterruptHandler(&eray0Int1ISR, IFX_ERAY_INT1_PRIO);
IfxCpu_Irq_installInterruptHandler(&eray0Ndat0ISR, IFX_ERAY_NDAT0_PRIO);
IfxCpu_Irq_installInterruptHandler(&eray0Ndat1ISR, IFX_ERAY_NDAT1_PRIO);
IfxCpu_Irq_installInterruptHandler(&eray0Mbsc0ISR, IFX_ERAY_MBSC0_PRIO);
IfxCpu_Irq_installInterruptHandler(&eray0Mbsc1ISR, IFX_ERAY_MBSC1_PRIO);
Module Initialisation
First ensure that the ERAY PLL is configured to output a 80 MHz clock for the ERAY module:
clib_ver_printf("Initialize ERAY PLL\n");
{
}
Thereafter initialize the module:
#if TEST_ERAY1
clib_ver_printf("Initialize ERAY1\n");
#else
clib_ver_printf("Initialize ERAY0\n");
#endif
Node Initialisation
The node initialisation can be done in the same function.
{
{
TbeMessage reply;
sendMessage(MSG_ID_TESTBENCH_ERAY, CMD_ERAY_TBE_START, 0 );
receiveMessageBlockingFrom(MSG_ID_TESTBENCH_ERAY, reply);
}
{
}
{
}
{
}
{
}
{
}
}
{ 1, 1,
TRUE,
TRUE,
IfxEray_BufferDirection_transmit,
TRUE,
IfxEray_TransmissionMode_continuous,
TRUE, 4, 0x30,
TRUE, TRUE },
{ 2, 1,
TRUE,
TRUE,
IfxEray_BufferDirection_receive,
FALSE,
IfxEray_TransmissionMode_continuous,
TRUE, 4, 0x40,
FALSE, FALSE },
};
};
for(int i=0; i < 2; ++i) {
}
#if TEST_ERAY1
&IfxEray1_RXDA0_P14_8_IN, &IfxEray1_TXDA_P14_10_OUT,
&IfxEray1_TXENA_P14_9_OUT
};
&IfxEray1_RXDB0_P14_7_IN, &IfxEray1_TXDB_P14_5_OUT,
&IfxEray1_TXENB_P14_6_OUT
};
#else
};
};
#endif
clib_ver_printf("Send wakeup pattern\n");
do {
}
do {
break;
}
}
Transactions
unsigned prevReceivedDataCounter = 0;
while( 1 ) {
if( receivedDataCounter != prevReceivedDataCounter ) {
prevReceivedDataCounter = receivedDataCounter;
clib_ver_printf("Received %d packets", receivedDataCounter);
if( receivedDataCounter >= NUMBER_ERAY_COMM_CYCLES )
break;
}
};
Interrupt Service Handlers
The ISR has to be implemented in the application. Following templates can be used to react on the events:
void ERAY_irqInt0Handler()
{
clib_ver_note(1);
if(StatusIntStat.B.SDS)
{
}
if(StatusIntStat.B.CYCS)
{
}
if(StatusIntStat.B.SUCS)
{
}
if(StatusIntStat.B.TIBC)
{
}
if(ErrIntStat.B.MHF)
{
}
}
void ERAY_irqInt1Handler()
{
clib_ver_note(2);
}
void ERAY_irqNdat0Handler()
{
clib_ver_note(3);
}
void ERAY_irqNdat1Handler()
{
clib_ver_note(4);
{
{
}
clib_ver_data(data[0]);
clib_ver_data(data[1]);
if( receivedDataCounter < NUMBER_ERAY_COMM_CYCLES ) {
receivedData[receivedDataCounter][0] = data[0];
receivedData[receivedDataCounter][1] = data[1];
}
++receivedDataCounter;
++data[0];
++data[1];
{
}
}
}
void ERAY_irqMbsc0Handler()
{
clib_ver_note(5);
}
void ERAY_irqMbsc1Handler()
{
clib_ver_note(6);
}