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.

BCM.h 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 BCM_h
  20. #define BCM_h
  21. #include <stdint.h>
  22. #include "bcm2835.h"
  23. #define INPUT BCM2835_GPIO_FSEL_INPT
  24. #define OUTPUT BCM2835_GPIO_FSEL_OUTP
  25. /**
  26. * @brief BCM class
  27. */
  28. class BCMClass
  29. {
  30. public:
  31. /**
  32. * @brief BCMClass destructor.
  33. */
  34. ~BCMClass();
  35. /**
  36. * @brief Initializes BCM.
  37. *
  38. * @return 1 if successful, else exits the program.
  39. */
  40. uint8_t init();
  41. /**
  42. * @brief Configures the specified pin to behave either as an input or an output.
  43. *
  44. * @param gpio The GPIO pin number.
  45. * @param mode INPUT or OUTPUT.
  46. */
  47. void pinMode(uint8_t gpio, uint8_t mode);
  48. /**
  49. * @brief Write a high or a low value for the given pin.
  50. *
  51. * @param gpio The GPIO pin number.
  52. * @param value HIGH or LOW.
  53. */
  54. void digitalWrite(uint8_t gpio, uint8_t value);
  55. /**
  56. * @brief Reads the value from a specified pin.
  57. *
  58. * @param gpio The GPIO pin number.
  59. * @return HIGH or LOW.
  60. */
  61. uint8_t digitalRead(uint8_t gpio);
  62. /**
  63. * @brief Returns the same GPIO, no conversion is required.
  64. *
  65. * @param gpio The GPIO pin number.
  66. * @return The GPIO pin number.
  67. */
  68. inline uint8_t digitalPinToInterrupt(uint8_t gpio);
  69. /**
  70. * @brief Checks if SPI was initialized.
  71. *
  72. * @return 1 if initialized, else 0.
  73. */
  74. uint8_t isInitialized();
  75. private:
  76. static uint8_t initialized; //!< @brief BCM initialized flag.
  77. };
  78. uint8_t BCMClass::digitalPinToInterrupt(uint8_t gpio)
  79. {
  80. return gpio;
  81. }
  82. extern BCMClass BCM;
  83. #endif