hal.h
Go to the documentation of this file.
/*
* hal.h
*
* Created on: Aug 3, 2016
* Author: sebastian
*/
#ifndef HAL_H_
#define HAL_H_
#define RELAIS_HEAT 29
#define RELAIS_PUMP 25
#define RELAIS_POWER 28
#define PIN_PRESSURE_CTRL 7
#define PIN_PROXIMITY_SENSOR 6
#define PIN_INT0 2 // Top button
#define PIN_INT1 0 // Bottom button
#define PIN_FLOW 3 // Flow sensor
#define FLOW_ML_PULSE (1000.0/990) // Flow sensor: volume (ml) per pulse
#define TIME_BUTTONLONGPRESS 3 //Time in s until a Signal for a long pressed button is sent
/*
* Explanation for the signal levels
* SigInt_Psh Button is pushed
* SigInt_Rls Button is released
* SigInt_RlsLong Button is pressed for more than TIME_BUTTONLONGPRESS seconds
* SigPressCls Pressure control is closed, System is heating
* SigPressOpn Pressure control is open, heating is off
* SigProxOpn Proximity Sensor is uncovered
* SigProxCvrd Proximity Sensor is covered
*/
/*
* Functions of the buttons, the letter in brackets defines if the event is triggered
* on push(P), release(R) or long pressing(RLong) of the button
* TOP Button: Turn machine on(R), start brewing(P),
*
* BOTTOM button: Stop brewing immediately(P), Turn machine off(RLong),
*/
enum HalSig {
SigInt0Psh = 1,
SigInt0Rls = 2,
SigInt0RlsLong = 3,
SigInt1Psh = 4,
SigInt1Rls = 5,
SigInt1RlsLong = 6,
SigPressCls = 7,
SigPressOpn = 8,
SigProxOpn = 9,
SigProxCvrd = 10,
SigBrewOn = 11,
SigBrewOff = 12
};
void halInit(void);
void halRelaisOn(int relais);
void halRelaisOff(int relais);
void halRelaisSet(int relais, int state);
int halGetRelaisState(int relais);
void halInt0(void);
void halInt1(void);
void halIntFlow(void);
void halIntPressure(void);
void halIntProximity(void);
float halGetFlow(void);
void halResetFlow(void);
bool halIsHeating(void);
bool halProxSensorCovered(void);
int halGetInt0(void);
int halGetInt1(void);
void halSendSignal(int value);
void halMachineOn(void);
void halMachineOff(void);
void halInt0TimerHandler(void);
void halInt1TimerHandler(void);
#endif /* HAL_H_ */
halRelaisOn
void halRelaisOn(int relais)
Switches relais on.
Definition: hal.cpp:80
halResetFlow
void halResetFlow(void)
Resets the Flow counter.
Definition: hal.cpp:240
halRelaisSet
void halRelaisSet(int relais, int state)
Switches relais to state.
Definition: hal.cpp:97
SigInt0RlsLong
Definition: hal.h:43
SigInt1RlsLong
Definition: hal.h:46
SigInt1Psh
Definition: hal.h:44
SigInt1Rls
Definition: hal.h:45
halProxSensorCovered
bool halProxSensorCovered(void)
Returns status of the proximity switch.
Definition: hal.cpp:260
halMachineOff
void halMachineOff(void)
Turn machine off.
Definition: hal.cpp:314
halRelaisOff
void halRelaisOff(int relais)
Switches relais off.
Definition: hal.cpp:88
HalSig
HalSig
Definition: hal.h:40
halMachineOn
void halMachineOn(void)
Turn machine on.
Definition: hal.cpp:304
SigBrewOff
Definition: hal.h:52
SigInt0Psh
Definition: hal.h:41
halGetFlow
float halGetFlow(void)
Returns total flow trough sensor in ml.
Definition: hal.cpp:233
halInt0
void halInt0(void)
Interrupt routine for Int0 (Top button)
Definition: hal.cpp:133
halGetRelaisState
int halGetRelaisState(int relais)
Returns the state of the relais relais Returns HIGH when Relais is ON.
Definition: hal.cpp:119
halGetInt0
int halGetInt0(void)
Returns the value of the top button Int0 (low active)
Definition: hal.cpp:274
halIsHeating
bool halIsHeating(void)
Reads the status of the Pressure Control.
Definition: hal.cpp:248
SigPressCls
Definition: hal.h:47
halInt1
void halInt1(void)
Interrupt routine for Int1 (Bottom button)
Definition: hal.cpp:164
halIntFlow
void halIntFlow(void)
Interrupt routine for the flow sensor It counts the edgdes and stores the value in flowcnt...
Definition: hal.cpp:196
halGetInt1
int halGetInt1(void)
Returns the value of the bottom button Int1 (low active)
Definition: hal.cpp:282
SigInt0Rls
Definition: hal.h:42
SigPressOpn
Definition: hal.h:48
SigProxOpn
Definition: hal.h:49
halInt1TimerHandler
void halInt1TimerHandler(void)
Definition: hal.cpp:182
halInit
void halInit(void)
Initializes HAL.
Definition: hal.cpp:30
SigProxCvrd
Definition: hal.h:50
halIntProximity
void halIntProximity(void)
Method to handle toggle of the proximity sensor.
Definition: hal.cpp:221
state
int state
Definition: coffee.cpp:27
halSendSignal
void halSendSignal(int value)
send Signal to coffee thread
Definition: hal.cpp:290
halIntPressure
void halIntPressure(void)
Interrupt routine for the pressure control.
Definition: hal.cpp:209
SigBrewOn
Definition: hal.h:51
halInt0TimerHandler
void halInt0TimerHandler(void)
Definition: hal.cpp:151