AceWire
0.1.0
Unified interface for selecting different I2C implementations on Arduino platforms
src
ace_wire
TwoWireInterface.h
1
/*
2
MIT License
3
4
Copyright (c) 2021 Brian T. Park
5
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
of this software and associated documentation files (the "Software"), to deal
8
in the Software without restriction, including without limitation the rights
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
copies of the Software, and to permit persons to whom the Software is
11
furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in all
14
copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
SOFTWARE.
23
*/
24
25
#ifndef ACE_WIRE_TWO_WIRE_INTERFACE_H
26
#define ACE_WIRE_TWO_WIRE_INTERFACE_H
27
28
#include <stdint.h>
29
30
namespace
ace_wire {
31
44
template
<
typename
T_WIRE>
45
class
TwoWireInterface
{
46
public
:
53
TwoWireInterface
(T_WIRE& wire) : mWire(wire) {}
54
56
void
begin
() {}
57
59
void
end
() {}
60
62
void
beginTransmission
(uint8_t addr) {
63
mWire.beginTransmission(addr);
64
}
65
67
void
write
(uint8_t data) {
68
mWire.write(data);
69
}
70
72
void
endTransmission
() {
73
mWire.endTransmission();
74
}
75
76
private
:
77
T_WIRE &mWire;
78
};
79
80
}
81
82
#endif
ace_wire::TwoWireInterface::TwoWireInterface
TwoWireInterface(T_WIRE &wire)
Constructor.
Definition:
TwoWireInterface.h:53
ace_wire::TwoWireInterface::beginTransmission
void beginTransmission(uint8_t addr)
Start transmission at specified I2C addr.
Definition:
TwoWireInterface.h:62
ace_wire::TwoWireInterface::end
void end()
End the interface.
Definition:
TwoWireInterface.h:59
ace_wire::TwoWireInterface::endTransmission
void endTransmission()
End transmission.
Definition:
TwoWireInterface.h:72
ace_wire::TwoWireInterface::write
void write(uint8_t data)
Write data.
Definition:
TwoWireInterface.h:67
ace_wire::TwoWireInterface
A thin wrapper around an I2C TwoWire class and its Wire object.
Definition:
TwoWireInterface.h:45
ace_wire::TwoWireInterface::begin
void begin()
Initial the interface.
Definition:
TwoWireInterface.h:56
Generated by
1.8.17