Integrator Resources

The official home for NAI Support

Not sure where to start? Try Quick Start Guide or ask a question below!

Toggle Components with Visual Button
JavaScript Form Processing

nai ar cfg

nai ar cfg

Explanation

About the Sample Application Code

This sample application code, provided by North Atlantic Industries (NAI), interacts with their Single Board Computer (SBC) and embedded function modules. The code emphasizes ARINC 429 responsibilities, setting timing controls, configuring receive (Rx) and transmit (Tx) channels, and managing FIFO thresholds.

The main components of the sample code are as follows:

Include Statements The sample includes several headers for interactions with NAI�s systems and general utilities: - '<stdio.h>', '<ctype.h>', '<stdlib.h>', and '<string.h>': Standard C libraries. - 'include/naiapp_*': Custom NAI application headers for interrupt handling, board access, and utility functions. - 'nai_ar_*': ARINC-specific configuration, interrupt, and utility functions. - 'nai.h', 'naibrd.h', 'functions/naibrd_ar.h': NAI board and ARINC-related functionalities.

Macro Definitions Several macros define default values for ARINC configurations: '''c #define DEF_AR_CARD_INDEX 0 #define DEF_AR_MODULE 1 #define DEF_AR_RECV_CHANNEL 1 #define DEF_AR_DATA_RATE AR_SPEED_LOW #define DEF_AR_TIMESTAMP_ENABLED TRUE '''

Function Definitions

'bool_t IsAR(uint32_t moduleID)' Determines if a given module ID corresponds to an ARINC module.

'void setARTiming(int32_t cardIndex, int32_t module, nai_ar_tstamp_t value)' Sets the ARINC timing control using the raw value. Utilizes the 'naibrd_AR_SetTimeCtrlRaw' function.

'void Cfg_Rx_AR(ArConfig inputARConfig)' Configures ARINC channels for receiving (Rx). This function: 1. Retrieves the data rate. 2. Iterates over channels to: - Reset channels. - Configure timing, FIFO thresholds, and other settings. - Enable the receiver and set the data rate.

'void Cfg_Tx_AR(ArConfig inputARConfig)' Configures ARINC channels for transmitting (Tx). This function: 1. Iterates over channels to: - Set AR timing. - Enable transmission.

'void setARFIFOStatusConditions(int32_t cardIndex, int32_t module, int32_t channel)' Sets FIFO threshold conditions for a given channel.

'void initializeARConfigurations(int32_t cardIndex, int32_t module, int32_t modid, int32_t channel, int32_t maxChannel, int32_t minChannel, int32_t buffer_Length, nai_ar_tstamp_t ar_timeStamp, bool_t timeStampEnable)' Initializes configurations for ARINC communication.

Data Structures and Types The code uses several NAI-specific types and structures: - 'bool_t': A boolean type, presumably defined in NAI headers. - 'nai_ar_tstamp_t': Represents ARINC timestamp-related values. - 'ArConfig': A structure presumably defined elsewhere in the code, containing ARINC configuration parameters like card index, module, channel, data rate, and more.

Function Calls The functions from 'naibrd_*/nai_*' headers play a crucial role in interacting with the hardware: - 'naibrd_AR_SetTimeCtrlRaw': Sets raw timing control values. - 'naibrd_AR_ChannelReset': Resets a specific channel. - 'naibrd_AR_SetTxEnable', 'naibrd_AR_SetRxEnable': Enable or disable transmission and reception. - 'naibrd_AR_ClearRxFifo': Clears the Rx FIFO. - 'naibrd_AR_SetDataRate': Sets the data rate for a channel. - 'naibrd_GetModuleID': Retrieves the module ID. - 'naibrd_AR_GetMaxFifoCount': Gets the maximum FIFO count for a module. - 'naibrd_AR_SetRxFifoThreshold', 'naibrd_AR_SetTxFifoThreshold': Sets FIFO thresholds. - 'naibrd_AR_SetParityAsData': Sets the parity as data. - 'naibrd_AR_SetRxStoreErrorDisable': Configures error storage on the receiver. - 'naibrd_AR_SetRxTimeStampEn': Enables or disables timestamping on reception.

Explanation and Flow The code initializes configurations for ARINC modules, setting parameters such as data rates, enabling channels for Rx and Tx, and managing FIFO settings. The functions provide modular configuration capabilities, allowing the user to set specific timings, error handling, parity, and data rates for multiple channels effectively.

Conclusion This sample application code is a robust starting point for interacting with NAI�s ARINC modules within an SBC. The functions collectively manage initialization, configuration, and real-time data communication setup, making it a comprehensive utility for embedded system developers working with NAI hardware.

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>

/* Common Sample Program include files */
#include "include/naiapp_interrupt.h"
#include "include/naiapp_interrupt_ether.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"

/* Common AR Sample Program include files */
#include "nai_ar_cfg.h"
#include "nai_ar_int.h"
#include "nai_ar_utils.h"

/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_ar.h"

#define DEF_AR_CARD_INDEX           0
#define DEF_AR_MODULE               1
#define DEF_AR_RECV_CHANNEL         1
#define DEF_AR_DATA_RATE            AR_SPEED_LOW
#define DEF_AR_TIMESTAMP_ENABLED    TRUE

bool_t IsAR(uint32_t moduleID)
{
   bool_t bARFunc = FALSE;
   switch (moduleID)
   {
      case NAI_MODULE_ID_A4:
      case NAI_MODULE_ID_AR1:
         bARFunc = TRUE;
         break;
      default:
         bARFunc = FALSE;
         break;
   }
   return bARFunc;
}

/**************************************************************************************************************/
/**
<summary>

</summary>
*/
/**************************************************************************************************************/

void setARTiming(int32_t cardIndex, int32_t module, nai_ar_tstamp_t value)
{
   check_status(naibrd_AR_SetTimeCtrlRaw(cardIndex, module, value));
}

/**************************************************************************************************************/
/**
<summary>
This function configures the baud rate of the ar channels in the minChannel,maxChannel range to the values set
in inputARConfig. Enables the channels to Rx
</summary>
*/
/**************************************************************************************************************/
void Cfg_Rx_AR(ArConfig inputARConfig)
{
   int32_t cardIndex = inputARConfig.cardIndex;
   int32_t module = inputARConfig.module;
   int32_t channel = inputARConfig.channel;
   int32_t minChannel = inputARConfig.minChannel;
   int32_t maxChannel = inputARConfig.maxChannel;
   nai_ar_datarate_t datarate;
   uint32_t moduleID;
   int32_t AR_FIFO_Size;
   bool_t bTimestampEnabled = inputARConfig.timeStampEnable;

   bool_t bQuit = FALSE;

   /* Get Data Rate */
   bQuit = GetARINCDataRate(DEF_AR_DATA_RATE, &datarate);
   if (!bQuit)
   {
      for (channel = minChannel; channel <= maxChannel; channel++)
      {
         /* Reset the channel */
         check_status(naibrd_AR_ChannelReset(cardIndex, module, channel));
         /* Disable Tx/Rx */
         check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, AR_DISABLE));
         check_status(naibrd_AR_SetRxEnable(cardIndex, module, channel, AR_DISABLE));
         /* Set AR timing */
         check_status(naibrd_AR_SetTimeCtrlRaw(cardIndex, module, inputARConfig.ar_timeStamp));

         setARFIFOStatusConditions(cardIndex, module, channel);

         /* Clear Rx FIFO */
         check_status(naibrd_AR_ClearRxFifo(cardIndex, module, channel));

         /* Enable AR Receiver */
         check_status(naibrd_AR_SetRxEnable(cardIndex, module, channel, TRUE));  /* Turn on RX in AR CTRL REG */
         /* Set the transmission speed */
         check_status(naibrd_AR_SetDataRate(cardIndex, module, channel, datarate));
         /* Set the Rx 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_SetRxFifoThreshold(cardIndex, module, channel, 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, channel, AR_PAR_ODD));
         check_status(naibrd_AR_SetRxStoreErrorDisable(cardIndex, module, channel, AR_STORE_ON_ERROR_ENABLE));

         /* Set Timestamp Enable */
         check_status(naibrd_AR_SetRxTimeStampEn(cardIndex, module, channel, bTimestampEnabled));
      }
   }
}

/**************************************************************************************************************/
/**
<summary>
This function configures the baud rate of the ar channels in the minChannel, maxChannel range to the values
set in inputARConfig. Enables the channels to Tx.
</summary>
*/
/**************************************************************************************************************/
void Cfg_Tx_AR(ArConfig inputARConfig)
{
   int32_t cardIndex = inputARConfig.cardIndex;
   int32_t module = inputARConfig.module;
   int32_t channel;
   int32_t minChannel = inputARConfig.minChannel;
   int32_t maxChannel = inputARConfig.maxChannel;

   for (channel = minChannel; channel <= maxChannel; channel++)
   {
      /* Set AR timing */
      check_status(naibrd_AR_SetTimeCtrlRaw(cardIndex, module, inputARConfig.ar_timeStamp));

      check_status(naibrd_AR_SetTxEnable(cardIndex, module, channel, TRUE));
   }
}

/**************************************************************************************************************/
/**
<summary>
Sets the thresholds for the status register of the passed in channel
</summary>
*/
/**************************************************************************************************************/
void setARFIFOStatusConditions(int32_t cardIndex, int32_t module, int32_t channel)
{
   int32_t writeVal;

   writeVal = 255;

   check_status(naibrd_AR_SetTxFifoThreshold(cardIndex, module, channel, writeVal));

   check_status(naibrd_AR_SetRxFifoThreshold(cardIndex, module, channel, writeVal));
}

/**************************************************************************************************************/
/**
<summary>

</summary>
*/
/**************************************************************************************************************/
void initializeARConfigurations(int32_t cardIndex, int32_t module, int32_t modid, int32_t channel, int32_t maxChannel, int32_t minChannel, int32_t buffer_Length, nai_ar_tstamp_t ar_timeStamp, bool_t timeStampEnable)
{
   inputARConfig.cardIndex = cardIndex;
   inputARConfig.module = module;
   inputARConfig.modid = modid;
   inputARConfig.channel = channel;
   inputARConfig.maxChannel = maxChannel;
   inputARConfig.minChannel = minChannel;
   inputARConfig.buffer_Length = buffer_Length;
   inputARConfig.ar_timeStamp = ar_timeStamp;
   inputARConfig.timeStampEnable = timeStampEnable;
}

Help Bot

X