support for 2
This commit is contained in:
parent
b0bacd9b0b
commit
a10f04ad6e
@ -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 \
|
||||
|
@ -27,22 +27,23 @@
|
||||
#include "shared-bindings/busio/I2C.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "pins.h"
|
||||
|
||||
STATIC mp_obj_t i2c_singleton = NULL;
|
||||
|
||||
STATIC mp_obj_t board_i2c(void) {
|
||||
#if !defined(DEFAULT_I2C_BUS_SCA) || !defined(DEFAULT_I2C_BUS_SCL)
|
||||
#if !defined(DEFAULT_I2C_BUS_SDA) || !defined(DEFAULT_I2C_BUS_SCL)
|
||||
mp_raise_NotImplementedError('no default bus');
|
||||
#endif
|
||||
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_SCA);
|
||||
assert_pin_free(DEFAULT_I2C_BUS_SDA);
|
||||
assert_pin_free(DEFAULT_I2C_BUS_SCL);
|
||||
common_hal_busio_i2c_construct(self, DEFAULT_I2C_BUS_SCA, DEFAULT_I2C_BUS_SCL, 400000);
|
||||
common_hal_busio_i2c_construct(self, DEFAULT_I2C_BUS_SCL, DEFAULT_I2C_BUS_SDA, 400000);
|
||||
i2c_singleton = (mp_obj_t)self;
|
||||
}
|
||||
return i2c_singleton;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
|
||||
|
@ -28,6 +28,6 @@
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H
|
||||
|
||||
void board_i2c(void);
|
||||
mp_obj_t board_i2c_obj;
|
||||
extern mp_obj_fun_builtin_fixed_t board_i2c_obj;
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H
|
||||
|
@ -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)
|
@ -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) },
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PA04)
|
||||
#define DEFAULT_I2C_BUS_SCA (&pin_PA05)
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PA05)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PA04)
|
||||
|
||||
#include "internal_flash.h"
|
||||
|
||||
|
@ -23,12 +23,3 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
||||
// https://learn.adafruit.com/building-circuitpython/build-circuitpython
|
||||
// make BOARD=gemma_m0
|
||||
// screen /dev/tty.usbmodem1411
|
||||
// enger
|
||||
// control AK to kill screen
|
||||
// import board
|
||||
// board.I2C()
|
||||
// two long clicks
|
||||
// /ports/amtel-sand/build-gemma_m0/firmware.uf2
|
Loading…
Reference in New Issue
Block a user