Index: firmware/App/Drivers/SafetyShutdown.c =================================================================== diff -u -r216bd924f989182e648ee5f33f4c91c43ac438ac -rda397faac84255cf064e0dc5f52b81a869dab6c2 --- firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision 216bd924f989182e648ee5f33f4c91c43ac438ac) +++ firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision da397faac84255cf064e0dc5f52b81a869dab6c2) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -16,22 +16,32 @@ #include "mibspi.h" +#include "SystemCommMessages.h" #include "SafetyShutdown.h" +/** + * @addtogroup SafetyShutdown + * @{ + */ + // ********** private definitions ********** // pin I/O macros #define SAFETY_SPI1_PORT_MASK 0x00000010 // (CS[4] - re-purposed as output GPIO) #define SET_SAFETY_SHUTDOWN() {mibspiREG1->PC3 |= SAFETY_SPI1_PORT_MASK;} #define CLR_SAFETY_SHUTDOWN() {mibspiREG1->PC3 &= ~SAFETY_SPI1_PORT_MASK;} +// ********** 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 initSafetyShutdown + * @brief * The initSafetyShutdown function initializes the Buttons module. * @details * Inputs : none * Outputs : Safety Shutdown module signal output set to initial state. - * @param none * @return none *************************************************************************/ void initSafetyShutdown( void ) @@ -40,16 +50,96 @@ } /************************************************************************* - * @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 * @return none *************************************************************************/ void activateSafetyShutdown( void ) { SET_SAFETY_SHUTDOWN(); } +/*********************************************************************//** + * @brief + * The isSafetyShutdownActivated function returns whether the safety shutdown \n + * signal has been activated. + * @details + * Inputs : none + * Outputs : none + * @return safetyShutdownActivated + *************************************************************************/ +BOOL isSafetyShutdownActivated( void ) +{ + return safetyShutdownActivated; +} + +/*********************************************************************//** + * @brief + * The testSetSafetyShutdownOverride function overrides the HD safety \n + * shutdown. + * @details + * Inputs : none + * 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() ) + { + MOTOR_DIR_T dir; + + // 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 \n + * HD safety shutdown. + * @details + * Inputs : none + * 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; +} + +/**@}*/ Index: firmware/App/Drivers/SafetyShutdown.h =================================================================== diff -u -rb64c49fdcf2b6d95e61e63f8e258c4e600935bbd -rda397faac84255cf064e0dc5f52b81a869dab6c2 --- firmware/App/Drivers/SafetyShutdown.h (.../SafetyShutdown.h) (revision b64c49fdcf2b6d95e61e63f8e258c4e600935bbd) +++ firmware/App/Drivers/SafetyShutdown.h (.../SafetyShutdown.h) (revision da397faac84255cf064e0dc5f52b81a869dab6c2) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -19,9 +19,24 @@ #include "DGCommon.h" +/** + * @defgroup SafetyShutdown SafetyShutdown + * @brief Safety Shutdown module. Allows any module to activate the safety shutdown + * signal. + * + * @addtogroup SafetyShutdown + * @{ + */ + // ********** public function prototypes ********** void initSafetyShutdown( void ); void activateSafetyShutdown( void ); +BOOL isSafetyShutdownActivated( void ); +BOOL testSetSafetyShutdownOverride( U32 value ); +BOOL testResetSafetyShutdownOverride( void ); + +/**@}*/ + #endif Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rbbf1e3736be03a4f041ace57e0f95e23caf472dd -rda397faac84255cf064e0dc5f52b81a869dab6c2 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision bbf1e3736be03a4f041ace57e0f95e23caf472dd) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision da397faac84255cf064e0dc5f52b81a869dab6c2) @@ -1082,6 +1082,10 @@ handleTestValvesStatesPublishIntervalOverrideRequest( message ); break; + case MSG_ID_DG_SAFETY_SHUTDOWN_OVERRIDE: + handleTestDGSafetyShutdownOverrideRequest( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rbbf1e3736be03a4f041ace57e0f95e23caf472dd -rda397faac84255cf064e0dc5f52b81a869dab6c2 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision bbf1e3736be03a4f041ace57e0f95e23caf472dd) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision da397faac84255cf064e0dc5f52b81a869dab6c2) @@ -1115,6 +1115,18 @@ *************************************************************************/ DATA_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestValvesStatesPublishIntervalOverrideRequest, testSetValvesStatesPublishIntervalOverride, testResetValvesStatesPublishIntervalOverride ) +/************************************************************************* + * @brief + * The handleTestDGSafetyShutdownOverrideRequest function handles a \n + * request to override the safety shutdown signal. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDGSafetyShutdownOverrideRequest, testSetSafetyShutdownOverride, testResetSafetyShutdownOverride ) + #ifdef CAN_TEST void broadcastCANTest1LargeFrequentMessage() { Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rbbf1e3736be03a4f041ace57e0f95e23caf472dd -rda397faac84255cf064e0dc5f52b81a869dab6c2 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision bbf1e3736be03a4f041ace57e0f95e23caf472dd) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision da397faac84255cf064e0dc5f52b81a869dab6c2) @@ -136,6 +136,9 @@ // MSG_ID_VALVES_STATES_PUBLISH_INTERVAL_OVERRIDE void handleTestValvesStatesPublishIntervalOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DG_SAFETY_SHUTDOWN_OVERRIDE: +void handleTestDGSafetyShutdownOverrideRequest( MESSAGE_T *message ); + #ifdef CAN_TEST // MSG_ID_DG_CAN_TEST_1_LARGE_FREQ void broadcastCANTest1LargeFrequentMessage(); Index: firmware/DG.dil =================================================================== diff -u -rc4434389fe6c3314c2bba98dc2f4cf737551f637 -rda397faac84255cf064e0dc5f52b81a869dab6c2 --- firmware/DG.dil (.../DG.dil) (revision c4434389fe6c3314c2bba98dc2f4cf737551f637) +++ firmware/DG.dil (.../DG.dil) (revision da397faac84255cf064e0dc5f52b81a869dab6c2) @@ -1,4 +1,4 @@ -# RM46L852PGE 05/28/20 09:00:50 +# RM46L852PGE 06/01/20 10:23:49 # ARCH=RM46L852PGE #