MX Foundation 4
ar429_embedded_side_timer.c
/*****************************************************************************
//
## File:
## ar429_embedded_side_timer.c
//
// Copyright (c) MAX Technologies Inc. 1988-2015, All Rights Reserved.
// CONFIDENTIAL AND PROPRIETARY INFORMATION WHICH IS THE
// PROPERTY OF MAX TECHNOLOGIES INC.
//
// This examples demonstrates how to use the embedded timer facility.
//
// The host program "ar429_embedded_timer.c" is required by this program
// and compiled executable must be located in
// the same folder as the embedded application executable.
//
*****************************************************************************/
#include <include/mxf_embedded.h>
//--- Constants ---//
#define USER_COMMAND_ID_START_TIMER 0
#define USER_COMMAND_ID_STOP_TIMER 1
#define USER_TIMER_PERIOD 100000
//--- Global Variables ---//
MXF_A429_DATAREC datarec429;
uint32 timerRunning=FALSE;
uint32 timerEvtCnt=0;
//--- mxfEmbeddedCommandHandler function ---//
extern void
mxfEmbeddedCommandHandler(uint32 command, uint32 bufferSize, uint32* buffer, uint32 reserved)
{
uint32 rc;
switch(command)
{
case USER_COMMAND_ID_START_TIMER:
if (buffer && bufferSize > 2)
{
// Initialize Tx Queue Info for Rx handler
memset(&TxQueueInfo, 0, sizeof(TxQueueInfo));
memset(&datarec429, 0, sizeof(MXF_A429_DATAREC));
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("Module %ld, Port %ld, %ld\n", TxQueueInfo.moduleIndex, TxQueueInfo.portIndex, TxQueueInfo.channelClass);
rc = mxfEmbeddedTimerHandlerEnableSet(USER_TIMER_PERIOD, TRUE);
if (!rc)
{
printf("Timer: %s rc=0x%08lx\n", rc==MAXT_SUCCESS ? "Success:" : " Error:", rc);
timerRunning=TRUE;
}
}
else
printf("\nA429 Parameters missing !\n");
break;
case USER_COMMAND_ID_STOP_TIMER:
rc = mxfEmbeddedTimerHandlerEnableSet(USER_TIMER_PERIOD, FALSE);
break;
default:
break;
}
}
//--- mxfEmbeddedDataDownloadHandler function ---//
extern void
mxfEmbeddedDataDownloadHandler(uint32 bufferSize, uint32* buffer, uint32 reserved)
{
}
//--- mxfEmbeddedRxIntHandler function ---//
extern void
{
}
//--- mxfEmbeddedTxPeriodicUpdateMsgIntHandler function ---//
extern void
{
}
//--- mxfEmbeddedTimerHandler function ---//
extern void
mxfEmbeddedTimerHandler(void* reserved, uint32 reserved1)
{
uint32 rc;
printf("RX Timer Event(%ld, %ld)\n", timerRunning, timerEvtCnt);
if (timerRunning)
{
datarec429.timeTag = 0;
datarec429.control = 0;
datarec429.repeatCount = 1;
datarec429.reserved = 0;
// Label: 0x7, Data: based on timerEvtCnt counter
datarec429.data = (timerEvtCnt++ << 10) | 7;
rc = mxfEmbeddedTxAperiodicWrite(&TxQueueInfo);
printf("A429 Write: %s rc=0x%08lx\n", rc==MAXT_SUCCESS ? "Success:" : " Error:", rc);
}
timerEvtCnt++;
}
Updated 03/30/2022