TTL BasicOps
Edit this on GitLab
TTL BasicOps
Explanation
About This C Sample Code
This C program is designed to interact with embedded function modules from North Atlantic Industries (NAI). It covers standard TTL (Transistor-Transistor Logic) operations using the naibrd library.
Key Components and Purpose
Header Files
-
Standard Libraries:
stdio.h
,stdlib.h
,string.h
,time.h
, andctype.h
. -
NAI-Specific Includes: These headers define various functions and utilities specific to NAI’s hardware.
-
naiapp_boardaccess_*
files: These files contain utilities for accessing, querying, and displaying board information. -
nai.h
andnaibrd.h
: Core NAI board interaction definitions. -
naibrd_ttl.h
: TTL-specific functions. -
nai_ether_adv.h
: Advanced Ethernet functions.
Constants
-
CONFIG_FILE
:"default_TTL_BasicOps.txt"
, configuration setting for the application. -
DEF_TTL_CHANNEL
: Default TTL channel, set to 1.
Enumerations
-
dt_basicops_commands
: Defines various TTL operation commands such as IO Format, Output State, Status, and Overcurrent Reset.
Command Table
The TTL_BasicOpMenuCmds
array defines commands with descriptive strings and their corresponding functions.
Functions and Definitions
Main Function
Depending on the platform (VXWORKS
vs. others), the main execution starts in TTL_BasicOps
or main
. The function performs the following:
- Runs the board menu with the configuration file.
- Queries the user for card index and module number.
- Calls Run_TTL_BasicOps
for the selected module.
Run_TTL_BasicOps
Queries the user for channel and validates if the selected module is a TTL module. If valid, calls Cfg_TTL_Channel
.
Cfg_TTL_Channel
Displays channel configuration and waits for user input to select and execute various TTL operations like IO Format, Output State, Status, etc.
Display_TTL_ChannelCfg
Shows the current configuration of the TTL channel, including its IO format, output state, input read state, and VCC configuration.
Display_TTL_Status
Retrieves and displays the status of the TTL channel, including latched and real-time information where available.
Clear_TTL_Status
Clears the latched status bits for the TTL channel.
Configure_TTL_IOFormat
, Configure_TTL_OutputState
, Configure_TTL_VCCConfig
These functions handle user inputs to configure the IO format, output state, and VCC configuration for the selected TTL channel.
Key Structures
-
ttl_params
: Typenaiapp_AppParameters_t
, used to store application parameters like card index, module, and channel.
Error Handling
Functions often use check_status
to validate calls to naibrd_*
functions.
Summary
This program is a comprehensive sample demonstrating the setup, control, and status reporting for TTL modules on NAI’s embedded systems using the naibrd library. It includes interaction via a command-line interface to configure and query various parameters of the TTL operations.
#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_ttl.h"
#include "advanced/nai_ether_adv.h"
static const int8_t *CONFIG_FILE = (const int8_t *)"default_TTL_BasicOps.txt";
/* Function prototypes */
int32_t Run_TTL_BasicOps(int32_t cardIndex, int32_t module, uint32_t ModuleID);
static void Cfg_TTL_Channel(int32_t cardIndex, int32_t module, uint32_t ModuleID, int32_t MaxChannel);
static void Display_TTL_ChannelCfg(int32_t cardIndex, int32_t module, int32_t chan, int32_t bank, uint32_t ModuleID);
static nai_status_t Display_TTL_Status(int32_t paramCount, int32_t* p_params);
static nai_status_t Clear_TTL_Status(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_TTL_IOFormat(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_TTL_OutputState(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_TTL_VCCConfig(int32_t paramCount, int32_t* p_params);
static const int32_t DEF_TTL_CHANNEL = 1;
/****** Command Table *******/
enum dt_basicops_commands
{
TTL_BASICOP_CMD_IOFORMAT,
TTL_BASICOP_CMD_OUTPUTSTATE,
TTL_BASICOP_CMD_STATUS,
TTL_BASICOP_CMD_ROC,
TTL_BASICOP_CMD_STATUS_CLEAR,
TTL_BASICOP_CMD_VCC_CFG,
TTL_BASICOP_CMD_COUNT
};
/****** Command Tables *******/
naiapp_cmdtbl_params_t TTL_BasicOpMenuCmds[] = {
{"Format", "TTL Set IO Format", TTL_BASICOP_CMD_IOFORMAT, Configure_TTL_IOFormat},
{"Out", "TTL Set Output State", TTL_BASICOP_CMD_OUTPUTSTATE, Configure_TTL_OutputState},
{"Stat", "TTL Display Status", TTL_BASICOP_CMD_STATUS, Display_TTL_Status},
{"Reset", "TTL Reset Overcurrent", TTL_BASICOP_CMD_ROC, NULL},
{"Clear", "TTL Clear Status", TTL_BASICOP_CMD_STATUS_CLEAR, Clear_TTL_Status},
{"Config", "TTL VCC Configuration", TTL_BASICOP_CMD_VCC_CFG, Configure_TTL_VCCConfig}
};
/**************************************************************************************************************/
/** \defgroup TTL_BasicOps TTL Basic Operations
The purpose of the TTL_BasicOps is to illustrate the naibrd library methods for standard TTL
operations with the module, including configuration setup, controlling drive outputs, and reading the logic
state of the channels.
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t TTL_BasicOps(void)
#else
int32_t main(void)
#endif
{
bool_t stop = FALSE;
int32_t cardIndex;
int32_t moduleCnt;
int32_t module;
uint32_t moduleID = 0;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
{
while (stop != TRUE)
{
/* Query the user for the card index */
stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
if (stop != TRUE)
{
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
/* Query the user for the module number */
stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
if (stop != TRUE)
{
moduleID = naibrd_GetModuleID(cardIndex, module);
if ((moduleID != 0))
{
Run_TTL_BasicOps(cardIndex, module, moduleID);
}
}
}
printf("\nType Q to quit or Enter key to restart application:\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
}
printf("\nType the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
naiapp_access_CloseAllOpenCards();
return 0;
}
/**************************************************************************************************************/
/** \ingroup TTL_BasicOps
Prompts the user for the card, module and channel to use for the application and calls
Cfg_TTL_Channel if the card, module, channel is valid for as a discrete module.
\param cardIndex (Input) Logical Card Index assigned to connection with the NAI_BOARD (0 - NAI_MAX_CARDS-1).
\param module (Input) Module Number of the module to access (1 - [max modules for board]).
\param ModuleID (Input) The ID of the module.
*/
/**************************************************************************************************************/
int32_t Run_TTL_BasicOps(int32_t cardIndex, int32_t module, uint32_t ModuleID)
{
int32_t MaxChannel;
MaxChannel = naibrd_TTL_GetChannelCount(ModuleID);
if (MaxChannel == 0)
{
printf(" *** Module selection not recognized as TTL module. ***\n\n");
}
else
{
Cfg_TTL_Channel(cardIndex, module, ModuleID, MaxChannel);
}
return cardIndex;
}
/**************************************************************************************************************/
/** \ingroup TTL_BasicOps
Handles calling the Display_TTL_ChannelCfg routine to display the discrete channel configuration
and prompts the user to enter in a menu command from the following:
\verbatim
TTL Set IO Format
> Configure the Input/Outpt configuration for the selected channel.
TTL Set Output State
> Configure the output state (i.e. high, low).
TTL Display Status
> Print TTL modules statuses.
TTL Clear Status
> Clear latched TTL module statuses.
TTL VCC Configuration
> Configure the VCC state (i.e. internal, external).
TTL Reset Overcurrent
> Reset overcurrent status.
\endverbatim
\param cardIndex (Input) Logical Card Index assigned to connection with the NAI_BOARD (0 - NAI_MAX_CARDS-1).
\param module (Input) Module Number of the module to access (1 - [max modules for board]).
\param ModuleID (Input) The ID of the module.
\param MaxChannel (Input) The maximum number of channels the module has.
*/
/**************************************************************************************************************/
static void Cfg_TTL_Channel(int32_t cardIndex, int32_t module, uint32_t ModuleID, int32_t MaxChannel)
{
bool_t bQuit = FALSE;
bool_t bContinue = TRUE;
bool_t bCmdFound = FALSE;
nai_status_t status = 0;
int32_t chan, defaultchan = 1;
int32_t bank = 0;
int32_t cmd;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
naiapp_AppParameters_t ttl_params;
p_naiapp_AppParameters_t ttl_basicops_params = &ttl_params;
ttl_basicops_params->cardIndex = cardIndex;
ttl_basicops_params->module = module;
while (bContinue)
{
printf(" \r\n\r\n");
printf("Channel selection \r\n");
printf("================= \r\n");
defaultchan = DEF_TTL_CHANNEL;
bQuit = naiapp_query_ChannelNumber(MaxChannel, defaultchan, &chan);
ttl_basicops_params->channel = chan;
bank = ((chan - 1) / naibrd_TTL_GetVCCBankSize(ModuleID)) + 1;
naiapp_utils_LoadParamMenuCommands(TTL_BASICOP_CMD_COUNT, TTL_BasicOpMenuCmds);
while (bContinue)
{
Display_TTL_ChannelCfg(cardIndex, module, chan, bank, ModuleID);
naiapp_display_ParamMenuCommands((int8_t *)"TTL Basic Operation Menu");
printf("\nType TTL 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 TTL_BASICOP_CMD_IOFORMAT:
case TTL_BASICOP_CMD_OUTPUTSTATE:
case TTL_BASICOP_CMD_STATUS_CLEAR:
case TTL_BASICOP_CMD_STATUS:
TTL_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)ttl_basicops_params);
break;
case TTL_BASICOP_CMD_VCC_CFG:
TTL_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)ttl_basicops_params);
break;
case TTL_BASICOP_CMD_ROC:
status = NAI_SUCCESS;
status |= check_status(naibrd_TTL_ResetAll(cardIndex, module, NAI_TTL_RESET_OVERCURRENT)); /*This resets all channels*/
status |= check_status(naibrd_TTL_Reset(cardIndex, module, chan, (nai_ttl_reset_type_t)NAI_TTL_RESET_OVERCURRENT)); /*This alternate function resets channel 1 only on Gen5 modules. */
if (status == NAI_SUCCESS)
printf("Overcurrent condition reset completed \n");
break;
default:
printf("Invalid command entered\n");
break;
}
}
else
printf("Invalid command entered\n");
}
}
else
bContinue = FALSE;
}
}
}
/**************************************************************************************************************/
/**
\ingroup TTL_BasicOps
Display_TTL_ChannelCfg illustrate the methods to call in the naibrd library to retrieve the configuration states
for basic operation.
\param cardIndex (Input) Logical Card Index assigned to connection with the NAI_BOARD (0 - NAI_MAX_CARDS-1).
\param module (Input) Module Number of the module to access (1 - [max modules for board]).
\param chan (Input) Channel Number of the channel to access (1 - [max channels for module]).
\param bank (Input) Number of the bank set (1 - [max banks for module]).
\param ModuleID (Input) The ID of the module.
*/
/**************************************************************************************************************/
static void Display_TTL_ChannelCfg(int32_t cardIndex, int32_t module, int32_t chan, int32_t bank, uint32_t ModuleID)
{
uint32_t ioformat = 0;
nai_ttl_state_t outputstate = 0;
nai_ttl_state_t inputstate = 0;
nai_ttl_vcc_t vccConfig = 0;
uint32_t ModuleVer;
uint32_t ModuleRev;
uint32_t ModInfo_Special;
naibrd_GetModuleInfo(cardIndex, module, &ModuleID, &ModuleVer, &ModuleRev, &ModInfo_Special);
check_status(naibrd_TTL_GetIOFormat(cardIndex, module, chan, &ioformat));
check_status(naibrd_TTL_GetOutputState(cardIndex, module, chan, &outputstate));
check_status(naibrd_TTL_GetInputState(cardIndex, module, chan, &inputstate));
check_status(naibrd_TTL_GetBankVCCSource(cardIndex, module, bank, &vccConfig));
printf("\n === Channel %d ===\n\n", chan);
printf(" IOFormat Output Input Bank VCCConfig\n");
printf(" --------- ------ ----- ----- ---------\n");
if (ModuleID == NAI_MODULE_ID_D7)
{
/*For all Gen3 and prior modules, I/O output mode configuration control setting is different.*/
switch (ioformat)
{
case NAI_TTL_IOFORMAT_INPUT:
printf(" Input ");
break;
case NAI_TTL_GEN3_IOFORMAT_OUTPUT:
printf(" Output ");
break;
default:
printf(" Unknown ");
break;
}
}
else
{
switch (ioformat)
{
case NAI_TTL_IOFORMAT_INPUT:
printf(" Input ");
break;
case NAI_TTL_GEN5_IOFORMAT_OUTPUT:
printf(" Output ");
break;
default:
printf(" Unknown ");
break;
}
}
if (ioformat != NAI_TTL_IOFORMAT_INPUT)
{
switch (outputstate)
{
case NAI_TTL_STATE_LO:
printf(" Low ");
break;
case NAI_TTL_STATE_HI:
printf(" High");
break;
/* undefined value read back */
default:
printf(" UNK ");
break;
}
}
else
printf(" --- ");
printf(" %3i ", inputstate);
printf(" %2i ", bank);
switch (vccConfig)
{
case NAI_TTL_VCC_INTERNAL:
printf("Internal");
break;
case NAI_TTL_VCC_EXTERNAL:
printf("External");
break;
default:
printf("Unknown ");
break;
}
}
/**************************************************************************************************************/
/** \ingroup TTL_BasicOps
Display_TTL_Status illustrate the methods to call in the naibrd library to retrieve the status states.
\param paramCount (Input) Number of parameter variables in p_params.
\param p_params (Input) Pointer to a naiapp_AppParameters struct containing information about the card and module.
*/
/**************************************************************************************************************/
static nai_status_t Display_TTL_Status(int32_t paramCount, int32_t* p_params)
{
nai_status_bit_t statusread;
nai_status_t status = 0;
p_naiapp_AppParameters_t p_ttl_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ttl_params->cardIndex;
int32_t module = p_ttl_params->module;
int32_t chan = p_ttl_params->channel;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
/* Available statusread:
NAI_TTL_STATUS_BIT_LATCHED,
NAI_TTL_STATUS_BIT_REALTIME, (GEN5 only)
NAI_TTL_STATUS_OVERCURRENT_LATCHED,
NAI_TTL_STATUS_OVERCURRENT_REALTIME, (GEN5 only)
NAI_TTL_STATUS_LO_HI_TRANS_LATCHED,
NAI_TTL_STATUS_LO_HI_TRANS_REALTIME, (GEN5 only)
NAI_TTL_STATUS_HI_LO_TRANS_LATCHED,
NAI_TTL_STATUS_HI_LO_TRANS_REALTIME, (GEN5 only)
*/
printf("\n");
printf(" ------------------------- Status ----------------------------\n");
printf(" | BIT | OC | Lo-Hi Trans | Hi-Lo Trans |\n");
printf(" Latch RT Latch RT Latch RT Latch RT \n");
printf(" -------------- --------------- -------------- ---------------\n");
status = check_status(naibrd_TTL_GetStatus(cardIndex, module, chan, NAI_TTL_STATUS_BIT_LATCHED, &statusread));
if (status == NAI_SUCCESS)
printf(" %3i ", statusread);
else
printf(" Err %3i", status);
status = check_status(naibrd_TTL_GetStatus(cardIndex, module, chan, NAI_TTL_STATUS_BIT_REALTIME, &statusread));
if (status == NAI_SUCCESS)
printf(" %3i ", statusread);
else if (status == NAI_ERROR_NOT_SUPPORTED)
printf(" N/A "); /*not available*/
else
printf(" Err %3i", status);
status = check_status(naibrd_TTL_GetStatus(cardIndex, module, chan, NAI_TTL_STATUS_OVERCURRENT_LATCHED, &statusread));
if (status == NAI_SUCCESS)
printf(" %3i ", statusread);
else
printf(" Err %3i", status);
status = check_status(naibrd_TTL_GetStatus(cardIndex, module, chan, NAI_TTL_STATUS_OVERCURRENT_REALTIME, &statusread));
if (status == NAI_SUCCESS)
printf(" %3i ", statusread);
else if (status == NAI_ERROR_NOT_SUPPORTED)
printf(" N/A "); /*not available*/
else
printf(" Err %3i", status);
status = check_status(naibrd_TTL_GetStatus(cardIndex, module, chan, NAI_TTL_STATUS_LO_HI_TRANS_LATCHED, &statusread));
if (status == NAI_SUCCESS)
printf(" %3i ", statusread);
else
printf(" Err %3i", status);
status = check_status(naibrd_TTL_GetStatus(cardIndex, module, chan, NAI_TTL_STATUS_LO_HI_TRANS_REALTIME, &statusread));
if (status == NAI_SUCCESS)
printf(" %3i ", statusread);
else if (status == NAI_ERROR_NOT_SUPPORTED)
printf(" N/A "); /*not available*/
else
printf(" Err %3i", status);
status = check_status(naibrd_TTL_GetStatus(cardIndex, module, chan, NAI_TTL_STATUS_HI_LO_TRANS_LATCHED, &statusread));
if (status == NAI_SUCCESS)
printf(" %3i ", statusread);
else
printf(" Err %3i", status);
status = check_status(naibrd_TTL_GetStatus(cardIndex, module, chan, NAI_TTL_STATUS_HI_LO_TRANS_REALTIME, &statusread));
if (status == NAI_SUCCESS)
printf(" %3i ", statusread);
else if (status == NAI_ERROR_NOT_SUPPORTED)
printf(" N/A "); /*not available*/
else
printf(" Err %3i", status);
printf("\n\n");
return NAI_ERROR_UNKNOWN;
}
/**************************************************************************************************************/
/** \ingroup TTL_BasicOps
Clear_TTL_Status illustrate the methods to call in the naibrd library to clear the latched status states.
\param paramCount (Input) Number of parameter variables in p_params.
\param p_params (Input) Pointer to a naiapp_AppParameters struct containing information about the card and module.
*/
/**************************************************************************************************************/
static nai_status_t Clear_TTL_Status(int32_t paramCount, int32_t* p_params)
{
nai_status_t status = 0;
p_naiapp_AppParameters_t p_ttl_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ttl_params->cardIndex;
int32_t module = p_ttl_params->module;
int32_t chan = p_ttl_params->channel;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
/* Available status:
NAI_TTL_STATUS_BIT_LATCHED,
NAI_TTL_STATUS_OVERCURRENT_LATCHED,
NAI_TTL_STATUS_LO_HI_TRANS_LATCHED,
NAI_TTL_STATUS_HI_LO_TRANS_LATCHED,
*/
/*Clear latched status - move this to separate operator option selection */
status |= check_status(naibrd_TTL_ClearStatus(cardIndex, module, chan, NAI_TTL_STATUS_BIT_LATCHED));
status |= check_status(naibrd_TTL_ClearStatus(cardIndex, module, chan, NAI_TTL_STATUS_OVERCURRENT_LATCHED));
status |= check_status(naibrd_TTL_ClearStatus(cardIndex, module, chan, NAI_TTL_STATUS_LO_HI_TRANS_LATCHED));
status |= check_status(naibrd_TTL_ClearStatus(cardIndex, module, chan, NAI_TTL_STATUS_HI_LO_TRANS_LATCHED));
if (status == NAI_SUCCESS)
printf("Latched Status cleared \n\n");
return NAI_ERROR_UNKNOWN;
}
/**************************************************************************************************************/
/** \ingroup TTL_BasicOps
Configure_TTL_IOFormat handles the user request to configure the Input/Output configuration for the selected
channel and calls the method in the naibrd library to set the Input/Output mode.
\param paramCount (Input) Number of parameter variables in p_params.
\param p_params (Input) Pointer to a naiapp_AppParameters struct containing information about the card and module.
*/
/**************************************************************************************************************/
static nai_status_t Configure_TTL_IOFormat(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
bool_t bUpdateIOCfg = FALSE;
uint32_t state = 0;
int8_t iofmtreq;
uint32_t ModuleID;
uint32_t ModuleVer;
uint32_t ModuleRev;
uint32_t ModInfo_Special;
p_naiapp_AppParameters_t p_ttl_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ttl_params->cardIndex;
int32_t module = p_ttl_params->module;
int32_t chan = p_ttl_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naibrd_GetModuleInfo(cardIndex, module, &ModuleID, &ModuleVer, &ModuleRev, &ModInfo_Special);
/* Set I/O format configuration for channel. Available configurations include:
NAI_TTL_IOFORMAT_INPUT
NAI_TTL_GEN3_IOFORMAT_OUTPUT
NAI_TTL_GEN5_IOFORMAT_OUTPUT
NAI_TTL_IOFORMAT_OUTPUT
*/
printf("Type the desired IO configuration ");
printf("(I=Input, Out=Output): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
iofmtreq = (int8_t)toupper(inputBuffer[0]);
if (iofmtreq == 'I')
{
state = NAI_TTL_IOFORMAT_INPUT;
bUpdateIOCfg = TRUE;
}
else if (iofmtreq == 'O')
{
if (ModuleID == NAI_MODULE_ID_D7)
state = NAI_TTL_GEN3_IOFORMAT_OUTPUT;
else
state = NAI_TTL_GEN5_IOFORMAT_OUTPUT;
bUpdateIOCfg = TRUE;
}
else
{
printf("ERROR: Invalid selection\n");
}
}
if (!bQuit)
{
if (bUpdateIOCfg)
check_status(naibrd_TTL_SetIOFormat(cardIndex, module, chan, state));
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
/**************************************************************************************************************/
/** \ingroup TTL_BasicOps
Configure_TTL_OutputState handles the user request to set the Output state for the selected
channel and calls the method in the naibrd library to set the Output state.
\param paramCount (Input) Number of parameter variables in p_params.
\param p_params (Input) Pointer to a naiapp_AppParameters struct containing information about the card and module.
*/
/**************************************************************************************************************/
static nai_status_t Configure_TTL_OutputState(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
bool_t bUpdateOutput = FALSE;
nai_ttl_state_t outputstate = 0;
uint32_t ModuleID;
uint32_t ModuleVer;
uint32_t ModuleRev;
uint32_t ModInfo_Special;
p_naiapp_AppParameters_t p_ttl_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ttl_params->cardIndex;
int32_t module = p_ttl_params->module;
int32_t chan = p_ttl_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naibrd_GetModuleInfo(cardIndex, module, &ModuleID, &ModuleVer, &ModuleRev, &ModInfo_Special);
/* Set the output state (high or low) on output channels.
This is not applicable for channels configured as inputs.
*/
printf("\nEnter the desired output state ");
printf("(L=low output, H=high output): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
switch (toupper(inputBuffer[0]))
{
case 'L':
outputstate = 0;
bUpdateOutput = TRUE;
break;
case 'H':
outputstate = 1;
bUpdateOutput = TRUE;
break;
default:
printf("ERROR: Invalid Output State Format Entry\n");
break;
}
}
}
if (!bQuit)
{
if (bUpdateOutput)
check_status(naibrd_TTL_SetOutputState(cardIndex, module, chan, outputstate));
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
/**************************************************************************************************************/
/** \ingroup TTL_BasicOps
Configure_TTL_VCCConfig handles the user request to set the VCC configuration for the selected
bank and calls the method in the naibrd library to set the configuration to external or internal.
\param paramCount (Input) Number of parameter variables in p_params.
\param p_params (Input) Pointer to a naiapp_AppParameters struct containing information about the card and module.
*/
/**************************************************************************************************************/
static nai_status_t Configure_TTL_VCCConfig(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
bool_t bUpdateVccCfg = FALSE;
nai_ttl_vcc_t vccCfg = 0;
uint32_t ModuleID;
uint32_t ModuleVer;
uint32_t ModuleRev;
uint32_t ModInfo_Special;
p_naiapp_AppParameters_t p_ttl_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ttl_params->cardIndex;
int32_t module = p_ttl_params->module;
int32_t bank = p_ttl_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naibrd_GetModuleInfo(cardIndex, module, &ModuleID, &ModuleVer, &ModuleRev, &ModInfo_Special);
/* Set the vcc config (external or internal) on bank.*/
printf("\nEnter the desired VCC configuration ");
printf("(E=external, I=internal): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
switch (toupper(inputBuffer[0]))
{
case 'E':
vccCfg = NAI_TTL_VCC_EXTERNAL;
bUpdateVccCfg = TRUE;
break;
case 'I':
vccCfg = NAI_TTL_VCC_INTERNAL;
bUpdateVccCfg = TRUE;
break;
default:
printf("ERROR: Invalid VCC Configuration Entry\n");
break;
}
}
}
if (!bQuit)
{
if (bUpdateVccCfg)
check_status(naibrd_TTL_SetBankVCCSource(cardIndex, module, bank, vccCfg));
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}