hal.h 2.3 KB

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