MX Foundation 4
ar429_embedded_side_discrete.c
/*****************************************************************************
//
## File:
## ar429_embedded_side_discrete.c
//
// Copyright (c) MAX Technologies Inc. 1988-2015, All Rights Reserved.
// CONFIDENTIAL AND PROPRIETARY INFORMATION WHICH IS THE
// PROPERTY OF MAX TECHNOLOGIES INC.
//
// The embedded program transmit one ARINC 429 label 004 at each discrete input #0
// rising edge detected. The transmission is sent on timetag, 25 msec
// later of discrete edge timetag.
//
// The host program "ar429_embedded_discrete.c" is required by this program
// and compiled executable must be located in
// the same folder as the embedded application executable.
//
// Hardware Requirements:
// - MAXT Flex with loopback between first TX and RX Discrete pin and one TX ARINC 429 Enhanced channel.
//
*****************************************************************************/
#include <include/mxf_embedded.h>
//--- Constants ---//
#define USER_COMMAND_ID_START_TEST 0
#define USER_COMMAND_ID_STOP_TEST 1
//--- Global variables ---//
MXF_A429_DATAREC DataRec429;
uint32 testStarted=FALSE;
uint32 loopCnt=0;
//--- mxfEmbeddedCommandHandler function ---//
extern void
mxfEmbeddedCommandHandler(uint32 command, uint32 bufferSize, uint32* buffer, uint32 reserved)
{
switch(command)
{
case USER_COMMAND_ID_START_TEST:
if (buffer && bufferSize > 2)
{
memset(&TxQueueInfo, 0, sizeof(TxQueueInfo));
// Initialize Tx Queue Info for sending data
TxQueueInfo.channelClass = MXF_CLASS_A429;
TxQueueInfo.moduleIndex = buffer[0];
TxQueueInfo.portIndex = buffer[1];
TxQueueInfo.priority = buffer[2];
TxQueueInfo.options = MXF_EMBEDDED_TXAPERIODIC_FLAG_DEFAULT;
TxQueueInfo.bufferCount = 1;
TxQueueInfo.buffer = &DataRec429;
printf("\nA429 TX channel initialized\n");
testStarted=TRUE;
}
else
printf("\nA429 Parameters missing !\n");
break;
case USER_COMMAND_ID_STOP_TEST:
testStarted=FALSE;
printf("\nA429 TX handler stopping\n");
break;
default:
break;
}
}
//--- mxfEmbeddedDataDownloadHandler function ---//
extern void
mxfEmbeddedDataDownloadHandler(uint32 bufferSize, uint32* buffer, uint32 reserved)
{
}
//--- mxfEmbeddedRxIntHandler function ---//
extern void
{
uint32 rc;
if (testStarted)
{
if(rxInfo->channelClass == MXF_CLASS_DISCRETE)
{
dioRec = (MXF_DISCRETE_DATAREC*)rxInfo->rec;
// if event is caused by discrete input #0
if(dioRec->edge & 0x0001)
{
// Adjust the next timetag
DataRec429.timeTag = dioRec->timeTag + 25000;
DataRec429.control = 0;
DataRec429.repeatCount = 1;
DataRec429.reserved = 0;
// Label: 0x4, Data: Generated by loopCnt variable
DataRec429.data = (loopCnt << 10) | 4;
rc = mxfEmbeddedTxAperiodicWrite(&TxQueueInfo);
printf("A429 Write: rc=0x%08x\n", rc);
}
}
}
loopCnt++;
}
//--- mxfEmbeddedTxPeriodicUpdateMsgIntHandler function ---//
extern void
{
}
//--- mxfEmbeddedTimerHandler function ---//
extern void
mxfEmbeddedTimerHandler(void* reserved, uint32 reserved1)
{
}
Updated 10/23/2023