Loading...
Searching...
No Matches
wireport.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
55#ifndef WIREPORT_HPP
56#define WIREPORT_HPP
57
58#include <inttypes.h>
59#include <stddef.h>
60
62#ifndef ARDUINO_I2C_DEV
63#define ARDUINO_I2C_DEV (I2C_DEV(0))
64#endif
65
67#define WIREPORT_BUFFER_LENGTH 32
68
71{
72 private:
73
74 static uint8_t rxBuffer[];
75 static uint8_t rxBufferIndex;
76 static uint8_t rxBufferLength;
78 static uint8_t txAddress;
79 static uint8_t txBuffer[];
80 static uint8_t txBufferIndex;
81 static uint8_t txBufferLength;
82 static uint8_t txError;
84 static uint8_t transmitting;
87 public:
88
92 TwoWire(void);
93
97 void begin(void);
98
107 void begin(uint8_t addr);
108
119 void setClock(uint32_t clk);
120
132 void beginTransmission(uint8_t addr);
133
149 uint8_t endTransmission(void);
150
168 uint8_t endTransmission(uint8_t stop);
169
184 uint8_t requestFrom(uint8_t addr, uint8_t size);
185
201 uint8_t requestFrom(uint8_t addr, uint8_t size, uint8_t stop);
202
215 virtual size_t write(uint8_t data);
216
230 virtual size_t write(const uint8_t *data, size_t size);
231
242 virtual int available(void);
243
254 virtual int read(void);
255
267 virtual size_t readBytes(uint8_t *buffer, size_t length);
281 virtual int peek(void);
282
291 virtual void flush(void);
292};
293
294extern TwoWire Wire;
295
296#endif /* WIREPORT_HPP */
Class definition for the Arduino Wire library implementation.
Definition wireport.hpp:71
uint8_t requestFrom(uint8_t addr, uint8_t size)
Request bytes from a I2C slave device.
uint8_t endTransmission(uint8_t stop)
End a transmission to a I2C slave device.
virtual size_t write(const uint8_t *data, size_t size)
Queue bytes for transmission from a master to slave device.
uint8_t requestFrom(uint8_t addr, uint8_t size, uint8_t stop)
Request bytes from a I2C slave device.
void setClock(uint32_t clk)
Set the clock speed of the I2C device defined by ARDUINO_I2C_DEV.
virtual int available(void)
Return the number of bytes available for retrieval.
virtual int read(void)
Reads one byte transmitted from slave device to the master.
virtual size_t write(uint8_t data)
Queue a byte for transmission from a master to slave device.
void begin(void)
Initializes the I2C device defined by ARDUINO_I2C_DEV as master.
void beginTransmission(uint8_t addr)
Begin a transmission to a I2C slave device.
virtual int peek(void)
Peeks one byte transmitted from slave device to the master.
virtual size_t readBytes(uint8_t *buffer, size_t length)
Read bytes transmitted from slave device to the master.
void begin(uint8_t addr)
Initializes the I2C device defined by ARDUINO_I2C_DEV as slave.
virtual void flush(void)
Flush the RX and TX buffer.
TwoWire(void)
Constructor.
uint8_t endTransmission(void)
End a transmission to a I2C slave device.
Adds include for missing inttype definitions.