RG BasicOps
Edit this on GitLab
RG BasicOps Sample Application (SSK 1.x)
Overview
The RG BasicOps sample application demonstrates how to configure and operate IRIG (Inter-Range Instrumentation Group) timecode channels using the NAI Software Support Kit (SSK 1.x). IRIG is a family of time distribution standards originally developed for instrumented test ranges and now widely used in avionics, defense systems, power grid synchronization, and any environment where multiple subsystems must agree on a precise time reference. An RG module can both generate and receive IRIG timecode signals, allowing it to act as a time source for downstream equipment or to synchronize its own master clock to an external IRIG reference.
This sample covers the core IRIG operations you will need in your own application: selecting the IRIG protocol (format, modulation, carrier frequency, and code expression), reading and setting time data, configuring AM output gain and signal levels, compensating for propagation delay, managing the real-time clock (RTC), handling daylight saving time (DST) adjustments, setting up event-based interrupts, and monitoring synchronization status.
This sample supports the RG1 module type. It serves as a practical API reference — each menu command maps directly to one or more naibrd_IRIG_*() API calls that you can lift into your own code.
Prerequisites
Before running this sample, make sure you have:
-
An NAI board with an RG module installed.
-
SSK 1.x installed on your development host.
-
The sample applications built. Refer to the SSK 1.x build instructions for your platform if you have not already compiled them.
How to Run
Launch the RG_BasicOps executable from your build output directory. On startup the application looks for a configuration file (default_RG_BasicOps.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, a top-level menu lets you choose between the Basic operations menu, the Interrupt configuration menu, or the DST (Daylight Saving Time) menu.
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 RG. |
The main() function follows a standard SSK 1.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_RG_BasicOps.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_GetModuleID()so downstream code can adapt to the specific RG variant installed.
#if defined (__VXWORKS__)
int32_t RG_BasicOps(void)
#else
int32_t main(void)
#endif
{
bool_t bQuit = FALSE;
int32_t cardIndex = -1;
int32_t module = 0;
uint32_t modId = 0u;
int32_t moduleCount;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
{
while (!bQuit)
{
naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
naibrd_GetModuleCount(cardIndex, &moduleCount);
naiapp_query_ModuleNumber(moduleCount, 1, &module);
modId = naibrd_GetModuleID(cardIndex, module);
bQuit = RGBasicOps_run(cardIndex, module, modId);
}
printf("Type the Enter key to exit the program: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
naiapp_access_CloseAllOpenCards();
return 0;
}
|
Important
|
Common connection errors you may encounter at this stage:
|
Program Structure
Application Parameters
Once connected, the sample populates an naiapp_AppParameters_t struct that is passed to every command handler. In your own application, you will need to track the same values:
-
cardIndex— identifies which board you are communicating with (zero-based). -
module— the slot number where the RG module is installed (one-based). -
channel— the IRIG channel to operate on (defaults to 1). -
maxChannels— total channel count for the detected module, obtained fromnaibrd_IRIG_GetChannelCount(modId). -
modId— the module identifier returned bynaibrd_GetModuleID().
Top-Level Menu and Submenus
The sample organizes its commands into three submenus, selected from a top-level menu:
-
BAS — IRIG Basic Menu: protocol configuration, time operations, signal levels, propagation offsets, and general IRIG settings.
-
INT — IRIG Interrupt Menu: event-mapped status, interrupt enable/disable, trigger type, vector, and steering configuration.
-
DST — IRIG DST Menu: daylight saving time status, offset, start, and end configuration.
Each submenu loads its own command table and displays the current module state before presenting the command list. The menu system is a sample convenience — in your own code, call these API functions directly.
Display Functions
Each submenu calls a display function before presenting commands:
-
RGBasicOps_displayConfigurations()reads and prints the current protocol, 1PPS pulse width, AM gain, drift threshold, reference source, IRIG time, master time, and free-running time for all channels. -
RGBasicOps_displayInterrupts()reads and prints every event-mapped status type (latched and realtime), interrupt enable state, trigger type, vectors, steering, and raw status registers. -
RGBasicOps_displayDSTSettings()reads and prints DST status, offset, and start/end rules for all channels.
These display functions serve as examples of how to read back the full module state using the naibrd_IRIG_Get*() API calls.
IRIG Protocol and Format Configuration
IRIG timecode encodes time-of-day information into an electrical signal. The protocol defines four independent parameters that together specify exactly how time data is encoded and transmitted:
-
Format — determines the frame rate and time resolution. Format A transmits at 1000 pulses per second, Format B at 100 pulses per second, and Format G at 10,000 pulses per second. Higher frame rates provide finer time resolution but require more bandwidth.
-
Modulation — defines how bits are represented on the wire. DCLS (DC Level Shift) uses simple high/low voltage levels, AM/ASK (Amplitude Modulation / Amplitude Shift Keying) superimposes data on a carrier sine wave, and DC Manchester uses mid-bit transitions.
-
Carrier frequency — the frequency of the carrier signal for AM/ASK modulation (100 Hz to 1 MHz). DCLS modulation uses no carrier.
-
Code expression — specifies which data fields appear in each frame: BCD Time of Year (BCDTOY), BCD Year (BCDYEAR), Control Functions (CF), and Straight Binary Seconds (SBS).
Set Protocol by Components (PR)
To configure the IRIG protocol by selecting each component individually, call naibrd_IRIG_SetProtocol() with a naibrd_irig_protocol_t struct. This approach gives you explicit control over each parameter and validates the combination.
naibrd_irig_protocol_t protocol;
protocol.irigFormat = NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_B;
protocol.irigModulation = NAIBRD_IRIG_CTRL_MODE_IRIG_MODULATION_AM_ASK;
protocol.carrierFreq = NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_1KHZ;
protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_CF_SBS;
status = naibrd_IRIG_SetProtocol(cardIndex, module, channel, protocol);
The format values are: NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_A (1), NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_B (2), NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_G (7). Modulation values are DCLS (0), AM_ASK (1), and DC_MANCHESTER (2). Not all combinations of format, modulation, carrier, and code expression are valid — the API returns NAI_ERROR_INVALID_VALUE for unsupported combinations. Consult your module’s manual for the complete list of supported protocols.
Set Protocol by Value (PRV)
Alternatively, to set the protocol using a single pre-defined value from the supported protocol table, call naibrd_IRIG_SetProtocolByValue(). The protocol value is a 16-bit hex code that encodes the format, modulation, carrier, and code expression in its nibbles.
status = naibrd_IRIG_SetProtocolByValue(cardIndex, module, channel,
(naibrd_irig_protocol_value_t)validIRIGProtocols[protocolIndex]);
The header file naibrd_irig.h defines the validIRIGProtocols[] array with all accepted values (e.g., 0x2120 = Format B, AM/ASK, 1 kHz carrier, BCDTOY/CF/SBS). This is often simpler than constructing the struct when you know the exact protocol code you need.
|
Important
|
Common Errors
|
Reference Source and Time Operations
Understanding IRIG Time Sources
The RG module maintains three independent time values, and understanding the distinction is key to using the module correctly:
-
IRIG Time — the time decoded from an incoming IRIG reference signal. This is read-only and reflects whatever the external time source is transmitting. Read it with
naibrd_IRIG_GetActualIRIGDateAndTime(). -
Master Time — the module’s authoritative time output, which is what gets encoded into the outgoing IRIG signal. The master time source is controlled by the reference source setting.
-
Free-Running Time — an independent time counter that runs regardless of any external reference. You can load it manually and use it as the master time source by setting the reference source to 7.
Set Reference Source (RS)
The reference source determines where the module’s master time comes from. To select the reference source, call naibrd_IRIG_SetReferenceSource(). The sample offers three options:
/* 0 = IRIG: sync master time to incoming IRIG reference */
status = naibrd_IRIG_SetReferenceSource(cardIndex, module, channel, 0u);
/* 3 = RTC: sync master time to the on-board real-time clock */
status = naibrd_IRIG_SetReferenceSource(cardIndex, module, channel, 3u);
/* 7 = No reference: use free-running time (no external sync) */
status = naibrd_IRIG_SetReferenceSource(cardIndex, module, channel, 7u);
When set to IRIG (0), the module locks its master clock to the incoming IRIG signal. This is the normal operating mode when you have an external time reference. When set to RTC (3), the on-board real-time clock drives master time. When set to no reference (7), the free-running time becomes the master time source — this is useful for standalone operation where the module acts as a time generator without any external input.
Set Year (Y)
IRIG formats that do not include the BCD Year field encode only the day-of-year, hour, minute, and second. To set the calendar year for these protocols, call naibrd_IRIG_SetYear():
status = naibrd_IRIG_SetYear(cardIndex, module, channel, year);
The year parameter is the last two digits of the year (e.g., 26 for 2026). This value is only meaningful for protocols whose code expression does not include BCDYEAR.
Set Free-Running Time (FRT)
To load a specific time into the free-running counter, call naibrd_IRIG_SetFreeRunningTimeAndDate(). The free-running time will appear as the master time when the reference source is set to 7.
naibrd_irig_master_timer_info_t time;
time.year = year; /* last two digits */
time.day = day; /* day of year, 1-365 */
time.hour = hour; /* 0-23 */
time.minute = min; /* 0-59 */
time.second = sec; /* 0-59 */
time.microSecond = microSec;
status = naibrd_IRIG_SetFreeRunningTimeAndDate(cardIndex, module, channel, time);
Set and Apply RTC Time (RTCT, RTCC)
The on-board real-time clock (RTC) provides a battery-backed time reference that persists across power cycles. Setting the RTC is a two-step process:
-
Load the desired time and date into staging registers with
naibrd_IRIG_SetRTCTime()andnaibrd_IRIG_SetRTCDate(). -
Commit the staged values by calling
naibrd_IRIG_SetRTC(), which transfers them to the RTC hardware.
/* Step 1: Stage the time */
naibrd_irig_rtc_time_t rtcTime;
rtcTime.hour = hour;
rtcTime.minute = min;
rtcTime.second = sec;
status = naibrd_IRIG_SetRTCTime(cardIndex, module, channel, rtcTime);
naibrd_irig_rtc_date_t rtcDate;
rtcDate.year = year;
rtcDate.month = month;
rtcDate.day = day;
status = naibrd_IRIG_SetRTCDate(cardIndex, module, channel, rtcDate);
/* Step 2: Commit to RTC hardware */
status = naibrd_IRIG_SetRTC(cardIndex, module, channel);
The commit call (naibrd_IRIG_SetRTC()) waits for a hardware ready bit before writing. If the ready bit is not set, the call returns NAI_ERROR_TIMEOUT. The sample retries up to five times. In your own code, you should implement similar retry logic.
Set Time Zone Offset (TZO)
To adjust the displayed time for your local time zone without modifying the underlying IRIG reference, call naibrd_IRIG_SetTimeZoneOffset() or naibrd_IRIG_SetRTCTimeZoneOffset(). The offset is specified in minutes and supports a range of -1439 to +1439 (covering all UTC offsets).
/* General time zone offset (affects IRIG-derived time) */
status = naibrd_IRIG_SetTimeZoneOffset(cardIndex, module, channel, timeZoneOffset);
/* RTC-specific time zone offset */
status = naibrd_IRIG_SetRTCTimeZoneOffset(cardIndex, module, channel, timeZoneOffset);
|
Important
|
Common Errors
|
Signal Level and Output Configuration
AM Output Gain (G)
When using AM/ASK modulation, the output gain controls the amplitude of the modulated IRIG signal. To set the gain level, call naibrd_IRIG_SetAMOutputGain():
status = naibrd_IRIG_SetAMOutputGain(cardIndex, module, channel, (uint8_t)level);
The level parameter ranges from 0 to 255 (NAIBRD_IRIG_AM_OUTPUT_LEVEL_LIMIT). Higher values increase the signal amplitude. This setting has no effect when using DCLS or DC Manchester modulation. Consult your module’s manual for the voltage mapping of each gain step.
1PPS Pulse Width (PW)
The module generates a one-pulse-per-second (1PPS) output that marks the start of each second. To set the pulse width, call naibrd_IRIG_Set1PPSPulseWidth():
status = naibrd_IRIG_Set1PPSPulseWidth(cardIndex, module, channel, pulseWidthUSec);
The pulse width is specified in microseconds. The 1PPS output is commonly used to synchronize other equipment that expects a precise once-per-second timing pulse.
Digital Input Signal Level (DI)
To set the electrical standard for the digital IRIG input, call naibrd_IRIG_SetDigitalInput():
/* RS-232 level */
status = naibrd_IRIG_SetDigitalInput(cardIndex, module, channel, NAIBRD_IRIG_SIGNAL_LEVEL_RS232);
/* RS-485 level */
status = naibrd_IRIG_SetDigitalInput(cardIndex, module, channel, NAIBRD_IRIG_SIGNAL_LEVEL_RS485);
Digital Output Signal Level (DO)
To set the electrical standard for the digital IRIG output, call naibrd_IRIG_SetDigitalLevel() with the signal type set to NAIBRD_IRIG_SIGNAL_DIGITAL_OUT:
status = naibrd_IRIG_SetDigitalLevel(cardIndex, module, channel,
NAIBRD_IRIG_SIGNAL_DIGITAL_OUT, NAIBRD_IRIG_SIGNAL_LEVEL_RS485);
Serial Signal Level (SSL)
To configure the signal level for serial port outputs and the 1PPS/event pin, call naibrd_IRIG_SetDigitalLevel() with the appropriate signal type. The sample lets you choose between RS-232 and RS-485 for either the digital output or the 1PPS-out/event-in pin:
/* Set 1PPS-out/event-in pin to RS-485 */
status = naibrd_IRIG_SetDigitalLevel(cardIndex, module, channel,
NAIBRD_IRIG_SIGNAL_1PPS_OUT_EVENT_IN, NAIBRD_IRIG_SIGNAL_LEVEL_RS485);
|
Important
|
Common Errors
|
Propagation Delay and Drift Compensation
Propagation Offset (O)
In systems where the IRIG signal travels long cable runs, the propagation delay introduces a time error. Each IRIG format has its own propagation offset register because the decoding path differs per format. To compensate, call the appropriate format-specific offset function:
/* Mode A propagation offset */
status = naibrd_IRIG_SetModeAPropOffset(cardIndex, module, channel, propOffset);
/* Mode B propagation offset */
status = naibrd_IRIG_SetModeBPropOffset(cardIndex, module, channel, propOffset);
/* Mode G propagation offset */
status = naibrd_IRIG_SetModeGPropOffset(cardIndex, module, channel, propOffset);
/* DCLS propagation offset */
status = naibrd_IRIG_SetDclsPropOffset(cardIndex, module, channel, propOffset);
/* RTC propagation offset */
status = naibrd_IRIG_SetRTCPropOffset(cardIndex, module, channel, propOffset);
The offset value ranges from -1,199,999,999 to +1,199,999,999 (nanoseconds, covering approximately +/- 1.2 seconds). A positive value shifts time into the future; a negative value shifts it into the past.
Drift Threshold (D)
The drift threshold defines how much the module’s internal clock is allowed to drift from the IRIG reference before the module flags a synchronization warning. To set the threshold, call naibrd_IRIG_SetDriftThreshold():
status = naibrd_IRIG_SetDriftThreshold(cardIndex, module, channel, driftThreshold);
The threshold is a 16-bit value. Consult your module’s manual for the units and recommended settings. A lower threshold causes the module to flag drift sooner, which is appropriate for high-accuracy applications.
Periodic Interrupt Period (PIP)
To generate a repeating interrupt at a user-defined interval, call naibrd_IRIG_SetPeriodicInterruptPeriod():
status = naibrd_IRIG_SetPeriodicInterruptPeriod(cardIndex, module, channel, periodUSec);
The period is specified in microseconds. This is useful for triggering periodic data acquisition or status polling synchronized to the IRIG time base.
|
Important
|
Common Errors
|
Control Bits
IRIG frames include a control-function field that carries user-defined data alongside the time information. This field is loaded at the beginning of each transmitted frame and can carry up to 27 bits of application-specific data.
Set Control Bits to Send (CB)
To load control bits into the outgoing IRIG frame, call naibrd_IRIG_SetCtrlBitsToSend():
status = naibrd_IRIG_SetCtrlBitsToSend(cardIndex, module, channel, ctrlbits);
Bits 0 through 26 are valid. The control bits are transmitted in the next IRIG frame after they are set.
Read Received Control Bits (CBR)
To read the control bits received from an incoming IRIG signal, call naibrd_IRIG_GetCtrlBitsReceived():
uint32_t ctrlbits = 0u;
status = naibrd_IRIG_GetCtrlBitsReceived(cardIndex, module, channel, &ctrlbits);
The received control bits reflect the content of the most recently decoded IRIG frame. This is a read-only operation.
|
Important
|
Common Errors
|
Capture Event Timing
The capture event feature timestamps an external event (a signal edge on the event input pin) with sub-second precision relative to the IRIG time base. This is useful for correlating external triggers to IRIG time.
Set Capture Event Time (CET)
To pre-load a capture event time (used for scheduling or comparison), call naibrd_IRIG_SetCaptureEventTime():
naibrd_irig_capture_event_time_t eventTime;
eventTime.hours = hour;
eventTime.minutes = min;
eventTime.seconds = sec;
eventTime.tenths = ten;
eventTime.hundredths = hun;
status = naibrd_IRIG_SetCaptureEventTime(cardIndex, module, channel, eventTime);
Set Capture Event Edge (CEE)
To select which signal edge triggers the event capture, call naibrd_IRIG_SetCaptureEventEdge():
/* Rising edge */
status = naibrd_IRIG_SetCaptureEventEdge(cardIndex, module, channel,
NAIBRD_IRIG_CAPTURE_EVENT_RISING_EDGE);
/* Falling edge */
status = naibrd_IRIG_SetCaptureEventEdge(cardIndex, module, channel,
NAIBRD_IRIG_CAPTURE_EVENT_FALLING_EDGE);
|
Important
|
Common Errors
|
Daylight Saving Time (DST)
The RG module can automatically adjust the displayed time for daylight saving time transitions. DST is configured by specifying when DST starts, when it ends, and the offset to apply.
Get DST Status (DSTS)
To check whether DST is currently active, call naibrd_IRIG_GetDSTStatus():
naibrd_irig_dst_status_type_t dstStatus;
status = naibrd_IRIG_GetDSTStatus(cardIndex, module, channel, &dstStatus);
The status returns NAIBRD_IRIG_DST_STATUS_ENABLED or NAIBRD_IRIG_DST_STATUS_DISABLED.
Set DST Offset (OFF)
To set the time offset applied during DST, call naibrd_IRIG_SetDSTOffset(). The offset is specified in HMM format (1 digit hour, 2 digits minutes) as a hexadecimal value:
status = naibrd_IRIG_SetDSTOffset(cardIndex, module, channel, dstOffset);
For example, a standard 1-hour DST offset would be 0x100 (1 hour, 00 minutes).
Set DST Start and End (START, END)
To define when DST begins and ends, call naibrd_IRIG_SetDSTStart() and naibrd_IRIG_SetDSTEnd() with a naibrd_irig_dst_timer_info_t struct:
naibrd_irig_dst_timer_info_t dstStart;
dstStart.month = 3; /* March */
dstStart.day = 0; /* Sunday */
dstStart.week = 2; /* Second week */
dstStart.hour = 2; /* 2:00 AM */
dstStart.minute = 0;
status = naibrd_IRIG_SetDSTStart(cardIndex, module, channel, dstStart);
The day field uses 0 for Sunday, 1 for Monday, through 6 for Saturday. The week field indicates which occurrence of that weekday in the month (1 = first, 2 = second, etc.).
|
Important
|
Common Errors
|
Status and Interrupt Configuration
Understanding Event-Mapped Status
The RG module provides a comprehensive event-mapped status system that tracks both BIT (Built-In Test) conditions and general operational events. Each event has both a latched and a realtime status bit:
-
Realtime status — reflects the current state of the condition right now. It is set when the condition is active and clears when the condition goes away.
-
Latched status — set when the condition occurs and remains set until explicitly cleared by software. This ensures that transient events are not missed between status polls.
The events are organized into two categories:
-
BIT category — hardware health indicators: data loss and software fault.
-
General category — operational events: reference lost, reference received, reference pulse received, 1PPS output, control bits changed/received, reference source change, event detected, user interrupt, DST adjust, and test interrupt.
Reading Status
The display function reads each status type using naibrd_IRIG_GetEventMappedStatus() for individual events and naibrd_IRIG_GetEventMappedStatusRaw() for the complete status register as a hex value:
nai_status_bit_t status, rtStatus;
/* Read latched and realtime status for a specific event */
naibrd_IRIG_GetEventMappedStatus(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_STATUS_REF_LOSS_LATCHED, &status);
naibrd_IRIG_GetEventMappedStatus(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_STATUS_REF_LOSS_REALTIME, &rtStatus);
/* Read the complete status register for a category */
uint32_t statusHex;
naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, NAI_STATUS_LATCHED, &statusHex);
Synchronization and Lock Status
For IRIG applications, the most important status events are:
-
IRIG Reference Lost (
NAIBRD_IRIG_EVTMAP_STATUS_REF_LOSS_*) — indicates that the module has lost contact with its external IRIG reference signal. When this occurs, the module can no longer synchronize its master clock and will begin to drift. In a properly functioning system with a valid IRIG input, this bit should remain clear. -
Receiving IRIG Reference (
NAIBRD_IRIG_EVTMAP_STATUS_RX_REF_*) — indicates that the module is actively receiving and decoding an IRIG signal. When this bit is set along with "reference lost" being clear, the module is synchronized — meaning its master time is locked to the external reference within the drift threshold. -
IRIG Reference Pulse Received (
NAIBRD_IRIG_EVTMAP_STATUS_REF_PULSE_RX_*) — fires each time a valid reference pulse is decoded. Useful for monitoring ongoing signal quality.
Clearing Latched Status
To clear a specific latched status bit, call naibrd_IRIG_ClearEventMappedStatus():
status = naibrd_IRIG_ClearEventMappedStatus(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_STATUS_REF_LOSS_LATCHED);
To clear all latched status bits in a category at once, call naibrd_IRIG_ClearEventMappedStatusRaw():
status = naibrd_IRIG_ClearEventMappedStatusRaw(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, 0xFFFFFFFF);
Interrupt Enable (E)
To enable or disable an interrupt for a specific event, call naibrd_IRIG_SetEventMappedInterruptEnable():
/* Enable interrupt for reference loss */
status = naibrd_IRIG_SetEventMappedInterruptEnable(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_STATUS_REF_LOSS_LATCHED, TRUE);
Interrupt Edge/Level (EL)
To configure whether an interrupt fires on the transition (edge) or persists as long as the condition is active (level), call naibrd_IRIG_SetEventMappedInterruptTriggerType():
/* Edge-triggered: fires once when condition occurs */
status = naibrd_IRIG_SetEventMappedInterruptTriggerType(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_STATUS_REF_LOSS_LATCHED, NAIBRD_IRIG_EDGE_INTERRUPT);
/* Level-triggered: fires continuously while condition persists */
status = naibrd_IRIG_SetEventMappedInterruptTriggerType(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_STATUS_REF_LOSS_LATCHED, NAIBRD_IRIG_LEVEL_INTERRUPT);
Interrupt Vector (V)
To set the interrupt vector for a status category, call naibrd_IRIG_SetEventMappedInterruptVector():
status = naibrd_IRIG_SetEventMappedInterruptVector(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, vector);
Vectors are configured separately for the BIT and General categories.
Interrupt Steering (S)
To route interrupts to a specific processor or bus, call naibrd_IRIG_SetEventMappedInterruptSteering():
status = naibrd_IRIG_SetEventMappedInterruptSteering(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, NAIBRD_INT_STEERING_PCIE_APP);
Steering options include VME, On-Board processors (0, 1, 2), PCIe, and CPCI.
|
Important
|
Common Errors
|
Troubleshooting Reference
|
Note
|
This section summarizes errors covered in the preceding sections. Consult your RG module’s manual for hardware-specific diagnostics and register definitions. |
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
|
Unsupported combination of format, modulation, carrier, and code expression. |
Use a value from the |
|
RTC hardware ready bit not set when |
Retry the operation (the sample retries up to 5 times). Ensure the RTC time and date staging registers were written before calling SetRTC. |
Reference lost status active |
No IRIG signal connected, cable disconnected, or signal level mismatch (RS-232 vs. RS-485). |
Verify cabling, confirm signal level settings match on both ends, and ensure the transmitting equipment is operational. |
Master time does not match IRIG input |
Reference source not set to IRIG (0), or time zone / propagation offset is applied. |
Verify reference source is 0. Check time zone offset and propagation offset registers for unintended values. |
Free-running time not updating master time |
Reference source not set to 7 (no reference / free-running). |
Set reference source to 7 with |
AM output signal too weak or absent |
Gain level set too low, or protocol not using AM/ASK modulation. |
Increase gain (0-255) and verify the protocol uses AM/ASK modulation. |
Received control bits always zero |
Protocol code expression does not include CF, or transmitter not loading control bits. |
Verify both ends use a protocol with CF in the code expression (e.g., BCDTOY_CF_SBS). |
Interrupts not firing |
Interrupt enable, vector, or steering not configured; or trigger type mismatch. |
Enable the interrupt for the desired event, set the vector, and verify steering routes to your processor. Check edge vs. level trigger type. |
Full Source
Full Source — RG_BasicOps.c (SSK 1.x)
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.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"
/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_irig.h"
#include "advanced/nai_ether_adv.h"
#include "boards/naibrd_gen5.h"
static const int8_t *SAMPLE_PGM_NAME = (const int8_t *)"RG Module Basic Operation Program";
static const int8_t *CONFIG_FILE = (const int8_t *)"default_RG_BasicOps.txt";
#define DEFAULT_CHANNEL 1
/* Function prototypes */
static bool_t RGBasicOps_run(int32_t cardIndex, int32_t module, uint32_t modId);
static nai_status_t RGBasicOps_runBasicMenu(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_runInterruptMenu(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_runDSTMenu(int32_t paramCount, int32_t* p_params);
static void RGBasicOps_displayConfigurations(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex);
static void RGBasicOps_displayInterrupts(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex);
static void RGBasicOps_displayDSTSettings(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex);
/* RG Basic Ops Command Functions */
static nai_status_t RGBasicOps_setIRIGProtocol(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGProtocolByValue(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGAMOutputGain(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGDriftThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGReferenceSource(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGCtrlBitsToSend(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_getIRIGCtrlBitsReceived(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGDigitalInput(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGDigitalOutput(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGTimeZoneOffset(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGPropOffset(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGYear(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGPulseWidth(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGFreeRunningTime(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGRTCTime(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGRTCControl(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGCaptureEventTime(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGCaptureEventEdge(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGSerialSignalLevel(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGPeriodicInterruptPeriod(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptSteering(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptEdgeLevel(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptVector(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_clearIRIGEventMappedStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_getIRIGEventMappedStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_clearIRIGChannelStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsDST_getIRIGDSTStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsDST_setIRIGDSTOffset(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsDST_setIRIGDSTStart(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsDST_setIRIGDSTEnd(int32_t paramCount, int32_t* p_params);
/****** Command Table *******/
enum rg_basicOps_commands
{
RG_BASICOPS_BASIC_MENU,
RG_BASICOPS_INTERRUPT_MENU,
RG_BASICOPS_DST_MENU,
RG_BASICOPS_COUNT
};
enum rg_basicOps_basic_commands
{
RG_BASICOPS_CMD_SET_PROTOCOL,
RG_BASICOPS_CMD_SET_PROTOCOL_BY_VALUE,
RG_BASICOPS_CMD_SET_GAIN,
RG_BASICOPS_CMD_SET_DRIFT_THRESHOLD,
RG_BASICOPS_CMD_SET_REFERENCE_SOURCE,
RG_BASICOPS_CMD_SET_CONTROL_BITS,
RG_BASICOPS_CMD_GET_CONTROL_BITS_RECEIVED,
RG_BASICOPS_CMD_SET_DIGITAL_INPUT,
RG_BASICOPS_CMD_SET_DIGITAL_OUTPUT,
RG_BASICOPS_CMD_SET_TIME_ZONE_OFFSET,
RG_BASICOPS_CMD_SET_PROP_OFFSET,
RG_BASICOPS_CMD_SET_YEAR,
RG_BASICOPS_CMD_SET_PULSE_WIDTH,
RG_BASICOPS_CMD_SET_PERIOD_INTERRUPT_PERIOD,
RG_BASICOPS_CMD_SET_FREE_RUNNING_TIME,
RG_BASICOPS_CMD_SET_CAPTURE_EVENT_TIME,
RG_BASICOPS_CMD_SET_CAPTURE_EVENT_EDGE,
RG_BASICOPS_CMD_SET_SERIAL_SIGNAL_LEVEL,
RG_BASICOPS_CMD_SET_RTC_TIME,
RG_BASICOPS_CMD_SET_RTC_CONTROL,
RG_BASICOPS_CMD_COUNT
};
enum rg_basicOps_Interrupts_commands
{
RG_BASICOPS_INTERRUPTS_CLEAR,
RG_BASICOPS_INTERRUPTS_CLEARSPECIFIC,
RG_BASICOPS_INTERRUPTS_ENABLE,
RG_BASICOPS_INTERRUPTS_STEERING,
RG_BASICOPS_INTERRUPTS_EDGELEVEL,
RG_BASICOPS_INTERRUPTS_VECTOR,
RG_BASICOPS_INTERRUPTS_CMD_COUNT
};
enum rg_basicOps_DST_commands
{
RG_BASICOPS_DST_CMD_GET_DST_STATUS,
RG_BASICOPS_DST_CMD_SET_DST_OFFSET,
RG_BASICOPS_DST_CMD_SET_DST_START,
RG_BASICOPS_DST_CMD_SET_DST_END,
RG_BASICOPS_DST_CMD_COUNT
};
naiapp_cmdtbl_params_t RG_BasicOpsCmds[] =
{
{"BAS", "IRIG Basic Menu", RG_BASICOPS_BASIC_MENU, RGBasicOps_runBasicMenu},
{"INT", "IRIG Interrupt Menu", RG_BASICOPS_INTERRUPT_MENU, RGBasicOps_runInterruptMenu},
{"DST", "IRIG DST (Daylight Savings Time) Menu", RG_BASICOPS_DST_MENU, RGBasicOps_runDSTMenu}
};
naiapp_cmdtbl_params_t RG_BasicOps_BasicCmds[] =
{
{"PR", "Set IRIG Protocol", RG_BASICOPS_CMD_SET_PROTOCOL, RGBasicOps_setIRIGProtocol },
{"PRV", "Set IRIG Protocol by Value", RG_BASICOPS_CMD_SET_PROTOCOL_BY_VALUE, RGBasicOps_setIRIGProtocolByValue },
{"G", "Set IRIG Gain Control", RG_BASICOPS_CMD_SET_GAIN, RGBasicOps_setIRIGAMOutputGain },
{"D", "Set IRIG Drift Threshold", RG_BASICOPS_CMD_SET_DRIFT_THRESHOLD, RGBasicOps_setIRIGDriftThreshold },
{"RS", "Set IRIG Reference Source", RG_BASICOPS_CMD_SET_REFERENCE_SOURCE, RGBasicOps_setIRIGReferenceSource },
{"CB", "Set IRIG Control Bits to Send", RG_BASICOPS_CMD_SET_CONTROL_BITS, RGBasicOps_setIRIGCtrlBitsToSend },
{"CBR", "View IRIG Control Bits Received",RG_BASICOPS_CMD_GET_CONTROL_BITS_RECEIVED, RGBasicOps_getIRIGCtrlBitsReceived },
{"DI", "Set IRIG Digital Input", RG_BASICOPS_CMD_SET_DIGITAL_INPUT, RGBasicOps_setIRIGDigitalInput },
{"DO", "Set IRIG Digital Output", RG_BASICOPS_CMD_SET_DIGITAL_OUTPUT, RGBasicOps_setIRIGDigitalOutput },
{"TZO", "Set IRIG Time Zone Offset", RG_BASICOPS_CMD_SET_TIME_ZONE_OFFSET, RGBasicOps_setIRIGTimeZoneOffset },
{"O", "Set Prop Offset", RG_BASICOPS_CMD_SET_PROP_OFFSET, RGBasicOps_setIRIGPropOffset },
{"Y", "Set IRIG Year", RG_BASICOPS_CMD_SET_YEAR, RGBasicOps_setIRIGYear },
{"PW", "Set 1PPS Pulse Width", RG_BASICOPS_CMD_SET_PULSE_WIDTH, RGBasicOps_setIRIGPulseWidth },
{"FRT", "Set Free Running Time", RG_BASICOPS_CMD_SET_FREE_RUNNING_TIME, RGBasicOps_setIRIGFreeRunningTime },
{"RTCT", "Set RTC Time", RG_BASICOPS_CMD_SET_RTC_TIME, RGBasicOps_setIRIGRTCTime },
{"RTCC", "Set RTC Control", RG_BASICOPS_CMD_SET_RTC_CONTROL, RGBasicOps_setIRIGRTCControl },
{"CET", "Set Capture Event Time", RG_BASICOPS_CMD_SET_CAPTURE_EVENT_TIME, RGBasicOps_setIRIGCaptureEventTime },
{"CEE", "Set Capture Event Edge", RG_BASICOPS_CMD_SET_CAPTURE_EVENT_EDGE, RGBasicOps_setIRIGCaptureEventEdge },
{"SSL", "Set Serial Signal Level", RG_BASICOPS_CMD_SET_SERIAL_SIGNAL_LEVEL, RGBasicOps_setIRIGSerialSignalLevel },
{"PIP", "Set Period Interrupt Period", RG_BASICOPS_CMD_SET_PERIOD_INTERRUPT_PERIOD,RGBasicOps_setIRIGPeriodicInterruptPeriod }
};
naiapp_cmdtbl_params_t RG_BasicOps_InterruptCmds[] =
{
{"C", "Clear All Event Mapped Status Bits", RG_BASICOPS_INTERRUPTS_CLEAR, RGBasicOpsInterrupts_clearIRIGChannelStatus },
{"CS", "Clear Specific Event Mapped Status Bit", RG_BASICOPS_INTERRUPTS_CLEARSPECIFIC, RGBasicOpsInterrupts_clearIRIGEventMappedStatus },
{"E", "Set Event Mapped Interrupt Enable", RG_BASICOPS_INTERRUPTS_ENABLE, RGBasicOpsInterrupts_setIRIGInterruptEnable },
{"S", "Set Event Mapped Interrupt Steering", RG_BASICOPS_INTERRUPTS_STEERING, RGBasicOpsInterrupts_setIRIGInterruptSteering },
{"V", "Set Event Mapped Interrupt Vector", RG_BASICOPS_INTERRUPTS_VECTOR, RGBasicOpsInterrupts_setIRIGInterruptVector },
{"EL", "Set Event Mapped Interrupt Edge Level", RG_BASICOPS_INTERRUPTS_EDGELEVEL, RGBasicOpsInterrupts_setIRIGInterruptEdgeLevel }
};
naiapp_cmdtbl_params_t RG_BasicOps_DSTCmds[] =
{
{"DSTS", "Get DST Status", RG_BASICOPS_DST_CMD_GET_DST_STATUS, RGBasicOpsDST_getIRIGDSTStatus },
{"OFF", "Set DST Offset", RG_BASICOPS_DST_CMD_SET_DST_OFFSET, RGBasicOpsDST_setIRIGDSTOffset },
{"START", "Set DST Start", RG_BASICOPS_DST_CMD_SET_DST_START, RGBasicOpsDST_setIRIGDSTStart },
{"END", "Set DST End", RG_BASICOPS_DST_CMD_SET_DST_END, RGBasicOpsDST_setIRIGDSTEnd }
};
int8_t interruptTypeStrings[NAIBRD_IRIG_EVTMAP_STATUS_TYPE_ENUM_COUNT][40] =
{
"BIT Data Loss",
"BIT Data Loss",
"BIT Software Fault",
"BIT Software Fault",
"IRIG Reference Lost",
"IRIG Reference Lost",
"Receiving IRIG Reference",
"Receiving IRIG Reference",
"IRIG Reference Pulse Received",
"IRIG Reference Pulse Received",
"Interrupt on 1PPS Output Going High",
"Interrupt on 1PPS Output Going High",
"Received Control Bits Changed",
"Received Control Bits Changed",
"Control Bits Received",
"Control Bits Received",
"Change In Reference Source",
"Change In Reference Source",
"Event Detected",
"Event Detected",
"Programmable-Duration User Interrupt",
"Programmable-Duration User Interrupt",
"Did a DST Adjust",
"Did a DST Adjust",
"Test Interrupt",
"Test Interrupt"
};
int8_t enableDisableStrings[2][10] =
{
"DISABLED",
"ENABLED "
};
int8_t interruptTriggerTypeStrings[2][10] =
{
"EDGE ",
"LEVEL"
};
int8_t interruptSteeringStrings[6][50] =
{
"VME",
"ARM Custom Application (On Board 0)",
"NAI Ethernet Listener Application (On Board 1)",
"On Board 2 (Unused)",
"PCIe Bus",
"CPCI Bus"
};
#if defined (__VXWORKS__)
int32_t RG_BasicOps(void)
#else
int32_t main(void)
#endif
{
bool_t bQuit = FALSE;
int32_t cardIndex = -1;
int32_t module = 0;
uint32_t modId = 0u;
int32_t moduleCount;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
{
while (!bQuit)
{
naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
naibrd_GetModuleCount(cardIndex, &moduleCount);
naiapp_query_ModuleNumber(moduleCount, 1, &module);
modId = naibrd_GetModuleID(cardIndex, module);
bQuit = RGBasicOps_run(cardIndex, module, modId);
}
printf("Type the Enter key to exit the program: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR,
inputBuffer, &inputResponseCnt);
}
naiapp_access_CloseAllOpenCards();
return 0;
}
static void RGBasicOps_displayConfigurations(int32_t cardIndex, int32_t module,
uint32_t modId, int32_t maxChannels, bool_t displayHex)
{
int channel;
naibrd_irig_protocol_value_t protocol;
naibrd_irig_master_timer_info_t timer;
uint8_t gain;
uint32_t driftThreshold, frameErrorCnt, refSource, pulseWidth;
#if defined (WIN32)
UNREFERENCED_PARAMETER(modId);
UNREFERENCED_PARAMETER(displayHex);
#endif
printf("\n\n ==============================================================================\n");
printf(" Protocol 1PPS PW Gain Drift Ref IRIG Time Master Time\n");
printf(" ------------------------------------------------------------------------------\n");
for (channel = 1; channel <= maxChannels; channel++)
{
check_status(naibrd_IRIG_GetProtocolByValue(cardIndex, module, channel, &protocol));
printf(" %x ", protocol);
check_status(naibrd_IRIG_Get1PPSPulseWidth(cardIndex, module, channel, &pulseWidth));
printf("%d ", pulseWidth);
check_status(naibrd_IRIG_GetAMOutputGain(cardIndex, module, channel, &gain));
printf("%d ", gain);
check_status(naibrd_IRIG_GetDriftThreshold(cardIndex, module, channel, &driftThreshold));
printf("%d ", driftThreshold);
check_status(naibrd_IRIG_GetActualReferenceSource(cardIndex, module, channel, &refSource));
printf("%d ", refSource);
check_status(naibrd_IRIG_GetActualIRIGDateAndTime(cardIndex, module, channel, &timer, &frameErrorCnt));
printf("%d/%d %d:%d:%d.%03d ", timer.day, timer.year, timer.hour, timer.minute,
timer.second, timer.microSecond / 1000u);
check_status(naibrd_IRIG_GetMasterTime(cardIndex, module, channel, &timer));
printf("%d/%d %d:%d:%d.%03d", timer.day, timer.year, timer.hour, timer.minute,
timer.second, timer.microSecond / 1000u);
}
}
static void RGBasicOps_displayInterrupts(int32_t cardIndex, int32_t module,
uint32_t modId, int32_t maxChannels, bool_t displayHex)
{
int channel = maxChannels;
bool_t enable = FALSE;
naibrd_irig_interrupt_trigger_type_t trigType = NAIBRD_IRIG_EDGE_INTERRUPT;
uint32_t statusType;
uint32_t bitVector = 0u, generalVector = 0u;
uint32_t statusHexLatchedBit = 0u, statusHexRealtimeBit = 0u;
uint32_t statusHexLatchedGeneral = 0u, statusHexRealtimeGeneral = 0u;
nai_status_bit_t status, rtStatus;
naibrd_int_steering_t bitSteering = NAIBRD_INT_STEERING_CPCI_APP;
naibrd_int_steering_t generalSteering = NAIBRD_INT_STEERING_CPCI_APP;
#if defined (WIN32)
UNREFERENCED_PARAMETER(modId);
UNREFERENCED_PARAMETER(displayHex);
#endif
printf("\n\n ================================================================\n");
printf(" Status Type Status (R/L) Enable Trigger\n");
printf(" ----------------------------------------------------------------\n");
for (statusType = (uint32_t)NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED;
statusType < NAIBRD_IRIG_EVTMAP_STATUS_TYPE_ENUM_COUNT; statusType += 2u)
{
printf("%37s", interruptTypeStrings[statusType]);
check_status(naibrd_IRIG_GetEventMappedStatus(cardIndex, module, channel,
(naibrd_irig_event_mapped_status_type_t)statusType, &status));
check_status(naibrd_IRIG_GetEventMappedStatus(cardIndex, module, channel,
(naibrd_irig_event_mapped_status_type_t)(statusType + 1u), &rtStatus));
printf(" (%d/%d) ", rtStatus, status);
check_status(naibrd_IRIG_GetEventMappedInterruptEnable(cardIndex, module, channel,
(naibrd_irig_event_mapped_status_type_t)statusType, &enable));
printf("%9s ", enableDisableStrings[enable]);
check_status(naibrd_IRIG_GetEventMappedInterruptTriggerType(cardIndex, module, channel,
(naibrd_irig_event_mapped_status_type_t)statusType, &trigType));
printf("%6s\n", interruptTriggerTypeStrings[trigType]);
}
check_status(naibrd_IRIG_GetEventMappedInterruptVector(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, &bitVector));
check_status(naibrd_IRIG_GetEventMappedInterruptVector(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, &generalVector));
check_status(naibrd_IRIG_GetEventMappedInterruptSteering(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, &bitSteering));
check_status(naibrd_IRIG_GetEventMappedInterruptSteering(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, &generalSteering));
check_status(naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, NAI_STATUS_LATCHED, &statusHexLatchedBit));
check_status(naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, NAI_STATUS_REALTIME, &statusHexRealtimeBit));
check_status(naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, NAI_STATUS_LATCHED, &statusHexLatchedGeneral));
check_status(naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel,
NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, NAI_STATUS_REALTIME, &statusHexRealtimeGeneral));
printf("\n BIT Vector: 0x%08X General Vector: 0x%08X", bitVector, generalVector);
printf("\n BIT Steering: %s General Steering: %s",
interruptSteeringStrings[(int32_t)bitSteering - 1],
interruptSteeringStrings[(int32_t)generalSteering - 1]);
}
static void RGBasicOps_displayDSTSettings(int32_t cardIndex, int32_t module,
uint32_t modId, int32_t maxChannels, bool_t displayHex)
{
int channel;
naibrd_irig_dst_status_type_t dstStatus = NAIBRD_IRIG_DST_STATUS_DISABLED;
uint32_t dstOffset = 0u;
naibrd_irig_dst_timer_info_t dstStartStruct, dstEndStruct;
memset(&dstStartStruct, 0, sizeof(naibrd_irig_dst_timer_info_t));
memset(&dstEndStruct, 0, sizeof(naibrd_irig_dst_timer_info_t));
#if defined (WIN32)
UNREFERENCED_PARAMETER(modId);
UNREFERENCED_PARAMETER(displayHex);
#endif
printf("\n\n ================================================================\n");
printf("Ch DST Status Offset Start(M/W/D/H/M) End(M/W/D/H/M)\n");
printf(" ----------------------------------------------------------------\n");
for (channel = 1; channel <= maxChannels; channel++)
{
check_status(naibrd_IRIG_GetDSTStatus(cardIndex, module, channel, &dstStatus));
check_status(naibrd_IRIG_GetDSTOffset(cardIndex, module, channel, &dstOffset));
check_status(naibrd_IRIG_GetDSTStart(cardIndex, module, channel, &dstStartStruct));
check_status(naibrd_IRIG_GetDSTEnd(cardIndex, module, channel, &dstEndStruct));
printf(" %d %8s 0x%08X %d/%d/%d/%d/%d %d/%d/%d/%d/%d\n",
channel, enableDisableStrings[dstStatus], dstOffset,
dstStartStruct.month, dstStartStruct.week, dstStartStruct.day,
dstStartStruct.hour, dstStartStruct.minute,
dstEndStruct.month, dstEndStruct.week, dstEndStruct.day,
dstEndStruct.hour, dstEndStruct.minute);
}
}
static bool_t RGBasicOps_run(int32_t cardIndex, int32_t module, uint32_t modId)
{
bool_t bQuit = FALSE;
bool_t bCmdFound = FALSE;
int32_t cmd;
naiapp_AppParameters_t rg_basicops_params;
p_naiapp_AppParameters_t rg_basicOps_params = &rg_basicops_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
rg_basicOps_params->cardIndex = cardIndex;
rg_basicOps_params->module = module;
rg_basicOps_params->channel = DEFAULT_CHANNEL;
rg_basicOps_params->maxChannels = naibrd_IRIG_GetChannelCount(modId);
rg_basicOps_params->modId = modId;
rg_basicOps_params->displayHex = FALSE;
do
{
naiapp_utils_LoadParamMenuCommands(RG_BASICOPS_COUNT, RG_BasicOpsCmds);
naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
printf("\n\nPlease enter a command or 'q' to quit:");
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)
RG_BasicOpsCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)rg_basicOps_params);
else
printf("Invalid command entered\n");
}
}
} while (!bQuit);
return bQuit;
}
/* Remaining command handler functions follow the same pattern:
extract parameters from p_params, prompt user for input,
call the appropriate naibrd_IRIG_*() API, and return status.
See the full source in the SSK at AppSrc/IRIG/RG_BasicOps/RG_BasicOps.c */