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.

Wire.h 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. TwoWire.h - TWI/I2C library for Arduino & Wiring
  3. Copyright (c) 2006 Nicholas Zambetti. All right reserved.
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
  16. Modified December 2014 by Ivan Grokhotkov (ivan@esp8266.com) - esp8266 support
  17. Modified April 2015 by Hrsto Gochkov (ficeto@ficeto.com) - alternative esp8266 support
  18. Modified October 2016 by Marcelo Aquino <marceloaqno@gmail.org> for Raspberry Pi
  19. */
  20. #ifndef Wire_h
  21. #define Wire_h
  22. #if !DOXYGEN
  23. #include <stdint.h>
  24. #include "Stream.h"
  25. #include "BCM.h"
  26. #define BUFFER_LENGTH 32
  27. class TwoWire : public Stream
  28. {
  29. private:
  30. static uint8_t rxBuffer[];
  31. static uint8_t rxBufferIndex;
  32. static uint8_t rxBufferLength;
  33. static uint8_t txAddress;
  34. static uint8_t txBuffer[];
  35. static uint8_t txBufferIndex;
  36. static uint8_t txBufferLength;
  37. static uint8_t transmitting;
  38. public:
  39. void begin();
  40. void begin(uint8_t address);
  41. void begin(int address);
  42. void end();
  43. void setClock(uint32_t clock);
  44. void beginTransmission(uint8_t address);
  45. void beginTransmission(int address);
  46. uint8_t endTransmission(void);
  47. size_t requestFrom(uint8_t address, size_t size);
  48. uint8_t requestFrom(uint8_t address, uint8_t quantity);
  49. uint8_t requestFrom(int address, int quantity);
  50. size_t write(uint8_t data);
  51. size_t write(const uint8_t *data, size_t quantity);
  52. int available();
  53. int read();
  54. int peek();
  55. void flush();
  56. inline size_t write(unsigned long n)
  57. {
  58. return write((uint8_t)n);
  59. }
  60. inline size_t write(long n)
  61. {
  62. return write((uint8_t)n);
  63. }
  64. inline size_t write(unsigned int n)
  65. {
  66. return write((uint8_t)n);
  67. }
  68. inline size_t write(int n)
  69. {
  70. return write((uint8_t)n);
  71. }
  72. using Print::write;
  73. };
  74. extern TwoWire Wire;
  75. #endif
  76. #endif