hal.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. //these are the wPi numberings
  11. #define RELAIS_HEAT 29
  12. #define RELAIS_PUMP 25
  13. #define RELAIS_POWER 28
  14. #define PIN_PRESSURE_CTRL 7
  15. #define PIN_PROXIMITY_SENSOR 6
  16. #define PIN_INT0 2 // Top button
  17. #define PIN_INT1 0 // Bottom button
  18. #define PIN_FLOW 3 // Flow sensor
  19. #define PIN_DISP 4
  20. #define FLOW_ML_PULSE (1000.0/2219) // Flow sensor: volume (ml) per pulse
  21. #define PIN_ROTARY1 15
  22. #define PIN_ROTARY2 16
  23. #define ROTARY_RESOLUTION 127
  24. #define ROTARY_STEPSIZE 15
  25. #define TIME_BUTTONLONGPRESS 3 //Time in s until a Signal for a long pressed button is sent
  26. #define BREW_MANUAL_TRIGGER 26 //specifies the ml after which a brew_manual signal is triggered
  27. /*
  28. * Explanation for the signal levels
  29. * SigInt_Psh Button is pushed
  30. * SigInt_Rls Button is released
  31. * SigInt_RlsLong Button is pressed for more than TIME_BUTTONLONGPRESS seconds
  32. * SigPressCls Pressure control is closed, System is heating
  33. * SigPressOpn Pressure control is open, heating is off
  34. * SigProxOpn Proximity Sensor is uncovered
  35. * SigProxCvrd Proximity Sensor is covered
  36. */
  37. /*
  38. * Functions of the buttons, the letter in brackets defines if the event is triggered
  39. * on push(P), release(R) or long pressing(RLong) of the button
  40. * TOP Button: Turn machine on(R), start brewing(P),
  41. *
  42. * BOTTOM button: Stop brewing immediately(P), Turn machine off(RLong),
  43. */
  44. enum HalSig {
  45. SigInt0Psh = 1,
  46. SigInt0Rls = 2,
  47. SigInt0RlsLong = 3,
  48. SigInt1Psh = 4,
  49. SigInt1Rls = 5,
  50. SigInt1RlsLong = 6,
  51. SigPressCls = 7,
  52. SigPressOpn = 8,
  53. SigProxOpn = 9,
  54. SigProxCvrd = 10,
  55. SigBrewOn = 11,
  56. SigBrewOff = 12,
  57. SigPowerUp = 13,
  58. SigPowerDown = 14,
  59. SigRotCW = 15,
  60. SigRotCCW = 16
  61. };
  62. extern const char* SigName[];
  63. void halInit(void);
  64. void halDisplayOff();
  65. void halDisplayOn();
  66. void halRelaisOn(int relais);
  67. void halRelaisOff(int relais);
  68. void halRelaisSet(int relais, int state);
  69. int halGetRelaisState(int relais);
  70. void halIntRotary(void);
  71. void halInt0(void);
  72. void halInt1(void);
  73. void flowResetTimerHandler(void);
  74. void halFlowTimerHandler(void);
  75. void halIntFlow(void);
  76. void halIntPressure(void);
  77. double halgetHeatingTime(void);
  78. void halIntProximity(void);
  79. float halGetFlow(void);
  80. uint16_t halGetFlowTime(void);
  81. float halGetLastFlow(void);
  82. uint16_t halGetLastFlowTime(void);
  83. void halResetFlow(void);
  84. bool halIsHeating(void);
  85. bool halProxSensorCovered(void);
  86. int halGetInt0(void);
  87. int halGetInt1(void);
  88. void halSendSignal(HalSig value);
  89. void halMachineOn(void);
  90. void halMachineOff(void);
  91. void halInt0TimerHandler(void);
  92. void halInt1TimerHandler(void);
  93. void halIdleTimerHandler(void);
  94. void halEnterIdle (void);
  95. void halLeaveIdle (void);
  96. void halPumpOn();
  97. void halPumpOff(void);
  98. void halIncreaseLogCycleCounter(void);
  99. void timespec_diff(timespec *start, timespec *stop, timespec *result);
  100. void halTerminate(event_t *event);
  101. void halWriteBackCache(void);
  102. #endif /* HAL_H_ */