Adafruit Pixel Trinkey M0
This commit is contained in:
parent
c978768d37
commit
00a18fe2c9
8 changed files with 152 additions and 10 deletions
29
ports/atmel-samd/boards/adafruit_pixel_trinkey_m0/board.c
Normal file
29
ports/atmel-samd/boards/adafruit_pixel_trinkey_m0/board.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 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 "supervisor/board.h"
|
||||
|
||||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#define MICROPY_HW_BOARD_NAME "Adafruit Pixel Trinkey M0"
|
||||
#define MICROPY_HW_MCU_NAME "samd21e18"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_PA01)
|
||||
#define MICROPY_HW_NEOPIXEL_COUNT (1)
|
||||
|
||||
#define CIRCUITPY_BOARD_SPI (1)
|
||||
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_PA05, .mosi = &pin_PA04, .miso = &pin_PA06}}
|
||||
|
||||
#define IGNORE_PIN_PA00 1
|
||||
|
||||
#define IGNORE_PIN_PA03 1
|
||||
|
||||
#define IGNORE_PIN_PA07 1
|
||||
#define IGNORE_PIN_PA08 1
|
||||
#define IGNORE_PIN_PA09 1
|
||||
#define IGNORE_PIN_PA10 1
|
||||
#define IGNORE_PIN_PA11 1
|
||||
// no PA12
|
||||
// no PA13
|
||||
#define IGNORE_PIN_PA14 1
|
||||
#define IGNORE_PIN_PA15 1
|
||||
#define IGNORE_PIN_PA16 1
|
||||
#define IGNORE_PIN_PA17 1
|
||||
#define IGNORE_PIN_PA18 1
|
||||
#define IGNORE_PIN_PA19 1
|
||||
// no PA20
|
||||
// no PA21
|
||||
#define IGNORE_PIN_PA22 1
|
||||
#define IGNORE_PIN_PA23 1
|
||||
// USB is always used internally so skip the pin objects for it.
|
||||
#define IGNORE_PIN_PA24 1
|
||||
#define IGNORE_PIN_PA25 1
|
||||
// no PA26
|
||||
#define IGNORE_PIN_PA27 1
|
||||
#define IGNORE_PIN_PA28 1
|
||||
// no PA29
|
||||
#define IGNORE_PIN_PA30 1
|
||||
#define IGNORE_PIN_PA31 1
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
USB_VID = 0x239A
|
||||
USB_PID = 0x8156
|
||||
USB_PRODUCT = "Pixel Trinkey M0"
|
||||
USB_MANUFACTURER = "Adafruit Industries LLC"
|
||||
|
||||
CHIP_VARIANT = SAMD21E18A
|
||||
CHIP_FAMILY = samd21
|
||||
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_AUDIOCORE = 0
|
||||
CIRCUITPY_BUSIO_I2C = 0
|
||||
CIRCUITPY_PULSEIO = 1
|
||||
CIRCUITPY_PULSEIO_PULSEOUT = 0
|
||||
CIRCUITPY_PWMIO = 1
|
||||
CIRCUITPY_ROTARYIO = 0
|
||||
CIRCUITPY_RTC = 0
|
||||
CIRCUITPY_TOUCHIO = 0
|
||||
|
||||
CIRCUITPY_PIXELBUF = 1
|
||||
|
||||
# Include these Python libraries in firmware.
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar
|
||||
23
ports/atmel-samd/boards/adafruit_pixel_trinkey_m0/pins.c
Normal file
23
ports/atmel-samd/boards/adafruit_pixel_trinkey_m0/pins.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA01) },
|
||||
|
||||
// 10K-10K voltage divider
|
||||
{ MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA02) },
|
||||
|
||||
// GPIO on 3-pin JST SH
|
||||
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_DATA), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA04) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_CLOCK), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
||||
|
|
@ -173,13 +173,16 @@ CFLAGS += -DCIRCUITPY_BUILTINS_POW3=$(CIRCUITPY_BUILTINS_POW3)
|
|||
CIRCUITPY_BUSIO ?= 1
|
||||
CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO)
|
||||
|
||||
# These two flags pretend to implement their class but raise a ValueError due to
|
||||
# unsupported pins. This should be used sparingly on boards that don't break out
|
||||
# generic IO but need parts of busio.
|
||||
CIRCUITPY_BUSIO_SPI ?= 1
|
||||
# Allow disabling of individual busio functionality.
|
||||
# This should be used sparingly on specialized boards that can only implement parts of busio
|
||||
# due to pin restrictions.
|
||||
CIRCUITPY_BUSIO_I2C ?= $(CIRCUITPY_BUSIO)
|
||||
CFLAGS += -DCIRCUITPY_BUSIO_I2C=$(CIRCUITPY_BUSIO_I2C)
|
||||
|
||||
CIRCUITPY_BUSIO_SPI ?= $(CIRCUITPY_BUSIO)
|
||||
CFLAGS += -DCIRCUITPY_BUSIO_SPI=$(CIRCUITPY_BUSIO_SPI)
|
||||
|
||||
CIRCUITPY_BUSIO_UART ?= 1
|
||||
CIRCUITPY_BUSIO_UART ?= $(CIRCUITPY_BUSIO)
|
||||
CFLAGS += -DCIRCUITPY_BUSIO_UART=$(CIRCUITPY_BUSIO_UART)
|
||||
|
||||
CIRCUITPY_CAMERA ?= 0
|
||||
|
|
@ -409,6 +412,12 @@ CFLAGS += -DCIRCUITPY_PS2IO=$(CIRCUITPY_PS2IO)
|
|||
CIRCUITPY_PULSEIO ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_PULSEIO=$(CIRCUITPY_PULSEIO)
|
||||
|
||||
# Allow disabling of pulseio.PulseOut
|
||||
# This should be used sparingly on specialized boards that need PulseIin but
|
||||
# don't have the space for PulseOut.
|
||||
CIRCUITPY_PULSEIO_PULSEOUT ?= $(CIRCUITPY_PULSEIO)
|
||||
CFLAGS += -DCIRCUITPY_PULSEIO_PULSEOUT=$(CIRCUITPY_PULSEIO_PULSEOUT)
|
||||
|
||||
CIRCUITPY_PWMIO ?= 1
|
||||
CFLAGS += -DCIRCUITPY_PWMIO=$(CIRCUITPY_PWMIO)
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@
|
|||
//| """
|
||||
//| ...
|
||||
STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
#if CIRCUITPY_BUSIO_I2C
|
||||
busio_i2c_obj_t *self = mp_obj_malloc(busio_i2c_obj_t, &busio_i2c_type);
|
||||
enum { ARG_scl, ARG_sda, ARG_frequency, ARG_timeout };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
|
|
@ -83,8 +84,13 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
|||
|
||||
common_hal_busio_i2c_construct(self, scl, sda, args[ARG_frequency].u_int, args[ARG_timeout].u_int);
|
||||
return (mp_obj_t)self;
|
||||
#else
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
#endif // CIRCUITPY_BUSIO_I2C
|
||||
|
||||
}
|
||||
|
||||
#if CIRCUITPY_BUSIO_I2C
|
||||
//| def deinit(self) -> None:
|
||||
//| """Releases control of the underlying hardware so other classes can use it."""
|
||||
//| ...
|
||||
|
|
@ -371,8 +377,10 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p
|
|||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_then_readfrom_obj, 1, busio_i2c_writeto_then_readfrom);
|
||||
#endif // CIRCUITPY_BUSIO_I2C
|
||||
|
||||
STATIC const mp_rom_map_elem_t busio_i2c_locals_dict_table[] = {
|
||||
#if CIRCUITPY_BUSIO_I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&busio_i2c_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busio_i2c___exit___obj) },
|
||||
|
|
@ -384,6 +392,7 @@ STATIC const mp_rom_map_elem_t busio_i2c_locals_dict_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_readfrom_into), MP_ROM_PTR(&busio_i2c_readfrom_into_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_writeto), MP_ROM_PTR(&busio_i2c_writeto_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_writeto_then_readfrom), MP_ROM_PTR(&busio_i2c_writeto_then_readfrom_obj) },
|
||||
#endif // CIRCUITPY_BUSIO_I2C
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(busio_i2c_locals_dict, busio_i2c_locals_dict_table);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
|||
common_hal_busio_spi_construct(self, clock, mosi, miso, args[ARG_half_duplex].u_bool);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
#else
|
||||
raise_ValueError_invalid_pins();
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
#endif // CIRCUITPY_BUSIO_SPI
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,11 @@
|
|||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/pulseio/PulseOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/util.h"
|
||||
|
||||
//| class PulseOut:
|
||||
//| """Pulse PWM "carrier" output on and off. This is commonly used in infrared remotes. The
|
||||
//| pulsed signal consists of timed on and off periods. Unlike PWM, there is no set duration
|
||||
//| """Pulse PWM-modulated "carrier" output on and off. This is commonly used in infrared remotes. The
|
||||
//| pulsed signal consists of timed on and off periods. Unlike `pwmio.PWMOut`, there is no set duration
|
||||
//| for on and off pairs."""
|
||||
//|
|
||||
//| def __init__(
|
||||
|
|
@ -53,7 +52,6 @@
|
|||
//|
|
||||
//| import array
|
||||
//| import pulseio
|
||||
//| import pwmio
|
||||
//| import board
|
||||
//|
|
||||
//| # 50% duty cycle at 38kHz.
|
||||
|
|
@ -67,6 +65,7 @@
|
|||
//| pulse.send(pulses)"""
|
||||
//| ...
|
||||
STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
#if CIRCUITPY_PULSEIO_PULSEOUT
|
||||
enum { ARG_pin, ARG_frequency, ARG_duty_cycle};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
|
|
@ -84,8 +83,12 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar
|
|||
self->base.type = &pulseio_pulseout_type;
|
||||
common_hal_pulseio_pulseout_construct(self, pin, frequency, duty_cycle);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
#else
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CIRCUITPY_PULSEIO_PULSEOUT
|
||||
//| def deinit(self) -> None:
|
||||
//| """Deinitialises the PulseOut and releases any hardware resources for reuse."""
|
||||
//| ...
|
||||
|
|
@ -138,14 +141,17 @@ STATIC mp_obj_t pulseio_pulseout_obj_send(mp_obj_t self_in, mp_obj_t pulses) {
|
|||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(pulseio_pulseout_send_obj, pulseio_pulseout_obj_send);
|
||||
#endif // CIRCUITPY_PULSEIO_PULSEOUT
|
||||
|
||||
STATIC const mp_rom_map_elem_t pulseio_pulseout_locals_dict_table[] = {
|
||||
// Methods
|
||||
#if CIRCUITPY_PULSEIO_PULSEOUT
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pulseio_pulseout_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&pulseio_pulseout_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&pulseio_pulseout___exit___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&pulseio_pulseout_send_obj) },
|
||||
#endif // CIRCUITPY_PULSEIO_PULSEOUT
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(pulseio_pulseout_locals_dict, pulseio_pulseout_locals_dict_table);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue