Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -rd8fa48ead3336b1fe090b42030a8648264831076 -r632bbd302a9ae48df66e40a6faadc3db0c164671 --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision d8fa48ead3336b1fe090b42030a8648264831076) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision 632bbd302a9ae48df66e40a6faadc3db0c164671) @@ -12,7 +12,6 @@ // ********** private definitions ********** #define SWITCHES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the switches data is published on the CAN bus. -#define FRONT_DOOR_SWITCH_BIT_MASK 0x00A0 ///< Front door switch bit mask. #define SWITCHES_FPGA_STATUS_CHECK_INTERVAL ( MS_PER_SECOND / ( 5 * TASK_GENERAL_INTERVAL ) ) ///< Switches FPGA status check interval. // ********** private data ********** @@ -53,18 +52,16 @@ /*********************************************************************//** * @brief * The execSwitches function executes the switches executive. - * @details Inputs: switchStatus - * @details Outputs: switchStatus + * @details Inputs: switchesFPGAStatusCheckCounter + * @details Outputs: switchStatus, switchesFPGAStatusCheckCounter * @return none *************************************************************************/ void execSwitches( void ) { if ( ++switchesFPGAStatusCheckCounter > SWITCHES_FPGA_STATUS_CHECK_INTERVAL ) { - U08 fpgaRegister = getFPGAGPIOCount(); + switchStatus[ FRONT_DOOR ].data = (U32)( getFPGAFrontDoorStatus() != 0 ? OPEN : CLOSED ); - switchStatus[ FRONT_DOOR ].data = fpgaRegister & FRONT_DOOR_SWITCH_BIT_MASK; - switchesFPGAStatusCheckCounter = 0; } @@ -95,8 +92,57 @@ return (SWITCH_STATUS_T)status; } +// ********** private functions ********** + /*********************************************************************//** * @brief + * The publishSwitchesData function broadcasts the switches data at the + * publication interval. + * @details Inputs: switchesDataPublicationCounter + * @details Outputs: switchesDataPublicationCounter + * @return none + *************************************************************************/ +static void publishSwitchesData( void ) +{ + if ( ++switchesDataPublicationCounter > getPublishSwitchesDataInterval() ) + { + SWITCHES_DATA_T data; + + data.frontDoor = (U32)getSwitchStatus( FRONT_DOOR ); + + switchesDataPublicationCounter = 0; + + broadcastSwitchesData( &data ); + } +} + +/*********************************************************************//** + * @brief + * The getPublishSwitchesDataInterval function returns the data + * publication interval either from the data or from the override. + * @details Inputs: switchesDataPublishInterval + * @details Outputs: none + * @return data publish interval + *************************************************************************/ +static U32 getPublishSwitchesDataInterval( void ) +{ + U32 result = switchesDataPublishInterval.data; + + if ( OVERRIDE_KEY == switchesDataPublishInterval.override ) + { + result = switchesDataPublishInterval.ovData; + } + + return result; +} + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief * The testSetSwitchesDataPublishIntervalOverride function overrides * the switches publish data interval. * @details Inputs: switchesDataPublishInterval @@ -195,50 +241,6 @@ return result; } -// ********** private functions ********** - -/*********************************************************************//** - * @brief - * The publishSwitchesData function broadcasts the switches data at the - * publication interval. - * @details Inputs: switchesDataPublicationCounter - * @details Outputs: switchesDataPublicationCounter - * @return none - *************************************************************************/ -static void publishSwitchesData( void ) -{ - if ( ++switchesDataPublicationCounter > getPublishSwitchesDataInterval() ) - { - SWITCHES_DATA_T data; - - data.frontDoor = (U32)getSwitchStatus( FRONT_DOOR ); - - switchesDataPublicationCounter = 0; - - broadcastSwitchesData( &data ); - } -} - -/*********************************************************************//** - * @brief - * The getPublishSwitchesDataInterval function returns the data - * publication interval either from the data or from the override. - * @details Inputs: switchesDataPublishInterval - * @details Outputs: none - * @return data publish interval - *************************************************************************/ -static U32 getPublishSwitchesDataInterval( void ) -{ - U32 result = switchesDataPublishInterval.data; - - if ( OVERRIDE_KEY == switchesDataPublishInterval.override ) - { - result = switchesDataPublishInterval.ovData; - } - - return result; -} - /**@}*/