/************************************************************************** * * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file TestSupport.c * * @author (last) Michael Garthwaite * @date (last) 01-Feb-2023 * * @author (original) Sean Nash * @date (original) 10-Aug-2021 * ***************************************************************************/ #include "Common.h" #include "SystemCommMessages.h" /** * @addtogroup TestSupport * @{ */ // ********** private definitions ********** #define TEST_CONFIG_ENABLE_KEY 0xDABA36B2 ///< Release software configuration enable kye. #define TEST_CONFIG_DISABLE_KEY 0x00000000 ///< Release software configuration disable key. // ********** private data ********** static U32 testConfig[ NUM_OF_TEST_CONFIGS ]; ///< Release software configuration. // ********** private function prototypes ********** /*********************************************************************//** * @brief * The getU08OverrideValue function extracts the appropriate U08 * value from a given U32 override record according to the record state. * @details Inputs: none * @details Outputs: none * @param ovU32 pointer to a floating point override record * @return overridden U08 point value from the record *************************************************************************/ U08 getU08OverrideValue( OVERRIDE_U32_T *ovU32 ) { U08 result = (U08)( ovU32->data & MASK_OFF_U32_MSBS ); if ( OVERRIDE_KEY == ovU32->override ) { result = (U08)( ovU32->ovData & MASK_OFF_U32_MSBS ); } return result; } /*********************************************************************//** * @brief * The getU16OverrideValue function extracts the appropriate U16 * value from a given U32 override record according to the record state. * @details Inputs: none * @details Outputs: none * @param ovU32 pointer to a floating point override record * @return overridden U16 point value from the record *************************************************************************/ U16 getU16OverrideValue( OVERRIDE_U32_T *ovU32 ) { U16 result = (U16)( ovU32->data & MASK_OFF_MSW ); if ( OVERRIDE_KEY == ovU32->override ) { result = (U16)( ovU32->ovData & MASK_OFF_MSW ); } return result; } /*********************************************************************//** * @brief * The getS32OverrideValue function extracts the appropriate signed integer * value from a given signed integer override record according to the * record state. * @details Inputs: none * @details Outputs: none * @param ovS32 pointer to an unsigned integer override record * @return either the real or overridden signed integer value from the record *************************************************************************/ S32 getS32OverrideValue( OVERRIDE_S32_T *ovS32 ) { S32 result = ovS32->data; if ( OVERRIDE_KEY == ovS32->override ) { result = ovS32->ovData; } return result; } /*********************************************************************//** * @brief * The getU32OverrideValue function extracts the appropriate unsigned integer * value from a given unsigned integer override record according to the * record state. * @details Inputs: none * @details Outputs: none * @param ovU32 pointer to an unsigned integer override record * @return either the real or overridden unsigned integer value from the record *************************************************************************/ U32 getU32OverrideValue( OVERRIDE_U32_T *ovU32 ) { U32 result = ovU32->data; if ( OVERRIDE_KEY == ovU32->override ) { result = ovU32->ovData; } return result; } /*********************************************************************//** * @brief * The getF32OverrideValue function extracts the appropriate floating point * value from a given float override record according to the record state. * @details Inputs: none * @details Outputs: none * @param ovF32 pointer to a floating point override record * @return either the real or overridden floating point value from the record *************************************************************************/ F32 getF32OverrideValue( OVERRIDE_F32_T *ovF32 ) { F32 result = ovF32->data; if ( OVERRIDE_KEY == ovF32->override ) { result = ovF32->ovData; } return result; } // ********** Release software configurations functions ********** /*********************************************************************//** * @brief * The initTestConfigs function initializes the test software configurations. * @details Inputs: none * @details Outputs: testConfig * @return none *************************************************************************/ void initTestConfigs( void ) { memset( &testConfig, TEST_CONFIG_DISABLE_KEY, sizeof( TEST_CONFIG_T ) ); } /*********************************************************************//** * @brief * The setTestConfig function sets the test configuration. * @details Inputs: none * @details Outputs: testConfig * @param config which is the configuration to set * @return TRUE if the set configuration was successful otherwise, FALSE *************************************************************************/ BOOL setTestConfig( TEST_CONFIG_T config ) { BOOL status = FALSE; if ( config < NUM_OF_TEST_CONFIGS ) { testConfig[ config ] = TEST_CONFIG_ENABLE_KEY; status = TRUE; } else { // TODO software fault because this is in release code? } return status; } /*********************************************************************//** * @brief * The resetTestConfig function resets the test configuration. * @details Inputs: none * @details Outputs: testConfig * @param config which is the configuration to reset * @return TRUE if the reset configuration was successful otherwise, FALSE *************************************************************************/ BOOL resetTestConfig( TEST_CONFIG_T config ) { BOOL status = FALSE; if ( config < NUM_OF_TEST_CONFIGS ) { testConfig[ config ] = TEST_CONFIG_DISABLE_KEY; status = TRUE; } else { // TODO software fault because this is in release code? } return status; } /*********************************************************************//** * @brief * The getTestConfigStatus function gets the status of the provided test * configuration. * @details Inputs: none * @details Outputs: testConfig * @param config the test configuration * @return TRUE if the release software configuration is enabled otherwise, FALSE *************************************************************************/ BOOL getTestConfigStatus( TEST_CONFIG_T config ) { BOOL status = FALSE; if ( ( TRUE == isTestingActivated() ) && ( TEST_CONFIG_ENABLE_KEY == testConfig[ config ] ) ) { status = TRUE; } return status; } /**@}*/