Index: firmware/App/Drivers/SafetyShutdown.c =================================================================== diff -u -re5bb82cad756fbb10f04d576dffd499df78f6b35 -r8e7158d8231435496fcf1d5649e51babf859ccc7 --- firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision e5bb82cad756fbb10f04d576dffd499df78f6b35) +++ firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision 8e7158d8231435496fcf1d5649e51babf859ccc7) @@ -1,24 +1,31 @@ -/************************************************************************** - * - * Copyright (c) 2019-2020 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 SafetyShutdown.c - * - * @date 20-Sep-2019 - * @author S. Nash - * - * @brief Controller for the safety shutdown signal. - * - **************************************************************************/ +/************************************************************************** +* +* Copyright (c) 2019-2021 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 SafetyShutdown.c +* +* @author (last) Sean Nash +* @date (last) 24-Sep-2020 +* +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 +* +***************************************************************************/ #include #include "gio.h" +#include "SystemCommMessages.h" #include "SafetyShutdown.h" +/** + * @addtogroup SafetyShutdown + * @{ + */ + // ********** private definitions ********** // GIO port A pin assignments for pins connected to CPLD @@ -28,31 +35,109 @@ #define SET_SAFETY_SHUTDOWN() gioSetBit( gioPORTB, SAFETY_GIO_PORT_PIN, PIN_SIGNAL_HIGH ) #define CLR_SAFETY_SHUTDOWN() gioSetBit( gioPORTB, SAFETY_GIO_PORT_PIN, PIN_SIGNAL_LOW ) -/************************************************************************* - * @brief initSafetyShutdown +// ********** private definitions ********** + +static BOOL safetyShutdownActivated = FALSE; ///< Status of safety shutdown signal. +static BOOL safetyShutdownOverrideResetState = FALSE; ///< Natural status of safety shutdown signal. Used to restore state on override reset. + +/*********************************************************************//** + * @brief * The initSafetyShutdown function initializes the Buttons module. - * @details - * Inputs : none - * Outputs : Safety Shutdown module signal output set to initial state. - * @param none + * @details Inputs: none + * @details Outputs: Safety Shutdown module signal output set to initial state. * @return none *************************************************************************/ void initSafetyShutdown( void ) { CLR_SAFETY_SHUTDOWN(); } -/************************************************************************* - * @brief activateSafetyShutdown +/*********************************************************************//** + * @brief * The activateSafetyShutdown function activates the safety shutdown signal. - * @details - * Inputs : none - * Outputs : Safety Shutdown signal output set to active state. - * @param none + * @details Inputs: none + * @details Outputs: Safety Shutdown signal output set to active state. * @return none *************************************************************************/ void activateSafetyShutdown( void ) { + safetyShutdownActivated = TRUE; SET_SAFETY_SHUTDOWN(); } +/*********************************************************************//** + * @brief + * The isSafetyShutdownActivated function returns whether the safety shutdown + * signal has been activated. + * @details Inputs: none + * @details Outputs: none + * @return safetyShutdownActivated + *************************************************************************/ +BOOL isSafetyShutdownActivated( void ) +{ + return safetyShutdownActivated; +} + +/*********************************************************************//** + * @brief + * The testSetSafetyShutdownOverride function overrides the HD safety + * shutdown. + * @details Inputs: none + * @details Outputs: HD safety shutdown overridden + * @param value TRUE to activate safety shutdown, FALSE to de-activate it. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetSafetyShutdownOverride( U32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + // remember natural state before override so we can reset + safetyShutdownOverrideResetState = safetyShutdownActivated; + // override safety shutdown signal + if ( value > 0 ) + { + activateSafetyShutdown(); + } + else + { + safetyShutdownActivated = FALSE; + CLR_SAFETY_SHUTDOWN(); + } + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetSafetyShutdownOverride function resets the override of the + * HD safety shutdown. + * @details Inputs: none + * @details Outputs: shutdown override reset + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetSafetyShutdownOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + if ( TRUE == safetyShutdownOverrideResetState ) + { + activateSafetyShutdown(); + } + else + { + safetyShutdownActivated = FALSE; + CLR_SAFETY_SHUTDOWN(); + } + result = TRUE; + } + + return result; +} + +/**@}*/