|
@@ -30,7 +30,8 @@
|
30
|
30
|
// Print debug messages with M111 S2 (Uses 236 bytes of PROGMEM)
|
31
|
31
|
//#define DEBUG_TWIBUS
|
32
|
32
|
|
33
|
|
-typedef void (*twiSlaveFunc_t)(int bytes);
|
|
33
|
+typedef void (*twiReceiveFunc_t)(int bytes);
|
|
34
|
+typedef void (*twiRequestFunc_t)();
|
34
|
35
|
|
35
|
36
|
/**
|
36
|
37
|
* TWIBUS class
|
|
@@ -143,13 +144,20 @@ class TWIBus {
|
143
|
144
|
inline void receive(uint8_t bytes) { relaydata(bytes); }
|
144
|
145
|
|
145
|
146
|
/**
|
146
|
|
- * @brief Register a slave handler
|
147
|
|
- * @details Set a handler to receive data from the bus,
|
148
|
|
- * so we can act as a slave.
|
|
147
|
+ * @brief Register a slave receive handler
|
|
148
|
+ * @details Set a handler to receive data addressed to us.
|
149
|
149
|
*
|
150
|
150
|
* @param handler A function to handle receiving bytes
|
151
|
151
|
*/
|
152
|
|
- inline void onReceive(const twiSlaveFunc_t handler) { Wire.onReceive(handler); }
|
|
152
|
+ inline void onReceive(const twiReceiveFunc_t handler) { Wire.onReceive(handler); }
|
|
153
|
+
|
|
154
|
+ /**
|
|
155
|
+ * @brief Register a slave request handler
|
|
156
|
+ * @details Set a handler to send data requested from us.
|
|
157
|
+ *
|
|
158
|
+ * @param handler A function to handle receiving bytes
|
|
159
|
+ */
|
|
160
|
+ inline void onRequest(const twiRequestFunc_t handler) { Wire.onRequest(handler); }
|
153
|
161
|
|
154
|
162
|
#endif
|
155
|
163
|
|