SpaIot Library
twowireslave.h
1/*
2 * SpaIot Library (c) by epsilonrt - epsilonrt@gmail.com
3 * This file is part of SpaIot library <https://github.com/epsilonrt/spaiot-lib>
4 *
5 * SpaIot library is licensed under a
6 * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
7 *
8 * You should have received a copy of the license along with this
9 * work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
10 *
11 * SpaIot library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY;
13 */
14#pragma once
15
16#include <Arduino.h>
17#include <Wire.h>
18namespace SpaIot {
19
26 public:
27
33 TwoWireSlave (uint8_t slaveAddress, TwoWire & bus = Wire);
34
43 int write (uint8_t value);
44
52 int read();
53
63 int write (const uint8_t *values, uint16_t len);
64
74 int read (uint8_t *values, uint16_t len);
75
85 int write (uint8_t dataAddress, uint8_t value);
86
95 int read (uint8_t dataAddress);
96
107 int write (uint8_t dataAddress, const uint8_t *values, uint16_t len);
108
119 int read (uint8_t dataAddress, uint8_t *values, uint16_t len);
120
125 inline uint8_t address() const {
126
127 return m_address;
128 }
129
134 inline void setAddress (uint8_t slaveAddress) {
135
136 m_address = slaveAddress;
137 }
138
143 inline TwoWire & bus() const {
144
145 return m_bus;
146 }
147
148 private:
149 TwoWire & m_bus;
150 uint8_t m_address;
151 };
152}
Definition: twowireslave.h:25
int write(uint8_t dataAddress, const uint8_t *values, uint16_t len)
Write bytes in integrated circuit registers.
int write(const uint8_t *values, uint16_t len)
Write several bytes in the integrated circuit.
TwoWireSlave(uint8_t slaveAddress, TwoWire &bus=Wire)
Constructor.
void setAddress(uint8_t slaveAddress)
Change of the slave m_address of the integrated circuit.
Definition: twowireslave.h:134
int read(uint8_t dataAddress)
Reading a byte in an integrated circuit register.
int write(uint8_t value)
Write a byte in the integrated circuit.
TwoWire & bus() const
Returns the I²C bus used to access the integrated circuit.
Definition: twowireslave.h:143
uint8_t address() const
Reading of the slave m_address of the integrated circuit.
Definition: twowireslave.h:125
int write(uint8_t dataAddress, uint8_t value)
Write a byte in an integrated circuit register.
int read(uint8_t dataAddress, uint8_t *values, uint16_t len)
Reading several bytes in the integrated circuit.
int read()
Reading a byte in the integrated circuit.
int read(uint8_t *values, uint16_t len)
Reading several bytes in the integrated circuit.
SpaIot name space.
Definition: bussettings.h:21