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

DT Ethernet IDR

DT Ethernet IDR

Explanation

About the DT_Ethernet_IDR Sample Application

This document explains the sample C code provided by North Atlantic Industries (NAI) for their DT_Ethernet_IDR application. This application demonstrates how to handle multiple channel interrupts (Fault, Low-to-High Transition, High-to-Low Transition, and Overcurrent) using Ethernet IDR (Interrupt Driven Response) commands for their discrete modules.

Key Components

  1. Include Declarations:

    • Necessary libraries and header files are included to provide the required functionality, including standard C libraries and specific NAI libraries.

  2. Ethernet IDR Declarations:

    • Default IP address, port number, and Ethernet protocol.

    • Constants and variables for Ethernet configuration.

  3. Internal Function Prototypes:

    • Declarations for internal functions used in the program.

  4. Main Routine:

    • Main function either main(void) for standard systems or DT_Ethernet_IDR(void) for VxWorks systems.

    • Handles the main execution flow including initialization, user prompt handling, Ethernet configuration, and interrupt management.

  5. Detailed Function Implementation:

    • Functions like SetupDTEtherIDRconfig, StartDTEtherIDR, HandleDTEtherInterrupt, and ExitApp_DTEtherIDR perform critical tasks such as configuring the IDR, starting the IDR process, handling Ethernet interrupts, and cleaning up the application respectively.

Important Definitions and Function Descriptions

  1. Network Constants and Variables:

    • DEF_RESPONSE_IP_LEN: Default IP address length.

    • DEF_RESPONSE_PROTOCOL: Default protocol (UDP in this case).

    • DEF_DT_RX_RESPONSE_PORT and DEF_DT_RX_RESPONSE_IP4_ADDR: Default port and IP address for receiving interrupt messages.

    • Variables dt_ether_int_rx_port, dt_ether_int_rx_ip4, and dt_ether_int_protocol are used for configuring the interrupt messages reception.

  2. Configuration Variables:

    • bPromptForInterruptClear: When TRUE, user is prompted to clear interrupts.

  3. Function Descriptions:

    • SetupDTEtherIDRconfig:

    • Configures the Ethernet IDR command for the discrete module.

    • Clears any existing configurations and sets up new IDR commands to read latched status registers upon interrupt detection.

    • StartDTEtherIDR:

    • Starts or enables the Ethernet IDR command for the discrete module.

    • Checks and prints an error message if the start operation fails.

    • HandleDTEtherInterrupt:

    • Parses the Ethernet interrupt message and retrieves the status information.

    • Clears the status and re-arms the interrupts if latched statuses are present.

    • Prompts the user for interrupt clearing if bPromptForInterruptClear is enabled.

    • ExitApp_DTEtherIDR:

    • Stops the Ethernet IDR command and closes the communication connection to the board.

    • Cleans up and terminates the application threads handling interrupts.

    • ConfigETHERInterrupt:

    • Configures Ethernet-based interrupts, including disabling existing interrupts, clearing status, setting interrupt vectors, and steering configurations.

    • Handles different statuses and sets up the latched status mode as required.

    • MakeIDRDTboardReadRegsCommand:

    • Builds the Read Register command for IDR messages.

Conclusion

The DT_Ethernet_IDR sample application is designed to illustrate how to configure and handle interrupts for discrete modules via Ethernet IDR commands. It covers initializing the Ethernet settings, configuring the IDR commands, handling interrupts, and cleaning up the application. The included functions and configuration settings allow for a structured approach to managing multiple-channel interrupts over an Ethernet interface.

This document provides a brief explanation of the components, key functions, and their purposes, facilitating a better understanding of the sample code and its operations.

/**************************************************************************************************************/
/**
<summary>
The DT_Ethernet_IDR program that handle multiple channel interrupts for the Discrete module using the
Ethernet IDR (Interrupt Driven Response) commands.

Interrupts for Fault, Low-to-High Transition, High-to-Low Transition and Overcurrent are enabled.
</summary>
*/
/**************************************************************************************************************/

/************************/
/* Include Declarations */
/************************/
#if defined (WIN32)
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #pragma comment (lib, "Ws2_32.lib")
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdint.h>

/* Common Sample Program include files */
#include "include/naiapp_interrupt.h"
#include "include/naiapp_interrupt_ether.h"
#include "include/naiapp_boardaccess_menu.h"
#include "include/naiapp_boardaccess_query.h"
#include "include/naiapp_boardaccess_access.h"
#include "include/naiapp_boardaccess_display.h"
#include "include/naiapp_boardaccess_utils.h"

/* Generic NAI Board Library include files */
#include "nai.h"
#include "naibrd.h"
#include "naibrd_ether.h"
#include "advanced/nai_ether_adv.h"

/* Module Specific NAI Board Library files */
#include "functions/naibrd_dt.h"
#include "maps/nai_map_dt.h"

/* Module Specific sample code include files */
#include "DT_Interrupt_Common.h"

/*********************************************/
/* Application Name and Revision Declaration */
/*********************************************/
/*
static const int8_t *App_Name = "DT ETHERNET INTERRUPT";
static const int8_t *App_Rev = "1.0";
*/

static const int8_t *DEF_CONFIG_FILE = (int8_t *)"default_DT_Ethernet_Int.txt";

/*****************************/
/* Ethernet IDR Declarations */
/*****************************/
/* Default Definitions for Ethernet IDR */
#define DEF_RESPONSE_IP_LEN              ETHER_GEN4_IPv4_ADDR_LEN
#define DEF_RESPONSE_PROTOCOL            ETHER_GEN4_UDP_PROTOCOL
uint16_t DEF_DT_RX_RESPONSE_PORT         =  52802;
uint8_t  DEF_DT_RX_RESPONSE_IP4_ADDR[]   = {192,168,1,200};

/* IP Address and Ethernet Port to receive the interrupt messages */
uint16_t dt_ether_int_rx_port;
uint8_t  dt_ether_int_rx_ip4[4];
uint16_t dt_ether_int_protocol;

/* Number of Registers to retrieve with each interrupt message:
   Fault, Low-to-High Transition, High-to-Low Transition and Overcurrent.
*/
#define DT_INTERRUPT_RESPONSE_REG_COUNT     4

bool_t bPromptForInterruptClear = TRUE;

/********************************/
/* Internal Function Prototypes */
/********************************/
bool_t SetupDTEtherIDRconfig(uint16_t protocol, int32_t IDRcardIndex, int32_t boardInterface);
bool_t QueryUserForClearingDTInterruptPrompts(void);
bool_t QueryUserForOnboardOffboardDTInterrupts();
void MakeIDRDTboardReadRegsCommand(uint16_t startIndex, uint32_t moduleOffset, uint32_t regAddr, uint32_t count, uint32_t stride, uint8_t commands[], uint16_t *cmdlen,int32_t boardInterface);
void HandleDTEtherInterrupt(uint16_t msglen, uint8_t msg[], uint16_t tdr_idr_id);void StartDTEtherIDR(int32_t IDRcardIndex);
void ExitApp_DTEtherIDR(int32_t IDRcardIndex);
void ConfigETHERInterrupt(naibrd_int_steering_t steering);

/**************************************************************************************************************/
/*****                                     Main Routine                                                   *****/
/**************************************************************************************************************/
/**************************************************************************************************************/
/**
<summary>
The purpose of the DT_Ethernet_IDR is to illustrate the methods to call in the naibrd library to configure the
discrete module to generate interrupts on any channel for the following events:
 - Fault,
 - Low-to-High Transition,
 - High-to-Low Transition, or
 - Overcurrent

The following routines from the DT_Interrupt_Common.c file are called to assist with displaying, handling prompting
the user for inputs and configuring the channels on the discrete modules:
 - DisplayMessage_DTInterrupt
 - PromptUserInput_DTInterrupt
 - ConfigDTInterrupt
 - EnableDTInterrupt

The following routines from the nai_sys_cfg.c file are called to assist with handling prompting
the user for inputs specific to configuring the discrete modules for Ethernet interrupts:
 - QueryUnpromptedEtherResponseIP4Addr
 - SetUPREtherPort

The following routines from the nai_sys_int_ether.c file are called to verify that the Ethernet Protocol
is supported by this application:
 - CheckNaiEtherProtocolVersion

The following routines from the nai_sys_int.c file are called to assist with setup the threads used by this
application to handle the interrupt and user interface:
 - InitInterruptAppThread
 - UpdateThreadState

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 DT routines.
 - ConfigDevice
 - DisplayDeviceCfg
 - GetBoardSNModCfg

</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
void DT_Ethernet_IDR(void)
#else
int32_t main(void)
#endif
{
   bool_t bQuit = FALSE;
   bool_t bSuccess = FALSE;
   bool_t bProcessOnboardInterrupts = FALSE;
   bool_t bPromptforInterruptClear = FALSE;
   int32_t IDRcardIndex=0;
   naibrd_int_steering_t steering;
   int32_t boardInterface;

   DisplayMessage_DTInterrupt(MSG_BANNER_DT_INT);
   bQuit = naiapp_RunBoardMenu(DEF_CONFIG_FILE);
   while (!bQuit)
   {
      naiapp_access_SystemSNModCfg();
      bQuit = PromptUserInput_DTInterrupt(&bSuccess);
      if ((!bQuit) & bSuccess)
      {
         bQuit = QueryUnpromptedEtherResponseIP4Addr(DEF_DT_RX_RESPONSE_IP4_ADDR, DEF_DT_RX_RESPONSE_PORT, DEF_RESPONSE_PROTOCOL, dt_ether_int_rx_ip4, &dt_ether_int_rx_port, &dt_ether_int_protocol);
         if (!bQuit)
            bQuit = QueryUserForEtherIDRMsgDisplay(&bDisplayEtherUPR);
         if (!bQuit)
            bQuit = QueryUserForClearingInterruptPrompts(&bPromptforInterruptClear);
        if(!bQuit){
         bQuit = QueryUserForOnboardOffboardInterrupts(&bProcessOnboardInterrupts);
         }
         if (!bQuit)
         {
          if(bProcessOnboardInterrupts == TRUE)
           {
            IDRcardIndex = userInput_DTInt.cardIndex;
            boardInterface =  NAI_INTF_ONBOARD;
            steering = NAIBRD_INT_STEERING_ON_BOARD_1;
           }
           else /*OffBoard Interrupt*/
           {
            IDRcardIndex = 0;
            boardInterface = NAI_INTF_PCI;
            steering =  NAIBRD_INT_STEERING_CPCI_APP;
           }

            naiapp_utils_SetUPREtherPort(dt_ether_int_rx_port);
            bSuccess = CheckNaiEtherProtocolVersion(userInput_DTInt.cardIndex);
            if (bSuccess)
               ConfigETHERInterrupt(steering);
            else
               printf("ERROR: Ethernet Interrupt Support Prior to Generation 4 Ethernet commands are currently NOT supported.\n");
            if (bSuccess)
            {
               InitInterruptAppThread(ETHERNET_INT, dt_ether_int_protocol);
               /* Set the dtEtherIntFunc global function pointer to point to the routine that will handle
                  Interrupt messages associated with the Discrete Interrupt Vector (DEF_ETHERNET_DT_IDR_ID).
               */
               dtEtherIntFunc = HandleDTEtherInterrupt;
               if (SetupDTEtherIDRconfig(dt_ether_int_protocol, IDRcardIndex, boardInterface))
               {
                  DisplayMessage_DTInterrupt(MSG_USER_TRIGGER_DT_INT);
                  StartDTEtherIDR(IDRcardIndex);
                  EnableDTInterrupt(TRUE);
                  UpdateThreadState(RUN);
               }
               else
                  bQuit = TRUE;
            }
         }
         else
         {
            UpdateThreadState(TERMINATED);
         }
         bQuit = TRUE;
      }
   }
   ExitApp_DTEtherIDR(IDRcardIndex);

#if !defined (__VXWORKS__)
   return(0);
#endif

}

/**************************************************************************************************************/
/*****                                  Internal Functions                                                *****/
/**************************************************************************************************************/

/**************************************************************************************************************/
/**
<summary>
SetupDTEtherIDRconfig calls the routines in the naibrd library to clear and setup the Ethernet IDR
(Interrupt Driven Response) command for the Discrete module. The DEF_ETHERNET_DT_IDR_ID and NAI_DT_INTERRUPT_VECTOR
specified in the nai_sys_int_common.h file are used as the IDR_ID and interrupt vector for this application.
The MakeIDROnboardReadRegsCommand() routine in the nai_sys_int_ether.c file is called to create a Ethernet
IDR command that consists of one ReadRegs command which retrieves and returns the contents in the Latched Status
registers for the BIT (Fault), Low-to-High Transition, High-to-Low Transition and Overcurrent when an interrupt
is detected.
</summary>
*/
/**************************************************************************************************************/
bool_t SetupDTEtherIDRconfig(uint16_t protocol, int32_t IDRcardIndex, int32_t boardInterface)
{
   bool_t bSuccess = FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint16_t msgIndex = 0;
   uint16_t idrcmdcnt = 0;
   uint16_t ethcmdlen = 0;
   uint16_t idrcmdlen = 0;
   uint32_t moduleOffset;
   uint8_t commands[MAX_ETHER_IDR_CMD_CNT*MAX_ETHER_BLOCK_REG_CNT];
   int32_t vector = NAI_DT_INTERRUPT_VECTOR;
   uint32_t stride = 0x10;  /* Register offset between the latched status register for each type of status */
   uint16_t cmdcount = 0;
   uint16_t cmdlength = 0;

   /* Clear the Ethernet Interrupt Driven Response Configuration associated with the ID: DEF_ETHERNET_DT_IDR_ID */
   status = naibrd_Ether_ClearIDRConfig(IDRcardIndex,(uint16_t)DEF_ETHERNET_DT_IDR_ID);
   if (status == NAI_SUCCESS)
   {
      status = check_status(naibrd_GetModuleOffset(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, &moduleOffset));
      if (status == NAI_SUCCESS)
      {
         /* First command */
         /* Perform ReadRegs command starting with NAI_DT_GEN5_REG_BIT_LATCHED_STATUS_ADD */
         /* This reads:
            - NAI_DT_GEN5_REG_BIT_LATCHED_STATUS_ADD,
            - NAI_DT_GEN5_REG_LO_HI_TRANS_LATCHED_STATUS_ADD,
            - NAI_DT_GEN5_REG_HI_LO_TRANS_LATCHED_STATUS_ADD
            - NAI_DT_GEN5_REG_OVERCURRENT_LATCHED_STATUS_ADD
         */
         MakeIDRDTboardReadRegsCommand(msgIndex, moduleOffset, NAI_DT_GEN5_REG_BIT_LATCHED_STATUS_ADD, DT_INTERRUPT_RESPONSE_REG_COUNT, stride, commands, &ethcmdlen, boardInterface);
         msgIndex += ethcmdlen;
         idrcmdlen += ethcmdlen;
         idrcmdcnt++;

         cmdcount = idrcmdcnt;
         cmdlength = msgIndex;
      }

      status = check_status(naibrd_Ether_SetIDRConfig(IDRcardIndex,(uint16_t)DEF_ETHERNET_DT_IDR_ID,protocol,DEF_RESPONSE_IP_LEN,dt_ether_int_rx_ip4,dt_ether_int_rx_port,vector,cmdcount,cmdlength,commands));
   }
   if (status == NAI_SUCCESS)
      bSuccess = TRUE;
   return bSuccess;
}

/**************************************************************************************************************/
/**
<summary>
StartDTEtherIDR calls the routines in the naibrd library to start/enable the Ethernet IDR
(Interrupt Driven Response) command associated with DEF_ETHERNET_DT_IDR_ID for the Discrete module.
</summary>
*/
/**************************************************************************************************************/
void StartDTEtherIDR(int32_t IDRcardIndex)
{
   nai_status_t status;

   /* Start the IDR */
   status = naibrd_Ether_StartIDR(IDRcardIndex, (uint16_t)DEF_ETHERNET_DT_IDR_ID);
    if (status != NAI_SUCCESS)
    {
      printf("Error IDR ID = %d Started\n", DEF_ETHERNET_DT_IDR_ID);
    }
}

/**************************************************************************************************************/
/**
<summary>
HandleDTEtherInterrupt is called by the decodeUPRIDRMessages() routine in nai_sys_int_ether.c when an
unprompted (UPR) Ethernet message is received with the TDR/IDR Index equal to DEF_ETHERNET_DT_IDR_ID.
This routine will parse the message to retrieve the information requested in the SetupDTEtherIDRconfig()
routine.
</summary>
*/
/**************************************************************************************************************/
void HandleDTEtherInterrupt(uint16_t msglen, uint8_t msg[],uint16_t tdr_idr_id)
{
   uint16_t seq;
   nai_ether_typecode_t tc;
   nai_ether_gen_t gen;
   int32_t size;
   int32_t offset;
   uint16_t datacnt = 0;
   uint32_t data;
   uint32_t dtstatus_int[DT_INTERRUPT_RESPONSE_REG_COUNT];
   nai_dt_status_type_t dt_status_type = NAI_DT_STATUS_BIT_LATCHED;
   int32_t i;

   gen = NAI_ETHER_GEN4;
   offset = nai_ether_DecodeMessageHeader(msg, msglen, &seq, &tc, gen, &size);

   switch (tc)
   {
   case NAI_ETHER_TYPECODE_RSP_COMMAND_COMPLETE_READ_4:
      datacnt = (msglen - 10)/NAI_REG32;
      for (i = 0; i < datacnt; i++)
      {
         data = 0;
         data = msg[offset++] << 24;
         data |=  msg[offset++] << 16;
         data |=  msg[offset++] << 8;
         data |= msg[offset++];
         if (i < DT_INTERRUPT_RESPONSE_REG_COUNT)
            dtstatus_int[i] = data;
      }
      break;
   }

    printf("\n\n");
    printf("IDR ID : %d\n", tdr_idr_id);

   /* Check to make sure we got all 4 status elements (BIT, Lo-Hi, Hi-Lo, Overcurrent) */
   if (datacnt == DT_INTERRUPT_RESPONSE_REG_COUNT)
   {
      for (i = 0; i < DT_INTERRUPT_RESPONSE_REG_COUNT; i++)
      {
         switch (i)
         {
         case 0:
            dt_status_type = NAI_DT_STATUS_BIT_LATCHED;
            break;
         case 1:
            dt_status_type = NAI_DT_STATUS_LO_HI_TRANS_LATCHED;
            break;
         case 2:
            dt_status_type = NAI_DT_STATUS_HI_LO_TRANS_LATCHED;
            break;
         case 3:
            dt_status_type = NAI_DT_STATUS_OVERCURRENT_LATCHED;
            break;
         }
         if (dtstatus_int[i] != 0)
         {
            switch (i)
            {
            case 0:
               printf("Received DT Bit Interrupt: (Interrupt_status) 0x%08X\n", dtstatus_int[i]);
            break;
            case 1:
               printf("Received DT Lo-Hi Interrupt: (Interrupt_status) 0x%08X\n", dtstatus_int[i]);
            break;
            case 2:
               printf("Received DT Hi-Lo Interrupt: (Interrupt_status) 0x%08X\n", dtstatus_int[i]);
            break;
            case 3:
               printf("Received DT Overcurrent Interrupt: (Interrupt_status) 0x%08X\n", dtstatus_int[i]);
            break;
            }
            if (bPromptForInterruptClear)
            {
               /* Prompt the user t to clear the interrupt received */
               SetUserRequestClearInt(FALSE);
               DisplayMessage_DTInterrupt(MSG_USER_CLEAR_DT_INT);
               /* Wait for the user to respond */
               while (!GetUserRequestClearInt())
               {
                  nai_msDelay(10);
               }
            }
            /* Clear the status state to re-arm the interrupts */
            check_status(naibrd_DT_ClearGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, dt_status_type, dtstatus_int[i]));
            switch (i)
            {
            case 0:
               printf("Cleared DT Bit Interrupt: 0x%08X\n", dtstatus_int[i]);
            break;
            case 1:
               printf("Cleared DT Lo-Hi Interrupt: 0x%08X\n", dtstatus_int[i]);
            break;
            case 2:
               printf("Cleared DT Hi-Lo Interrupt: 0x%08X\n", dtstatus_int[i]);
            break;
            case 3:
               printf("Cleared DT Overcurrent Interrupt: 0x%08X\n", dtstatus_int[i]);
            break;
            }
         }
      }
   }
}

/**************************************************************************************************************/
/**
<summary>
ExitApp_DTEtherIDR calls ExitInterruptThreads() in the nai_sys_int.c file to kill the threads created by
this application and calls the routines in the naibrd library to stop/disable) the Ethernet IDR
(Interrupt Driven Response) command associated with DEF_ETHERNET_DT_IDR_ID for the Discrete module and
close communication connection to the board.
</summary>
*/
/**************************************************************************************************************/
void ExitApp_DTEtherIDR(int32_t IDRcardIndex)
{
   ExitInterruptThreads();
   if (userInput_DTInt.cardIndex >= 0)
   {
      check_status(naibrd_Ether_StopIDR(IDRcardIndex, (uint16_t)DEF_ETHERNET_DT_IDR_ID));
      naibrd_Close(userInput_DTInt.cardIndex);
   }
}

/* QueryUserForOnboardOffbordDTInterrupts handles querying the user to see if she wants process Onboard or */

/**************************************************************************************************************/
/**
<summary>
MakeIDROnboardReadRegsCommand calls nai_ether_MakeReadMessage() in the naibrd library build the Read Register
command for the IDR message.
</summary>
*/
/**************************************************************************************************************/
void MakeIDRDTboardReadRegsCommand(uint16_t startIndex, uint32_t moduleOffset, uint32_t regAddr, uint32_t count, uint32_t stride, uint8_t commands[], uint16_t *cmdlen, int32_t boardInterface)
{
   uint16_t msgIndex = startIndex;
   uint16_t seqno;
   uint32_t regaddr;

   seqno = 0;
   regaddr = moduleOffset + regAddr;
   msgIndex = (uint16_t)nai_ether_MakeReadMessage(&commands[startIndex],seqno,NAI_ETHER_GEN4,(nai_intf_t)boardInterface,regaddr,stride,count,NAI_REG32);

   *cmdlen = msgIndex;
}

/**************************************************************************************************************/
/**
<summary>
ConfigDTInterrupt handles disabling the discrete interrupts, clearing any latched statuses, setting the
interrupt vector (NAI_DT_INTERRUPT_VECTOR), and latch status mode (Edge/Level). The interrupt steering
configuration is configuration based on the interruptCommType that is passed in.
</summary>
*/
/**************************************************************************************************************/
void ConfigETHERInterrupt(naibrd_int_steering_t steering)
{
   uint32_t rawstatus = 0;
   int32_t chan;
   uint8_t interrupt_t;

   /* Disable Interrupts */
   EnableDTInterrupt(FALSE);

   /* Clear the Interrupt Status (Read the status and write back "1" to statuses which are set to clear the status) */
   check_status(naibrd_DT_GetGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_BIT_LATCHED, &rawstatus));
   check_status(naibrd_DT_ClearGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_BIT_LATCHED, rawstatus));
   check_status(naibrd_DT_GetGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_LO_HI_TRANS_LATCHED, &rawstatus));
   check_status(naibrd_DT_ClearGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_LO_HI_TRANS_LATCHED, rawstatus));
   check_status(naibrd_DT_GetGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_HI_LO_TRANS_LATCHED, &rawstatus));
   check_status(naibrd_DT_ClearGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_HI_LO_TRANS_LATCHED, rawstatus));
   check_status(naibrd_DT_GetGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_OVERCURRENT_LATCHED, &rawstatus));
   check_status(naibrd_DT_ClearGroupStatusRaw(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_OVERCURRENT_LATCHED, rawstatus));

   /* Setup the Interrupt Vector - map to the same vector */
   check_status(naibrd_DT_SetGroupInterruptVector(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_BIT_LATCHED, NAI_DT_INTERRUPT_VECTOR));
   check_status(naibrd_DT_SetGroupInterruptVector(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_LO_HI_TRANS_LATCHED, NAI_DT_INTERRUPT_VECTOR));
   check_status(naibrd_DT_SetGroupInterruptVector(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_HI_LO_TRANS_LATCHED, NAI_DT_INTERRUPT_VECTOR));
   check_status(naibrd_DT_SetGroupInterruptVector(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_OVERCURRENT_LATCHED, NAI_DT_INTERRUPT_VECTOR));

   /* Setup the Latched Status Mode */
   interrupt_t = (uint8_t)userInput_DTInt.intTriggerType;
   for (chan = 1; chan <= boardState_DTInt.maxChannels; chan++)
   {
      check_status(naibrd_DT_SetEdgeLevelInterrupt(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, chan, NAI_DT_STATUS_BIT_LATCHED, interrupt_t));
      check_status(naibrd_DT_SetEdgeLevelInterrupt(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, chan, NAI_DT_STATUS_LO_HI_TRANS_LATCHED, interrupt_t));
      check_status(naibrd_DT_SetEdgeLevelInterrupt(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, chan, NAI_DT_STATUS_HI_LO_TRANS_LATCHED, interrupt_t));
      check_status(naibrd_DT_SetEdgeLevelInterrupt(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, chan, NAI_DT_STATUS_OVERCURRENT_LATCHED, interrupt_t));
   }

   /* Setup the Interrupt Steering */

      check_status(naibrd_DT_SetGroupInterruptSteering(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_BIT_LATCHED,         steering));
      check_status(naibrd_DT_SetGroupInterruptSteering(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_LO_HI_TRANS_LATCHED, steering));
      check_status(naibrd_DT_SetGroupInterruptSteering(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_HI_LO_TRANS_LATCHED, steering));
      check_status(naibrd_DT_SetGroupInterruptSteering(userInput_DTInt.cardIndex, userInput_DTInt.moduleNumber, 1, NAI_DT_STATUS_OVERCURRENT_LATCHED, steering));
}

Help Bot

X