92 lines
3.1 KiB
C
92 lines
3.1 KiB
C
/**
|
|
* @file sdl.c
|
|
*
|
|
* @copyright Nehemis SARL reserves all rights even in the event of industrial
|
|
* property rights. We reserve all rights of disposal such as
|
|
* copying and passing on to third parties.
|
|
*
|
|
* @brief This file contains the initialization and execution logic for
|
|
* the Valve Controller and CANopen stack. It defines the main
|
|
* scheduler loop for running these components within the firmware.
|
|
*
|
|
* @todo SDL_MIN_OPERATIONAL_NODES to be changed to 20, are the node is fixed.
|
|
* (electronic issue in the board)
|
|
*
|
|
*/
|
|
|
|
/******************************************************************************
|
|
* Include Header Files
|
|
******************************************************************************/
|
|
/* User includes */
|
|
#include "sdl.h"
|
|
#include "nms_can.h"
|
|
#include "processBoard.h"
|
|
#include "enduranceTestBench.h"
|
|
#include "stdlib.h"
|
|
#include "hal_system.h"
|
|
/******************************************************************************
|
|
* Macro constant declarations
|
|
******************************************************************************/
|
|
#define SDL_MIN_OPERATIONAL_NODES 18u /* To be 20, one node not in working state currently */
|
|
#define SDL_LSS_NODE_COUNT 20u
|
|
/******************************************************************************
|
|
* Type Declarations
|
|
******************************************************************************/
|
|
|
|
/******************************************************************************
|
|
* Global Declarations
|
|
******************************************************************************/
|
|
static CO_NMT_STATE_T nodeNMTState_gaen[SDL_LSS_NODE_COUNT];
|
|
/******************************************************************************
|
|
* Static function Declarations
|
|
******************************************************************************/
|
|
/* Supress warnings for implicit declaration.
|
|
* Need this function for overwriting the manual COB ids
|
|
* for the TPDO. */
|
|
extern void userOverwriteCobIdSettings(void);
|
|
static bool SdlAreAllNodesOperational(void);
|
|
|
|
/******************************************************************************
|
|
* Public Function Definitions
|
|
******************************************************************************/
|
|
void SdlInit(void)
|
|
{
|
|
HalSystemInit();
|
|
NmsCanInit();
|
|
}
|
|
|
|
|
|
void SdlRun(void)
|
|
{
|
|
NmsCanRun();
|
|
if (SdlAreAllNodesOperational())
|
|
{
|
|
EnduranceTestBenchRun();
|
|
ProcessBoardRun();
|
|
}
|
|
}
|
|
|
|
/******************************************************************************
|
|
* Private Function Definitions
|
|
******************************************************************************/
|
|
|
|
/**
|
|
* @brief Checks if all nodes are in OPERATIONAL state.
|
|
*
|
|
* @return CO_TRUE if all nodes are OPERATIONAL, CO_FALSE otherwise.
|
|
*/
|
|
static bool SdlAreAllNodesOperational(void)
|
|
{
|
|
uint8 operationalNodeNb_u8 = 0u;
|
|
|
|
for (uint8 i_u8 = 0u; i_u8 < SDL_LSS_NODE_COUNT ; i_u8++)
|
|
{
|
|
if (nodeNMTState_gaen[i_u8] == CO_NMT_STATE_OPERATIONAL)
|
|
{
|
|
operationalNodeNb_u8++;
|
|
}
|
|
}
|
|
|
|
return (operationalNodeNb_u8 >= SDL_MIN_OPERATIONAL_NODES) ? CO_TRUE : CO_FALSE;
|
|
}
|