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