hal.h 2.5 KB

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