AR568 Xmit
Edit this on GitLab
AR568 Xmit Sample Application (SSK 2.x)
Overview
The AR568 Xmit sample application demonstrates how to configure an ARINC 568 channel for message transmission using the NAI Software Support Kit (SSK 2.x). The application supports two transmit modes: FIFO immediate (data transmits as soon as it is loaded) and FIFO triggered (data waits for a trigger signal). The user selects the card, module, channel, and transmit mode, then enters the number of words to send.
This sample supports AR568 module types. It is designed to work with the AR568 Recv sample application for receive testing.
This sample is new to SSK 2.x and has no SSK 1.x counterpart.
Prerequisites
Before running this sample, make sure you have:
-
An NAI board with an AR568 module installed.
-
SSK 2.x installed on your development host.
-
The sample applications built. Refer to the SSK 2.x Software Development Guide for platform-specific build instructions.
Channel Configuration
The AR568_Transmit_run() function configures the transmitter:
check_status( naibrd_AR568_ChannelReset( cardIndex, module, archan ) );
check_status( naibrd_AR568_SetTxFifoThresholds( cardIndex, module, archan, 250, 750 ) );
check_status( naibrd_AR568_SetTxGapTime( cardIndex, module, archan, 6 ) );
-
Tx FIFO thresholds — Almost Empty at 250, Almost Full at 750.
-
Gap time — 6 bit-times between messages.
Transmit Modes
FIFO Immediate Mode
Data transmits as soon as it is loaded:
check_status( naibrd_AR568_SetTransmitSendMode( cardIndex, module, channel, txmode ) );
check_status( naibrd_AR568_SetTxEnable( cardIndex, module, channel, NAI_TRUE ) );
check_status( naibrd_AR568_LoadTxFifo( cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent ) );
Troubleshooting Reference
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
No board found or connection timeout |
Board not powered, incorrect configuration file |
Verify hardware is powered and connected. |
Data not received by receiver |
Cable not connected, wrong channel |
Verify ARINC 568 cabling. |
Tx FIFO overflow |
Loading data faster than transmit rate |
Wait for Tx FIFO Almost Empty before loading more data. |
Triggered mode does not transmit |
Trigger not sent |
Call |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — ar568_xmit.c (SSK 2.x)
/* nailib include files */
#include "nai_libs/nailib/include/naitypes.h"
#include "nai_libs/nailib/include/nailib.h"
#include "nai_libs/nailib/include/nailib_utils.h"
/* naibrd include files */
#include "nai_libs/naibrd/include/naibrd.h"
/* naiif include files */
#include "nai_libs/naiif/include/naiif_stdio.h"
/* Common Sample Program include files */
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_menu.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_query.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_access.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_display.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_utils.h"
/* AD Sample App include files */
#include "nai_sample_apps/naiapp_src/board_modules/ar568/ar568_common_utils/ar568_common_utils.h"
static const int8_t *CONFIG_FILE = (int8_t *)"default_AR568Xmit.txt";
/* Function prototypes */
static bool_t AR568_Transmit_run();
static bool_t AR568_TxFIFO( int32_t cardIndex, int32_t module, int32_t channel, naibrd_ar568_tx_mode_t txmode );
static void waitForStatus(int32_t cardIndex, int32_t module, int32_t channel, uint32_t status);
/* Default channel selection */
#define DEF_AR_CARD_INDEX 0
#define DEF_AR_MODULE 1
#define DEF_AR_XMIT_CHANNEL 1
/* Default channel configuration settings */
#define DEF_AR_TX_MODE NAIBRD_AR568_TX_SENDMODE_IMMED
#define DEF_AR_XMIT_DATA_COUNT 1
/**************************************************************************************************************/
/**
* <summary>
* The purpose of the AR568_Transmit is to illustrate the methods to call in the naibrd library to configure
* the ARINC-568 channel to transmit ARINC-568 messages in FIFO 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.
* - ConfigDevice
* - DisplayDeviceCfg
* - GetBoardSNModCfg
* - CheckModule
*
* Note, the AR568_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>
*/
/**************************************************************************************************************/
#ifdef NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS
int32_t AR568_Transmit(void)
#else
int32_t main(void)
#endif
{
bool_t bQuit = NAI_FALSE;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(CONFIG_FILE) == (bool_t)NAI_TRUE)
{
while (!bQuit)
{
bQuit = AR568_Transmit_run();
}
naiif_printf("Type the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
naiapp_access_CloseAllOpenCards();
return 0;
}
/**************************************************************************************************************/
/**
<summary>
Run_AR568_Transmit queries the user for the card, module and channel to configure as the ARINC-568 transmitter
and the mode of message transmission (FIFO Immediate, or FIFO Triggered). Methods in the naibrd library are
invoked to configure the ARINC-568 channel. Once the ARINC channel is configured:
1) In FIFO Immediate mode, the user enters the number of words to transmit. When the Tx FIFO is loaded with data,
transmission begins immediately and the program polls the channel status to check Tx FIFO Almost Empty and if true,
more data (if any) is loaded into the Tx FIFO to keep the transmission going.
2) In FIFO Triggered mode, the user enters the number of words to transmit. When the Tx FIFO is loaded with data,
transmission does not begin immediately. Instead the user will be asked to send a trigger to initiate transmission
and the program polls the channel status to check Tx FIFO Almost Empty and if true, more data (if any) is loaded
into the Tx FIFO to keep the transmission going.
</summary>
*/
/**************************************************************************************************************/
static bool_t AR568_Transmit_run()
{
int32_t archan;
bool_t bQuit = NAI_FALSE;
naibrd_ar568_tx_mode_t txmode;
int32_t cardIndex, module;
bQuit = GetAR568Cfg( DEF_AR_CARD_INDEX, DEF_AR_MODULE, DEF_AR_XMIT_CHANNEL, &cardIndex, &module, &archan );
if (!bQuit)
{
/* Reset the channel */
check_status( naibrd_AR568_ChannelReset( cardIndex, module, archan ) );
/* Set the Tx Fifo Almost Empty Threshold to 250 and the Tx Fifo Almost Full Threshold to 750 */
/* If the number of messages in the Tx FIFO falls under 250, the Tx FIFO Almost Empty Status will be set */
/* If the number of messages in the Tx FIFO rises above 750, the Tx FIFO Almost Full Status will be set */
check_status( naibrd_AR568_SetTxFifoThresholds( cardIndex, module, archan, 250, 750 ) );
/* Set the inter-message transmission gap time (interval rate) */
check_status( naibrd_AR568_SetTxGapTime( cardIndex, module, archan, 6 ) ); /* 6 bit-times */
/* Get the Tx Mode */
bQuit = GetAR568TxMode( DEF_AR_TX_MODE, &txmode );
if (!bQuit)
{
bQuit = AR568_TxFIFO( cardIndex, module, archan, txmode );
}
}
return bQuit;
}
static bool_t AR568_TxFIFO( int32_t cardIndex, int32_t module, int32_t channel, naibrd_ar568_tx_mode_t txmode )
{
bool_t bQuit = NAI_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];
int32_t blockSize = 200;
bool_t triggerSent = NAI_FALSE;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
/* Set FIFO Transmission mode */
check_status( naibrd_AR568_SetTransmitSendMode( cardIndex, module, channel, txmode ) );
/* Enable transmitter */
check_status( naibrd_AR568_SetTxEnable( cardIndex, module, channel, NAI_TRUE ) );
while (!bQuit)
{
/* Query for the number of data words to send */
bQuit = GetAR568TransmitDataCount( DEF_AR_XMIT_DATA_COUNT, &nNumWordsToSend );
if (!bQuit)
{
/* Break up the FIFO updates to blocks of 200. The idea here is to load and transmit 200 ARINC words at a time */
/* until all of the words have been sent. The following code causes loading and re-loading of the Tx buffer to */
/* occur when the Tx FIFO is almost empty, which means less than 32 ARINC messages are in the FIFO and there is */
/* room in the buffer for 200 more messages. */
blockCnt = nNumWordsToSend / blockSize;
if ( blockCnt * blockSize < nNumWordsToSend )
blockCnt++;
dataCnt = 0;
for ( i = 0; i < blockCnt; i++ )
{
dataIndex = 0;
do
{
SendData[dataIndex++] = (uint32_t)increment++; /* incremental data */
dataCnt++;
} while ( ( dataIndex < blockSize ) && ( dataCnt < nNumWordsToSend ) );
naiif_printf( "\r\nLoading %d words ...\r\n", dataIndex );
for ( j = 0; j < dataIndex; j++ )
naiif_printf( "0x%08X\r\n", SendData[j] );
check_status( naibrd_AR568_LoadTxFifo( cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent ) ); /* send data */
if ((txmode == NAIBRD_AR568_TX_SENDMODE_TRGF) && (triggerSent == NAI_FALSE))
{
/* If Triggered Mode, user sends trigger signal to start transmission */
naiif_printf("Press Enter to send trigger signal and start transmission...\r\n");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
check_status( naibrd_AR568_SetTxSendTrigger(cardIndex, module, channel) );
triggerSent = NAI_TRUE;
}
naiif_printf( " %d words sent. Total words sent = %d\r\n", nNumWordsSent, dataCnt );
/* Wait for Tx Buffer Almost Empty before loading more messages into Tx FIFO */
waitForStatus(cardIndex, module, channel, NAIBRD_AR568_EVENT_STATUS_GENERAL_TX_FIFO_ALM_EMPTY);
}
/* Lastly, wait for Tx Buffer to empty */
waitForStatus(cardIndex, module, channel, NAIBRD_AR568_EVENT_STATUS_GENERAL_TX_FIFO_EMPTY);
}
}
/* Disable transmitter */
check_status( naibrd_AR568_SetTxEnable( cardIndex, module, channel, NAI_FALSE ) );
return bQuit;
}
/* This function waits on one or more realtime (dynamic) channel status bits as defined by the user and exits when all bits are set. */
static void waitForStatus(int32_t cardIndex, int32_t module, int32_t channel, uint32_t status)
{
uint32_t chanStatus;
do
{
check_status( naibrd_AR568_GetEventMappedStatusRaw(cardIndex, module, channel, NAI_STATUS_REALTIME, NAIBRD_AR568_EVENT_MAP_GENERAL, &chanStatus) );
naibrd_msDelay(1);
} while ((chanStatus & status) != status);
}