Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -r28787751424ba118764b865009edf9b0842b2ac7 -r901c8ee0edeef9c09ff74f8f5866aa0277ef8f33 --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision 28787751424ba118764b865009edf9b0842b2ac7) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision 901c8ee0edeef9c09ff74f8f5866aa0277ef8f33) @@ -13,9 +13,9 @@ // ********** 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 FLUID_DOOR_SWITCH_BIT_MASK 0x01 ///< Fluid door switch bit mask. -#define DIALYSATE_CAP_SWITCH_BIT_MASK 0x02 ///< Dialysate cap switch bit mask. -#define CONCENTRATE_CAP_SWITCH_BIT_MASK 0x04 ///< Concentrate cap switch bit mask. +#define FLUID_DOOR_SWITCH_BIT_MASK 0x08 ///< Fluid door switch bit mask. +#define DIALYSATE_CAP_SWITCH_BIT_MASK 0x10 ///< Dialysate cap switch bit mask. +#define CONCENTRATE_CAP_SWITCH_BIT_MASK 0x1A ///< Concentrate cap switch bit mask. #define SWITCHES_FPGA_STATUS_CHECK_INTERVAL ( MS_PER_SECOND / ( 5 * TASK_GENERAL_INTERVAL ) ) ///< Switches FPGA status check interval. // ********** private data ********** @@ -66,9 +66,9 @@ { U08 fpgaRegister = getFPGAGPIOCount(); - switchStatus[ CONCENTRATE_CAP ].data = fpgaRegister & CONCENTRATE_CAP_SWITCH_BIT_MASK; - switchStatus[ DIALYSATE_CAP ].data = fpgaRegister & DIALYSATE_CAP_SWITCH_BIT_MASK; - switchStatus[ FLUID_DOOR ].data = fpgaRegister & FLUID_DOOR_SWITCH_BIT_MASK; + switchStatus[ CONCENTRATE_CAP ].data = (U32)( fpgaRegister & CONCENTRATE_CAP_SWITCH_BIT_MASK > 0 ? OPEN : CLOSED); + switchStatus[ DIALYSATE_CAP ].data = (U32)( fpgaRegister & DIALYSATE_CAP_SWITCH_BIT_MASK > 0 ? OPEN : CLOSED); + switchStatus[ FLUID_DOOR ].data = (U32)( fpgaRegister & FLUID_DOOR_SWITCH_BIT_MASK > 0 ? OPEN : CLOSED); switchesFPGAStatusCheckCounter = 0; } @@ -100,8 +100,55 @@ 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.concentrateCap = (U32)getSwitchStatus( CONCENTRATE_CAP ); + data.dialysateCap = (U32)getSwitchStatus( DIALYSATE_CAP ); + data.fluidDoor = (U32)getSwitchStatus( FLUID_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; +} + + +/*********************************************************************//** + * @brief * The testSetSwitchesDataPublishIntervalOverride function overrides * the switches publish data interval. * @details Inputs: switchesDataPublishInterval @@ -174,6 +221,11 @@ return result; } +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + /*********************************************************************//** * @brief * The testResetSwitchesStatusOverride function resets the override @@ -200,50 +252,4 @@ 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.concentrateCap = (U32)getSwitchStatus( CONCENTRATE_CAP ); - data.dialysateCap = (U32)getSwitchStatus( DIALYSATE_CAP ); - data.fluidDoor = (U32)getSwitchStatus( FLUID_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; -} - /**@}*/