File tree Expand file tree Collapse file tree 4 files changed +17
-0
lines changed
Expand file tree Collapse file tree 4 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ class HardwareI2C : public Stream
4141
4242 virtual void onReceive (void (*)(int )) = 0;
4343 virtual void onRequest (void (*)(void )) = 0;
44+
45+ virtual int writeQuick (uint8_t toWrite) = 0;
4446};
4547
4648}
Original file line number Diff line number Diff line change 99#include < iostream>
1010#include < linux/i2c.h>
1111
12+
13+ extern " C"
14+ {
15+ #include < linux/i2c-dev.h>
16+ #include < i2c/smbus.h>
17+ }
18+
19+
1220namespace arduino {
1321 char buf[100 ] = {0 };
1422 int requestedBytes = 0 ;
@@ -46,6 +54,10 @@ namespace arduino {
4654
4755 }
4856
57+ int LinuxHardwareI2C::writeQuick (uint8_t toWrite) {
58+ int a = i2c_smbus_write_quick (i2c_file, toWrite);
59+ return a;
60+ }
4961
5062 size_t LinuxHardwareI2C::write (uint8_t toWrite) {
5163 buf[requestedBytes] = toWrite; // todo: alloc and copy
Original file line number Diff line number Diff line change @@ -53,6 +53,8 @@ class LinuxHardwareI2C : public HardwareI2C {
5353 // Methods from Print
5454
5555 virtual size_t write (uint8_t toWrite);
56+
57+ int writeQuick (uint8_t toWrite);
5658
5759 virtual size_t write (const uint8_t *buffer, size_t size);
5860
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ enum ResultI2c {
2222class SimHardwareI2C : public HardwareI2C {
2323public:
2424 virtual void begin () NOT_IMPLEMENTED(" i2cbegin" );
25+ virtual int writeQuick (uint8_t toWrite) NOT_IMPLEMENTED(" writeQuick" );
2526
2627 virtual void begin (uint8_t address) NOT_IMPLEMENTED(" i2cslave begin" );
2728
You can’t perform that action at this time.
0 commit comments