AR Transmit
Edit this on GitLab
AR Transmit
Explanation
About the Sample Application Code
This sample application code, written in C, is provided by North Atlantic Industries (NAI) for utilizing their Embedded Function Modules through their Software Support Kit (SSK). The code demonstrates how to interact with NAI’s ARINC 429 transmitter using FIFO and scheduled transmission modes. Below is a detailed walkthrough of the provided code structure and functionality.
Includes
The code begins with include directives for standard libraries and NAI-specific headers:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "include/naiapp_boardaccess_menu.h"
#include "include/naiapp_boardaccess_query.h"
#include "include/naiapp_boardaccess_access.h"
#include "include/naiapp_boardaccess_display.h"
#include "include/naiapp_boardaccess_utils.h"
#include "nai_ar_utils.h"
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_ar.h"
-
Standard Libraries: Provide basic functions (e.g., I/O operations, memory management).
-
NAI-Specific Headers: Provide functions for accessing and manipulating ARINC hardware and related utilities.
Configuration
static const int8_t *CONFIG_FILE = (int8_t *)"default_ARXmit.txt";
CONFIG_FILE
points to a configuration file used for setting up the ARINC transmitter.
Function Prototypes
void Run_AR_Transmit(void);
nai_status_t AR_TxFIFO(int32_t paramCount, int32_t* p_params);
nai_status_t AR_TxSchedule(int32_t paramCount, int32_t* p_params);
These prototypes declare the main functionality of the code: 1. Run_AR_Transmit: Manages ARINC transmit operation. 2. AR_TxFIFO: Handles FIFO mode transmission. 3. AR_TxSchedule: Manages scheduled transmission.
Enumeration and Command Tables
enum arfuncgen_commands {
AR_FUNCGEN_CMD_TX_FIFO,
AR_FUNCGEN_CMD_TX_SCHEDULE,
AR_FUNCGEN_CMD_COUNT
};
This enumeration defines command identifiers for FIFO and scheduled transmission modes.
static naiapp_cmdtbl_params_t AR_FuncGenMenuCmds[] = {
{"FIFO ", "AR Transmit FIFO Mode ", AR_FUNCGEN_CMD_TX_FIFO, AR_TxFIFO},
{"SCHED ", "AR Transmit Scheduled Mode ", AR_FUNCGEN_CMD_TX_SCHEDULE, AR_TxSchedule}
};
The command table maps command strings to their respective functions.
Global Variables
static int32_t AR_FIFO_Size = 255;
-
AR_FIFO_Size: Defines the size of the FIFO buffer for transmissions.
Main Function
The main function is where the application begins execution:
int32_t main(void)
{
// Initialization and main loop for ARINC transmission
bool_t stop = FALSE;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE) {
while (stop != TRUE) {
Run_AR_Transmit();
}
printf("\nType Q to quit or Enter key to restart application:\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
naiapp_access_CloseAllOpenCards();
return 0;
}
This function: 1. Initializes and runs the board menu using the configuration file. 2. Enters a loop to continuously run the ARINC transmit application. 3. Allows quitting or restarting upon user input. 4. Ensures all open cards are closed before exiting.
Detailed Functions
1. Run_AR_Transmit
void Run_AR_Transmit(void)
{
// Query configuration and set up the ARINC transmission
int32_t cardIndex, module, archan;
nai_ar_datarate_t datarate;
bool_t bQuit = FALSE;
bool_t bContinue, bCmdFound;
int32_t cmd;
naiapp_AppParameters_t ar_params;
p_naiapp_AppParameters_t ar_transmit_params = &ar_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
bQuit = GetARCfg(DEF_AR_CARD_INDEX, DEF_AR_MODULE, DEF_AR_XMIT_CHANNEL, &cardIndex, &module, &archan);
ar_transmit_params->cardIndex = cardIndex;
ar_transmit_params->module = module;
ar_transmit_params->channel = archan;
if (!bQuit) {
bQuit = GetARINCDataRate(DEF_AR_DATA_RATE, &datarate);
if (!bQuit) {
bContinue = TRUE;
naiapp_utils_LoadParamMenuCommands(AR_FUNCGEN_CMD_COUNT, AR_FuncGenMenuCmds);
while (bContinue) {
// Reset and configure the channel
check_status(naibrd_AR_ChannelReset(cardIndex, module, archan));
check_status(naibrd_AR_SetTxEnable(cardIndex, module, archan, AR_DISABLE));
check_status(naibrd_AR_SetRxEnable(cardIndex, module, archan, AR_DISABLE));
check_status(naibrd_AR_SetDataRate(cardIndex, module, archan, datarate));
moduleID = naibrd_GetModuleID(cardIndex, module);
AR_FIFO_Size = naibrd_AR_GetMaxFifoCount(moduleID);
check_status(naibrd_AR_SetTxFifoThreshold(cardIndex, module, archan, AR_FIFO_Size));
check_status(naibrd_AR_SetParityAsData(cardIndex, module, archan, AR_PAR_ODD));
naibrd_AR_SetTxIntervalRate(cardIndex, module, archan, 6);
naiapp_display_ParamMenuCommands((int8_t *)"AR Receive Mode Menu");
printf("\nType AR command or %c to quit : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit) {
if (inputResponseCnt > 0) {
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound) {
switch (cmd) {
case AR_FUNCGEN_CMD_TX_FIFO:
case AR_FUNCGEN_CMD_TX_SCHEDULE:
AR_FuncGenMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)ar_transmit_params);
break;
default:
printf("Invalid command entered\n");
break;
}
}
else
printf("Invalid command entered\n");
}
}
else
bContinue = FALSE;
}
}
}
return;
}
Functionality: - Prompts the user for ARINC configuration (e.g., card, module, channel, data rate). - Displays a menu for selecting transmission mode. - Configures the ARINC channel and executes the corresponding transmission function.
2. AR_TxFIFO
nai_status_t AR_TxFIFO(int32_t paramCount, int32_t* p_params)
{
// Transmits data in FIFO mode
bool_t bQuit = FALSE;
int32_t nNumWordsToSend = 1;
int32_t nNumWordsSent;
int32_t i, j;
int32_t blockCnt, dataCnt, dataIndex;
int32_t increment = 0x55555555;
uint32_t SendData[255];
p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ad_params->cardIndex;
int32_t module = p_ad_params->module;
int32_t channel = p_ad_params->channel;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
check_status(naibrd_AR_SetTxSendMode(cardIndex, module, channel, AR_TX_SENDMODE_IMMED));
check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_ENABLE));
while (!bQuit) {
bQuit = GetARTransmitDataCount(DEF_AR_XMIT_DATA_COUNT, &nNumWordsToSend);
if (!bQuit) {
blockCnt = nNumWordsToSend / AR_FIFO_Size;
if (blockCnt * AR_FIFO_Size < nNumWordsToSend)
blockCnt++;
dataCnt = 0;
for (i = 0; i < blockCnt; i++) {
dataIndex = 0;
do {
SendData[dataIndex++] = (uint32_t)increment++;
dataCnt++;
} while ((dataIndex < AR_FIFO_Size) && (dataCnt < nNumWordsToSend));
printf("\nSending %d words ...\n", dataIndex);
for (j = 0; j < dataIndex; j++)
printf("Sent 0x%08X\n", SendData[j]);
check_status(naibrd_AR_TransmitBuffer(cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent));
printf(" %d words sent. Total words sent = %d\n", nNumWordsSent, dataCnt);
naibrd_Wait(1000000); // Delay to allow FIFO buffer to empty
}
}
}
check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_DISABLE));
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
Functionality: - Implements FIFO mode by sending blocks of data. - Prompts user for number of data words to send. - Sends data in blocks, prints sent data, and manages FIFO buffer emptying.
3. AR_TxSchedule
nai_status_t AR_TxSchedule(int32_t paramCount, int32_t* p_params)
{
// Transmits data in scheduled mode
bool_t bQuit = FALSE;
int32_t nMsgAddr, nSchedAddr, nJumpSchedAddr;
uint32_t uiMsgData, uiGapTime;
uint16_t usSchedData;
p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
int32_t Card = p_ad_params->cardIndex;
int32_t nMod = p_ad_params->module;
int32_t nChan = p_ad_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
check_status(naibrd_AR_SetTxSendMode(Card, nMod, nChan, AR_TX_SENDMODE_SCHED));
check_status(naibrd_AR_SetTxEnable(Card, nMod, nChan, AR_ENABLE));
printf("Initializing Message Memory\n");
// Initialize Message Memory with predefined message words and gap times
nMsgAddr = 0; uiMsgData = 0x55555555; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
nMsgAddr = 1; uiMsgData = 0xaaaaaaaa; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
nMsgAddr = 2; uiMsgData = 0xABCDEF55; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
nMsgAddr = 3; uiMsgData = 0x987654EE; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
nMsgAddr = 4; uiMsgData = 0x3210FD07; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
nMsgAddr = 5; uiMsgData = 0x555555EE; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
nMsgAddr = 6; uiMsgData = 0xAAAAAA0F; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
nMsgAddr = 7; uiMsgData = 0xFFFFFFFF; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
nMsgAddr = 8; uiGapTime = 0x00001234; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiGapTime));
nMsgAddr = 9; uiGapTime = 0x00002564; check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiGapTime));
printf("Building and Downloading Schedule\n");
// Build and download schedule
nMsgAddr = 0; nSchedAddr = 0; usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
nMsgAddr = 9; nSchedAddr++; usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
// Follow similar steps for the rest of the schedule...
usSchedData = (uint16_t)(AR_TX_SCHED_STOP | nJumpSchedAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
printf("Starting Schedule\n");
check_status(naibrd_AR_SetTxSendTrigger(Card, nMod, nChan));
while (!bQuit) {
printf("\nType A to send Async Data (0x11111111) or %c to quit (default: A) : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
check_status(naibrd_AR_WrTxAsyncWd(Card, nMod, nChan, 0x11111111)); // Send Async Data
}
printf("Stopping Schedule\n");
check_status(naibrd_AR_SetTxStop(Card, nMod, nChan));
check_status(naibrd_AR_SetTxEnable(Card, nMod, nChan, AR_DISABLE));
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
Functionality: - Initializes message and gap time memory. - Builds and downloads a predefined schedule. - Starts the schedule for transmitting data. - Prompts the user to send asynchronous data and handles the stopping of the transmission.
This sample application demonstrates how to set up and configure the ARINC 429 transmitter, using both FIFO and scheduled transmission modes, with NAI’s hardware. The provided functions utilize specific utility functions and handle configuration querying, user input, and transmission processes. This well-structured code allows users to effectively understand and manipulate ARINC data transmission.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* Common Sample Program include files */
#include "include/naiapp_boardaccess_menu.h"
#include "include/naiapp_boardaccess_query.h"
#include "include/naiapp_boardaccess_access.h"
#include "include/naiapp_boardaccess_display.h"
#include "include/naiapp_boardaccess_utils.h"
#include "nai_ar_utils.h"
#include "nai_ar_utils.h"
/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_ar.h"
static const int8_t *CONFIG_FILE = (int8_t *)"default_ARXmit.txt";
/* Function prototypes */
void Run_AR_Transmit(void);
nai_status_t AR_TxFIFO(int32_t paramCount, int32_t* p_params);
nai_status_t AR_TxSchedule(int32_t paramCount, int32_t* p_params);
/****** Command Table *******/
enum arfuncgen_commands
{
AR_FUNCGEN_CMD_TX_FIFO,
AR_FUNCGEN_CMD_TX_SCHEDULE,
AR_FUNCGEN_CMD_COUNT
};
/****** Command Tables *******/
static naiapp_cmdtbl_params_t AR_FuncGenMenuCmds[] =
{
{"FIFO ", "AR Transmit FIFO Mode ", AR_FUNCGEN_CMD_TX_FIFO, AR_TxFIFO},
{"SCHED ", "AR Transmit Scheduled Mode ", AR_FUNCGEN_CMD_TX_SCHEDULE, AR_TxSchedule}
};
#define DEF_AR_CARD_INDEX 0
#define DEF_AR_MODULE 1
#define DEF_AR_XMIT_CHANNEL 1
#define DEF_AR_SCHED 0
#define DEF_AR_DATA_RATE AR_SPEED_LOW
#define DEF_AR_XMIT_DATA_COUNT 1
/***** Global Variables *****/
static int32_t AR_FIFO_Size = 255;
/**************************************************************************************************************/
/**
<summary>
The purpose of the AR_Transmit is to illustrate the methods to call in the naibrd library to configure
the ARINC channel to transmit ARINC messages in FIFO or scheduled mode.
The following system configuration routines from the nai_sys_cfg.c file are called to assist with the configuration
setup for this program prior to calling the naibrd 1553 routines.
- ClearDeviceCfg
- QuerySystemCfg
- DisplayDeviceCfg
- GetBoardSNModCfg
- SaveDeviceCfg
Note, the AR_Transmit application can run in conjunction with the AR_Receive, AR_ReceiveInterruptEther or
AR_ReceiveInterruptBus applications to illustrate ARINC transmit and receive operations together with the NAI ARINC module.
</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t AR_Transmit(void)
#else
int32_t main(void)
#endif
{
bool_t stop = FALSE;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
{
while (stop != TRUE)
{
Run_AR_Transmit();
}
printf("\nType Q to quit or Enter key to restart application:\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
naiapp_access_CloseAllOpenCards();
return 0;
}
nai_status_t AR_TxSchedule(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
int32_t nMsgAddr, nSchedAddr, nJumpSchedAddr;
uint32_t uiMsgData, uiGapTime;
uint16_t usSchedData;
p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
int32_t Card = p_ad_params->cardIndex;
int32_t nMod = p_ad_params->module;
int32_t nChan = p_ad_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
/* Set Scheduled Transmission mode */
check_status(naibrd_AR_SetTxSendMode(Card, nMod, nChan, AR_TX_SENDMODE_SCHED));
/* Enable Transmitter */
check_status(naibrd_AR_SetTxEnable(Card, nMod, nChan, AR_ENABLE));
/************************************************************************/
/* Initialize Message Memory (0 - 255) with Message Words and Gap Times */
/************************************************************************/
printf("Initializing Message Memory\n");
/* Put 32-bit Message Word into Message Memory at address 0 */
nMsgAddr = 0;
uiMsgData = 0x55555555;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
/* Put 32-bit Message Word into Message Memory at address 1 */
nMsgAddr = 1;
uiMsgData = 0xaaaaaaaa;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
/* Put 32-bit Message Word into Message Memory at address 2 */
nMsgAddr = 2;
uiMsgData = 0xABCDEF55;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
/* Put 32-bit Message Word into Message Memory at address 3 */
nMsgAddr = 3;
uiMsgData = 0x987654EE;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
/* Put 32-bit Message Word into Message Memory at address 4 */
nMsgAddr = 4;
uiMsgData = 0x3210FD07;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
/* Put 32-bit Message Word into Message Memory at address 5 */
nMsgAddr = 5;
uiMsgData = 0x555555EE;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
/* Put 32-bit Message Word into Message Memory at address 6 */
nMsgAddr = 6;
uiMsgData = 0xAAAAAA0F;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
/* Put 32-bit Message Word into Message Memory at address 7 */
nMsgAddr = 7;
uiMsgData = 0xFFFFFFFF;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiMsgData));
/* Put Gap Time into Message Memory at address 8 */
nMsgAddr = 8;
uiGapTime = 0x00001234;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiGapTime));
/* Put Fixed Gap Time into Message Memory at address 9 */
nMsgAddr = 9;
uiGapTime = 0x00002564;
check_status(naibrd_AR_WrTxMsgMem(Card, nMod, nChan, nMsgAddr, uiGapTime));
/***********************************************************/
/* Build and Download Schedule - Schedule Memory (0 - 511) */
/***********************************************************/
printf("Building and Downloading Schedule\n");
/* Put Schedule Message Command into Schedule Memory at address 0 */
printf("\nSchedule 0 is Message 0x55555555\n");
nMsgAddr = 0;
nSchedAddr = 0;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Fixed Gap Command into next Schedule Memory */
printf("Schedule 1 is Fixed Gap 0x00002564\n");
nMsgAddr = 9;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Message Command into next Schedule Memory */
printf("Schedule 2 is Message 0xAAAAAAAA\n");
nMsgAddr = 1;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Gap Command into next Schedule Memory */
printf("Schedule 3 is Gap 0x00001234\n");
nMsgAddr = 8;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_GAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Message Command into Schedule Memory at address 0 */
printf("Schedule 4 is Message 0xABCDEF55\n");
nMsgAddr = 2;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Fixed Gap Command into next Schedule Memory */
printf("Schedule 5 is Fixed Gap 0x00002564\n");
nMsgAddr = 9;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Message Command into next Schedule Memory */
printf("Schedule 6 is Message 0x987654EE\n");
nMsgAddr = 3;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Gap Command into next Schedule Memory */
printf("Schedule 7 is Gap 0x00001234\n");
nMsgAddr = 8;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_GAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Message Command into Schedule Memory at address 0 */
printf("Schedule 8 is Message 0x3210FD07\n");
nMsgAddr = 4;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Fixed Gap Command into next Schedule Memory */
printf("Schedule 9 is Fixed Gap 0x00002564\n");
nMsgAddr = 9;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Message Command into next Schedule Memory */
printf("Schedule 10 is Message 0x555555EE\n");
nMsgAddr = 5;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Gap Command into next Schedule Memory */
printf("Schedule 11 is Gap 0x00001234\n");
nMsgAddr = 8;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_GAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Message Command into Schedule Memory at address 0 */
printf("Schedule 12 is Message 0xAAAAAA0F\n");
nMsgAddr = 6;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Fixed Gap Command into next Schedule Memory */
printf("Schedule 13 is Fixed Gap 0x00002564\n");
nMsgAddr = 9;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_FIXEDGAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Message Command into next Schedule Memory */
printf("Schedule 14 is Message 0xFFFFFFFF\n");
nMsgAddr = 7;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_MESSAGE | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Gap Command into next Schedule Memory */
printf("Schedule 15 is Gap 0x00001234\n");
nMsgAddr = 8;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_GAP | nMsgAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Put Schedule Jump Command into next Schedule Memory */
printf("Schedule 4 is Jump to Schedule 0\n");
nJumpSchedAddr = 3;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_JUMP | nJumpSchedAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
printf("Schedule 16 is Stop\n");
nJumpSchedAddr = 0;
nSchedAddr++;
usSchedData = (uint16_t)(AR_TX_SCHED_STOP | nJumpSchedAddr);
check_status(naibrd_AR_WrTxSchMem(Card, nMod, nChan, nSchedAddr, usSchedData));
/* Start schedule mode */
printf("\nStarting Schedule\n");
check_status(naibrd_AR_SetTxSendTrigger(Card, nMod, nChan));
while (!bQuit)
{
printf("\nType A to send Async Data (0x11111111) or %c to quit (default: A) : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
check_status(naibrd_AR_WrTxAsyncWd(Card, nMod, nChan, 0x11111111)); /* Send Async Data */
}
/* Stop schedule mode */
printf("\nStopping Schedule\n");
check_status(naibrd_AR_SetTxStop(Card, nMod, nChan));
/* Disable transmitter */
check_status(naibrd_AR_SetTxEnable(Card, nMod, nChan, AR_DISABLE));
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
nai_status_t AR_TxFIFO(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
int32_t nNumWordsToSend = 1;
int32_t nNumWordsSent;
int32_t i, j;
int32_t blockCnt, dataCnt, dataIndex;
int32_t increment = 0x55555555;
uint32_t SendData[255];
p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ad_params->cardIndex;
int32_t module = p_ad_params->module;
int32_t channel = p_ad_params->channel;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
/* Set Immediate FIFO Transmission mode */
check_status(naibrd_AR_SetTxSendMode(cardIndex, module, channel, AR_TX_SENDMODE_IMMED));
/* Enable transmitter */
check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_ENABLE));
while (!bQuit)
{
/* Query for the number of data words to send */
bQuit = GetARTransmitDataCount(DEF_AR_XMIT_DATA_COUNT, &nNumWordsToSend);
if (!bQuit)
{
/* Break up the FIFO updates to blocks of AR_FIFOSize */
blockCnt = nNumWordsToSend / AR_FIFO_Size;
if (blockCnt * AR_FIFO_Size < nNumWordsToSend)
blockCnt++;
dataCnt = 0;
for (i = 0; i < blockCnt; i++)
{
dataIndex = 0;
do
{
SendData[dataIndex++] = (uint32_t)increment++; /* incremental data */
dataCnt++;
} while ((dataIndex < AR_FIFO_Size) && (dataCnt < nNumWordsToSend));
printf("\nSending %d words ...\n", dataIndex);
for (j = 0; j < dataIndex; j++)
printf("Sent 0x%08X\n", SendData[j]);
check_status(naibrd_AR_TransmitBuffer(cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent)); /* send data */
printf(" %d words sent. Total words sent = %d\n", nNumWordsSent, dataCnt);
naibrd_Wait(1000000); /* Delay is necessary to allow the FIFO buffer to empty before filling it up with more data */
}
}
}
/* Disable transmitter */
check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_DISABLE));
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
/**************************************************************************************************************/
/**
<summary>
Run_AR_Transmit queries the user for the card, module and channel to configure as the ARINC transmitter
as well as the data rate (high (100KHz) or low (12.5KHz)) and the type of message transmission (FIFO or scheduled).
Methods in the naibrd library are invoked to configure the ARINC channel.
Once the ARINC channel is configured and running, the user can:
1) In FIFO mode, enter the number of words to transmit. Note, the data sent is an incremental value.
2) In Scheduled mode, transmit an async ARINC data word.
</summary>
*/
/**************************************************************************************************************/
void Run_AR_Transmit(void)
{
int32_t cardIndex, module, archan;
nai_ar_datarate_t datarate;
uint32_t moduleID;
bool_t bQuit = FALSE;
bool_t bContinue, bCmdFound;
int32_t cmd;
naiapp_AppParameters_t ar_params;
p_naiapp_AppParameters_t ar_transmit_params = &ar_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
bQuit = GetARCfg(DEF_AR_CARD_INDEX, DEF_AR_MODULE, DEF_AR_XMIT_CHANNEL, &cardIndex, &module, &archan);
ar_transmit_params->cardIndex = cardIndex;
ar_transmit_params->module = module;
ar_transmit_params->channel = archan;
if (!bQuit)
{
/* Get Data Rate */
bQuit = GetARINCDataRate(DEF_AR_DATA_RATE, &datarate);
if (!bQuit)
{
bContinue = TRUE;
naiapp_utils_LoadParamMenuCommands(AR_FUNCGEN_CMD_COUNT, AR_FuncGenMenuCmds);
while (bContinue)
{
/* Reset the channel */
check_status(naibrd_AR_ChannelReset(cardIndex, module, archan));
/* Disable Tx/Rx */
check_status(naibrd_AR_SetTxEnable(cardIndex, module, archan, AR_DISABLE));
check_status(naibrd_AR_SetRxEnable(cardIndex, module, archan, AR_DISABLE));
/* Set the transmission speed */
check_status(naibrd_AR_SetDataRate(cardIndex, module, archan, datarate));
/* Set the Tx Fifo Threshold to the maximum size of the FIFO */
moduleID = naibrd_GetModuleID(cardIndex, module);
AR_FIFO_Size = naibrd_AR_GetMaxFifoCount(moduleID);
check_status(naibrd_AR_SetTxFifoThreshold(cardIndex, module, archan, AR_FIFO_Size));
/* Set the Parity Disable bit to cause the ARINC bit 32 to be treated as an odd parity bit */
check_status(naibrd_AR_SetParityAsData(cardIndex, module, archan, AR_PAR_ODD));
naibrd_AR_SetTxIntervalRate(cardIndex, module, archan, 6);
naiapp_display_ParamMenuCommands((int8_t *)"AR Receive Mode Menu");
printf("\nType AR command or %c to quit : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
switch (cmd)
{
case AR_FUNCGEN_CMD_TX_FIFO:
case AR_FUNCGEN_CMD_TX_SCHEDULE:
AR_FuncGenMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)ar_transmit_params);
break;
default:
printf("Invalid command entered\n");
break;
}
}
else
printf("Invalid command entered\n");
}
}
else
bContinue = FALSE;
}
}
}
return;
}