hal.h 2.7 KB

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