Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -r264d5853c97ab9550878609c9302e87464078734 -r04c5d5d9198c1fde05df66ec8f5e660f7f7174b1 --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision 264d5853c97ab9550878609c9302e87464078734) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision 04c5d5d9198c1fde05df66ec8f5e660f7f7174b1) @@ -51,6 +51,7 @@ // ********** private function prototypes ********** static void publishSwitchesData( void ); +static void publishSwitchChanged( SWITCH_T switchId, U32 current_state ); /*********************************************************************//** * @brief @@ -117,6 +118,7 @@ // If the debounce time has been elapsed, update the switch status to the new status else if ( TRUE == didTimeout( switchesStatus[ i ].debounceStartTime, SWITCHES_DEBOUNCE_TIME_MS ) ) { + publishSwitchChanged( (SWITCH_T)i, (U32)currentSwitchStatus ); switchesStatus[ i ].debounceStartTime = 0; switchesStatus[ i ].status.data = currentSwitchStatus; } @@ -185,7 +187,15 @@ } } +static void publishSwitchChanged( SWITCH_T switchId, U32 current_state ) +{ + SWITCH_CHANGED_DATA_T data; + data.SwitchId = (U32)switchId; + data.newstate = current_state; + + broadcastData( MSG_ID_DG_SWITCH_CHANGE, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( SWITCH_CHANGED_DATA_T ) ); +} /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Controllers/Switches.h =================================================================== diff -u -r264d5853c97ab9550878609c9302e87464078734 -r04c5d5d9198c1fde05df66ec8f5e660f7f7174b1 --- firmware/App/Controllers/Switches.h (.../Switches.h) (revision 264d5853c97ab9550878609c9302e87464078734) +++ firmware/App/Controllers/Switches.h (.../Switches.h) (revision 04c5d5d9198c1fde05df66ec8f5e660f7f7174b1) @@ -31,7 +31,11 @@ */ // ********** public definitions ********** - +/**@}*/ +/** + * @addtogroup Switches + * @{ + */ /// DG doors and caps enumeration typedef enum switches_names { @@ -40,13 +44,22 @@ NUM_OF_CAPS ///< Number of doors and caps } SWITCH_T; +/**@}*/ + /// DG doors and caps data publish structure typedef struct { U32 concentrateCap; ///< Concentrate cap U32 dialysateCap; ///< Dialysate cap } SWITCHES_DATA_T; +/// DG doors and caps switches changed publish structure +typedef struct +{ + U32 SwitchId; ///< Switch ID + U32 newstate; ///< New state of switch +} SWITCH_CHANGED_DATA_T; + // ********** public function prototypes ********** void initSwitches( void );