Skip to content

Commit b051e56

Browse files
committed
libraries: Wire: Add member variable i2c_dev
Add member variable i2c_dev to Wire to hold it own i2c device instance. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
1 parent fda91b4 commit b051e56

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

libraries/Wire/Wire.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66

77
#include <Wire.h>
8+
arduino::ZephyrI2C::ZephyrI2C(const struct device *i2c) : i2c_dev(i2c)
9+
{
10+
}
811

912
void arduino::ZephyrI2C::begin() {
1013
ring_buf_init(&rxRingBuffer.rb, sizeof(rxRingBuffer.buffer), rxRingBuffer.buffer);
@@ -101,4 +104,4 @@ void arduino::ZephyrI2C::flush() {}
101104
void arduino::ZephyrI2C::onReceive(voidFuncPtrParamInt cb) {}
102105
void arduino::ZephyrI2C::onRequest(voidFuncPtr cb) {}
103106

104-
arduino::ZephyrI2C Wire;
107+
arduino::ZephyrI2C Wire(i2c_dev);

libraries/Wire/Wire.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace arduino {
1717

1818
class ZephyrI2C : public HardwareI2C {
1919
public:
20+
ZephyrI2C(const struct device* i2c);
21+
2022
virtual void begin();
2123
virtual void end();
2224
virtual void begin(uint8_t address);
@@ -50,10 +52,11 @@ class ZephyrI2C : public HardwareI2C {
5052
uint8_t buffer[256];
5153
};
5254
struct rx_ring_buf rxRingBuffer;
55+
const struct device* i2c_dev;
5356
};
5457

5558
} // namespace arduino
5659

5760
extern arduino::ZephyrI2C Wire;
5861

59-
typedef arduino::ZephyrI2C TwoWire;
62+
typedef arduino::ZephyrI2C TwoWire;

0 commit comments

Comments
 (0)