hal.h 3.1 KB

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