Skip to content

Commit 91db71e

Browse files
authored
Merge pull request adafruit#841 from matt-land/feature-i2c-gemma
Feature: shortcut I2C support for atmel-samd boards
2 parents 6a8db03 + 0511bec commit 91db71e

File tree

39 files changed

+191
-0
lines changed

39 files changed

+191
-0
lines changed

ports/atmel-samd/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF))
227227

228228
SRC_C = \
229229
audio_dma.c \
230+
board_busses.c \
230231
background.c \
231232
clocks.c \
232233
$(CHIP_FAMILY)_clocks.c \

ports/atmel-samd/board_busses.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "shared-bindings/busio/I2C.h"
28+
#include "shared-bindings/microcontroller/Pin.h"
29+
#include "mpconfigboard.h"
30+
#include "pins.h"
31+
#include "py/runtime.h"
32+
33+
34+
35+
#if !defined(DEFAULT_I2C_BUS_SDA) || !defined(DEFAULT_I2C_BUS_SCL)
36+
37+
STATIC mp_obj_t board_i2c(void) {
38+
//board_i2c_obj = NULL;
39+
mp_raise_NotImplementedError("No default I2C bus");
40+
return NULL;
41+
}
42+
43+
#else
44+
STATIC mp_obj_t i2c_singleton = NULL;
45+
46+
STATIC mp_obj_t board_i2c(void) {
47+
48+
if (i2c_singleton == NULL) {
49+
busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t);
50+
self->base.type = &busio_i2c_type;
51+
52+
assert_pin_free(DEFAULT_I2C_BUS_SDA);
53+
assert_pin_free(DEFAULT_I2C_BUS_SCL);
54+
common_hal_busio_i2c_construct(self, DEFAULT_I2C_BUS_SCL, DEFAULT_I2C_BUS_SDA, 400000, 0);
55+
i2c_singleton = (mp_obj_t)self;
56+
}
57+
return i2c_singleton;
58+
59+
}
60+
#endif
61+
62+
MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);

ports/atmel-samd/board_busses.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H
28+
#define MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H
29+
30+
void board_i2c(void);
31+
extern mp_obj_fun_builtin_fixed_t board_i2c_obj;
32+
33+
#endif // MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H

ports/atmel-samd/boards/arduino_zero/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@
1414
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
1515

1616
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
17+
18+
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
19+
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)

ports/atmel-samd/boards/arduino_zero/pins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "shared-bindings/board/__init__.h"
22

33
#include "samd21_pins.h"
4+
#include "board_busses.h"
5+
46

57
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
68
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -30,5 +32,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
3032
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
3133
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
3234
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
35+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
3336
};
3437
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@
5858

5959
// Explanation of how a user got into safe mode.
6060
#define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up"
61+
62+
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
63+
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)

ports/atmel-samd/boards/circuitplayground_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -56,5 +57,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
5657
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) },
5758
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA07) },
5859
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) },
60+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
5961
};
6062
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
1313

1414
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
15+
16+
#define DEFAULT_I2C_BUS_SCL (&pin_PA22)
17+
#define DEFAULT_I2C_BUS_SDA (&pin_PA23)

ports/atmel-samd/boards/feather_m0_adalogger/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -30,5 +31,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
3031
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
3132
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
3233
{ MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_PA17) },
34+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
3335
};
3436
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
1414

1515
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
16+
17+
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
18+
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)

ports/atmel-samd/boards/feather_m0_basic/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -23,5 +24,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
2324
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) },
2425
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
2526
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
27+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
2628
};
2729
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@
4848
#include "external_flash/external_flash.h"
4949

5050
#define BOARD_HAS_CRYSTAL 1
51+
52+
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
53+
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)

ports/atmel-samd/boards/feather_m0_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -24,5 +25,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
2425
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
2526
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
2627
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA06) },
28+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
2729
};
2830
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@
1313
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
1414

1515
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
16+
17+
// https://learn.adafruit.com/assets/46254
18+
// https://learn.adafruit.com/assets/46255
19+
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
20+
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)

ports/atmel-samd/boards/feather_m0_rfm69/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -26,5 +27,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
2627
{ MP_ROM_QSTR(MP_QSTR_RFM69_D0), MP_ROM_PTR(&pin_PA09) },
2728
{ MP_ROM_QSTR(MP_QSTR_RFM69_RST), MP_ROM_PTR(&pin_PA08) },
2829
{ MP_ROM_QSTR(MP_QSTR_RFM69_CS), MP_ROM_PTR(&pin_PA06) },
30+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
2931
};
3032
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
1414

1515
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
16+
17+
// https://learn.adafruit.com/assets/46254
18+
// https://learn.adafruit.com/assets/46255
19+
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
20+
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
21+

ports/atmel-samd/boards/feather_m0_rfm9x/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -26,5 +27,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
2627
{ MP_ROM_QSTR(MP_QSTR_RFM9X_D0), MP_ROM_PTR(&pin_PA09) },
2728
{ MP_ROM_QSTR(MP_QSTR_RFM9X_RST), MP_ROM_PTR(&pin_PA08) },
2829
{ MP_ROM_QSTR(MP_QSTR_RFM9X_CS), MP_ROM_PTR(&pin_PA06) },
30+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
2931
};
3032
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@
4747
#define EXTERNAL_FLASH_DEVICES S25FL064L
4848

4949
#include "external_flash/external_flash.h"
50+
51+
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
52+
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)

ports/atmel-samd/boards/feather_m0_supersized/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -24,5 +25,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
2425
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
2526
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
2627
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA06) },
28+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
2729
};
2830
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@
3131
#define EXTERNAL_FLASH_QSPI_DUAL
3232

3333
#include "external_flash/external_flash.h"
34+
35+
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
36+
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)

ports/atmel-samd/boards/feather_m4_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -26,5 +27,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
2627
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22) },
2728
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) },
2829
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PB23) },
30+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
2931
};
3032
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/gemma_m0/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
1414

15+
#define DEFAULT_I2C_BUS_SCL (&pin_PA05)
16+
#define DEFAULT_I2C_BUS_SDA (&pin_PA04)
17+
1518
#include "internal_flash.h"
1619

1720
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

ports/atmel-samd/boards/gemma_m0/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, // pad 1
@@ -19,5 +20,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
1920

2021
{ MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PA00) },
2122
{ MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PA01) },
23+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
2224
};
2325
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@
4646
GD25Q16C
4747

4848
#include "external_flash/external_flash.h"
49+
50+
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
51+
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)

ports/atmel-samd/boards/itsybitsy_m0_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) },
@@ -38,5 +39,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
3839

3940
{ MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PA01) },
4041
{ MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PA00) },
42+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
4143
};
4244
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@
3131
#define EXTERNAL_FLASH_DEVICES GD25Q16C
3232

3333
#include "external_flash/external_flash.h"
34+
35+
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
36+
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)

ports/atmel-samd/boards/itsybitsy_m4_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd51_pins.h"
2+
#include "board_busses.h"
23

34
// This mapping only includes functional names because pins broken
45
// out on connectors are labeled with their MCU name available from
@@ -35,5 +36,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
3536

3637
{ MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PB03) },
3738
{ MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PB02) },
39+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
3840
};
3941
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@
4949
#include "external_flash/external_flash.h"
5050

5151
#define BOARD_HAS_CRYSTAL 1
52+
53+
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
54+
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)

ports/atmel-samd/boards/metro_m0_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd21_pins.h"
2+
#include "board_busses.h"
23

34
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
45
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
@@ -29,5 +30,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
2930
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
3031
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
3132
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
33+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
3234
};
3335
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@
3232
#define EXTERNAL_FLASH_DEVICES S25FL116K, S25FL216K, GD25Q16C
3333

3434
#include "external_flash/external_flash.h"
35+
36+
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
37+
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)

ports/atmel-samd/boards/metro_m4_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "samd51_pins.h"
2+
#include "board_busses.h"
23

34
// This mapping only includes functional names because pins broken
45
// out on connectors are labeled with their MCU name available from
@@ -41,5 +42,6 @@ STATIC const mp_map_elem_t board_global_dict_table[] = {
4142

4243
{ MP_OBJ_NEW_QSTR(MP_QSTR_LED_RX), (mp_obj_t)&pin_PB06 },
4344
{ MP_OBJ_NEW_QSTR(MP_QSTR_LED_TX), (mp_obj_t)&pin_PA27 },
45+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
4446
};
4547
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

0 commit comments

Comments
 (0)