Wire.h
Go to the documentation of this file.
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 (todd@krein.org) to implement repeated starts
20 */
21 
22 #ifndef TwoWire_h
23 #define TwoWire_h
24 
25 #include <inttypes.h>
26 #include "Stream.h"
27 
28 #define BUFFER_LENGTH 32
29 
30 // WIRE_HAS_END means Wire has end()
31 #define WIRE_HAS_END 1
32 
33 class TwoWire : public Stream
34 {
35  private:
36  static uint8_t rxBuffer[];
37  static uint8_t rxBufferIndex;
38  static uint8_t rxBufferLength;
39 
40  static uint8_t txAddress;
41  static uint8_t txBuffer[];
42  static uint8_t txBufferIndex;
43  static uint8_t txBufferLength;
44 
45  static uint8_t transmitting;
46  static void (*user_onRequest)(void);
47  static void (*user_onReceive)(int);
48  static void onRequestService(void);
49  static void onReceiveService(uint8_t*, int);
50  public:
51  TwoWire();
52  void begin();
53  void begin(uint8_t);
54  void begin(int);
55  void end();
56  void setClock(uint32_t);
57  void beginTransmission(uint8_t);
58  void beginTransmission(int);
59  uint8_t endTransmission(void);
60  uint8_t endTransmission(uint8_t);
61  uint8_t requestFrom(uint8_t, uint8_t);
62  uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
63  uint8_t requestFrom(uint8_t, uint8_t, uint32_t, uint8_t, uint8_t);
64  uint8_t requestFrom(int, int);
65  uint8_t requestFrom(int, int, int);
66  virtual size_t write(uint8_t);
67  virtual size_t write(const uint8_t *, size_t);
68  virtual int available(void);
69  virtual int read(void);
70  virtual int peek(void);
71  virtual void flush(void);
72  void onReceive( void (*)(int) );
73  void onRequest( void (*)(void) );
74 
75  inline size_t write(unsigned long n) { return write((uint8_t)n); }
76  inline size_t write(long n) { return write((uint8_t)n); }
77  inline size_t write(unsigned int n) { return write((uint8_t)n); }
78  inline size_t write(int n) { return write((uint8_t)n); }
79  using Print::write;
80 };
81 
82 extern TwoWire Wire;
83 
84 #endif
85 
virtual int peek(void)
Definition: Wire.cpp:259
GLvoid *typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
size_t write(unsigned long n)
Definition: Wire.h:75
static uint8_t transmitting
Definition: Wire.h:45
static void(* user_onRequest)(void)
Definition: Wire.h:46
virtual size_t write(uint8_t)=0
virtual size_t write(uint8_t)
Definition: Wire.cpp:192
static void onRequestService(void)
Definition: Wire.cpp:301
void begin()
Definition: Wire.cpp:54
uint8_t requestFrom(uint8_t, uint8_t)
Definition: Wire.cpp:125
void end()
Definition: Wire.cpp:78
unsigned int uint32_t
static uint8_t txBufferIndex
Definition: Wire.h:42
GLsizei n
TwoWire Wire
Definition: Wire.cpp:329
size_t write(int n)
Definition: Wire.h:78
Definition: Wire.h:33
virtual int available(void)
Definition: Wire.cpp:235
uint8_t endTransmission(void)
Definition: Wire.cpp:184
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
static uint8_t rxBuffer[]
Definition: Wire.h:36
static uint8_t rxBufferLength
Definition: Wire.h:38
static uint8_t txBuffer[]
Definition: Wire.h:41
static uint8_t rxBufferIndex
Definition: Wire.h:37
static void onReceiveService(uint8_t *, int)
Definition: Wire.cpp:276
size_t write(unsigned int n)
Definition: Wire.h:77
void onRequest(void(*)(void))
Definition: Wire.cpp:322
void setClock(uint32_t)
Definition: Wire.cpp:83
void beginTransmission(uint8_t)
Definition: Wire.cpp:140
void onReceive(void(*)(int))
Definition: Wire.cpp:316
static void(* user_onReceive)(int)
Definition: Wire.h:47
TwoWire()
Definition: Wire.cpp:48
virtual void flush(void)
Definition: Wire.cpp:270
static uint8_t txAddress
Definition: Wire.h:40
static uint8_t txBufferLength
Definition: Wire.h:43
size_t write(long n)
Definition: Wire.h:76
virtual int read(void)
Definition: Wire.cpp:243
Definition: Stream.h:49


arduino_daq
Author(s):
autogenerated on Mon Jun 10 2019 12:46:03