Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -r8791132fbfcb8fa25fb11a9ab15d695686aaef75 -r4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5 --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 8791132fbfcb8fa25fb11a9ab15d695686aaef75) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5) @@ -32,12 +32,12 @@ */ // ********** private definitions ********** -#define AIR_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) +#define AIR_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) #define DATA_PUBLISH_COUNTER_START_COUNT #define AIR_PUMP_GPIO_PIN 0x24 -static const U32 AIR_PUMP_STATUS_PERSISTENCE = ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ); +static const U32 AIR_PUMP_STATUS_PERSISTENCE = ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); typedef enum AirPumpMotorStates { @@ -74,9 +74,9 @@ static void setAirPumpMotor(AIR_PUMP_MOTOR_STATE_T state) { - if ( NUM_OF_AIR_PUMP_MOTOR_STATES < state ) + if ( state < NUM_OF_AIR_PUMP_MOTOR_STATES ) { - gioSetBit( hetPORT1, AIR_PUMP_GPIO_PIN, (BOOL) state ); + gioSetBit( hetPORT1, AIR_PUMP_GPIO_PIN, (U32)state ); } else { @@ -86,7 +86,7 @@ void setAirPumpState( AIR_PUMP_STATE_T state ) { - if ( NUM_OF_AIR_PUMP_STATES < state ) + if ( state < NUM_OF_AIR_PUMP_STATES ) { currentAirPumpState = state; } @@ -98,25 +98,14 @@ AIR_PUMP_MOTOR_STATE_T getAirPumpMotorState( void ) { - return gioGetBit( hetPORT1, AIR_PUMP_GPIO_PIN ); + return (AIR_PUMP_MOTOR_STATE_T)gioGetBit( hetPORT1, AIR_PUMP_GPIO_PIN ); } AIR_PUMP_STATE_T getAirPumpState( void ) { return currentAirPumpState; } - -void execAirPumpMonitor( void ) -{ - AIR_PUMP_MOTOR_STATE_T state = currentAirPumpMotorState; - //check if motor is running at the state we requested it to. - // how to handle testers? - // otherwise we alarm/fault - - publishAirPumpData(); -} - void execAirPumpController( void ) { switch( currentAirPumpState ) @@ -132,41 +121,31 @@ case AIR_PUMP_STATE_ON: currentAirPumpState = handleAirPumpOnState(); break; - /// open loop state for testing? + default: //hard fault break; } + publishAirPumpData(); } static AIR_PUMP_STATE_T handleAirPumpStartState( void ) { AIR_PUMP_STATE_T state = AIR_PUMP_STATE_OFF; - return state; } static AIR_PUMP_STATE_T handleAirPumpOffState( void ) { AIR_PUMP_STATE_T state = AIR_PUMP_STATE_OFF; - - if (AIR_PUMP_MOTOR_ON == getAirPumpMotorState() ) - { - setAirPumpMotor( AIR_PUMP_MOTOR_OFF ); - } - + setAirPumpMotor( AIR_PUMP_MOTOR_OFF ); return state; } static AIR_PUMP_STATE_T handleAirPumpOnState( void ) { AIR_PUMP_STATE_T state = AIR_PUMP_STATE_ON; - - if (AIR_PUMP_MOTOR_OFF == getAirPumpMotorState()) - { - setAirPumpMotor( AIR_PUMP_MOTOR_ON ); - } - + setAirPumpMotor( AIR_PUMP_MOTOR_ON ); return state; } @@ -183,25 +162,6 @@ } -/*********************************************************************//** - * @brief - * The execAirPumpTest function executes the state machine for the air pump - * self-test. - * @details Inputs: none - * @details Outputs: none - * @return the current state of the air pump self-test. - *************************************************************************/ -SELF_TEST_STATUS_T execAirPumpTest( void ) -{ - SELF_TEST_STATUS_T status = SELF_TEST_STATUS_PASSED; - - // TODO - Implement POST - - return status; -} - - - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Controllers/AirPump.h =================================================================== diff -u -r8791132fbfcb8fa25fb11a9ab15d695686aaef75 -r4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5 --- firmware/App/Controllers/AirPump.h (.../AirPump.h) (revision 8791132fbfcb8fa25fb11a9ab15d695686aaef75) +++ firmware/App/Controllers/AirPump.h (.../AirPump.h) (revision 4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5) @@ -17,31 +17,40 @@ #ifndef __AIRPUMP_H__ #define __AIRPUMP_H__ + // ********** public definitions ********** - #include "HDCommon.h" +/** + * @defgroup AirPump AirPump + * @brief Air Pump controller module. Controls the air pump GPIO pin. + * + * @addtogroup AirPump + * @{ + */ + /// Payload record structure for air pump data broadcast message typedef struct { U32 airPumpStateStatus; U32 airPumpMotorStatus; } AIR_PUMP_PAYLOAD_T; +/// Enumeration of air pump states. typedef enum AirPumpControllerStates { - AIR_PUMP_STATE_START = 0, - AIR_PUMP_STATE_OFF, ///< Air Pump Off - AIR_PUMP_STATE_ON, ///< Air Pump On + AIR_PUMP_STATE_OFF= 0, ///< Air Pump Off + AIR_PUMP_STATE_ON, ///< Air Pump On + AIR_PUMP_STATE_START, NUM_OF_AIR_PUMP_STATES, } AIR_PUMP_STATE_T; // ********** public function prototypes ********** + void initAirPump(void); -void execAirPumpMonitor(void); void execAirPumpController(void); void setAirPumpState( AIR_PUMP_STATE_T state ); AIR_PUMP_STATE_T getAirPumpState( void ); @@ -50,8 +59,4 @@ BOOL testResetAirPumpDataPublishIntervalOverride( void ); BOOL testSetAirPump( U32 state ); - - - - #endif Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -ref6283257df7c1f993d58fb934da57ea3e0a7067 -r4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision ef6283257df7c1f993d58fb934da57ea3e0a7067) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5) @@ -107,6 +107,9 @@ // Control dialysate outlet pump (keep after call to BP and DPi controllers) execDialOutFlowController(); + // Control Air Pump + execAirPumpController(); + // Monitor/Control fans execFans(); Index: firmware/source/sys_main.c =================================================================== diff -u -r59b37c61dbf5710c0a9e26b58e1419fdd3c803a9 -r4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5 --- firmware/source/sys_main.c (.../sys_main.c) (revision 59b37c61dbf5710c0a9e26b58e1419fdd3c803a9) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5) @@ -65,6 +65,7 @@ #include "HDCommon.h" #include "Accel.h" #include "AirTrap.h" +#include "AirPump.h" #include "AlarmLamp.h" #include "Battery.h" #include "BloodFlow.h" @@ -207,6 +208,7 @@ initSwitches(); // Initialize controllers initAirTrap(); + initAirPump(); initAlarmLamp(); initBloodFlow(); initDialInFlow();