Skip to content
Merged
1 change: 1 addition & 0 deletions ports/atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF))

SRC_C = \
audio_dma.c \
board_busses.c \
background.c \
clocks.c \
$(CHIP_FAMILY)_clocks.c \
Expand Down
62 changes: 62 additions & 0 deletions ports/atmel-samd/board_busses.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "shared-bindings/busio/I2C.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "mpconfigboard.h"
#include "pins.h"
#include "py/runtime.h"



#if !defined(DEFAULT_I2C_BUS_SDA) || !defined(DEFAULT_I2C_BUS_SCL)

STATIC mp_obj_t board_i2c(void) {
//board_i2c_obj = NULL;
mp_raise_NotImplementedError("No default I2C bus");
return NULL;
}

#else
STATIC mp_obj_t i2c_singleton = NULL;

STATIC mp_obj_t board_i2c(void) {

if (i2c_singleton == NULL) {
busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t);
self->base.type = &busio_i2c_type;

assert_pin_free(DEFAULT_I2C_BUS_SDA);
assert_pin_free(DEFAULT_I2C_BUS_SCL);
common_hal_busio_i2c_construct(self, DEFAULT_I2C_BUS_SCL, DEFAULT_I2C_BUS_SDA, 400000, 0);
i2c_singleton = (mp_obj_t)self;
}
return i2c_singleton;

}
#endif

MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
33 changes: 33 additions & 0 deletions ports/atmel-samd/board_busses.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H
#define MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H

void board_i2c(void);
extern mp_obj_fun_builtin_fixed_t board_i2c_obj;

#endif // MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/arduino_zero/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
#define CIRCUITPY_INTERNAL_NVM_SIZE 0

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

#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/arduino_zero/pins.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "shared-bindings/board/__init__.h"

#include "samd21_pins.h"
#include "board_busses.h"


STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand Down Expand Up @@ -30,5 +32,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@

// Explanation of how a user got into safe mode.
#define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up"

#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/circuitplayground_express/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand Down Expand Up @@ -56,5 +57,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA07) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
#define CIRCUITPY_INTERNAL_NVM_SIZE 0

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

#define DEFAULT_I2C_BUS_SCL (&pin_PA22)
#define DEFAULT_I2C_BUS_SDA (&pin_PA23)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/feather_m0_adalogger/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand Down Expand Up @@ -30,5 +31,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
{ MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_PA17) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
#define CIRCUITPY_INTERNAL_NVM_SIZE 0

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

#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/feather_m0_basic/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand All @@ -23,5 +24,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) },
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@
#include "external_flash/external_flash.h"

#define BOARD_HAS_CRYSTAL 1

#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/feather_m0_express/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand All @@ -24,5 +25,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
5 changes: 5 additions & 0 deletions ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
#define CIRCUITPY_INTERNAL_NVM_SIZE 0

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

// https://learn.adafruit.com/assets/46254
// https://learn.adafruit.com/assets/46255
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/feather_m0_rfm69/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand Down Expand Up @@ -26,5 +27,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_RFM69_D0), MP_ROM_PTR(&pin_PA09) },
{ MP_ROM_QSTR(MP_QSTR_RFM69_RST), MP_ROM_PTR(&pin_PA08) },
{ MP_ROM_QSTR(MP_QSTR_RFM69_CS), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
6 changes: 6 additions & 0 deletions ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
#define CIRCUITPY_INTERNAL_NVM_SIZE 0

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

// https://learn.adafruit.com/assets/46254
// https://learn.adafruit.com/assets/46255
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)

2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/feather_m0_rfm9x/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand Down Expand Up @@ -26,5 +27,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_RFM9X_D0), MP_ROM_PTR(&pin_PA09) },
{ MP_ROM_QSTR(MP_QSTR_RFM9X_RST), MP_ROM_PTR(&pin_PA08) },
{ MP_ROM_QSTR(MP_QSTR_RFM9X_CS), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@
#define EXTERNAL_FLASH_DEVICES S25FL064L

#include "external_flash/external_flash.h"

#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/feather_m0_supersized/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand All @@ -24,5 +25,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
#define EXTERNAL_FLASH_QSPI_DUAL

#include "external_flash/external_flash.h"

#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/feather_m4_express/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand Down Expand Up @@ -26,5 +27,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) },
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PB23) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/gemma_m0/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

#define CIRCUITPY_INTERNAL_NVM_SIZE 0

#define DEFAULT_I2C_BUS_SCL (&pin_PA05)
#define DEFAULT_I2C_BUS_SDA (&pin_PA04)

#include "internal_flash.h"

#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
Expand Down
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/gemma_m0/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

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

{ MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PA00) },
{ MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PA01) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@
GD25Q16C

#include "external_flash/external_flash.h"

#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/itsybitsy_m0_express/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

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

{ MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PA01) },
{ MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PA00) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
#define EXTERNAL_FLASH_DEVICES GD25Q16C

#include "external_flash/external_flash.h"

#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/itsybitsy_m4_express/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd51_pins.h"
#include "board_busses.h"

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

{ MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PB03) },
{ MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PB02) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@
#include "external_flash/external_flash.h"

#define BOARD_HAS_CRYSTAL 1

#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/metro_m0_express/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd21_pins.h"
#include "board_busses.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
Expand Down Expand Up @@ -29,5 +30,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
#define EXTERNAL_FLASH_DEVICES S25FL116K, S25FL216K, GD25Q16C

#include "external_flash/external_flash.h"

#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/metro_m4_express/pins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "samd51_pins.h"
#include "board_busses.h"

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

{ MP_OBJ_NEW_QSTR(MP_QSTR_LED_RX), (mp_obj_t)&pin_PB06 },
{ MP_OBJ_NEW_QSTR(MP_QSTR_LED_TX), (mp_obj_t)&pin_PA27 },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
Loading