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.

MyHwSAMD.h 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 MyHwSAMD_h
  20. #define MyHwSAMD_h
  21. #ifdef __cplusplus
  22. #include <Arduino.h>
  23. #endif
  24. #include <avr/dtostrf.h>
  25. #define CRYPTO_LITTLE_ENDIAN
  26. #ifndef MY_SERIALDEVICE
  27. #define MY_SERIALDEVICE SerialUSB
  28. #endif
  29. #ifndef MY_DEBUGDEVICE
  30. #define MY_DEBUGDEVICE MY_SERIALDEVICE
  31. #endif
  32. #ifndef MY_SAMD_TEMPERATURE_OFFSET
  33. #define MY_SAMD_TEMPERATURE_OFFSET (0.0f)
  34. #endif
  35. #ifndef MY_SAMD_TEMPERATURE_GAIN
  36. #define MY_SAMD_TEMPERATURE_GAIN (1.0f)
  37. #endif
  38. // defines for sensebender gw variant.h
  39. #define MY_EXT_EEPROM_I2C_ADDRESS (0x50u)
  40. #define MY_EXT_EEPROM_SIZE (kbits_512)
  41. #define MY_EXT_EEPROM_PAGE_SIZE (32u)
  42. extEEPROM eep(MY_EXT_EEPROM_SIZE, 1, MY_EXT_EEPROM_PAGE_SIZE,
  43. MY_EXT_EEPROM_I2C_ADDRESS); //device size, number of devices, page size
  44. #define MY_EXT_EEPROM_TWI_CLOCK (eep.twiClock100kHz) // can be set to 400kHz with precaution if other i2c devices on bus
  45. #define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
  46. #define vsnprintf_P(s, n, f, ...) vsnprintf((s), (n), (f), __VA_ARGS__)
  47. // Define these as macros to save valuable space
  48. #define hwDigitalWrite(__pin, __value) digitalWrite(__pin, __value)
  49. #define hwDigitalRead(__pin) digitalRead(__pin)
  50. #define hwPinMode(__pin, __value) pinMode(__pin, __value)
  51. #define hwMillis() millis()
  52. #define hwRandomNumberInit() randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN))
  53. bool hwInit(void);
  54. void hwWatchdogReset(void);
  55. void hwReboot(void);
  56. void hwReadConfigBlock(void *buf, void *addr, size_t length);
  57. void hwWriteConfigBlock(void *buf, void *addr, size_t length);
  58. void hwWriteConfig(const int addr, uint8_t value);
  59. uint8_t hwReadConfig(const int addr);
  60. /**
  61. * Disable all interrupts.
  62. * Helper function for MY_CRITICAL_SECTION.
  63. */
  64. static __inline__ uint8_t __disableIntsRetVal(void)
  65. {
  66. __disable_irq();
  67. return 1;
  68. }
  69. /**
  70. * Restore priority mask register.
  71. * Helper function for MY_CRITICAL_SECTION.
  72. */
  73. static __inline__ void __priMaskRestore(const uint32_t *priMask)
  74. {
  75. __set_PRIMASK(*priMask);
  76. }
  77. #ifndef DOXYGEN
  78. #define MY_CRITICAL_SECTION for ( uint32_t __savePriMask __attribute__((__cleanup__(__priMaskRestore))) = __get_PRIMASK(), __ToDo = __disableIntsRetVal(); __ToDo ; __ToDo = 0 )
  79. #endif /* DOXYGEN */
  80. #endif // #ifdef ARDUINO_ARCH_SAMD