finish Makefile refactoring; nrf builds work
This commit is contained in:
parent
cf545cd477
commit
a345ef28f2
@ -40,7 +40,7 @@ include boards/$(BOARD)/mpconfigboard.mk
|
||||
# Port-specific
|
||||
include mpconfigport.mk
|
||||
# CircuitPython-specific
|
||||
include ../circuitpy-common/mpconfig_circuitpy.mk
|
||||
include $(TOP)/ports/circuitpy-common/mpconfig_circuitpy.mk
|
||||
|
||||
# qstr definitions (must come before including py.mk)
|
||||
QSTR_DEFS = qstrdefsport.h
|
||||
@ -50,6 +50,9 @@ include $(TOP)/py/py.mk
|
||||
|
||||
include $(TOP)/supervisor/supervisor.mk
|
||||
|
||||
# Include make rules and variables common across CircuitPython builds.
|
||||
include $(TOP)/ports/circuitpy-common/circuitpy_defns.mk
|
||||
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
||||
HAL_DIR=hal/$(MCU_SERIES)
|
||||
@ -79,36 +82,6 @@ INC += -I. \
|
||||
-I../../supervisor/shared/usb \
|
||||
-I$(BUILD)
|
||||
|
||||
BASE_CFLAGS = \
|
||||
-fsingle-precision-constant \
|
||||
-fno-strict-aliasing \
|
||||
-Wdouble-promotion \
|
||||
-Wno-endif-labels \
|
||||
-Wstrict-prototypes \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wnested-externs \
|
||||
-Wunreachable-code \
|
||||
-Wcast-align \
|
||||
-Wno-error=lto-type-mismatch \
|
||||
-D__$(CHIP_VARIANT)__ \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-fshort-enums \
|
||||
-DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \
|
||||
-DCIRCUITPY_CANARY_WORD=0xADAF00 \
|
||||
-DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
|
||||
--param max-inline-insns-single=500
|
||||
|
||||
# Use these flags to debug build times and header includes.
|
||||
# -ftime-report
|
||||
# -H
|
||||
|
||||
# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt.
|
||||
|
||||
@ -169,22 +142,7 @@ CFLAGS += \
|
||||
-DSAMD51
|
||||
endif
|
||||
|
||||
ifneq ($(FROZEN_DIR),)
|
||||
# To use frozen source modules, put your .py files in a subdirectory (eg scripts/)
|
||||
# and then invoke make with FROZEN_DIR=scripts (be sure to build from scratch).
|
||||
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
||||
CFLAGS += -Wno-error=lto-type-mismatch
|
||||
endif
|
||||
|
||||
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
|
||||
# then invoke make with FROZEN_MPY_DIR=frozen or FROZEN_MPY_DIRS="dir1 dir2"
|
||||
# (be sure to build from scratch).
|
||||
|
||||
ifneq ($(FROZEN_MPY_DIRS),)
|
||||
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
||||
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
||||
CFLAGS += -Wno-error=lto-type-mismatch
|
||||
endif
|
||||
|
||||
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
|
||||
LIBS := -lgcc -lc
|
||||
@ -194,20 +152,6 @@ ifndef INTERNAL_LIBM
|
||||
LIBS += -lm
|
||||
endif
|
||||
|
||||
# Propagate longint choice from .mk to C. There's no easy string comparison
|
||||
# in cpp coniditionals, so we #define separate names for each.
|
||||
ifeq ($(LONGINT_IMPL),NONE)
|
||||
CFLAGS += -DLONGINT_IMPL_NONE
|
||||
endif
|
||||
|
||||
ifeq ($(LONGINT_IMPL),MPZ)
|
||||
CFLAGS += -DLONGINT_IMPL_MPZ
|
||||
endif
|
||||
|
||||
ifeq ($(LONGINT_IMPL),LONGLONG)
|
||||
CFLAGS += -DLONGINT_IMPL_LONGLONG
|
||||
endif
|
||||
|
||||
ifeq ($(CHIP_FAMILY), samd21)
|
||||
LDFLAGS += -mthumb -mcpu=cortex-m0plus -Lasf/thirdparty/CMSIS/Lib/GCC/
|
||||
BOOTLOADER_SIZE := 0x2000
|
||||
@ -302,6 +246,7 @@ SRC_C = \
|
||||
supervisor/shared/memory.c \
|
||||
tick.c \
|
||||
|
||||
|
||||
ifeq ($(CIRCUITPY_NETWORK),1)
|
||||
CFLAGS += -DMICROPY_PY_NETWORK=1
|
||||
|
||||
@ -322,231 +267,6 @@ SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
|
||||
endif # MICROPY_PY_WIZNET5K
|
||||
endif # CIRCUITPY_NETWORK
|
||||
|
||||
ifeq ($(CIRCUITPY_ANALOGIO),1)
|
||||
SRC_PATTERNS += analogio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_AUDIOBUSIO),1)
|
||||
SRC_PATTERNS += audiobusio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_AUDIOIO),1)
|
||||
SRC_PATTERNS += audioio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BITBANGIO),1)
|
||||
SRC_PATTERNS += bitbangio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BOARD),1)
|
||||
SRC_PATTERNS += board/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BUSIO),1)
|
||||
SRC_PATTERNS += busio/% bitbangio/OneWire.%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_DIGITALIO),1)
|
||||
SRC_PATTERNS += digitalio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_DISPLAYIO),1)
|
||||
SRC_PATTERNS += displayio/% terminalio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_GAMEPAD),1)
|
||||
SRC_PATTERNS += gamepad/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_I2CSLAVE),1)
|
||||
SRC_PATTERNS += i2cslave/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_MATH),1)
|
||||
SRC_PATTERNS += math/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_MICROCONTROLLER),1)
|
||||
SRC_PATTERNS += microcontroller/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_NEOPIXEL_WRITE),1)
|
||||
SRC_PATTERNS += neopixel_write/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_NETWORK),1)
|
||||
SRC_PATTERNS += network/% socket/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_NVM),1)
|
||||
SRC_PATTERNS += nvm/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_OS),1)
|
||||
SRC_PATTERNS += os/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_PIXELBUF),1)
|
||||
SRC_PATTERNS += _pixelbuf/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_PULSEIO),1)
|
||||
SRC_PATTERNS += pulseio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_RANDOM),1)
|
||||
SRC_PATTERNS += random/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_ROTARYIO),1)
|
||||
SRC_PATTERNS += rotaryio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_RTC),1)
|
||||
SRC_PATTERNS += rtc/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_SAMD),1)
|
||||
SRC_PATTERNS += samd/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_STAGE),1)
|
||||
SRC_PATTERNS += _stage/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_STORAGE),1)
|
||||
SRC_PATTERNS += storage/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_STRUCT),1)
|
||||
SRC_PATTERNS += struct/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_SUPERVISOR),1)
|
||||
SRC_PATTERNS += supervisor/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_TIME),1)
|
||||
SRC_PATTERNS += time/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_TOUCHIO),1)
|
||||
SRC_PATTERNS += touchio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_UHEAP),1)
|
||||
SRC_PATTERNS += uheap/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_USB_HID),1)
|
||||
SRC_PATTERNS += usb_hid/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_USB_MIDI),1)
|
||||
SRC_PATTERNS += usb_midi/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_USTACK),1)
|
||||
SRC_PATTERNS += ustack/%
|
||||
endif
|
||||
|
||||
# All possible sources are listed here, and are filtered by SRC_PATTERNS.
|
||||
SRC_COMMON_HAL = \
|
||||
$(filter $(SRC_PATTERNS), \
|
||||
analogio/AnalogIn.c \
|
||||
analogio/AnalogOut.c \
|
||||
analogio/__init__.c \
|
||||
audiobusio/__init__.c \
|
||||
audiobusio/I2SOut.c \
|
||||
audiobusio/PDMIn.c \
|
||||
audioio/__init__.c \
|
||||
audioio/AudioOut.c \
|
||||
board/__init__.c \
|
||||
busio/I2C.c \
|
||||
busio/SPI.c \
|
||||
busio/UART.c \
|
||||
busio/__init__.c \
|
||||
digitalio/DigitalInOut.c \
|
||||
digitalio/__init__.c \
|
||||
displayio/ParallelBus.c \
|
||||
i2cslave/I2CSlave.c \
|
||||
i2cslave/__init__.c \
|
||||
microcontroller/Pin.c \
|
||||
microcontroller/Processor.c \
|
||||
microcontroller/__init__.c \
|
||||
neopixel_write/__init__.c \
|
||||
nvm/ByteArray.c \
|
||||
nvm/__init__.c \
|
||||
os/__init__.c \
|
||||
pulseio/PWMOut.c \
|
||||
pulseio/PulseIn.c \
|
||||
pulseio/PulseOut.c \
|
||||
pulseio/__init__.c \
|
||||
rotaryio/IncrementalEncoder.c \
|
||||
rotaryio/__init__.c \
|
||||
rtc/RTC.c \
|
||||
rtc/__init__.c \
|
||||
supervisor/Runtime.c \
|
||||
supervisor/__init__.c \
|
||||
time/__init__.c \
|
||||
touchio/TouchIn.c \
|
||||
touchio/__init__.c \
|
||||
)
|
||||
|
||||
# These don't have corresponding files in each port but are still located in
|
||||
# shared-bindings to make it clear what the contents of the modules are.
|
||||
# All possible sources are listed here, and are filtered by SRC_PATTERNS.
|
||||
SRC_BINDINGS_ENUMS = \
|
||||
$(filter $(SRC_PATTERNS), \
|
||||
digitalio/Direction.c \
|
||||
digitalio/DriveMode.c \
|
||||
digitalio/Pull.c \
|
||||
displayio/Glyph.c \
|
||||
microcontroller/RunMode.c \
|
||||
math/__init__.c \
|
||||
supervisor/__init__.c \
|
||||
)
|
||||
|
||||
SRC_BINDINGS_ENUMS += \
|
||||
help.c \
|
||||
util.c
|
||||
|
||||
# All possible sources are listed here, and are filtered by SRC_PATTERNS.
|
||||
SRC_SHARED_MODULE = \
|
||||
$(filter $(SRC_PATTERNS), \
|
||||
_pixelbuf/PixelBuf.c \
|
||||
_pixelbuf/__init__.c \
|
||||
_stage/Layer.c \
|
||||
_stage/Text.c \
|
||||
_stage/__init__.c \
|
||||
audioio/__init__.c \
|
||||
audioio/Mixer.c \
|
||||
audioio/RawSample.c \
|
||||
audioio/WaveFile.c \
|
||||
bitbangio/I2C.c \
|
||||
bitbangio/OneWire.c \
|
||||
bitbangio/SPI.c \
|
||||
bitbangio/__init__.c \
|
||||
busio/OneWire.c \
|
||||
displayio/Bitmap.c \
|
||||
displayio/BuiltinFont.c \
|
||||
displayio/ColorConverter.c \
|
||||
displayio/Display.c \
|
||||
displayio/FourWire.c \
|
||||
displayio/Group.c \
|
||||
displayio/OnDiskBitmap.c \
|
||||
displayio/Palette.c \
|
||||
displayio/Shape.c \
|
||||
displayio/TileGrid.c \
|
||||
displayio/__init__.c \
|
||||
gamepad/GamePad.c \
|
||||
gamepad/__init__.c \
|
||||
os/__init__.c \
|
||||
random/__init__.c \
|
||||
socket/__init__.c \
|
||||
network/__init__.c \
|
||||
storage/__init__.c \
|
||||
struct/__init__.c \
|
||||
terminalio/Terminal.c \
|
||||
terminalio/__init__.c \
|
||||
uheap/__init__.c \
|
||||
ustack/__init__.c \
|
||||
)
|
||||
|
||||
ifeq ($(INTERNAL_LIBM),1)
|
||||
SRC_LIBM = \
|
||||
$(addprefix lib/,\
|
||||
libm/math.c \
|
||||
libm/roundf.c \
|
||||
libm/fmodf.c \
|
||||
libm/nearbyintf.c \
|
||||
libm/ef_sqrt.c \
|
||||
libm/kf_rem_pio2.c \
|
||||
libm/kf_sin.c \
|
||||
libm/kf_cos.c \
|
||||
libm/kf_tan.c \
|
||||
libm/ef_rem_pio2.c \
|
||||
libm/sf_sin.c \
|
||||
libm/sf_cos.c \
|
||||
libm/sf_tan.c \
|
||||
libm/sf_frexp.c \
|
||||
libm/sf_modf.c \
|
||||
libm/sf_ldexp.c \
|
||||
libm/asinfacosf.c \
|
||||
libm/atanf.c \
|
||||
libm/atan2f.c \
|
||||
)
|
||||
endif
|
||||
|
||||
ifeq ($(CIRCUITPY_NETWORK),1)
|
||||
ifneq ($(MICROPY_PY_WIZNET5K),0)
|
||||
SRC_SHARED_MODULE += wiznet/__init__.c wiznet/wiznet5k.c
|
||||
@ -577,7 +297,7 @@ endif
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
|
||||
|
||||
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(STM_SRC_C)
|
||||
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
|
||||
# Sources that only hold QSTRs after pre-processing.
|
||||
SRC_QSTR_PREPROCESSOR += peripherals/samd/$(CHIP_FAMILY)/clocks.c
|
||||
|
||||
|
@ -64,9 +64,10 @@
|
||||
#ifdef SAMD51
|
||||
#define CIRCUITPY_MCU_FAMILY samd51
|
||||
#define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51"
|
||||
// 128KiB
|
||||
// 128KiB heap
|
||||
#define PORT_HEAP_SIZE (0x20000)
|
||||
#define SPI_FLASH_MAX_BAUDRATE 24000000
|
||||
// 24kiB stack
|
||||
#define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000
|
||||
#define MICROPY_CPYTHON_COMPAT (1)
|
||||
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
|
||||
@ -85,7 +86,8 @@
|
||||
|
||||
#define MICROPY_PORT_ROOT_POINTERS \
|
||||
CIRCUITPY_COMMON_ROOT_POINTERS \
|
||||
mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]; \
|
||||
mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT] \
|
||||
;
|
||||
|
||||
#include "ports/circuitpy-common/mpconfig_circuitpy.h"
|
||||
|
||||
|
346
ports/circuitpy-common/circuitpy_defns.mk
Normal file
346
ports/circuitpy-common/circuitpy_defns.mk
Normal file
@ -0,0 +1,346 @@
|
||||
# This file is part of the MicroPython project, http://micropython.org/
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2019 Dan Halbert 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.
|
||||
|
||||
# Common Makefile definitions that can be shared across CircuitPython ports.
|
||||
|
||||
###
|
||||
# Common compile warnings.
|
||||
|
||||
BASE_CFLAGS = \
|
||||
-fsingle-precision-constant \
|
||||
-fno-strict-aliasing \
|
||||
-Wdouble-promotion \
|
||||
-Wno-endif-labels \
|
||||
-Wstrict-prototypes \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wnested-externs \
|
||||
-Wunreachable-code \
|
||||
-Wcast-align \
|
||||
-Wno-error=lto-type-mismatch \
|
||||
-D__$(CHIP_VARIANT)__ \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-fshort-enums \
|
||||
-DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \
|
||||
-DCIRCUITPY_CANARY_WORD=0xADAF00 \
|
||||
-DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
|
||||
--param max-inline-insns-single=500
|
||||
|
||||
# Use these flags to debug build times and header includes.
|
||||
# -ftime-report
|
||||
# -H
|
||||
|
||||
|
||||
###
|
||||
# Handle frozen modules.
|
||||
|
||||
ifneq ($(FROZEN_DIR),)
|
||||
# To use frozen source modules, put your .py files in a subdirectory (eg scripts/)
|
||||
# and then invoke make with FROZEN_DIR=scripts (be sure to build from scratch).
|
||||
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
||||
CFLAGS += -Wno-error=lto-type-mismatch
|
||||
endif
|
||||
|
||||
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
|
||||
# then invoke make with FROZEN_MPY_DIR=frozen or FROZEN_MPY_DIRS="dir1 dir2"
|
||||
# (be sure to build from scratch).
|
||||
|
||||
ifneq ($(FROZEN_MPY_DIRS),)
|
||||
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
||||
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
||||
CFLAGS += -Wno-error=lto-type-mismatch
|
||||
endif
|
||||
|
||||
|
||||
###
|
||||
# Propagate longint choice from .mk to C. There's no easy string comparison
|
||||
# in cpp conditionals, so we #define separate names for each.
|
||||
ifeq ($(LONGINT_IMPL),NONE)
|
||||
CFLAGS += -DLONGINT_IMPL_NONE
|
||||
endif
|
||||
|
||||
ifeq ($(LONGINT_IMPL),MPZ)
|
||||
CFLAGS += -DLONGINT_IMPL_MPZ
|
||||
endif
|
||||
|
||||
ifeq ($(LONGINT_IMPL),LONGLONG)
|
||||
CFLAGS += -DLONGINT_IMPL_LONGLONG
|
||||
endif
|
||||
|
||||
|
||||
###
|
||||
# Select which builtin modules to compile and include.
|
||||
|
||||
ifeq ($(CIRCUITPY_ANALOGIO),1)
|
||||
SRC_PATTERNS += analogio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_AUDIOBUSIO),1)
|
||||
SRC_PATTERNS += audiobusio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_AUDIOIO),1)
|
||||
SRC_PATTERNS += audioio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BITBANGIO),1)
|
||||
SRC_PATTERNS += bitbangio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BLEIO),1)
|
||||
SRC_PATTERNS += bleio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BOARD),1)
|
||||
SRC_PATTERNS += board/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BUSIO),1)
|
||||
SRC_PATTERNS += busio/% bitbangio/OneWire.%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_DIGITALIO),1)
|
||||
SRC_PATTERNS += digitalio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_DISPLAYIO),1)
|
||||
SRC_PATTERNS += displayio/% terminalio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_GAMEPAD),1)
|
||||
SRC_PATTERNS += gamepad/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_I2CSLAVE),1)
|
||||
SRC_PATTERNS += i2cslave/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_MATH),1)
|
||||
SRC_PATTERNS += math/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_MICROCONTROLLER),1)
|
||||
SRC_PATTERNS += microcontroller/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_NEOPIXEL_WRITE),1)
|
||||
SRC_PATTERNS += neopixel_write/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_NETWORK),1)
|
||||
SRC_PATTERNS += network/% socket/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_NVM),1)
|
||||
SRC_PATTERNS += nvm/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_OS),1)
|
||||
SRC_PATTERNS += os/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_PIXELBUF),1)
|
||||
SRC_PATTERNS += _pixelbuf/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_PULSEIO),1)
|
||||
SRC_PATTERNS += pulseio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_RANDOM),1)
|
||||
SRC_PATTERNS += random/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_ROTARYIO),1)
|
||||
SRC_PATTERNS += rotaryio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_RTC),1)
|
||||
SRC_PATTERNS += rtc/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_SAMD),1)
|
||||
SRC_PATTERNS += samd/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_STAGE),1)
|
||||
SRC_PATTERNS += _stage/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_STORAGE),1)
|
||||
SRC_PATTERNS += storage/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_STRUCT),1)
|
||||
SRC_PATTERNS += struct/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_SUPERVISOR),1)
|
||||
SRC_PATTERNS += supervisor/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_TIME),1)
|
||||
SRC_PATTERNS += time/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_TOUCHIO),1)
|
||||
SRC_PATTERNS += touchio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_UHEAP),1)
|
||||
SRC_PATTERNS += uheap/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_USB_HID),1)
|
||||
SRC_PATTERNS += usb_hid/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_USB_MIDI),1)
|
||||
SRC_PATTERNS += usb_midi/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_USTACK),1)
|
||||
SRC_PATTERNS += ustack/%
|
||||
endif
|
||||
|
||||
# All possible sources are listed here, and are filtered by SRC_PATTERNS.
|
||||
SRC_COMMON_HAL = \
|
||||
$(filter $(SRC_PATTERNS), \
|
||||
analogio/AnalogIn.c \
|
||||
analogio/AnalogOut.c \
|
||||
analogio/__init__.c \
|
||||
audiobusio/__init__.c \
|
||||
audiobusio/I2SOut.c \
|
||||
audiobusio/PDMIn.c \
|
||||
audioio/__init__.c \
|
||||
audioio/AudioOut.c \
|
||||
bleio/__init__.c \
|
||||
bleio/Adapter.c \
|
||||
bleio/Broadcaster.c \
|
||||
bleio/Characteristic.c \
|
||||
bleio/CharacteristicBuffer.c \
|
||||
bleio/Descriptor.c \
|
||||
bleio/Peripheral.c \
|
||||
bleio/Scanner.c \
|
||||
bleio/Service.c \
|
||||
bleio/UUID.c \
|
||||
board/__init__.c \
|
||||
busio/I2C.c \
|
||||
busio/SPI.c \
|
||||
busio/UART.c \
|
||||
busio/__init__.c \
|
||||
digitalio/DigitalInOut.c \
|
||||
digitalio/__init__.c \
|
||||
displayio/ParallelBus.c \
|
||||
i2cslave/I2CSlave.c \
|
||||
i2cslave/__init__.c \
|
||||
microcontroller/Pin.c \
|
||||
microcontroller/Processor.c \
|
||||
microcontroller/__init__.c \
|
||||
neopixel_write/__init__.c \
|
||||
nvm/ByteArray.c \
|
||||
nvm/__init__.c \
|
||||
os/__init__.c \
|
||||
pulseio/PWMOut.c \
|
||||
pulseio/PulseIn.c \
|
||||
pulseio/PulseOut.c \
|
||||
pulseio/__init__.c \
|
||||
rotaryio/IncrementalEncoder.c \
|
||||
rotaryio/__init__.c \
|
||||
rtc/RTC.c \
|
||||
rtc/__init__.c \
|
||||
supervisor/Runtime.c \
|
||||
supervisor/__init__.c \
|
||||
time/__init__.c \
|
||||
touchio/TouchIn.c \
|
||||
touchio/__init__.c \
|
||||
)
|
||||
|
||||
# These don't have corresponding files in each port but are still located in
|
||||
# shared-bindings to make it clear what the contents of the modules are.
|
||||
# All possible sources are listed here, and are filtered by SRC_PATTERNS.
|
||||
SRC_BINDINGS_ENUMS = \
|
||||
$(filter $(SRC_PATTERNS), \
|
||||
digitalio/Direction.c \
|
||||
digitalio/DriveMode.c \
|
||||
digitalio/Pull.c \
|
||||
displayio/Glyph.c \
|
||||
microcontroller/RunMode.c \
|
||||
math/__init__.c \
|
||||
supervisor/__init__.c \
|
||||
)
|
||||
|
||||
SRC_BINDINGS_ENUMS += \
|
||||
help.c \
|
||||
util.c
|
||||
|
||||
SRC_BINDINGS_ENUMS += \
|
||||
$(filter $(SRC_PATTERNS), \
|
||||
bleio/Address.c \
|
||||
bleio/AddressType.c \
|
||||
bleio/AdvertisementData.c \
|
||||
bleio/ScanEntry.c \
|
||||
)
|
||||
|
||||
# All possible sources are listed here, and are filtered by SRC_PATTERNS.
|
||||
SRC_SHARED_MODULE = \
|
||||
$(filter $(SRC_PATTERNS), \
|
||||
_pixelbuf/PixelBuf.c \
|
||||
_pixelbuf/__init__.c \
|
||||
_stage/Layer.c \
|
||||
_stage/Text.c \
|
||||
_stage/__init__.c \
|
||||
audioio/__init__.c \
|
||||
audioio/Mixer.c \
|
||||
audioio/RawSample.c \
|
||||
audioio/WaveFile.c \
|
||||
bitbangio/I2C.c \
|
||||
bitbangio/OneWire.c \
|
||||
bitbangio/SPI.c \
|
||||
bitbangio/__init__.c \
|
||||
busio/OneWire.c \
|
||||
displayio/Bitmap.c \
|
||||
displayio/BuiltinFont.c \
|
||||
displayio/ColorConverter.c \
|
||||
displayio/Display.c \
|
||||
displayio/FourWire.c \
|
||||
displayio/Group.c \
|
||||
displayio/OnDiskBitmap.c \
|
||||
displayio/Palette.c \
|
||||
displayio/Shape.c \
|
||||
displayio/TileGrid.c \
|
||||
displayio/__init__.c \
|
||||
gamepad/GamePad.c \
|
||||
gamepad/__init__.c \
|
||||
os/__init__.c \
|
||||
random/__init__.c \
|
||||
socket/__init__.c \
|
||||
network/__init__.c \
|
||||
storage/__init__.c \
|
||||
struct/__init__.c \
|
||||
terminalio/Terminal.c \
|
||||
terminalio/__init__.c \
|
||||
uheap/__init__.c \
|
||||
ustack/__init__.c \
|
||||
)
|
||||
|
||||
ifeq ($(INTERNAL_LIBM),1)
|
||||
SRC_LIBM = \
|
||||
$(addprefix lib/,\
|
||||
libm/math.c \
|
||||
libm/roundf.c \
|
||||
libm/fmodf.c \
|
||||
libm/nearbyintf.c \
|
||||
libm/ef_sqrt.c \
|
||||
libm/kf_rem_pio2.c \
|
||||
libm/kf_sin.c \
|
||||
libm/kf_cos.c \
|
||||
libm/kf_tan.c \
|
||||
libm/ef_rem_pio2.c \
|
||||
libm/sf_sin.c \
|
||||
libm/sf_cos.c \
|
||||
libm/sf_tan.c \
|
||||
libm/sf_frexp.c \
|
||||
libm/sf_modf.c \
|
||||
libm/sf_ldexp.c \
|
||||
libm/asinfacosf.c \
|
||||
libm/atanf.c \
|
||||
libm/atan2f.c \
|
||||
)
|
||||
endif
|
48
ports/circuitpy-common/circuitpy_rules.mk
Normal file
48
ports/circuitpy-common/circuitpy_rules.mk
Normal file
@ -0,0 +1,48 @@
|
||||
# This file is part of the MicroPython project, http://micropython.org/
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2019 Dan Halbert 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.
|
||||
|
||||
###
|
||||
# Common make rules. These are split from the common variable defintions due to ordering issues.
|
||||
|
||||
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
|
||||
|
||||
$(BUILD)/firmware.elf: $(OBJ)
|
||||
$(STEPECHO) "LINK $@"
|
||||
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE)
|
||||
|
||||
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
||||
$(STEPECHO) "Create $@"
|
||||
$(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
|
||||
|
||||
$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin
|
||||
$(STEPECHO) "Create $@"
|
||||
$(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $^
|
||||
|
||||
include $(TOP)/py/mkrules.mk
|
||||
|
||||
# Print out the value of a make variable.
|
||||
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
||||
print-%:
|
||||
@echo $* = $($*)
|
@ -235,6 +235,13 @@ extern const struct _mp_obj_module_t bitbangio_module;
|
||||
#define BITBANGIO_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_BLEIO
|
||||
#define BLEIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_bleio), (mp_obj_t)&bleio_module },
|
||||
extern const struct _mp_obj_module_t bleio_module;
|
||||
#else
|
||||
#define BLEIO_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_BOARD
|
||||
#define BOARD_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module },
|
||||
extern const struct _mp_obj_module_t board_module;
|
||||
@ -461,6 +468,7 @@ extern const struct _mp_obj_module_t ustack_module;
|
||||
AUDIOBUSIO_MODULE \
|
||||
AUDIOIO_MODULE \
|
||||
BITBANGIO_MODULE \
|
||||
BLEIO_MODULE \
|
||||
BOARD_MODULE \
|
||||
BUSIO_MODULE \
|
||||
DIGITALIO_MODULE \
|
||||
|
@ -13,6 +13,7 @@ else
|
||||
CIRCUITPY_FULL_BUILD = 1
|
||||
CFLAGS += -DCIRCUITPY_FULL_BUILD=1
|
||||
endif
|
||||
endif
|
||||
|
||||
# All builtin modules are listed below, with default values (0 for off, 1 for on)
|
||||
# Some are always on, some are always off, and some depend on CIRCUITPY_FULL_BUILD.
|
||||
@ -34,11 +35,17 @@ CIRCUITPY_AUDIOIO = $(CIRCUITPY_FULL_BUILD)
|
||||
endif
|
||||
CFLAGS += -DCIRCUITPY_AUDIOIO=$(CIRCUITPY_AUDIOIO)
|
||||
|
||||
#ifndef CIRCUITPY_BITBANGIO
|
||||
ifndef CIRCUITPY_BITBANGIO
|
||||
CIRCUITPY_BITBANGIO = $(CIRCUITPY_FULL_BUILD)
|
||||
endif
|
||||
CFLAGS += -DCIRCUITPY_BITBANGIO=$(CIRCUITPY_BITBANGIO)
|
||||
|
||||
# Explicitly enabled for boards that support bleio.
|
||||
ifndef CIRCUITPY_BLEIO
|
||||
CIRCUITPY_BLEIO = 0
|
||||
endif
|
||||
CFLAGS += -DCIRCUITPY_BLEIO=$(CIRCUITPY_BLEIO)
|
||||
|
||||
ifndef CIRCUITPY_BOARD
|
||||
CIRCUITPY_BOARD = 1
|
||||
endif
|
||||
@ -127,7 +134,7 @@ CFLAGS += -DCIRCUITPY_RTC=$(CIRCUITPY_RTC)
|
||||
|
||||
# Only for SAMD chips.
|
||||
ifndef CIRCUITPY_SAMD
|
||||
ifneq ($findstring sam,$(CHIP_FAMILY),)
|
||||
ifneq ($(findstring sam,$(CHIP_FAMILY)),)
|
||||
CIRCUITPY_SAMD = $(CIRCUITPY_FULL_BUILD)
|
||||
else
|
||||
# Not a SAMD build.
|
||||
|
@ -1,3 +1,27 @@
|
||||
# This file is part of the MicroPython project, http://micropython.org/
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2019 Dan Halbert 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.
|
||||
|
||||
# Select the board to build for.
|
||||
ifeq ($(BOARD),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD=')
|
||||
@ -11,16 +35,29 @@ else
|
||||
endif
|
||||
|
||||
CLI_SD := $(SD)
|
||||
|
||||
include boards/$(BOARD)/mpconfigboard.mk
|
||||
|
||||
SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
# Build directory with SD if it's different from the default.
|
||||
BUILD ?= $(if $(CLI_SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
|
||||
|
||||
include ../../py/mkenv.mk
|
||||
-include mpconfigport.mk
|
||||
# Board-specific
|
||||
include boards/$(BOARD)/mpconfigboard.mk
|
||||
# Port-specific
|
||||
include mpconfigport.mk
|
||||
# CircuitPython-specific
|
||||
include $(TOP)/ports/circuitpy-common/mpconfig_circuitpy.mk
|
||||
|
||||
# qstr definitions (must come before including py.mk)
|
||||
QSTR_DEFS = qstrdefsport.h
|
||||
|
||||
# include py core make definitions
|
||||
include $(TOP)/py/py.mk
|
||||
|
||||
include $(TOP)/supervisor/supervisor.mk
|
||||
|
||||
# Include make rules and variables common across CircuitPython builds.
|
||||
include $(TOP)/ports/circuitpy-common/circuitpy_defns.mk
|
||||
|
||||
ifneq ($(SD), )
|
||||
include bluetooth/bluetooth_common.mk
|
||||
@ -28,19 +65,10 @@ endif
|
||||
|
||||
FROZEN_MPY_DIR = freeze
|
||||
|
||||
# include py core make definitions
|
||||
include ../../py/py.mk
|
||||
|
||||
ifneq ($(MCU_SUB_VARIANT),nrf52840)
|
||||
USB = FALSE
|
||||
endif
|
||||
|
||||
include $(TOP)/supervisor/supervisor.mk
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
||||
FATFS_DIR = lib/oofatfs
|
||||
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
||||
INC += -I.
|
||||
INC += -I../..
|
||||
INC += -I$(BUILD)
|
||||
@ -59,43 +87,51 @@ INC += -I../../lib/mp-readline
|
||||
INC += -I../../lib/tinyusb/src
|
||||
INC += -I../../supervisor/shared/usb
|
||||
|
||||
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
|
||||
|
||||
CFLAGS += -mthumb -mabi=aapcs -fsingle-precision-constant -Wdouble-promotion
|
||||
CFLAGS += -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES) $(CFLAGS_MOD)
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
CFLAGS += -fstack-usage -fno-builtin -fshort-enums
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
CFLAGS += -D__START=main
|
||||
|
||||
LDFLAGS = $(CFLAGS)
|
||||
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
|
||||
LDFLAGS += -mthumb -mabi=aapcs -T $(LD_FILE) -L boards/
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
# TinyUSB defines
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128
|
||||
|
||||
#Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
#ASMFLAGS += -g -gtabs+
|
||||
CFLAGS += -O1 -ggdb
|
||||
LDFLAGS += -O1
|
||||
CFLAGS += -ggdb
|
||||
# You may want to enable these flags to make setting breakpoints easier.
|
||||
CFLAGS += -fno-inline -fno-ipa-sra
|
||||
else
|
||||
CFLAGS += -Os -DNDEBUG
|
||||
LDFLAGS += -Os
|
||||
# TODO: Test with -flto
|
||||
### CFLAGS += -flto
|
||||
endif
|
||||
|
||||
LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
|
||||
LIBC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a)
|
||||
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
||||
|
||||
LIBS := -L $(dir $(LIBM_FILE_NAME)) -lm
|
||||
LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc
|
||||
LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc
|
||||
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)
|
||||
|
||||
# Undo some warnings.
|
||||
# nrfx uses undefined preprocessor variables quite casually, so we can't do warning checks for these.
|
||||
CFLAGS += -Wno-undef
|
||||
# nrfx does casts that increase alignment requirements.
|
||||
CFLAGS += -Wno-cast-align
|
||||
|
||||
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
|
||||
CFLAGS += $(NRF_DEFINES)
|
||||
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mabi=aapcs-linux \
|
||||
-mfloat-abi=hard \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfpu=fpv4-sp-d16
|
||||
|
||||
# TODO: check this
|
||||
CFLAGS += -D__START=main
|
||||
|
||||
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
|
||||
LIBS := -lgcc -lc
|
||||
|
||||
LDFLAGS += -mthumb -mcpu=cortex-m4
|
||||
|
||||
# Use toolchain libm if we're not using our own.
|
||||
ifndef INTERNAL_LIBM
|
||||
LIBS += -lm
|
||||
endif
|
||||
|
||||
# TinyUSB defines
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128
|
||||
|
||||
SRC_NRFX = $(addprefix nrfx/,\
|
||||
drivers/src/nrfx_power.c \
|
||||
@ -144,117 +180,11 @@ SRC_C += \
|
||||
sd_mutex.c \
|
||||
supervisor/shared/memory.c
|
||||
|
||||
|
||||
SRC_COMMON_HAL += \
|
||||
analogio/AnalogIn.c \
|
||||
analogio/AnalogOut.c \
|
||||
analogio/__init__.c \
|
||||
board/__init__.c \
|
||||
busio/I2C.c \
|
||||
busio/SPI.c \
|
||||
busio/UART.c \
|
||||
busio/__init__.c\
|
||||
digitalio/DigitalInOut.c \
|
||||
digitalio/__init__.c \
|
||||
displayio/ParallelBus.c \
|
||||
microcontroller/Pin.c \
|
||||
microcontroller/Processor.c \
|
||||
microcontroller/__init__.c \
|
||||
neopixel_write/__init__.c \
|
||||
os/__init__.c \
|
||||
pulseio/PWMOut.c \
|
||||
pulseio/PulseIn.c \
|
||||
pulseio/PulseOut.c \
|
||||
pulseio/__init__.c \
|
||||
rotaryio/__init__.c \
|
||||
rotaryio/IncrementalEncoder.c \
|
||||
supervisor/Runtime.c \
|
||||
supervisor/__init__.c \
|
||||
time/__init__.c \
|
||||
touchio/__init__.c \
|
||||
touchio/TouchIn.c \
|
||||
|
||||
ifneq ($(SD), )
|
||||
SRC_COMMON_HAL += \
|
||||
bleio/__init__.c \
|
||||
bleio/Adapter.c \
|
||||
bleio/Broadcaster.c \
|
||||
bleio/Characteristic.c \
|
||||
bleio/CharacteristicBuffer.c \
|
||||
bleio/Descriptor.c \
|
||||
bleio/Peripheral.c \
|
||||
bleio/Scanner.c \
|
||||
bleio/Service.c \
|
||||
bleio/UUID.c
|
||||
endif
|
||||
|
||||
# These don't have corresponding files in each port but are still located in
|
||||
# shared-bindings to make it clear what the contents of the modules are.
|
||||
SRC_BINDINGS_ENUMS = \
|
||||
busio/OneWire.c \
|
||||
digitalio/Direction.c \
|
||||
digitalio/DriveMode.c \
|
||||
digitalio/Pull.c \
|
||||
displayio/Glyph.c \
|
||||
microcontroller/RunMode.c \
|
||||
help.c \
|
||||
math/__init__.c \
|
||||
util.c
|
||||
|
||||
ifneq ($(SD), )
|
||||
SRC_BINDINGS_ENUMS += \
|
||||
bleio/Address.c \
|
||||
bleio/AddressType.c \
|
||||
bleio/AdvertisementData.c \
|
||||
bleio/ScanEntry.c
|
||||
endif
|
||||
|
||||
SRC_SHARED_MODULE = \
|
||||
_pixelbuf/__init__.c \
|
||||
_pixelbuf/PixelBuf.c
|
||||
os/__init__.c \
|
||||
random/__init__.c \
|
||||
struct/__init__.c \
|
||||
gamepad/__init__.c \
|
||||
gamepad/GamePad.c \
|
||||
bitbangio/__init__.c \
|
||||
bitbangio/I2C.c \
|
||||
bitbangio/OneWire.c \
|
||||
bitbangio/SPI.c \
|
||||
busio/OneWire.c \
|
||||
displayio/__init__.c \
|
||||
displayio/Bitmap.c \
|
||||
displayio/BuiltinFont.c \
|
||||
displayio/ColorConverter.c \
|
||||
displayio/Display.c \
|
||||
displayio/FourWire.c \
|
||||
displayio/Group.c \
|
||||
displayio/OnDiskBitmap.c \
|
||||
displayio/Palette.c \
|
||||
displayio/Shape.c \
|
||||
displayio/TileGrid.c \
|
||||
storage/__init__.c \
|
||||
terminalio/__init__.c \
|
||||
terminalio/Terminal.c
|
||||
|
||||
|
||||
ifndef EXCLUDE_PIXELBUF
|
||||
endif
|
||||
|
||||
# uheap/__init__.c \
|
||||
ustack/__init__.c
|
||||
|
||||
# USB source files for nrf52840
|
||||
ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
||||
|
||||
SRC_C += \
|
||||
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \
|
||||
lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c
|
||||
|
||||
SRC_SHARED_MODULE += \
|
||||
usb_hid/__init__.c \
|
||||
usb_hid/Device.c \
|
||||
|
||||
endif
|
||||
|
||||
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
|
||||
@ -271,36 +201,44 @@ FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
|
||||
|
||||
OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_NRFX:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
|
||||
ifeq ($(INTERNAL_LIBM),1)
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
|
||||
endif
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
||||
|
||||
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
|
||||
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
|
||||
|
||||
.phony: all flash sd binary hex
|
||||
# List of sources for qstr extraction
|
||||
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
|
||||
# Sources that only hold QSTRs after pre-processing.
|
||||
SRC_QSTR_PREPROCESSOR +=
|
||||
|
||||
all: binary hex uf2
|
||||
|
||||
OUTPUT_FILENAME = firmware
|
||||
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
|
||||
|
||||
## Create binary .bin file from the .out file
|
||||
binary: $(BUILD)/$(OUTPUT_FILENAME).bin
|
||||
$(BUILD)/firmware.elf: $(OBJ)
|
||||
$(STEPECHO) "LINK $@"
|
||||
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE)
|
||||
|
||||
$(BUILD)/$(OUTPUT_FILENAME).bin: $(BUILD)/$(OUTPUT_FILENAME).elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
||||
$(STEPECHO) "Create $@"
|
||||
$(Q)$(OBJCOPY) -O binary $^ $@
|
||||
# $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
|
||||
|
||||
## Create binary .hex file from the .out file
|
||||
hex: $(BUILD)/$(OUTPUT_FILENAME).hex
|
||||
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
|
||||
$(STEPECHO) "Create $@"
|
||||
$(Q)$(OBJCOPY) -O ihex $^ $@
|
||||
# $(Q)$(OBJCOPY) -O ihex -j .vectors -j .text -j .data $^ $@
|
||||
|
||||
$(BUILD)/firmware.uf2: $(BUILD)/firmware.hex
|
||||
$(ECHO) "Create $@"
|
||||
$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/firmware.uf2" $^
|
||||
|
||||
$(BUILD)/$(OUTPUT_FILENAME).hex: $(BUILD)/$(OUTPUT_FILENAME).elf
|
||||
$(OBJCOPY) -O ihex $< $@
|
||||
|
||||
## Create uf2 file
|
||||
uf2: $(BUILD)/$(OUTPUT_FILENAME).hex
|
||||
$(ECHO) "Create $(OUTPUT_FILENAME).uf2"
|
||||
$(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/$(OUTPUT_FILENAME).uf2" $^
|
||||
|
||||
#####################
|
||||
# Flash with debugger
|
||||
@ -310,13 +248,13 @@ FLASHER ?=
|
||||
ifeq ($(FLASHER),)
|
||||
|
||||
# Also update to bootloader settting to validate application and skip checksum ( app valid = 0x0001, crc = 0x0000 )
|
||||
flash: $(BUILD)/$(OUTPUT_FILENAME).hex
|
||||
flash: $(BUILD)/firmware.hex
|
||||
nrfjprog --program $< --sectorerase -f $(MCU_VARIANT)
|
||||
nrfjprog --erasepage $(BOOT_SETTING_ADDR) -f $(MCU_VARIANT)
|
||||
nrfjprog --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f $(MCU_VARIANT)
|
||||
nrfjprog --reset -f $(MCU_VARIANT)
|
||||
|
||||
sd: $(BUILD)/$(OUTPUT_FILENAME).hex
|
||||
sd: $(BUILD)/firmware.hex
|
||||
nrfjprog --eraseall -f $(MCU_VARIANT)
|
||||
nrfjprog --program $(SOFTDEV_HEX) -f $(MCU_VARIANT)
|
||||
nrfjprog --program $< --sectorerase -f $(MCU_VARIANT)
|
||||
@ -324,13 +262,13 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).hex
|
||||
|
||||
else ifeq ($(FLASHER), pyocd)
|
||||
|
||||
flash: $(BUILD)/$(OUTPUT_FILENAME).hex
|
||||
flash: $(BUILD)/firmware.hex
|
||||
pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase
|
||||
#pyocd-tool -t $(MCU_VARIANT) erase $(BOOT_SETTING_ADDR)
|
||||
pyocd-tool -t $(MCU_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001
|
||||
pyocd-tool -t $(MCU_VARIANT) reset
|
||||
|
||||
sd: $(BUILD)/$(OUTPUT_FILENAME).hex
|
||||
sd: $(BUILD)/firmware.hex
|
||||
pyocd-flashtool -t $(MCU_VARIANT) --chip_erase
|
||||
pyocd-flashtool -t $(MCU_VARIANT) $(SOFTDEV_HEX)
|
||||
pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase
|
||||
@ -366,36 +304,13 @@ dfu-flash: $(BUILD)/dfu-package.zip
|
||||
## Create DFU package file
|
||||
dfu-gen: $(BUILD)/dfu-package.zip
|
||||
|
||||
$(BUILD)/dfu-package.zip: $(BUILD)/$(OUTPUT_FILENAME).hex
|
||||
$(BUILD)/dfu-package.zip: $(BUILD)/firmware.hex
|
||||
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $^ $(BUILD)/dfu-package.zip
|
||||
|
||||
# You must have $^ here because it deduplicates entries in $(OBJ)
|
||||
$(BUILD)/$(OUTPUT_FILENAME).elf: $(OBJ)
|
||||
$(ECHO) "LINK $@"
|
||||
$(Q)$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
# List of sources for qstr extraction
|
||||
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(DRIVERS_SRC_C) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
|
||||
|
||||
# Append any auto-generated sources that are needed by sources listed in
|
||||
# SRC_QSTR
|
||||
SRC_QSTR_AUTO_DEPS +=
|
||||
|
||||
AF_FILE = $(MCU_VARIANT)_af.csv
|
||||
PREFIX_FILE = boards/$(MCU_VARIANT)_prefix.c
|
||||
|
||||
ifneq ($(FROZEN_DIR),)
|
||||
# To use frozen source modules, put your .py files in a subdirectory (eg scripts/)
|
||||
# and then invoke make with FROZEN_DIR=scripts (be sure to build from scratch).
|
||||
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
||||
endif
|
||||
|
||||
ifneq ($(FROZEN_MPY_DIR),)
|
||||
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
|
||||
# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
|
||||
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
||||
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
||||
endif
|
||||
|
||||
include $(TOP)/py/mkrules.mk
|
||||
|
||||
# Print out the value of a make variable.
|
||||
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
||||
print-%:
|
||||
@echo $* = $($*)
|
||||
|
@ -87,6 +87,8 @@ void ble_drv_remove_event_handler(ble_drv_evt_handler_t func, void *param) {
|
||||
}
|
||||
}
|
||||
|
||||
extern void tusb_hal_nrf_power_event (uint32_t event);
|
||||
|
||||
void SD_EVT_IRQHandler(void) {
|
||||
uint32_t evt_id;
|
||||
while (sd_evt_get(&evt_id) != NRF_ERROR_NOT_FOUND) {
|
||||
@ -101,7 +103,6 @@ void SD_EVT_IRQHandler(void) {
|
||||
(evt_id == NRF_EVT_POWER_USB_POWER_READY) ? NRFX_POWER_USB_EVT_READY :
|
||||
(evt_id == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1;
|
||||
|
||||
extern void tusb_hal_nrf_power_event (uint32_t event);
|
||||
tusb_hal_nrf_power_event(usbevt);
|
||||
}
|
||||
break;
|
||||
|
@ -50,7 +50,7 @@
|
||||
|
||||
typedef void (*ble_drv_evt_handler_t)(ble_evt_t*, void*);
|
||||
|
||||
void ble_drv_reset();
|
||||
void ble_drv_reset(void);
|
||||
void ble_drv_add_event_handler(ble_drv_evt_handler_t func, void *param);
|
||||
void ble_drv_remove_event_handler(ble_drv_evt_handler_t func, void *param);
|
||||
|
||||
|
@ -16,6 +16,7 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
@ -16,6 +16,7 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
@ -17,6 +17,7 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
@ -16,6 +16,7 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
@ -16,6 +16,7 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
@ -16,6 +16,7 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
@ -16,6 +16,7 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
@ -17,6 +17,7 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
@ -16,10 +16,11 @@ ifeq ($(SD),)
|
||||
LD_FILE = boards/nrf52840_1M_256k.ld
|
||||
else
|
||||
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
|
||||
CIRCUITPY_BLEIO = 1
|
||||
endif
|
||||
|
||||
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
|
||||
|
||||
QSPI_FLASH_FILESYSTEM = 0
|
||||
EXTERNAL_FLASH_DEVICE_COUNT = 0
|
||||
EXTERNAL_FLASH_DEVICES =
|
||||
QSPI_FLASH_FILESYSTEM = 0
|
||||
EXTERNAL_FLASH_DEVICE_COUNT = 0
|
||||
EXTERNAL_FLASH_DEVICES =
|
||||
|
@ -86,7 +86,7 @@ static NRF_PWM_Type* find_free_pwm (void) {
|
||||
#endif
|
||||
};
|
||||
|
||||
for ( int device = 0; device < ARRAY_SIZE(PWM); device++ ) {
|
||||
for ( size_t device = 0; device < ARRAY_SIZE(PWM); device++ ) {
|
||||
if ( (PWM[device]->ENABLE == 0) &&
|
||||
(PWM[device]->PSEL.OUT[0] & PWM_PSEL_OUT_CONNECT_Msk) && (PWM[device]->PSEL.OUT[1] & PWM_PSEL_OUT_CONNECT_Msk) &&
|
||||
(PWM[device]->PSEL.OUT[2] & PWM_PSEL_OUT_CONNECT_Msk) && (PWM[device]->PSEL.OUT[3] & PWM_PSEL_OUT_CONNECT_Msk) ) {
|
||||
|
@ -58,7 +58,7 @@ STATIC uint16_t pwm_seq[MP_ARRAY_SIZE(pwms)][CHANNELS_PER_PWM];
|
||||
static uint8_t never_reset_pwm[MP_ARRAY_SIZE(pwms)];
|
||||
|
||||
void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
NRF_PWM_Type* pwm = pwms[i];
|
||||
if (pwm == self->pwm) {
|
||||
never_reset_pwm[i] += 1;
|
||||
@ -69,7 +69,7 @@ void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
NRF_PWM_Type* pwm = pwms[i];
|
||||
if (pwm == self->pwm) {
|
||||
never_reset_pwm[i] -= 1;
|
||||
@ -78,7 +78,7 @@ void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
}
|
||||
|
||||
void pwmout_reset(void) {
|
||||
for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
if (never_reset_pwm[i] > 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ static pulseio_pulsein_obj_t* _objs[GPIOTE_CH_NUM];
|
||||
|
||||
// return index of the object in array
|
||||
static int _find_pulsein_obj(pulseio_pulsein_obj_t* obj) {
|
||||
for(int i = 0; i < NRFX_ARRAY_SIZE(_objs); i++ ) {
|
||||
for(size_t i = 0; i < NRFX_ARRAY_SIZE(_objs); i++ ) {
|
||||
if ( _objs[i] == obj) {
|
||||
return i;
|
||||
}
|
||||
@ -63,7 +63,7 @@ static void _pulsein_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action
|
||||
current_us = 1000 - current_us;
|
||||
|
||||
pulseio_pulsein_obj_t* self = NULL;
|
||||
for(int i = 0; i < NRFX_ARRAY_SIZE(_objs); i++ ) {
|
||||
for(size_t i = 0; i < NRFX_ARRAY_SIZE(_objs); i++ ) {
|
||||
if ( _objs[i] && _objs[i]->pin == pin ) {
|
||||
self = _objs[i];
|
||||
break;
|
||||
|
@ -4,6 +4,7 @@
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Glenn Ruben Bakke
|
||||
* Copyright (c) 2019 Dan Halbert 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
|
||||
@ -27,105 +28,18 @@
|
||||
#ifndef NRF5_MPCONFIGPORT_H__
|
||||
#define NRF5_MPCONFIGPORT_H__
|
||||
|
||||
#include <mpconfigboard.h>
|
||||
|
||||
// options to control how MicroPython is built
|
||||
#define MICROPY_ALLOC_PATH_MAX (512)
|
||||
#define MICROPY_PERSISTENT_CODE_LOAD (1)
|
||||
#define MICROPY_EMIT_THUMB (0)
|
||||
#define MICROPY_EMIT_INLINE_THUMB (0)
|
||||
#define MICROPY_COMP_MODULE_CONST (0)
|
||||
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
|
||||
#define MICROPY_READER_VFS (MICROPY_VFS)
|
||||
#define MICROPY_ENABLE_GC (1)
|
||||
#define MICROPY_ENABLE_FINALISER (1)
|
||||
#define MICROPY_STACK_CHECK (0)
|
||||
#define MICROPY_HELPER_REPL (1)
|
||||
#define MICROPY_REPL_EMACS_KEYS (0)
|
||||
#define MICROPY_REPL_AUTO_INDENT (1)
|
||||
#define MICROPY_ENABLE_SOURCE_LINE (1)
|
||||
//CP UPDATE: See mpconfigport.h for LONGINT implementation
|
||||
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
|
||||
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
|
||||
#define MICROPY_FLOAT_HIGH_QUALITY_HASH (1)
|
||||
|
||||
#define MICROPY_OPT_COMPUTED_GOTO (0)
|
||||
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
|
||||
#define MICROPY_OPT_MPZ_BITWISE (0)
|
||||
|
||||
// fatfs configuration used in ffconf.h
|
||||
#define MICROPY_FATFS_ENABLE_LFN (1)
|
||||
#define MICROPY_FATFS_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
|
||||
#define MICROPY_FATFS_USE_LABEL (1)
|
||||
#define MICROPY_FATFS_RPATH (2)
|
||||
#define MICROPY_FATFS_MULTI_PARTITION (1)
|
||||
#define MICROPY_FATFS_NUM_PERSISTENT (1)
|
||||
|
||||
//#define MICROPY_FATFS_MAX_SS (4096)
|
||||
#define FILESYSTEM_BLOCK_SIZE (512)
|
||||
|
||||
#define MICROPY_VFS (1)
|
||||
#define MICROPY_VFS_FAT (MICROPY_VFS)
|
||||
|
||||
// use vfs's functions for import stat and builtin open
|
||||
#if MICROPY_VFS
|
||||
#define mp_import_stat mp_vfs_import_stat
|
||||
#define mp_builtin_open mp_vfs_open
|
||||
#define mp_builtin_open_obj mp_vfs_open_obj
|
||||
#endif
|
||||
|
||||
#define MICROPY_CPYTHON_COMPAT (1)
|
||||
#define MICROPY_STREAMS_NON_BLOCK (1)
|
||||
#define MICROPY_MODULE_WEAK_LINKS (1)
|
||||
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
|
||||
#define MICROPY_USE_INTERNAL_ERRNO (0)
|
||||
#define MICROPY_PY_FUNCTION_ATTRS (1)
|
||||
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
|
||||
#define MICROPY_PY_BUILTINS_STR_CENTER (1)
|
||||
#define MICROPY_PY_BUILTINS_STR_PARTITION (1)
|
||||
#define MICROPY_PY_BUILTINS_STR_SPLITLINES (1)
|
||||
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
|
||||
#define MICROPY_PY_BUILTINS_FROZENSET (1)
|
||||
#define MICROPY_PY_BUILTINS_EXECFILE (0)
|
||||
#define MICROPY_PY_BUILTINS_COMPILE (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
|
||||
#define MICROPY_PY_BUILTINS_INPUT (1)
|
||||
#define MICROPY_MODULE_BUILTIN_INIT (1)
|
||||
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
|
||||
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
|
||||
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
|
||||
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
|
||||
#define MICROPY_NONSTANDARD_TYPECODES (0)
|
||||
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
|
||||
#define MICROPY_PY_SYS_EXIT (1)
|
||||
#define MICROPY_PY_SYS_MAXSIZE (1)
|
||||
#define MICROPY_PY_SYS_STDFILES (1)
|
||||
#define MICROPY_PY_SYS_STDIO_BUFFER (1)
|
||||
//#define MICROPY_MODULE_BUILTIN_INIT (1) // TODO check this
|
||||
//#define MICROPY_MODULE_WEAK_LINKS (1) // TODO check this
|
||||
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
|
||||
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
|
||||
#define MICROPY_PY_CMATH (0)
|
||||
#define MICROPY_PY_FUNCTION_ATTRS (1)
|
||||
#define MICROPY_PY_IO (1)
|
||||
#define MICROPY_PY_IO_FILEIO (1)
|
||||
#define MICROPY_PY_UERRNO (0)
|
||||
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
|
||||
#define MICROPY_PY_SYS_STDIO_BUFFER (1)
|
||||
#define MICROPY_PY_UBINASCII (1)
|
||||
#define MICROPY_PY_URANDOM (0)
|
||||
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
|
||||
#define MICROPY_PY_UCTYPES (0)
|
||||
#define MICROPY_PY_UZLIB (0)
|
||||
#define MICROPY_PY_UJSON (1)
|
||||
#define MICROPY_PY_URE (1)
|
||||
#define MICROPY_PY_UHEAPQ (0)
|
||||
#define MICROPY_PY_UHASHLIB (0)
|
||||
// This is py/modstruct.c, not shared-bindings/struct/
|
||||
#define MICROPY_PY_STRUCT (0)
|
||||
#define MICROPY_PY_FRAMEBUF (0)
|
||||
|
||||
#define MICROPY_KBD_EXCEPTION (1)
|
||||
|
||||
// Scan gamepad every 32ms
|
||||
#define CIRCUITPY_GAMEPAD_TICKS 0x1f
|
||||
|
||||
// TODO this is old BLE stuff
|
||||
#if BLUETOOTH_SD
|
||||
#define MICROPY_PY_BLEIO (1)
|
||||
#define MICROPY_PY_BLE_NUS (0)
|
||||
@ -135,114 +49,13 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// type definitions for the specific machine
|
||||
|
||||
#define BYTES_PER_WORD (4)
|
||||
|
||||
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
|
||||
|
||||
#define MP_SSIZE_MAX (0x7fffffff)
|
||||
|
||||
#define UINT_FMT "%u"
|
||||
#define INT_FMT "%d"
|
||||
#define HEX2_FMT "%02x"
|
||||
|
||||
typedef int mp_int_t; // must be pointer size
|
||||
typedef unsigned int mp_uint_t; // must be pointer size
|
||||
typedef long mp_off_t;
|
||||
|
||||
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
|
||||
#define mp_type_fileio mp_type_vfs_fat_fileio
|
||||
#define mp_type_textio mp_type_vfs_fat_textio
|
||||
|
||||
// extra built in modules to add to the list of known ones
|
||||
|
||||
extern const struct _mp_obj_module_t microcontroller_module;
|
||||
extern const struct _mp_obj_module_t bitbangio_module;
|
||||
extern const struct _mp_obj_module_t analogio_module;
|
||||
extern const struct _mp_obj_module_t digitalio_module;
|
||||
extern const struct _mp_obj_module_t displayio_module;
|
||||
extern const struct _mp_obj_module_t pulseio_module;
|
||||
extern const struct _mp_obj_module_t busio_module;
|
||||
extern const struct _mp_obj_module_t board_module;
|
||||
extern const struct _mp_obj_module_t os_module;
|
||||
extern const struct _mp_obj_module_t random_module;
|
||||
extern const struct _mp_obj_module_t rotaryio_module;
|
||||
extern const struct _mp_obj_module_t storage_module;
|
||||
extern const struct _mp_obj_module_t struct_module;
|
||||
extern const struct _mp_obj_module_t time_module;
|
||||
extern const struct _mp_obj_module_t supervisor_module;
|
||||
extern const struct _mp_obj_module_t gamepad_module;
|
||||
extern const struct _mp_obj_module_t neopixel_write_module;
|
||||
extern const struct _mp_obj_module_t usb_hid_module;
|
||||
extern const struct _mp_obj_module_t usb_midi_module;
|
||||
extern const struct _mp_obj_module_t bleio_module;
|
||||
extern const struct _mp_obj_module_t touchio_module;
|
||||
|
||||
|
||||
#if MICROPY_PY_BLEIO
|
||||
#define BLEIO_MODULE { MP_ROM_QSTR(MP_QSTR_bleio), MP_ROM_PTR(&bleio_module) },
|
||||
#else
|
||||
#define BLEIO_MODULE
|
||||
#endif
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#define USBHID_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid), (mp_obj_t)&usb_hid_module },
|
||||
#else
|
||||
#define USBHID_MODULE
|
||||
#endif
|
||||
|
||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_board ), (mp_obj_t)&board_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_busio ), (mp_obj_t)&busio_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_analogio ), (mp_obj_t)&analogio_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_digitalio ), (mp_obj_t)&digitalio_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_displayio ), (mp_obj_t)&displayio_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_pulseio ), (mp_obj_t)&pulseio_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_microcontroller ), (mp_obj_t)µcontroller_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_neopixel_write ), (mp_obj_t)&neopixel_write_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_bitbangio ), (mp_obj_t)&bitbangio_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_os ), (mp_obj_t)&os_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_random ), (mp_obj_t)&random_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_rotaryio ), (mp_obj_t)&rotaryio_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_storage ), (mp_obj_t)&storage_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_struct ), (mp_obj_t)&struct_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_supervisor ), (mp_obj_t)&supervisor_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_gamepad ), (mp_obj_t)&gamepad_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_time ), (mp_obj_t)&time_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_json ), (mp_obj_t)&mp_module_ujson }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_touchio ), (mp_obj_t)&touchio_module }, \
|
||||
USBHID_MODULE \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_usb_midi),(mp_obj_t)&usb_midi_module }, \
|
||||
BLEIO_MODULE
|
||||
|
||||
// extra built in names to add to the global namespace
|
||||
#define MICROPY_PORT_BUILTINS \
|
||||
{ MP_ROM_QSTR (MP_QSTR_help ), MP_ROM_PTR(&mp_builtin_help_obj) }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_input ), (mp_obj_t)&mp_builtin_input_obj }, \
|
||||
{ MP_ROM_QSTR (MP_QSTR_open ), MP_ROM_PTR(&mp_builtin_open_obj) }, \
|
||||
|
||||
#define MP_STATE_PORT MP_STATE_VM
|
||||
|
||||
#include "supervisor/flash_root_pointers.h"
|
||||
// 24kiB stack
|
||||
#define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000
|
||||
|
||||
#define MICROPY_PORT_ROOT_POINTERS \
|
||||
const char *readline_hist[8]; \
|
||||
mp_obj_t gamepad_singleton; \
|
||||
mp_obj_t terminal_tilegrid_tiles; \
|
||||
FLASH_ROOT_POINTERS \
|
||||
CIRCUITPY_COMMON_ROOT_POINTERS \
|
||||
;
|
||||
|
||||
// We need to provide a declaration/definition of alloca()
|
||||
#include <alloca.h>
|
||||
#include "ports/circuitpy-common/mpconfig_circuitpy.h"
|
||||
|
||||
void run_background_tasks(void);
|
||||
#define MICROPY_VM_HOOK_LOOP run_background_tasks();
|
||||
#define MICROPY_VM_HOOK_RETURN run_background_tasks();
|
||||
|
||||
//#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
|
||||
#define CIRCUITPY_DEFAULT_STACK_SIZE 4096
|
||||
#define CIRCUITPY_DISPLAYIO (1)
|
||||
#define CIRCUITPY_DISPLAY_LIMIT (3)
|
||||
|
||||
#endif
|
||||
#endif // NRF5_MPCONFIGPORT_H__
|
||||
|
@ -3,6 +3,21 @@
|
||||
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
|
||||
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
|
||||
|
||||
INTERNAL_LIBM = (1)
|
||||
INTERNAL_LIBM = 1
|
||||
|
||||
USB_SERIAL_NUMBER_LENGTH = 16
|
||||
|
||||
# No DAC, so no regular audio.
|
||||
CIRCUITPY_AUDIOIO = 0
|
||||
|
||||
# No I2S yet.
|
||||
CIRCUITPY_AUDIOBUSIO = 0
|
||||
|
||||
# No I2CSlave implementation
|
||||
CIRCUITPY_I2CSLAVE = 0
|
||||
|
||||
# nvm not yet implemented
|
||||
CIRCUITPY_NVM = 0
|
||||
|
||||
# rtc not yet implemented
|
||||
CIRCUITPY_RTC = 0
|
||||
|
@ -71,7 +71,7 @@ uint32_t supervisor_flash_get_block_count(void) {
|
||||
}
|
||||
|
||||
#ifdef BLUETOOTH_SD
|
||||
STATIC bool wait_for_flash_operation() {
|
||||
STATIC bool wait_for_flash_operation(void) {
|
||||
do {
|
||||
sd_app_evt_wait();
|
||||
uint32_t evt_id;
|
||||
|
@ -88,7 +88,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
GET_STR_DATA_LEN(address, str, str_len);
|
||||
|
||||
size_t value_index = 0;
|
||||
size_t str_index = str_len;
|
||||
int str_index = str_len;
|
||||
bool error = false;
|
||||
|
||||
// Loop until fewer than two characters left.
|
||||
@ -138,7 +138,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
mp_printf(print, "Address('"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT"')",
|
||||
mp_printf(print, "Address('%02x:%02x:%02x:%02x:%02x:%02x')",
|
||||
self->value[5], self->value[4], self->value[3],
|
||||
self->value[2], self->value[1], self->value[0]);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ STATIC mp_obj_t scanentry_get_name(mp_obj_t self_in);
|
||||
|
||||
STATIC void bleio_scanentry_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
bleio_scanentry_obj_t *self = (bleio_scanentry_obj_t *)self_in;
|
||||
mp_printf(print, "ScanEntry(address: "HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT"",
|
||||
mp_printf(print, "ScanEntry(address: %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
self->address.value[5], self->address.value[4], self->address.value[3],
|
||||
self->address.value[1], self->address.value[1], self->address.value[0]);
|
||||
|
||||
|
@ -79,7 +79,7 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, co
|
||||
len == 36 && chars[8] == '-' && chars[13] == '-' && chars[18] == '-' && chars[23] == '-';
|
||||
if (good_uuid) {
|
||||
size_t hex_idx = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (unichar_isxdigit(chars[i])) {
|
||||
hex[hex_idx] = chars[i];
|
||||
hex_idx++;
|
||||
|
Loading…
Reference in New Issue
Block a user