|
@@ -42,25 +42,26 @@ void TWIBus::reset() {
|
42
|
42
|
void TWIBus::address(uint8_t addr) {
|
43
|
43
|
this->addr = addr;
|
44
|
44
|
|
45
|
|
- if (DEBUGGING(INFO)) {
|
46
|
|
- SERIAL_ECHOPAIR("TWIBus::sendto: ", this->addr);
|
47
|
|
- SERIAL_EOL;
|
48
|
|
- }
|
|
45
|
+ #if ENABLED(DEBUG_TWIBUS)
|
|
46
|
+ debug(PSTR("sendto"), this->addr);
|
|
47
|
+ #endif
|
49
|
48
|
}
|
50
|
49
|
|
51
|
50
|
void TWIBus::addbyte(char c) {
|
52
|
51
|
if (buffer_s >= sizeof(this->buffer)) return;
|
53
|
52
|
this->buffer[this->buffer_s++] = c;
|
54
|
53
|
|
55
|
|
- if (DEBUGGING(INFO)) {
|
56
|
|
- SERIAL_ECHOPAIR("TWIBus::addbyte: ", this->buffer[this->buffer_s -1]);
|
57
|
|
- SERIAL_EOL;
|
58
|
|
- }
|
|
54
|
+ #if ENABLED(DEBUG_TWIBUS)
|
|
55
|
+ debug(PSTR("addbyte"), this->buffer[this->buffer_s - 1]);
|
|
56
|
+ #endif
|
59
|
57
|
}
|
60
|
58
|
|
61
|
59
|
void TWIBus::send() {
|
62
|
60
|
if (!this->addr) return;
|
63
|
|
- if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("TWIBus::send()");
|
|
61
|
+
|
|
62
|
+ #if ENABLED(DEBUG_TWIBUS)
|
|
63
|
+ debug(PSTR("send()"));
|
|
64
|
+ #endif
|
64
|
65
|
|
65
|
66
|
Wire.beginTransmission(this->addr);
|
66
|
67
|
Wire.write(this->buffer, this->buffer_s);
|
|
@@ -72,10 +73,10 @@ void TWIBus::send() {
|
72
|
73
|
|
73
|
74
|
void TWIBus::reqbytes(uint8_t bytes) {
|
74
|
75
|
if (!this->addr) return;
|
75
|
|
- if (DEBUGGING(INFO)) {
|
76
|
|
- SERIAL_ECHOPAIR("TWIBus::reqbytes(): ", bytes);
|
77
|
|
- SERIAL_EOL;
|
78
|
|
- }
|
|
76
|
+
|
|
77
|
+ #if ENABLED(DEBUG_TWIBUS)
|
|
78
|
+ debug(PSTR("reqbytes"), bytes);
|
|
79
|
+ #endif
|
79
|
80
|
|
80
|
81
|
millis_t t = millis() + this->timeout;
|
81
|
82
|
Wire.requestFrom(this->addr, bytes);
|
|
@@ -101,4 +102,17 @@ void TWIBus::reqbytes(uint8_t bytes) {
|
101
|
102
|
this->reset();
|
102
|
103
|
}
|
103
|
104
|
|
|
105
|
+#if ENABLED(DEBUG_TWIBUS)
|
|
106
|
+
|
|
107
|
+ void TWIBus::debug(const char func[], int32_t val/*=-1*/) {
|
|
108
|
+ if (DEBUGGING(INFO)) {
|
|
109
|
+ SERIAL_ECHOPGM("TWIBus::");
|
|
110
|
+ serialprintPGM(func);
|
|
111
|
+ if (val >= 0) SERIAL_ECHOPAIR(": ", val);
|
|
112
|
+ SERIAL_EOL;
|
|
113
|
+ }
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+#endif
|
|
117
|
+
|
104
|
118
|
#endif //EXPERIMENTAL_I2CBUS
|