hal.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * hal.h
  3. *
  4. * Created on: Aug 3, 2016
  5. * Author: sebastian
  6. */
  7. #ifndef HAL_H_
  8. #define HAL_H_
  9. #define RELAIS_HEAT 29
  10. #define RELAIS_PUMP 25
  11. #define RELAIS_POWER 28
  12. #define PIN_PRESSURE_CTRL 7
  13. #define PIN_PROXIMITY_SENSOR 6
  14. #define PIN_INT0 2 // Top button
  15. #define PIN_INT1 0 // Bottom button
  16. #define PIN_FLOW 3 // Flow sensor
  17. #define FLOW_ML_PULSE (1000.0/990) // Flow sensor: volume (ml) per pulse
  18. #define TIME_BUTTONLONGPRESS 3 //Time in s until a Signal for a long pressed button is sent
  19. /*
  20. * Explanation for the signal levels
  21. * SigInt_Psh Button is pushed
  22. * SigInt_Rls Button is released
  23. * SigInt_RlsLong Button is pressed for more than TIME_BUTTONLONGPRESS seconds
  24. * SigPressCls Pressure control is closed, System is heating
  25. * SigPressOpn Pressure control is open, heating is off
  26. * SigProxOpn Proximity Sensor is uncovered
  27. * SigProxCvrd Proximity Sensor is covered
  28. */
  29. /*
  30. * Functions of the buttons, the letter in brackets defines if the event is triggered
  31. * on push(P), release(R) or long pressing(RLong) of the button
  32. * TOP Button: Turn machine on(R), start brewing(P),
  33. *
  34. * BOTTOM button: Stop brewing immediately(P), Turn machine off(RLong),
  35. */
  36. enum HalSig {
  37. SigInt0Psh = 1,
  38. SigInt0Rls = 2,
  39. SigInt0RlsLong = 3,
  40. SigInt1Psh = 4,
  41. SigInt1Rls = 5,
  42. SigInt1RlsLong = 6,
  43. SigPressCls = 7,
  44. SigPressOpn = 8,
  45. SigProxOpn = 9,
  46. SigProxCvrd = 10,
  47. SigBrewOn = 11,
  48. SigBrewOff = 12
  49. };
  50. void halInit(void);
  51. void halRelaisOn(int relais);
  52. void halRelaisOff(int relais);
  53. void halRelaisSet(int relais, int state);
  54. int halGetRelaisState(int relais);
  55. void halInt0(void);
  56. void halInt1(void);
  57. void halIntFlow(void);
  58. void halIntPressure(void);
  59. void halIntProximity(void);
  60. float halGetFlow(void);
  61. void halResetFlow(void);
  62. bool halIsHeating(void);
  63. bool halProxSensorCovered(void);
  64. int halGetInt0(void);
  65. int halGetInt1(void);
  66. void halSendSignal(HalSig value);
  67. void halMachineOn(void);
  68. void halMachineOff(void);
  69. void halInt0TimerHandler(void);
  70. void halInt1TimerHandler(void);
  71. #endif /* HAL_H_ */