DT Summary
Edit this on GitLab
DT Summary Sample Application (SSK 2.x)
Overview
The DT Summary sample application demonstrates how to read and manage fault status across all channels of a Discrete module using the NAI Software Support Kit (SSK 2.x). It covers the core status operations you will need in your own application: displaying latched BIT, overcurrent, and summary status for every channel, clearing latched status registers, forcing a BIT error for diagnostic testing, and configuring interrupts on the summary status register.
The summary register is the key concept in this sample. It is a bit-mapped register where each bit corresponds to a channel (bit 0 = channel 1). A bit reads 1 when the corresponding channel has detected a fault in either its BIT status or overcurrent status. This gives you a single register to poll for any fault condition across the entire module, rather than reading BIT and overcurrent status individually for each channel.
This sample supports DT module types: DT1-DT5. It serves as a practical API reference — each menu command maps directly to one or more naibrd_DT_*() API calls that you can lift into your own code.
|
Note
|
This pattern 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 a Discrete module installed (DT1-DT5).
-
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.
How to Run
Launch the dt_summary executable from your build output directory. On startup the application looks for a configuration file (default_DT_Summary.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, select a channel for interrupt and fault injection operations, then use the command menu to display status, configure interrupts, force BIT errors, and clear status registers.
The recommended sequence for exploring this sample is:
-
CLEAR — clear all latched status registers to start from a clean state.
-
STAT — display all latched statuses (should all be zero after clearing).
-
INT — configure the interrupt subsystem on your selected channel.
-
FAULT — force a BIT error on the selected channel.
-
STAT — display statuses again to see the BIT and summary bits set.
-
CLEAR — clear all statuses to reset.
Board Connection and Module Selection
|
Note
|
This startup sequence is common to all NAI sample applications. The board connection and module selection code shown here is not specific to Discrete modules. |
The main() function follows a standard SSK 2.x startup flow:
-
Call
naiapp_RunBoardMenu()to load a saved configuration file (if one exists) or present the interactive board menu. The configuration file (default_DT_Summary.txt) is not included with the SSK — it is created when the user saves their connection settings from the board menu. On the first run, the menu will always appear. -
Query the user for a card index with
naiapp_query_CardIndex(). -
Query for a module slot with
naiapp_query_ModuleNumber(). -
Retrieve the module ID with
naibrd_GetModuleName()so downstream code can adapt to the specific Discrete variant installed.
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t dt_summary(void)
#else
int32_t main(void)
#endif
{
int32_t cardIndex;
int32_t moduleCnt;
int32_t module;
bool_t stop = NAI_FALSE;
uint32_t moduleID;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
{
while (stop != NAI_TRUE)
{
stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), DEF_DT_CARD_INDEX, &cardIndex);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
stop = naiapp_query_ModuleNumber(moduleCnt, DEF_DT_MODULE, &module);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if ((moduleID != 0))
{
Run_DT_Summary(cardIndex, module, moduleID);
}
}
}
}
}
naiapp_access_CloseAllOpenCards();
return 0;
}
After module selection, Run_DT_Summary() calls naibrd_DT_GetChannelCount() to determine how many channels the installed module supports, then hands off to the command loop in Cfg_DT_Channel().
maxchannel = naibrd_DT_GetChannelCount(modid);
if (maxchannel == 0)
{
naiif_printf(" *** Module selection not recognized as DT module. ***\r\n\r\n");
}
else
{
Cfg_DT_Channel(cardIndex, module, maxchannel);
}
-
modid— the module ID returned bynaibrd_GetModuleName(). -
naibrd_DT_GetChannelCount()— returns 0 if the module ID does not match a known Discrete module type.
Program Structure
Application Parameters
The sample stores connection and module context in an naiapp_AppParameters_t struct:
naiapp_AppParameters_t dtparams;
p_naiapp_AppParameters_t dtParams = &dtparams;
dtParams->cardIndex = cardIndex;
dtParams->module = module;
dtParams->maxChannels = MaxChannel;
dtParams->channel = chan;
-
cardIndex— identifies the board. -
module— the slot containing the Discrete module. -
maxChannels— the channel count for the installed module. -
channel— the channel selected for interrupt and fault injection operations. This is queried once when entering the command loop.
In your own application, you will track these same values however is convenient — the struct is a sample convenience, not an API requirement.
Command Menu
The sample presents four commands through its menu system:
| Command | Menu Label | Operation |
|---|---|---|
|
DT Configure Interrupt |
Configure interrupt on the selected channel |
|
DT Display Status |
Display latched BIT, overcurrent, and summary status for all channels |
|
DT Clear Status |
Clear all latched status registers across all channels |
|
DT Force BIT Error |
Force a BIT error on the selected channel |
The menu system is a sample convenience — in your own code, call these API functions directly. The command table and menu handling use the standard naiapp_cmdtbl_params_t pattern shared across all SSK 2.x samples.
Display Configuration
Reading Latched Status
To read the latched fault status for every channel on a Discrete module in your own application, call naibrd_DT_GetChanMappedStatus() with each status type. The sample reads three status registers per channel:
nai_status_bit_t statusBit;
for (chan = 1; chan <= dtParams->maxChannels; chan++)
{
check_status(naibrd_DT_GetChanMappedStatus(cardIndex, module, chan,
NAIBRD_DT_STATUS_BIT_LATCHED, &statusBit));
check_status(naibrd_DT_GetChanMappedStatus(cardIndex, module, chan,
NAIBRD_DT_STATUS_OVERCURRENT_LATCHED, &statusBit));
check_status(naibrd_DT_GetChanMappedStatus(cardIndex, module, chan,
NAIBRD_DT_STATUS_SUMMARY_LATCHED, &statusBit));
}
-
cardIndex— identifies the board. -
module— the slot containing the Discrete module. -
chan— the channel number (1-based). -
NAIBRD_DT_STATUS_BIT_LATCHED— the latched built-in test status. Reads1if the channel has detected a BIT failure since the status was last cleared. -
NAIBRD_DT_STATUS_OVERCURRENT_LATCHED— the latched overcurrent status. Reads1if the channel has detected an overcurrent condition. -
NAIBRD_DT_STATUS_SUMMARY_LATCHED— the latched summary status. Reads1if either BIT or overcurrent has been detected on this channel. This is the aggregated fault indicator.
The sample also reads raw status words using naibrd_DT_GetChanMappedStatusRaw() to display the entire register in hexadecimal, giving a consolidated view of all channels at once.
Understanding the Summary Register
The summary register provides a consolidated view of all fault conditions on a channel. Rather than polling BIT and overcurrent status separately, you can check the summary bit for a channel — if it reads 1, at least one fault condition exists. This is particularly useful in applications that monitor many channels and need a fast way to detect any fault.
A latched summary bit remains set until you explicitly clear it by writing a 1 to the corresponding bit position.
Clearing Latched Status
To clear all latched status registers in your own application, call naibrd_DT_ClearChanMappedStatusRaw() for each status type with a bitmask of 0xFFFFFFFF to clear all channels at once:
status = check_status(naibrd_DT_ClearChanMappedStatusRaw(cardIndex, module,
NAIBRD_DT_STATUS_BIT_LATCHED, 0xFFFFFFFFu));
if (status == NAI_SUCCESS)
{
status = check_status(naibrd_DT_ClearChanMappedStatusRaw(cardIndex, module,
NAIBRD_DT_STATUS_OVERCURRENT_LATCHED, 0xFFFFFFFFu));
if (status == NAI_SUCCESS)
{
status = check_status(naibrd_DT_ClearChanMappedStatusRaw(cardIndex, module,
NAIBRD_DT_STATUS_SUMMARY_LATCHED, 0xFFFFFFFFu));
}
}
The sample clears all three status types (BIT, overcurrent, and summary). The order matters — if you clear summary without clearing the underlying BIT or overcurrent status, the summary bit may reassert on the next status scan. Clear all three to ensure a clean state.
|
Important
|
Common Errors
|
Optional Interrupt Setup
The sample provides optional interrupt configuration on the summary status register. When enabled, the module generates a hardware interrupt whenever a summary status bit transitions, rather than requiring your application to poll the status registers.
|
Note
|
The interrupt callback mechanism requires POSIX thread support. This sample is available on Petalinux and VxWorks but not on DEOS. Consult the SSK 2.x Software Development Guide for platform-specific build configuration. |
Configuring the Interrupt
To set up an interrupt on the summary status register in your own application, call the following sequence of API functions:
uint32_t vector = 0xB0u;
/* Step 1: Connect the ISR callback (once per card) */
check_status(naibrd_ConnectISR(cardIndex, SampleCallBack));
/* Step 2: Set trigger type to edge */
check_status(naibrd_DT_SetChanMappedInterruptTriggerType(cardIndex, module, chan,
NAIBRD_DT_STATUS_SUMMARY_LATCHED, NAIBRD_INT_TRIGGER_TYPE_EDGE));
/* Step 3: Steer interrupts to the on-board ARM processor */
check_status(naibrd_DT_SetChanMappedInterruptSteering(cardIndex, module,
NAIBRD_DT_STATUS_SUMMARY_LATCHED, NAIBRD_INT_STEERING_ONBOARD_ARM));
/* Step 4: Set the interrupt vector */
check_status(naibrd_DT_SetChanMappedInterruptVector(cardIndex, module,
NAIBRD_DT_STATUS_SUMMARY_LATCHED, vector));
/* Step 5: Enable the interrupt on the selected channel */
check_status(naibrd_DT_SetChanMappedInterruptEnable(cardIndex, module, chan,
NAIBRD_DT_STATUS_SUMMARY_LATCHED, NAI_TRUE));
-
naibrd_ConnectISR()— registers your callback function with the NAI interrupt subsystem. Call this once per card, not once per interrupt type. The callback receives the interrupt vector as its argument. -
NAIBRD_DT_STATUS_SUMMARY_LATCHED— specifies which status register the interrupt is tied to. This sample uses the summary register so that a single interrupt fires for any fault type on the channel. -
NAIBRD_INT_TRIGGER_TYPE_EDGE— the interrupt fires on a status transition (0 to 1), not while the status is held high. Edge triggering is the typical choice for latched status registers. -
NAIBRD_INT_STEERING_ONBOARD_ARM— routes the interrupt to the on-board ARM processor. Other steering options include PCIe or VME backplane delivery. -
vector— the interrupt vector value (0xB0in this sample). Your callback receives this value so it can identify which interrupt source fired. -
The final
SetChanMappedInterruptEnable()call arms the interrupt on the specified channel. Until this call, the interrupt is configured but will not fire.
Interrupt Callback
The sample provides a minimal callback that logs the interrupt vector:
static void SampleCallBack(uint32_t vector)
{
NAIBSP_UNREFERENCED_PARAMETER(vector);
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
logMsg("Interrupt Received!!! Vector:0x%x\n Clear Status to receive new interrupt!!!\r\n",
vector, 0, 0, 0, 0, 0);
#endif
}
In your own application, the callback is where you would read status registers to identify the fault, log the event, or signal a processing thread. Keep the callback short — perform extended processing outside the ISR context.
|
Note
|
On VxWorks, the callback uses logMsg() because printf() is not safe in interrupt context. On Petalinux, the callback body is empty in this sample because the status is read through the menu commands. In your own application, use interrupt-safe I/O functions within the callback.
|
For background on interrupt concepts — including edge vs. level triggering, interrupt vector numbering, steering architecture, and latency measurement — see the Interrupts API Guide.
|
Important
|
Common Errors
|
Forcing a BIT Error
The sample provides a diagnostic command that forces a BIT error on the selected channel. This lets you verify that the status registers and interrupt configuration are working without requiring external hardware changes.
To force a BIT error on a Discrete channel, the sample sets the I/O format to push-pull output, drives the output high (with no external VCC connected), waits briefly, then drives the output low and restores the channel to input mode:
/* Step 1: Set channel to push-pull output mode */
status = check_status(naibrd_DT_SetIOFormat(cardIndex, module, chan,
NAIBRD_DT_IOFORMAT_OUTPUT_PUSHPULL));
/* Step 2: Drive output high -- with no external VCC, this creates a BIT error */
check_status(naibrd_DT_SetOutputState(cardIndex, module, chan, NAIBRD_DT_STATE_HI));
/* Step 3: Wait for the BIT logic to detect the error */
naibrd_msDelay(300);
/* Step 4: Drive output low and restore input mode */
check_status(naibrd_DT_SetOutputState(cardIndex, module, chan, NAIBRD_DT_STATE_LO));
check_status(naibrd_DT_SetIOFormat(cardIndex, module, chan,
NAIBRD_DT_IOFORMAT_INPUT));
-
NAIBRD_DT_IOFORMAT_OUTPUT_PUSHPULL— configures the channel for push-pull output. -
NAIBRD_DT_STATE_HI— drives the output high. -
naibrd_msDelay(300)— a 300 ms delay gives the BIT logic time to detect the open-circuit condition. -
After the test, the channel is returned to input mode (
NAIBRD_DT_IOFORMAT_INPUT) and the output driven low.
The BIT error occurs because the channel is configured for push-pull output with a high state, but there is no external VCC to complete the circuit. The hardware BIT logic detects this open-circuit condition and sets the BIT latched status bit, which in turn sets the summary latched status bit for that channel.
After running this command, use the STAT command to verify that the BIT and summary status bits are set on the channel you selected. If you configured an interrupt, you should also observe the callback firing.
|
Important
|
Common Errors
|
Troubleshooting Reference
This table summarizes common errors and symptoms covered in the sections above. For detailed context on each entry, refer to the relevant section. Consult your module’s manual (DT1 Manual) for hardware-specific diagnostic procedures.
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
No board found or connection timeout |
Board not powered, incorrect or missing configuration file, network issue |
Verify hardware is powered and connected. If |
Module not detected at selected slot |
No module installed at the specified slot, incorrect module number entered |
Verify hardware configuration and module slot assignment |
Module not recognized as Discrete |
Module ID does not match a known DT type — wrong slot selected or non-DT module installed |
Select a different module slot. Verify that a DT1-DT5 module is installed at the selected position. |
|
Feature not available for this module type, or calling a DT function on a non-DT module |
Check your module type with |
Summary bit reasserts after clearing |
Underlying BIT or overcurrent fault still active |
Clear all three status types (BIT, overcurrent, summary). If the condition persists, resolve the hardware fault. |
Interrupt does not fire |
Missing one or more interrupt configuration steps (ISR connect, trigger type, steering, vector, enable) |
Verify all five configuration calls completed successfully. Check that steering is set to |
Interrupt fires once but not again |
Latched status not cleared after first interrupt |
Clear the latched summary status to allow the next edge transition to trigger a new interrupt. |
BIT error not detected after FAULT command |
External VCC still connected to the test channel |
Disconnect external VCC from the channel before running the force-error test. |
Channel left in output mode after abnormal exit |
Sample interrupted during the force-error sequence before restoring input mode |
Call |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — dt_summary.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"
#include "nai_libs/naibrd/include/functions/naibrd_dt.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"
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
#include "logLib.h"
#endif
static const int8_t *DEF_CONFIG_FILE = (const int8_t *)"default_DT_Summary.txt";
/* Function prototypes */
static int32_t Run_DT_Summary(int32_t cardIndex, int32_t module, uint32_t modid);
static void Cfg_DT_Channel(int32_t cardIndex, int32_t module, int32_t MaxChannel);
static void Verify_DT_ParamCnt(int32_t paramCnt);
static nai_status_t Display_DT_Status(int32_t paramCnt, int32_t* p_params);
static nai_status_t Clear_DT_Status(int32_t paramCnt, int32_t* p_params);
static nai_status_t Force_BIT_Error(int32_t paramCnt, int32_t* p_params);
static nai_status_t Configure_DT_Interrupt(int32_t paramCnt, int32_t* p_params);
static void SampleCallBack(uint32_t vector);
static const int32_t DEF_DT_CARD_INDEX = 0;
static const int32_t DEF_DT_MODULE = 1;
static const int32_t DEF_DT_CHANNEL = 1;
/****** Command Table *******/
enum dt_basic_interrupt_commands
{
DT_SUMMARY_INTERRUPT_CMD_CONFIGURE,
DT_SUMMARY_INTERRUPT_CMD_STATUS_READ,
DT_SUMMARY_INTERRUPT_CMD_STATUS_CLEAR,
DT_SUMMARY_INTERRUPT_CMD_FORCE_ERROR,
DT_SUMMARY_INTERRUPT_CMD_COUNT
};
/****** Command Tables *******/
static naiapp_cmdtbl_params_t DT_SummaryMenuCmds[] = {
{"INT", "DT Configure Interrupt", DT_SUMMARY_INTERRUPT_CMD_CONFIGURE, Configure_DT_Interrupt},
{"STAT", "DT Display Status", DT_SUMMARY_INTERRUPT_CMD_STATUS_READ, Display_DT_Status},
{"CLEAR", "DT Clear Status", DT_SUMMARY_INTERRUPT_CMD_STATUS_CLEAR, Clear_DT_Status},
{"FAULT", "DT Force BIT Error", DT_SUMMARY_INTERRUPT_CMD_FORCE_ERROR, Force_BIT_Error},
};
/**************************************************************************************************************/
/**
* <summary>
* The purpose of the dt_summary example is to illustrate the methods to call in the naibrd library to perform basic
* operations with the discrete modules for interrupt configuration, reading fault statuses including the summary
* status register, clearing status bits and forcing a BIT error to observe status bits getting set in both the
* BIT status and summary registers. The summary register is bit-mapped by channel (bit index zero is channel 1)
* and reports a '1' if the corresponding channel has detected a fault in either BIT or over-current status. A
* latched summary bit can be cleared by writing a '1' to the bit. A BIT error condition can be forced in a DT
* channel by configuring the IO format for Push-Pull and setting the output state HIGH while an external VCC is
* unconnected. To demonstrate the aforementioned concepts, the user should run this sample application and enter
* the following sequence of menu commands (though in reality the user is free to follow any sequence):
*
* clear - to clear all latched status registers (BIT, Overcurrent and Summary statuses)
* stat - to display all latched statuses
* int - to configure the interrupt subsystem on the user-selected channel
* fault - to generate a BIT error on the user-selected channel
* stat - to display all latched statuses
* clear - to clear all latched status registers
*
* </summary>
*/
/**************************************************************************************************************/
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t dt_summary(void)
#else
int32_t main(void)
#endif
{
int32_t cardIndex;
int32_t moduleCnt;
int32_t module;
bool_t stop = NAI_FALSE;
uint32_t moduleID;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
{
while (stop != NAI_TRUE)
{
/* Select Card Index */
stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), DEF_DT_CARD_INDEX, &cardIndex);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
/* Select Module */
stop = naiapp_query_ModuleNumber(moduleCnt, DEF_DT_MODULE, &module);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if ((moduleID != 0))
{
Run_DT_Summary(cardIndex, module, moduleID);
naiif_printf("\r\nType Q to quit or Enter to continue:\r\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
}
}
}
}
naiif_printf("\r\nType the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
naiapp_access_CloseAllOpenCards();
return 0;
}
/**************************************************************************************************************/
/**
* <summary>
* Verify_DT_ParamCnt verifies parameter count and displays error message if invalid.
* </summary>
*/
/**************************************************************************************************************/
static void Verify_DT_ParamCnt(int32_t paramCnt)
{
if (paramCnt != APP_PARAM_COUNT)
{
naiif_printf(" *** Parameter count specified is incorrect!!! ***\r\n");
}
}
/**************************************************************************************************************/
/**
* <summary>
* Run_DT_Summary prompts the user for the card, module and channel to use for the application and calls
* Cfg_DT_Channel if the card, module, channel is valid for as a discrete module.
* </summary>
*/
/**************************************************************************************************************/
static int32_t Run_DT_Summary(int32_t cardIndex, int32_t module, uint32_t modid)
{
bool_t bQuit = NAI_FALSE;
int32_t maxchannel;
if (!bQuit)
{
maxchannel = naibrd_DT_GetChannelCount(modid);
if (maxchannel == 0)
{
naiif_printf(" *** Module selection not recognized as DT module. ***\r\n\r\n");
}
else
{
Cfg_DT_Channel(cardIndex, module, maxchannel);
}
}
return cardIndex;
}
/**************************************************************************************************************/
/**
* <summary>
* Cfg_DT_Channel handles calling the Display_DT_ChannelCfg routine to display the discrete channel configuration
* and calling the routines associated with the user's menu commands.
* </summary>
*/
/**************************************************************************************************************/
static void Cfg_DT_Channel(int32_t cardIndex, int32_t module, int32_t MaxChannel)
{
bool_t bQuit = NAI_FALSE;
bool_t bContinue = NAI_TRUE;
bool_t bCmdFound = NAI_FALSE;
int32_t chan, defaultchan = 1; /* This is channel selection for interrupt only */
int32_t cmd;
naiapp_AppParameters_t dtparams;
p_naiapp_AppParameters_t dtParams = &dtparams;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
while (bContinue)
{
naiif_printf("\r\n\r\n");
naiif_printf("Channel selection for Interrupt\r\n");
naiif_printf("=================\r\n");
defaultchan = DEF_DT_CHANNEL;
bQuit = naiapp_query_ChannelNumber(MaxChannel, defaultchan, &chan);
dtParams->cardIndex = cardIndex;
dtParams->module = module;
dtParams->maxChannels = MaxChannel;
dtParams->channel = chan;
naiapp_utils_LoadParamMenuCommands(DT_SUMMARY_INTERRUPT_CMD_COUNT, DT_SummaryMenuCmds);
while (bContinue)
{
naiapp_display_ParamMenuCommands((int8_t *)"DT Summary Interrupt Menu");
naiif_printf("\r\nType DT 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 DT_SUMMARY_INTERRUPT_CMD_CONFIGURE:
case DT_SUMMARY_INTERRUPT_CMD_STATUS_READ:
case DT_SUMMARY_INTERRUPT_CMD_STATUS_CLEAR:
case DT_SUMMARY_INTERRUPT_CMD_FORCE_ERROR:
DT_SummaryMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)dtParams);
break;
default:
naiif_printf("Invalid command entered\r\n");
break;
}
}
else
{
naiif_printf("Invalid command entered\r\n");
}
}
}
else
{
bContinue = NAI_FALSE;
}
}
}
}
/**************************************************************************************************************/
/**
* <summary>
* Display_DT_Status illustrate the methods to call in the naibrd library to retrieve the status states.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Display_DT_Status(int32_t paramCnt, int32_t* p_params)
{
p_naiapp_AppParameters_t dtParams = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = dtParams->cardIndex;
int32_t module = dtParams->module;
int32_t chan;
nai_status_bit_t statusBit;
uint32_t rawValue;
Verify_DT_ParamCnt(paramCnt);
naiif_printf("\r\n");
naiif_printf(" --------------Latched Status--------------\r\n");
naiif_printf(" Chan BIT OC SUMMARY \r\n");
naiif_printf(" ------ ---------- ---------- -------------\r\n");
for (chan = 1; chan <= dtParams->maxChannels; chan++)
{
naiif_printf(" %3i ", chan);
check_status(naibrd_DT_GetChanMappedStatus(cardIndex, module, chan, NAIBRD_DT_STATUS_BIT_LATCHED, &statusBit));
naiif_printf(" %3i ", statusBit);
check_status(naibrd_DT_GetChanMappedStatus(cardIndex, module, chan, NAIBRD_DT_STATUS_OVERCURRENT_LATCHED, &statusBit));
naiif_printf(" %3i ", statusBit);
check_status(naibrd_DT_GetChanMappedStatus(cardIndex, module, chan, NAIBRD_DT_STATUS_SUMMARY_LATCHED, &statusBit));
naiif_printf(" %3i ", statusBit);
naiif_printf("\r\n");
}
/* Print status words in hex */
naiif_printf(" All ");
check_status(naibrd_DT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_DT_STATUS_BIT_LATCHED, &rawValue));
naiif_printf(" 0x%08X ", rawValue);
check_status(naibrd_DT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_DT_STATUS_OVERCURRENT_LATCHED, &rawValue));
naiif_printf(" 0x%08X ", rawValue);
check_status(naibrd_DT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_DT_STATUS_SUMMARY_LATCHED, &rawValue));
naiif_printf(" 0x%08X ", rawValue);
naiif_printf("\r\n\r\n");
return NAI_SUCCESS;
}
static nai_status_t Clear_DT_Status(int32_t paramCnt, int32_t* p_params)
{
nai_status_t status = NAI_ERROR_NOT_SUPPORTED;
p_naiapp_AppParameters_t dtParams = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = dtParams->cardIndex;
int32_t module = dtParams->module;
Verify_DT_ParamCnt(paramCnt);
status = check_status(naibrd_DT_ClearChanMappedStatusRaw(cardIndex, module, NAIBRD_DT_STATUS_BIT_LATCHED, 0xFFFFFFFFu));
if (status == NAI_SUCCESS)
{
status = check_status(naibrd_DT_ClearChanMappedStatusRaw(cardIndex, module, NAIBRD_DT_STATUS_OVERCURRENT_LATCHED, 0xFFFFFFFFu));
if (status == NAI_SUCCESS)
{
status = check_status(naibrd_DT_ClearChanMappedStatusRaw(cardIndex, module, NAIBRD_DT_STATUS_SUMMARY_LATCHED, 0xFFFFFFFFu));
}
}
if (status == NAI_SUCCESS)
{
naiif_printf("Cleared all statuses...\r\n");
}
return status;
}
static nai_status_t Force_BIT_Error(int32_t paramCnt, int32_t* p_params)
{
nai_status_t status = NAI_ERROR_NOT_SUPPORTED;
p_naiapp_AppParameters_t dtParams = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = dtParams->cardIndex;
int32_t module = dtParams->module;
int32_t chan = dtParams->channel;
NAIBSP_UNREFERENCED_PARAMETER(paramCnt);
naiif_printf("Forcing BIT Error on Channel %d. Make sure external VCC is off...\r\n", chan);
status = check_status(naibrd_DT_SetIOFormat( cardIndex, module, chan, NAIBRD_DT_IOFORMAT_OUTPUT_PUSHPULL));
if (status == NAI_SUCCESS)
{
naiif_printf("Setting IO Format to Push-Pull on Channel %d...\r\n", chan);
check_status(naibrd_DT_SetOutputState( cardIndex, module, chan, NAIBRD_DT_STATE_HI));
if (status == NAI_SUCCESS)
{
naiif_printf("Setting DT Output State High on Channel %d...\r\n", chan);
naibrd_msDelay(300);
check_status(naibrd_DT_SetOutputState( cardIndex, module, chan, NAIBRD_DT_STATE_LO));
if (status == NAI_SUCCESS)
{
naiif_printf("Setting DT Output State Low on Channel %d...\r\n", chan);
if (status == NAI_SUCCESS)
{
status = check_status(naibrd_DT_SetIOFormat( cardIndex, module, chan, NAIBRD_DT_IOFORMAT_INPUT));
naiif_printf("Setting IO Format to Input on Channel %d...\r\n", chan);
}
}
}
}
if (status != NAI_SUCCESS)
{
naiif_printf("Failed to generate BIT Error on Channel %d...\r\n", chan);
}
naiif_printf("\r\n\r\n");
return status;
}
static nai_status_t Configure_DT_Interrupt(int32_t paramCnt, int32_t* p_params)
{
p_naiapp_AppParameters_t dtParams = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = dtParams->cardIndex;
int32_t module = dtParams->module;
int32_t chan = dtParams->channel; /* Channel to generate interrupt on */
uint32_t vector = 0xB0u;
Verify_DT_ParamCnt(paramCnt);
/* Specify callback function for interrupt type */
check_status(naibrd_ConnectISR(cardIndex, SampleCallBack)); /* Invoked once per card, not per interrupt type */
check_status(naibrd_DT_SetChanMappedInterruptTriggerType(cardIndex, module, chan, NAIBRD_DT_STATUS_SUMMARY_LATCHED,
NAIBRD_INT_TRIGGER_TYPE_EDGE));
check_status(naibrd_DT_SetChanMappedInterruptSteering(cardIndex, module, NAIBRD_DT_STATUS_SUMMARY_LATCHED,
NAIBRD_INT_STEERING_ONBOARD_ARM));
check_status(naibrd_DT_SetChanMappedInterruptVector(cardIndex, module, NAIBRD_DT_STATUS_SUMMARY_LATCHED, vector));
check_status(naibrd_DT_SetChanMappedInterruptEnable(cardIndex, module, chan, NAIBRD_DT_STATUS_SUMMARY_LATCHED, NAI_TRUE));
naiif_printf("\r\nInterrupt Configuration\r\n");
naiif_printf("=======================\r\n");
naiif_printf("Card Index:%d\r\n", cardIndex);
naiif_printf("Module Number:%d\r\n", module);
naiif_printf("Channel:%d\r\n", chan);
naiif_printf("Vector:0x%X\r\n", vector);
naiif_printf("Status:Summary\r\n");
naiif_printf("\r\n\r\n Waiting for Summary Latched interrupt on channel %d...\r\n", chan);
return NAI_SUCCESS;
}
static void SampleCallBack(uint32_t vector)
{
NAIBSP_UNREFERENCED_PARAMETER(vector);
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
logMsg("Interrupt Received!!! Vector:0x%x\n Clear Status to receive new interrupt!!!\r\n",vector,0,0,0,0,0);
#endif
}