Smart-Home am Beispiel der Präsenzerkennung im Raum Projektarbeit Lennart Heimbs, Johannes Krug, Sebastian Dohle und Kevin Holzschuh bei Prof. Oliver Hofmann SS2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MyHwHAL.h 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * The MySensors Arduino library handles the wireless radio link and protocol
  3. * between your home built sensors/actuators and HA controller of choice.
  4. * The sensors forms a self healing radio network with optional repeaters. Each
  5. * repeater and gateway builds a routing tables in EEPROM which keeps track of the
  6. * network topology allowing messages to be routed to nodes.
  7. *
  8. * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
  9. * Copyright (C) 2013-2018 Sensnology AB
  10. * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
  11. *
  12. * Documentation: http://www.mysensors.org
  13. * Support Forum: http://forum.mysensors.org
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * version 2 as published by the Free Software Foundation.
  18. */
  19. /**
  20. * @file MyHwHAL.h
  21. *
  22. * MySensors hardware abstraction layer
  23. */
  24. #ifndef MyHwHAL_h
  25. #define MyHwHAL_h
  26. /**
  27. * @def MY_HWID_PADDING_BYTE
  28. * @brief HwID padding byte
  29. */
  30. #define MY_HWID_PADDING_BYTE (0xAAu)
  31. // Implement these as functions or macros
  32. /*
  33. #define hwInit() MY_SERIALDEVICE.begin(BAUD_RATE)
  34. #define hwWatchdogReset() wdt_reset()
  35. #define hwReboot() wdt_enable(WDTO_15MS); while (1)
  36. #define hwMillis() millis()
  37. #define hwDigitalWrite(__pin, __value)
  38. #define hwDigitalRead(__pin)
  39. #define hwPinMode(__pin, __value)
  40. void hwReadConfigBlock(void *buf, void *addr, size_t length);
  41. void hwWriteConfigBlock(void *buf, void *addr, size_t length);
  42. void hwWriteConfig(const int addr, uint8_t value);
  43. uint8_t hwReadConfig(const int addr);
  44. */
  45. /**
  46. * @def MY_HW_HAS_GETENTROPY
  47. * @brief Define this, if hwGetentropy is implemented
  48. *
  49. * ssize_t hwGetentropy(void *__buffer, size_t __length);
  50. */
  51. //#define MY_HW_HAS_GETENTROPY
  52. /// @brief unique ID
  53. typedef uint8_t unique_id_t[16];
  54. /**
  55. * Sleep for a defined time, using minimum power.
  56. * @param ms Time to sleep, in [ms].
  57. * @return MY_WAKE_UP_BY_TIMER.
  58. */
  59. int8_t hwSleep(uint32_t ms);
  60. /**
  61. * Sleep for a defined time, using minimum power, or until woken by interrupt.
  62. * @param interrupt Interrupt number, which can wake the mcu from sleep.
  63. * @param mode Interrupt mode, as passed to attachInterrupt.
  64. * @param ms Time to sleep, in [ms].
  65. * @return MY_WAKE_UP_BY_TIMER when woken by timer, or interrupt number when woken by interrupt.
  66. */
  67. int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms);
  68. /**
  69. * Sleep for a defined time, using minimum power, or until woken by one of the interrupts.
  70. * @param interrupt1 Interrupt1 number, which can wake the mcu from sleep.
  71. * @param mode1 Interrupt1 mode, as passed to attachInterrupt.
  72. * @param interrupt2 Interrupt2 number, which can wake the mcu from sleep.
  73. * @param mode2 Interrupt2 mode, as passed to attachInterrupt.
  74. * @param ms Time to sleep, in [ms].
  75. * @return MY_WAKE_UP_BY_TIMER when woken by timer, or interrupt number when woken by interrupt.
  76. */
  77. int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2,
  78. uint32_t ms);
  79. /**
  80. * Retrieve unique hardware ID
  81. * @param uniqueID unique ID
  82. * @return True if unique ID successfully retrieved
  83. */
  84. bool hwUniqueID(unique_id_t *uniqueID);
  85. /**
  86. * CPU voltage
  87. * @return CPU voltage in mV
  88. */
  89. uint16_t hwCPUVoltage(void);
  90. /**
  91. * CPU frequency
  92. * @return CPU frequency in 1/10Mhz
  93. */
  94. uint16_t hwCPUFrequency(void);
  95. /**
  96. * CPU temperature (if available)
  97. * Adjust calibration parameters via MY_<ARCH>_TEMPERATURE_OFFSET and MY_<ARCH>_TEMPERATURE_GAIN
  98. * @return CPU temperature in °C, -127 if not available
  99. */
  100. int8_t hwCPUTemperature(void);
  101. /**
  102. * Report free memory (if function available)
  103. * @return free memory in bytes
  104. */
  105. uint16_t hwFreeMem(void);
  106. #if defined(DEBUG_OUTPUT_ENABLED)
  107. void hwDebugPrint(const char *fmt, ... );
  108. #endif
  109. /**
  110. * @def MY_CRITICAL_SECTION
  111. * @brief Creates a block of code that is guaranteed to be executed atomically.
  112. * Upon entering the block all interrupts are disabled, and re-enabled upon
  113. * exiting the block from any exit path.
  114. * A typical example that requires atomic access is a 16 (or more) bit variable
  115. * that is shared between the main execution path and an ISR, on an 8-bit
  116. * platform (e.g AVR):
  117. * @code
  118. * volatile uint16_t val = 0;
  119. *
  120. * void interrupHandler()
  121. * {
  122. * val = ~val;
  123. * }
  124. *
  125. * void loop()
  126. * {
  127. * uint16_t copy_val;
  128. * MY_CRITICAL_SECTION
  129. * {
  130. * copy_val = val;
  131. * }
  132. * }
  133. * @endcode
  134. * All code within the MY_CRITICAL_SECTION block will be protected from being
  135. * interrupted during execution.
  136. */
  137. #ifdef DOXYGEN
  138. #define MY_CRITICAL_SECTION
  139. #define MY_HW_HAS_GETENTROPY
  140. #endif /* DOXYGEN */
  141. #endif // #ifdef MyHw_h