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.

MyHwLinuxGeneric.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. #ifndef MyHwLinuxGeneric_h
  20. #define MyHwLinuxGeneric_h
  21. #include <cstdlib>
  22. #include <pthread.h>
  23. #include "SerialPort.h"
  24. #include "StdInOutStream.h"
  25. #define CRYPTO_LITTLE_ENDIAN
  26. #ifdef MY_LINUX_SERIAL_PORT
  27. #ifdef MY_LINUX_SERIAL_IS_PTY
  28. SerialPort Serial = SerialPort(MY_LINUX_SERIAL_PORT, true);
  29. #else
  30. SerialPort Serial = SerialPort(MY_LINUX_SERIAL_PORT, false);
  31. #endif
  32. #else
  33. StdInOutStream Serial = StdInOutStream();
  34. #endif
  35. #ifndef MY_SERIALDEVICE
  36. #define MY_SERIALDEVICE Serial
  37. #endif
  38. // Define these as macros (do nothing)
  39. #define hwWatchdogReset()
  40. #define hwReboot()
  41. inline void hwDigitalWrite(uint8_t, uint8_t);
  42. inline int hwDigitalRead(uint8_t);
  43. inline void hwPinMode(uint8_t, uint8_t);
  44. bool hwInit(void);
  45. inline void hwReadConfigBlock(void *buf, void *addr, size_t length);
  46. inline void hwWriteConfigBlock(void *buf, void *addr, size_t length);
  47. inline uint8_t hwReadConfig(const int addr);
  48. inline void hwWriteConfig(const int addr, uint8_t value);
  49. inline void hwRandomNumberInit(void);
  50. ssize_t hwGetentropy(void *__buffer, size_t __length);
  51. #define MY_HW_HAS_GETENTROPY
  52. inline uint32_t hwMillis(void);
  53. #ifdef MY_RF24_IRQ_PIN
  54. static pthread_mutex_t hw_mutex = PTHREAD_MUTEX_INITIALIZER;
  55. static __inline__ void __hwUnlock(const uint8_t *__s)
  56. {
  57. pthread_mutex_unlock(&hw_mutex);
  58. (void)__s;
  59. }
  60. static __inline__ void __hwLock()
  61. {
  62. pthread_mutex_lock(&hw_mutex);
  63. }
  64. #endif
  65. #if defined(DOXYGEN)
  66. #define ATOMIC_BLOCK_CLEANUP
  67. #elif defined(MY_RF24_IRQ_PIN)
  68. #define ATOMIC_BLOCK_CLEANUP uint8_t __atomic_loop \
  69. __attribute__((__cleanup__( __hwUnlock ))) = 1
  70. #else
  71. #define ATOMIC_BLOCK_CLEANUP
  72. #endif /* DOXYGEN */
  73. #if defined(DOXYGEN)
  74. #define ATOMIC_BLOCK
  75. #elif defined(MY_RF24_IRQ_PIN)
  76. #define ATOMIC_BLOCK for ( ATOMIC_BLOCK_CLEANUP, __hwLock(); \
  77. __atomic_loop ; __atomic_loop = 0 )
  78. #else
  79. #define ATOMIC_BLOCK
  80. #endif /* DOXYGEN */
  81. #ifndef DOXYGEN
  82. #define MY_CRITICAL_SECTION ATOMIC_BLOCK
  83. #endif /* DOXYGEN */
  84. #endif