Skip to content

Commit ba4e4cc

Browse files
Merge pull request #58 from JordanMajd/patch_samd51_i2c_slave
SAMD51 I2C slave support for Wire library and SAMD51 Thing Plus
2 parents 715cafd + 2653d81 commit ba4e4cc

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

sparkfun/samd/libraries/Wire/Wire.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ void TwoWire::onService(void)
287287
void WIRE_IT_HANDLER(void) {
288288
Wire.onService();
289289
}
290+
291+
#if defined(__SAMD51__)
292+
void WIRE_IT_HANDLER_0(void) { Wire.onService(); }
293+
void WIRE_IT_HANDLER_1(void) { Wire.onService(); }
294+
void WIRE_IT_HANDLER_2(void) { Wire.onService(); }
295+
void WIRE_IT_HANDLER_3(void) { Wire.onService(); }
296+
#endif // __SAMD51__
290297
#endif
291298

292299
#if WIRE_INTERFACES_COUNT > 1
@@ -295,6 +302,13 @@ void TwoWire::onService(void)
295302
void WIRE1_IT_HANDLER(void) {
296303
Wire1.onService();
297304
}
305+
306+
#if defined(__SAMD51__)
307+
void WIRE1_IT_HANDLER_0(void) { Wire1.onService(); }
308+
void WIRE1_IT_HANDLER_1(void) { Wire1.onService(); }
309+
void WIRE1_IT_HANDLER_2(void) { Wire1.onService(); }
310+
void WIRE1_IT_HANDLER_3(void) { Wire1.onService(); }
311+
#endif // __SAMD51__
298312
#endif
299313

300314
#if WIRE_INTERFACES_COUNT > 2
@@ -303,6 +317,13 @@ void TwoWire::onService(void)
303317
void WIRE2_IT_HANDLER(void) {
304318
Wire2.onService();
305319
}
320+
321+
#if defined(__SAMD51__)
322+
void WIRE2_IT_HANDLER_0(void) { Wire2.onService(); }
323+
void WIRE2_IT_HANDLER_1(void) { Wire2.onService(); }
324+
void WIRE2_IT_HANDLER_2(void) { Wire2.onService(); }
325+
void WIRE2_IT_HANDLER_3(void) { Wire2.onService(); }
326+
#endif // __SAMD51__
306327
#endif
307328

308329
#if WIRE_INTERFACES_COUNT > 3
@@ -311,6 +332,13 @@ void TwoWire::onService(void)
311332
void WIRE3_IT_HANDLER(void) {
312333
Wire3.onService();
313334
}
335+
336+
#if defined(__SAMD51__)
337+
void WIRE3_IT_HANDLER_0(void) { Wire3.onService(); }
338+
void WIRE3_IT_HANDLER_1(void) { Wire3.onService(); }
339+
void WIRE3_IT_HANDLER_2(void) { Wire3.onService(); }
340+
void WIRE3_IT_HANDLER_3(void) { Wire3.onService(); }
341+
#endif // __SAMD51__
314342
#endif
315343

316344
#if WIRE_INTERFACES_COUNT > 4
@@ -319,6 +347,13 @@ void TwoWire::onService(void)
319347
void WIRE4_IT_HANDLER(void) {
320348
Wire4.onService();
321349
}
350+
351+
#if defined(__SAMD51__)
352+
void WIRE4_IT_HANDLER_0(void) { Wire4.onService(); }
353+
void WIRE4_IT_HANDLER_1(void) { Wire4.onService(); }
354+
void WIRE4_IT_HANDLER_2(void) { Wire4.onService(); }
355+
void WIRE4_IT_HANDLER_3(void) { Wire4.onService(); }
356+
#endif // __SAMD51__
322357
#endif
323358

324359
#if WIRE_INTERFACES_COUNT > 5
@@ -327,5 +362,12 @@ void TwoWire::onService(void)
327362
void WIRE5_IT_HANDLER(void) {
328363
Wire5.onService();
329364
}
365+
366+
#if defined(__SAMD51__)
367+
void WIRE5_IT_HANDLER_0(void) { Wire5.onService(); }
368+
void WIRE5_IT_HANDLER_1(void) { Wire5.onService(); }
369+
void WIRE5_IT_HANDLER_2(void) { Wire5.onService(); }
370+
void WIRE5_IT_HANDLER_3(void) { Wire5.onService(); }
371+
#endif // __SAMD51__
330372
#endif
331373

sparkfun/samd/variants/SparkFun_SAMD51_Thing_Plus/variant.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ static const uint8_t FLASH_SCK = PIN_SPI1_SCK ;
166166
#define PIN_WIRE_SCL (21u)
167167
#define PERIPH_WIRE sercom3
168168
#define WIRE_IT_HANDLER SERCOM3_Handler
169+
#define WIRE_IT_HANDLER_0 SERCOM3_0_Handler
170+
#define WIRE_IT_HANDLER_1 SERCOM3_1_Handler
171+
#define WIRE_IT_HANDLER_2 SERCOM3_2_Handler
172+
#define WIRE_IT_HANDLER_3 SERCOM3_3_Handler
169173

170174
static const uint8_t SDA = PIN_WIRE_SDA;
171175
static const uint8_t SCL = PIN_WIRE_SCL;

0 commit comments

Comments
 (0)