summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorBernhard Boser <boser@berkeley.edu>2021-01-18 11:26:39 -0800
committerBernhard Boser <boser@berkeley.edu>2021-01-18 11:26:39 -0800
commite27dd26dc72b3603c0f50796d7747fb4858af113 (patch)
tree4d139685ae771e0854e2d9187d496253106a4572 /ports
parent1e88b9411d54e5c15a27d4a9c2748c264cb9522f (diff)
parent6a76b60027aa163756aace389a5c9203594759ce (diff)
make translate, BEWARE adds the 'world'
Diffstat (limited to 'ports')
-rw-r--r--ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/neopixel_trinkey_m0/board.c40
-rw-r--r--ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.h57
-rw-r--r--ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk44
-rw-r--r--ports/atmel-samd/boards/neopixel_trinkey_m0/pins.c9
-rw-r--r--ports/atmel-samd/boards/pewpew10/mpconfigboard.mk5
-rw-r--r--ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/shirtty/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/snekboard/mpconfigboard.mk1
-rwxr-xr-xports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/common-hal/analogio/AnalogOut.c31
-rw-r--r--ports/atmel-samd/common-hal/pwmio/PWMOut.c7
-rw-r--r--ports/atmel-samd/supervisor/port.c7
-rw-r--r--ports/cxd56/boards/spresense/mpconfigboard.mk2
-rw-r--r--ports/esp32s2/Makefile6
-rw-r--r--ports/esp32s2/bindings/espidf/__init__.c88
-rw-r--r--ports/esp32s2/bindings/espidf/__init__.h8
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/board.c52
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h45
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk22
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/pins.c63
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/sdkconfig0
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c122
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h45
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.mk22
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/pins.c72
-rw-r--r--ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/sdkconfig0
-rw-r--r--ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c4
-rw-r--r--ports/esp32s2/common-hal/alarm/__init__.c4
-rw-r--r--ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c66
-rw-r--r--ports/esp32s2/common-hal/audiobusio/I2SOut.c126
-rw-r--r--ports/esp32s2/common-hal/audiobusio/I2SOut.h45
-rw-r--r--ports/esp32s2/common-hal/audiobusio/PDMIn.c0
-rw-r--r--ports/esp32s2/common-hal/audiobusio/PDMIn.h0
-rw-r--r--ports/esp32s2/common-hal/audiobusio/__init__.c245
-rw-r--r--ports/esp32s2/common-hal/audiobusio/__init__.h61
-rw-r--r--ports/esp32s2/common-hal/socketpool/Socket.c7
-rw-r--r--ports/esp32s2/common-hal/wifi/Network.c34
-rw-r--r--ports/esp32s2/common-hal/wifi/Radio.c4
-rw-r--r--ports/esp32s2/common-hal/wifi/__init__.c8
-rw-r--r--ports/esp32s2/esp-idf-config/sdkconfig-debug.defaults5
-rw-r--r--ports/esp32s2/esp_error.c91
-rw-r--r--ports/esp32s2/mpconfigport.h1
-rw-r--r--ports/esp32s2/mpconfigport.mk6
-rw-r--r--ports/esp32s2/supervisor/port.c28
-rw-r--r--ports/nrf/boards/TG-Watch/board.c (renamed from ports/nrf/boards/TG-Watch02A/board.c)0
-rw-r--r--ports/nrf/boards/TG-Watch/mpconfigboard.h (renamed from ports/nrf/boards/TG-Watch02A/mpconfigboard.h)11
-rw-r--r--ports/nrf/boards/TG-Watch/mpconfigboard.mk (renamed from ports/nrf/boards/TG-Watch02A/mpconfigboard.mk)9
-rw-r--r--ports/nrf/boards/TG-Watch/pins.c74
-rw-r--r--ports/nrf/boards/TG-Watch02A/pins.c51
-rw-r--r--ports/nrf/boards/pca10100/mpconfigboard.mk1
-rw-r--r--ports/nrf/boards/simmel/mpconfigboard.mk1
-rw-r--r--ports/nrf/common-hal/_bleio/Adapter.c12
-rw-r--r--ports/nrf/common-hal/_bleio/Characteristic.c15
-rw-r--r--ports/nrf/common-hal/_bleio/Connection.c2
-rw-r--r--ports/nrf/common-hal/_bleio/Descriptor.c15
-rw-r--r--ports/unix/Makefile2
66 files changed, 1552 insertions, 139 deletions
diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk
index fd24edafa..07b1b9800 100644
--- a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk
@@ -11,3 +11,5 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
SUPEROPT_GC = 0
+
+CFLAGS_BOARD = --param max-inline-insns-auto=15
diff --git a/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk b/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk
index a0d9a779f..cff5a32d1 100644
--- a/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk
@@ -14,6 +14,7 @@ LONGINT_IMPL = MPZ
CIRCUITPY_BITBANGIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_VECTORIO = 0
CIRCUITPY_BUSDEVICE = 0
diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
index 13ec9e861..505f5c145 100644
--- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
@@ -15,6 +15,7 @@ LONGINT_IMPL = MPZ
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
MICROPY_PY_ASYNC_AWAIT = 0
SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk
index 7aa45eb39..c3be33134 100644
--- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk
@@ -16,6 +16,7 @@ CIRCUITPY_BITBANGIO = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_PIXELBUF = 1
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk
index 3a43093a9..51e9b05af 100644
--- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk
@@ -16,6 +16,7 @@ CIRCUITPY_BITBANGIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_PIXELBUF = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk
index 2fe085567..d1a6fc7ae 100644
--- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk
@@ -15,6 +15,7 @@ CIRCUITPY_BITBANGIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_VECTORIO = 0
CIRCUITPY_BUSDEVICE = 0
diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk
index 5624144e8..f06163b84 100644
--- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk
@@ -18,6 +18,7 @@ CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
CIRCUITPY_GAMEPAD = 0
CFLAGS_INLINE_LIMIT = 50
+CIRCUITPY_MSGPACK = 0
# Include these Python libraries in firmware.
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk
index c2d692f9b..3078544fc 100644
--- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk
@@ -15,6 +15,7 @@ CIRCUITPY_BITBANGIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
# supersized, not ultra-supersized
CIRCUITPY_VECTORIO = 0
CIRCUITPY_BUSDEVICE = 0
diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk
index c35854758..03f633e6d 100644
--- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk
@@ -14,6 +14,7 @@ LONGINT_IMPL = MPZ
CIRCUITPY_BITBANGIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_VECTORIO = 0
CIRCUITPY_BUSDEVICE = 0
diff --git a/ports/atmel-samd/boards/neopixel_trinkey_m0/board.c b/ports/atmel-samd/boards/neopixel_trinkey_m0/board.c
new file mode 100644
index 000000000..cde441b3d
--- /dev/null
+++ b/ports/atmel-samd/boards/neopixel_trinkey_m0/board.c
@@ -0,0 +1,40 @@
+/*
+ * 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"
+#include "common-hal/microcontroller/Pin.h"
+#include "supervisor/shared/board.h"
+#include "hal/include/hal_gpio.h"
+
+void board_init(void) {
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+}
diff --git a/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.h
new file mode 100644
index 000000000..ebf8b1e34
--- /dev/null
+++ b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.h
@@ -0,0 +1,57 @@
+#define MICROPY_HW_BOARD_NAME "Adafruit NeoPixel Trinkey M0"
+#define MICROPY_HW_MCU_NAME "samd21e18"
+
+#define MICROPY_HW_NEOPIXEL (&pin_PA05)
+
+#define MICROPY_PORT_A (0)
+#define MICROPY_PORT_B (0)
+#define MICROPY_PORT_C (0)
+
+#define IGNORE_PIN_PA00 1
+#define IGNORE_PIN_PA01 1
+#define IGNORE_PIN_PA02 1
+#define IGNORE_PIN_PA04 1
+#define IGNORE_PIN_PA06 1
+#define IGNORE_PIN_PA08 1
+#define IGNORE_PIN_PA09 1
+#define IGNORE_PIN_PA10 1
+#define IGNORE_PIN_PA11 1
+#define IGNORE_PIN_PA12 1
+#define IGNORE_PIN_PA13 1
+#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
+#define IGNORE_PIN_PA20 1
+#define IGNORE_PIN_PA21 1
+// USB is always used internally so skip the pin objects for it.
+#define IGNORE_PIN_PA24 1
+#define IGNORE_PIN_PA25 1
+#define IGNORE_PIN_PA27 1
+#define IGNORE_PIN_PA28 1
+#define IGNORE_PIN_PA30 1
+#define IGNORE_PIN_PA31 1
+#define IGNORE_PIN_PB00 1
+#define IGNORE_PIN_PB01 1
+#define IGNORE_PIN_PB02 1
+#define IGNORE_PIN_PB03 1
+#define IGNORE_PIN_PB04 1
+#define IGNORE_PIN_PB05 1
+#define IGNORE_PIN_PB06 1
+#define IGNORE_PIN_PB07 1
+#define IGNORE_PIN_PB08 1
+#define IGNORE_PIN_PB09 1
+#define IGNORE_PIN_PB10 1
+#define IGNORE_PIN_PB11 1
+#define IGNORE_PIN_PB12 1
+#define IGNORE_PIN_PB13 1
+#define IGNORE_PIN_PB14 1
+#define IGNORE_PIN_PB15 1
+#define IGNORE_PIN_PB16 1
+#define IGNORE_PIN_PB17 1
+#define IGNORE_PIN_PB22 1
+#define IGNORE_PIN_PB23 1
+#define IGNORE_PIN_PB30 1
+#define IGNORE_PIN_PB31 1
diff --git a/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk
new file mode 100644
index 000000000..ab8065a9c
--- /dev/null
+++ b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk
@@ -0,0 +1,44 @@
+USB_VID = 0x239A
+USB_PID = 0x80F0
+USB_PRODUCT = "NeoPixel Trinkey M0"
+USB_MANUFACTURER = "Adafruit Industries LLC"
+
+CHIP_VARIANT = SAMD21E18A
+CHIP_FAMILY = samd21
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = NONE
+
+SUPEROPT_GC = 0
+
+CIRCUITPY_ANALOGIO = 0
+CIRCUITPY_ROTARYIO = 0
+CIRCUITPY_RTC = 0
+CIRCUITPY_SAMD = 0
+CIRCUITPY_PS2IO = 0
+CIRCUITPY_PULSEIO = 0
+CIRCUITPY_PWMIO = 0
+CIRCUITPY_AUDIOCORE = 0
+CIRCUITPY_BUSIO = 0
+CIRCUITPY_STORAGE = 0
+
+CIRCUITPY_MATH = 1
+CIRCUITPY_PIXELBUF = 1
+CIRCUITPY_USB_MIDI = 1
+CIRCUITPY_TOUCHIO = 1
+CIRCUITPY_FULL_BUILD = 0
+
+CFLAGS_BOARD = --param max-inline-insns-auto=15
+ifeq ($(TRANSLATION), zh_Latn_pinyin)
+RELEASE_NEEDS_CLEAN_BUILD = 1
+CFLAGS_INLINE_LIMIT = 35
+endif
+ifeq ($(TRANSLATION), de_DE)
+RELEASE_NEEDS_CLEAN_BUILD = 1
+CFLAGS_INLINE_LIMIT = 35
+SUPEROPT_VM = 0
+endif
+
+# Include these Python libraries in firmware.
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
diff --git a/ports/atmel-samd/boards/neopixel_trinkey_m0/pins.c b/ports/atmel-samd/boards/neopixel_trinkey_m0/pins.c
new file mode 100644
index 000000000..3673fcbec
--- /dev/null
+++ b/ports/atmel-samd/boards/neopixel_trinkey_m0/pins.c
@@ -0,0 +1,9 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_TOUCH1), MP_ROM_PTR(&pin_PA03) },
+ { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA05) },
+ { MP_ROM_QSTR(MP_QSTR_TOUCH2), MP_ROM_PTR(&pin_PA07) },
+
+};
+MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk
index 1cc91a8df..fadcc2144 100644
--- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk
@@ -24,3 +24,8 @@ SUPEROPT_GC = 0
FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x
CFLAGS_BOARD = --param max-inline-insns-auto=15
+ifeq ($(TRANSLATION), de_DE)
+RELEASE_NEEDS_CLEAN_BUILD = 1
+CFLAGS_INLINE_LIMIT = 35
+SUPEROPT_VM = 0
+endif
diff --git a/ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk b/ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk
index a63f14274..8773c5771 100644
--- a/ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk
@@ -17,6 +17,7 @@ CIRCUITPY_BITBANGIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk
index a04e09769..0b56e9ae0 100644
--- a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk
@@ -13,3 +13,5 @@ CIRCUITPY_I2CPERIPHERAL = 1
CIRCUITPY_TOUCHIO = 0
SUPEROPT_GC = 0
+
+CFLAGS_BOARD = --param max-inline-insns-auto=15
diff --git a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk
index 67e5b2312..889490450 100644
--- a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk
@@ -14,6 +14,7 @@ LONGINT_IMPL = MPZ
CIRCUITPY_BITBANGIO = 0
CIRCUITPY_GAMEPAD = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_VECTORIO = 0
CIRCUITPY_BUSDEVICE = 0
diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk
index 590c4795f..5b7f93328 100755
--- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk
@@ -15,6 +15,7 @@ CIRCUITPY_BITBANGIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_GAMEPAD = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_VECTORIO = 0
CIRCUITPY_BUSDEVICE = 0
diff --git a/ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk b/ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk
index 704d26514..734be2d14 100644
--- a/ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk
@@ -16,6 +16,7 @@ CIRCUITPY_BITBANGIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_VECTORIO = 0
CIRCUITPY_BUSDEVICE = 0
diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c
index 1565b0a8f..3ddd9cac6 100644
--- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c
+++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c
@@ -55,21 +55,22 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
mp_raise_NotImplementedError(translate("No DAC on chip"));
#else
- int channel = -1;
-
- #if defined(PIN_PA02) && !defined(IGNORE_PIN_PA02)
- if (pin->number != PIN_PA02) {
- channel = 0;
- }
- #endif
- #if defined(PIN_PA05) && defined(PIN_PA05) && !defined(IGNORE_PIN_PA05)
- if (pin->number != PIN_PA05) {
- channel = 1;
- }
- #endif
-
- if(channel == -1) {
- mp_raise_ValueError(translate("AnalogOut not supported on given pin"));
+ uint8_t channel;
+ switch (pin->number) {
+ #if defined(PIN_PA02) && !defined(IGNORE_PIN_PA02)
+ case PIN_PA02:
+ channel = 0;
+ break;
+ #endif
+
+ #if defined(SAM_D5X_E5X) && defined(PIN_PA05) && !defined(IGNORE_PIN_PA05)
+ case PIN_PA05:
+ channel = 1;
+ break;
+ #endif
+
+ default:
+ mp_raise_ValueError(translate("AnalogOut not supported on given pin"));
return;
}
diff --git a/ports/atmel-samd/common-hal/pwmio/PWMOut.c b/ports/atmel-samd/common-hal/pwmio/PWMOut.c
index 2e538ccdc..b5142c21e 100644
--- a/ports/atmel-samd/common-hal/pwmio/PWMOut.c
+++ b/ports/atmel-samd/common-hal/pwmio/PWMOut.c
@@ -44,6 +44,7 @@
# define _TCC_SIZE(unused, n) TCC ## n ## _SIZE,
# define TCC_SIZES { REPEAT_MACRO(_TCC_SIZE, 0, TCC_INST_NUM) }
+static const uint8_t tcc_sizes[TCC_INST_NUM] = TCC_SIZES;
static uint32_t tcc_periods[TCC_INST_NUM];
static uint32_t tc_periods[TC_INST_NUM];
@@ -233,8 +234,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
resolution = 16;
} else {
// TCC resolution varies so look it up.
- const uint8_t _tcc_sizes[TCC_INST_NUM] = TCC_SIZES;
- resolution = _tcc_sizes[timer->index];
+ resolution = tcc_sizes[timer->index];
}
// First determine the divisor that gets us the highest resolution.
uint32_t system_clock = common_hal_mcu_processor_get_frequency();
@@ -421,7 +421,8 @@ void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self,
if (t->is_tc) {
resolution = 16;
} else {
- resolution = 24;
+ // TCC resolution varies so look it up.
+ resolution = tcc_sizes[t->index];
}
uint32_t system_clock = common_hal_mcu_processor_get_frequency();
uint32_t new_top;
diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c
index b9977fdc4..c2e27e1e7 100644
--- a/ports/atmel-samd/supervisor/port.c
+++ b/ports/atmel-samd/supervisor/port.c
@@ -319,8 +319,9 @@ safe_mode_t port_init(void) {
}
void reset_port(void) {
+#if CIRCUITPY_BUSIO
reset_sercoms();
-
+#endif
#if CIRCUITPY_AUDIOIO
audio_dma_reset();
audioout_reset();
@@ -429,7 +430,9 @@ uint32_t port_get_saved_word(void) {
// TODO: Move this to an RTC backup register so we can preserve it when only the BACKUP power domain
// is enabled.
static volatile uint64_t overflowed_ticks = 0;
+#ifdef SAMD21
static volatile bool _ticks_enabled = false;
+#endif
static uint32_t _get_count(uint64_t* overflow_count) {
#ifdef SAM_D5X_E5X
@@ -537,9 +540,11 @@ void port_disable_tick(void) {
// they'll wake us up earlier. If we don't, we'll mess up ticks by overwriting
// the next RTC wake up time.
void port_interrupt_after_ticks(uint32_t ticks) {
+ #ifdef SAMD21
if (_ticks_enabled) {
return;
}
+ #endif
_port_interrupt_after_ticks(ticks);
}
diff --git a/ports/cxd56/boards/spresense/mpconfigboard.mk b/ports/cxd56/boards/spresense/mpconfigboard.mk
index 7b8ac6ff6..80c6e4b69 100644
--- a/ports/cxd56/boards/spresense/mpconfigboard.mk
+++ b/ports/cxd56/boards/spresense/mpconfigboard.mk
@@ -4,3 +4,5 @@ USB_PRODUCT = "Spresense"
USB_MANUFACTURER = "Sony"
INTERNAL_FLASH_FILESYSTEM = 1
+
+CIRCUITPY_MSGPACK = 0
diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile
index f33a1d2eb..aac934782 100644
--- a/ports/esp32s2/Makefile
+++ b/ports/esp32s2/Makefile
@@ -299,6 +299,8 @@ ESP_AUTOGEN_LD = $(BUILD)/esp-idf/esp-idf/esp32s2/esp32s2_out.ld $(BUILD)/esp-id
FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE) --flash_freq $(CIRCUITPY_ESP_FLASH_FREQ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE)
+ESPTOOL_FLAGS ?= -b 460800 --before=default_reset --after=no_reset
+
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
.PHONY: esp-idf-stamp
@@ -337,10 +339,10 @@ $(BUILD)/firmware.uf2: $(BUILD)/circuitpython-firmware.bin
$(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xbfdd4eee -b 0x0000 -c -o $@ $^
flash: $(BUILD)/firmware.bin
- esptool.py --chip esp32s2 -p $(PORT) -b 460800 --before=default_reset --after=no_reset write_flash $(FLASH_FLAGS) 0x0000 $^
+ esptool.py --chip esp32s2 -p $(PORT) $(ESPTOOL_FLAGS) write_flash $(FLASH_FLAGS) 0x0000 $^
flash-circuitpython-only: $(BUILD)/circuitpython-firmware.bin
- esptool.py --chip esp32s2 -p $(PORT) -b 460800 --before=default_reset --after=no_reset write_flash $(FLASH_FLAGS) 0x10000 $^
+ esptool.py --chip esp32s2 -p $(PORT) $(ESPTOOL_FLAGS) write_flash $(FLASH_FLAGS) 0x10000 $^
include $(TOP)/py/mkrules.mk
diff --git a/ports/esp32s2/bindings/espidf/__init__.c b/ports/esp32s2/bindings/espidf/__init__.c
index 554bfaa39..708c30c39 100644
--- a/ports/esp32s2/bindings/espidf/__init__.c
+++ b/ports/esp32s2/bindings/espidf/__init__.c
@@ -65,12 +65,12 @@ STATIC mp_obj_t espidf_heap_caps_get_largest_free_block(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(espidf_heap_caps_get_largest_free_block_obj, espidf_heap_caps_get_largest_free_block);
-//| class MemoryError(MemoryError):
-//| """Raised when an ESP IDF memory allocation fails."""
+//| class IDFError(OSError):
+//| """Raised for certain generic ESP IDF errors."""
//| ...
//|
-NORETURN void mp_raise_espidf_MemoryError(void) {
- nlr_raise(mp_obj_new_exception(&mp_type_espidf_MemoryError));
+NORETURN void mp_raise_espidf_IDFError(void) {
+ nlr_raise(mp_obj_new_exception(&mp_type_espidf_IDFError));
}
void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
@@ -83,6 +83,24 @@ void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin
mp_obj_exception_print(print, o_in, kind);
}
+const mp_obj_type_t mp_type_espidf_IDFError = {
+ { &mp_type_type },
+ .name = MP_QSTR_IDFError,
+ .print = espidf_exception_print,
+ .make_new = mp_obj_exception_make_new,
+ .attr = mp_obj_exception_attr,
+ .parent = &mp_type_OSError,
+};
+
+
+//| class MemoryError(MemoryError):
+//| """Raised when an ESP IDF memory allocation fails."""
+//| ...
+//|
+NORETURN void mp_raise_espidf_MemoryError(void) {
+ nlr_raise(mp_obj_new_exception(&mp_type_espidf_MemoryError));
+}
+
const mp_obj_type_t mp_type_espidf_MemoryError = {
{ &mp_type_type },
.name = MP_QSTR_MemoryError,
@@ -99,6 +117,7 @@ STATIC const mp_rom_map_elem_t espidf_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_heap_caps_get_free_size), MP_ROM_PTR(&espidf_heap_caps_get_free_size_obj)},
{ MP_ROM_QSTR(MP_QSTR_heap_caps_get_largest_free_block), MP_ROM_PTR(&espidf_heap_caps_get_largest_free_block_obj)},
+ { MP_ROM_QSTR(MP_QSTR_IDFError), MP_ROM_PTR(&mp_type_espidf_IDFError) },
{ MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_espidf_MemoryError) },
};
@@ -108,3 +127,64 @@ const mp_obj_module_t espidf_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&espidf_module_globals,
};
+
+void raise_esp_error(esp_err_t err) {
+ const compressed_string_t *msg = NULL;
+ const mp_obj_type_t * exception_type = &mp_type_espidf_IDFError;
+ switch(err) {
+ case ESP_FAIL:
+ msg = translate("Generic Failure");
+ break;
+ case ESP_ERR_NO_MEM:
+ exception_type = &mp_type_espidf_MemoryError;
+ msg = translate("Out of memory");
+ break;
+ case ESP_ERR_INVALID_ARG:
+ msg = translate("Invalid argument");
+ break;
+ case ESP_ERR_INVALID_STATE:
+ msg = translate("Invalid state");
+ break;
+ case ESP_ERR_INVALID_SIZE:
+ msg = translate("Invalid size");
+ break;
+ case ESP_ERR_NOT_FOUND:
+ msg = translate("Requested resource not found");
+ break;
+ case ESP_ERR_NOT_SUPPORTED:
+ msg = translate("Operation or feature not supported");
+ break;
+ case ESP_ERR_TIMEOUT:
+ msg = translate("Operation timed out");
+ break;
+ case ESP_ERR_INVALID_RESPONSE:
+ msg = translate("Received response was invalid");
+ break;
+ case ESP_ERR_INVALID_CRC:
+ msg = translate("CRC or checksum was invalid");
+ break;
+ case ESP_ERR_INVALID_VERSION:
+ msg = translate("Version was invalid");
+ break;
+ case ESP_ERR_INVALID_MAC:
+ msg = translate("MAC address was invalid");
+ break;
+ }
+ if (msg) {
+ mp_raise_msg(exception_type, msg);
+ }
+
+ const char *group = "ESP-IDF";
+
+ // tests must be in descending order
+ MP_STATIC_ASSERT( ESP_ERR_FLASH_BASE > ESP_ERR_MESH_BASE );
+ MP_STATIC_ASSERT( ESP_ERR_MESH_BASE > ESP_ERR_WIFI_BASE );
+ if(err >= ESP_ERR_FLASH_BASE) {
+ group = "Flash";
+ } else if (err >= ESP_ERR_MESH_BASE) {
+ group = "Mesh";
+ } else if (err >= ESP_ERR_WIFI_BASE) {
+ group = "WiFi";
+ }
+ mp_raise_msg_varg(exception_type, translate("%s error 0x%x"), group, err);
+}
diff --git a/ports/esp32s2/bindings/espidf/__init__.h b/ports/esp32s2/bindings/espidf/__init__.h
index 356c1c814..9248b01ac 100644
--- a/ports/esp32s2/bindings/espidf/__init__.h
+++ b/ports/esp32s2/bindings/espidf/__init__.h
@@ -27,8 +27,16 @@
#ifndef MICROPY_INCLUDED_ESP32S2_BINDINGS_ESPIDF___INIT___H
#define MICROPY_INCLUDED_ESP32S2_BINDINGS_ESPIDF___INIT___H
+#include "esp_err.h"
+#include "py/mpconfig.h"
+#include "py/obj.h"
+
+extern const mp_obj_type_t mp_type_espidf_IDFError;
extern const mp_obj_type_t mp_type_espidf_MemoryError;
NORETURN void mp_raise_espidf_MemoryError(void);
+void raise_esp_error(esp_err_t err) NORETURN;
+#define CHECK_ESP_RESULT(x) do { int res = (x); if(res != ESP_OK) raise_esp_error(res); } while(0)
+
#endif // MICROPY_INCLUDED_ESP32S2_BINDINGS_ESPIDF___INIT___H
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/board.c b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/board.c
new file mode 100644
index 000000000..aaef97c7d
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/board.c
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 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"
+#include "mpconfigboard.h"
+#include "shared-bindings/microcontroller/Pin.h"
+
+void board_init(void) {
+ // USB
+ common_hal_never_reset_pin(&pin_GPIO19);
+ common_hal_never_reset_pin(&pin_GPIO20);
+
+ // Debug UART
+#ifdef DEBUG
+ common_hal_never_reset_pin(&pin_GPIO43);
+ common_hal_never_reset_pin(&pin_GPIO44);
+#endif /* DEBUG */
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
+
+void board_deinit(void) {
+}
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h
new file mode 100644
index 000000000..9d95e8e43
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 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.
+ */
+
+//Micropython setup
+
+#define MICROPY_HW_BOARD_NAME "Feather ESP32S2 without PSRAM"
+#define MICROPY_HW_MCU_NAME "ESP32S2"
+
+#define MICROPY_HW_NEOPIXEL (&pin_GPIO33)
+
+#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
+
+#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")
+
+#define AUTORESET_DELAY_MS 500
+
+#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4)
+#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36)
+#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35)
+#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37)
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk
new file mode 100644
index 000000000..3290f8cae
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk
@@ -0,0 +1,22 @@
+USB_VID = 0x239A
+USB_PID = 0x80EC
+USB_PRODUCT = "Feather ESP32S2 no PSRAM"
+USB_MANUFACTURER = "Adafruit"
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = MPZ
+
+# The default queue depth of 16 overflows on release builds,
+# so increase it to 32.
+CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
+
+CIRCUITPY_ESP_FLASH_MODE=dio
+CIRCUITPY_ESP_FLASH_FREQ=40m
+CIRCUITPY_ESP_FLASH_SIZE=4MB
+
+CIRCUITPY_MODULE=wroom
+
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/pins.c b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/pins.c
new file mode 100644
index 000000000..d4704c224
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/pins.c
@@ -0,0 +1,63 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) },
+
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) },
+
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) },
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO4) },
+
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
+
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },
+ { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) },
+
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) },
+
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) },
+ { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_GPIO13) },
+
+ { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) },
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO14) },
+
+ { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) },
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO15) },
+
+ { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO16) },
+
+ { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) },
+
+ { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) },
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) },
+
+ { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) },
+ { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) },
+
+ { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },
+
+ { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) },
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) },
+
+ { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },
+
+
+ { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO38) },
+
+ { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO39) },
+
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
+};
+MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/sdkconfig b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/sdkconfig
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_nopsram/sdkconfig
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c
new file mode 100644
index 000000000..c8be18747
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c
@@ -0,0 +1,122 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 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"
+#include "mpconfigboard.h"
+#include "shared-bindings/busio/SPI.h"
+#include "shared-bindings/displayio/FourWire.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-module/displayio/__init__.h"
+#include "shared-module/displayio/mipi_constants.h"
+
+/*
+displayio_fourwire_obj_t board_display_obj;
+
+#define DELAY 0x80
+
+uint8_t display_init_sequence[] = {
+ 0x01, 0 | DELAY, 150, // SWRESET
+ 0x11, 0 | DELAY, 255, // SLPOUT
+ 0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order.
+ 0x3a, 1, 0x55, // COLMOD - 16bit color
+ 0x21, 0 | DELAY, 10, // _INVON
+ 0x13, 0 | DELAY, 10, // _NORON
+ 0x29, 0 | DELAY, 255, // _DISPON
+};
+
+*/
+
+void board_init(void) {
+ // USB
+ common_hal_never_reset_pin(&pin_GPIO19);
+ common_hal_never_reset_pin(&pin_GPIO20);
+
+ // Debug UART
+#ifdef DEBUG
+ common_hal_never_reset_pin(&pin_GPIO43);
+ common_hal_never_reset_pin(&pin_GPIO44);
+#endif /* DEBUG */
+
+ /*
+ busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
+ common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL);
+ common_hal_busio_spi_never_reset(spi);
+
+ displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
+ bus->base.type = &displayio_fourwire_type;
+ common_hal_displayio_fourwire_construct(bus,
+ spi,
+ &pin_GPIO40, // TFT_DC Command or data
+ &pin_GPIO42, // TFT_CS Chip select
+ &pin_GPIO41, // TFT_RST Reset
+ 4000000, // Baudrate
+ 0, // Polarity
+ 0); // Phase
+
+ displayio_display_obj_t* display = &displays[0].display;
+ display->base.type = &displayio_display_type;
+ common_hal_displayio_display_construct(display,
+ bus,
+ 240, // Width (after rotation)
+ 135, // Height (after rotation)
+ 0, // column start
+ 0, // row start
+ 0, // rotation
+ 16, // Color depth
+ false, // Grayscale
+ false, // Pixels in a byte share a row. Only used for depth < 8
+ 1, // bytes per cell. Only valid for depths < 8
+ false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
+ MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
+ MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
+ MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
+ 0x37, // set vertical scroll command
+ display_init_sequence,
+ sizeof(display_init_sequence),
+ &pin_GPIO7, // backlight pin
+ NO_BRIGHTNESS_COMMAND,
+ 1.0f, // brightness (ignored)
+ true, // auto_brightness
+ false, // single_byte_bounds
+ false, // data_as_commands
+ true, // auto_refresh
+ 60, // native_frames_per_second
+ true, // backlight_on_high
+ false); // not SH1107
+ */
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
+
+void board_deinit(void) {
+}
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h
new file mode 100644
index 000000000..9d95e8e43
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 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.
+ */
+
+//Micropython setup
+
+#define MICROPY_HW_BOARD_NAME "Feather ESP32S2 without PSRAM"
+#define MICROPY_HW_MCU_NAME "ESP32S2"
+
+#define MICROPY_HW_NEOPIXEL (&pin_GPIO33)
+
+#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
+
+#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")
+
+#define AUTORESET_DELAY_MS 500
+
+#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4)
+#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36)
+#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35)
+#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37)
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.mk b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.mk
new file mode 100644
index 000000000..3ba6f6228
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.mk
@@ -0,0 +1,22 @@
+USB_VID = 0x239A
+USB_PID = 0x80EE
+USB_PRODUCT = "Feather ESP32S2 TFT no PSRAM"
+USB_MANUFACTURER = "Adafruit"
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = MPZ
+
+# The default queue depth of 16 overflows on release builds,
+# so increase it to 32.
+CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
+
+CIRCUITPY_ESP_FLASH_MODE=dio
+CIRCUITPY_ESP_FLASH_FREQ=40m
+CIRCUITPY_ESP_FLASH_SIZE=4MB
+
+CIRCUITPY_MODULE=wroom
+
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/pins.c b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/pins.c
new file mode 100644
index 000000000..7e1a72374
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/pins.c
@@ -0,0 +1,72 @@
+#include "shared-bindings/board/__init__.h"
+
+#include "shared-module/displayio/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) },
+
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) },
+
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) },
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO4) },
+
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
+
+ { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO7) },
+
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },
+ { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) },
+
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) },
+
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) },
+ { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_GPIO13) },
+
+ { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) },
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO14) },
+
+ { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) },
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO15) },
+
+ { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO16) },
+
+ { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) },
+
+ { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) },
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) },
+
+ { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) },
+ { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) },
+
+ { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },
+
+ { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) },
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) },
+
+ { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },
+
+ { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO38) },
+
+ { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO39) },
+
+ { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO40) },
+ { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO41) },
+ { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO42) },
+
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
+
+ // { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
+};
+MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
diff --git a/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/sdkconfig b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/sdkconfig
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/sdkconfig
diff --git a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c
index 645dc12a1..ff44d9edb 100644
--- a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c
+++ b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c
@@ -4,7 +4,11 @@
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },
+
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) },
+ // Previous name from schematic.
{ MP_ROM_QSTR(MP_QSTR_AD1), MP_ROM_PTR(&pin_GPIO18) },
+
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO17) },
diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c
index 47764a03a..1cec5d4ae 100644
--- a/ports/esp32s2/common-hal/alarm/__init__.c
+++ b/ports/esp32s2/common-hal/alarm/__init__.c
@@ -92,9 +92,9 @@ STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) {
return alarm_pin_pinalarm_get_wakeup_alarm(n_alarms, alarms);
}
- case ESP_SLEEP_WAKEUP_TOUCHPAD:
+ case ESP_SLEEP_WAKEUP_TOUCHPAD: {
return alarm_touch_touchalarm_get_wakeup_alarm(n_alarms, alarms);
- break;
+ }
case ESP_SLEEP_WAKEUP_UNDEFINED:
default:
diff --git a/ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c b/ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c
index 20553877c..3095bc9e8 100644
--- a/ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c
+++ b/ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c
@@ -31,8 +31,8 @@
#include "peripherals/touch.h"
#include "supervisor/esp_port.h"
+static uint16_t touch_channel_mask;
static volatile bool woke_up = false;
-static touch_pad_t touch_channel = TOUCH_PAD_MAX;
void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) {
if (pin->touch_channel == TOUCH_PAD_MAX) {
@@ -50,14 +50,20 @@ mp_obj_t alarm_touch_touchalarm_get_wakeup_alarm(const size_t n_alarms, const mp
}
}
+ // Create TouchAlarm object.
alarm_touch_touchalarm_obj_t *alarm = m_new_obj(alarm_touch_touchalarm_obj_t);
alarm->base.type = &alarm_touch_touchalarm_type;
alarm->pin = NULL;
+ touch_pad_t wake_channel = touch_pad_get_current_meas_channel();
+ if (wake_channel == TOUCH_PAD_MAX) {
+ return alarm;
+ }
+
// Map the pin number back to a pin object.
for (size_t i = 0; i < mcu_pin_globals.map.used; i++) {
const mcu_pin_obj_t* pin_obj = MP_OBJ_TO_PTR(mcu_pin_globals.map.table[i].value);
- if (pin_obj->touch_channel == touch_channel) {
+ if (pin_obj->touch_channel == wake_channel) {
alarm->pin = mcu_pin_globals.map.table[i].value;
break;
}
@@ -83,46 +89,66 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
for (size_t i = 0; i < n_alarms; i++) {
if (MP_OBJ_IS_TYPE(alarms[i], &alarm_touch_touchalarm_type)) {
- if (!touch_alarm_set) {
- touch_alarm = MP_OBJ_TO_PTR(alarms[i]);
- touch_alarm_set = true;
- } else {
- mp_raise_ValueError(translate("Only one alarm.touch alarm can be set."));
+ if (deep_sleep && touch_alarm_set) {
+ mp_raise_ValueError(translate("Only one TouchAlarm can be set in deep sleep."));
}
+ touch_alarm = MP_OBJ_TO_PTR(alarms[i]);
+ touch_channel_mask |= 1 << touch_alarm->pin->number;
+ touch_alarm_set = true;
}
}
+
if (!touch_alarm_set) {
return;
}
- touch_channel = touch_alarm->pin->touch_channel;
-
// configure interrupt for pretend to deep sleep
// this will be disabled if we actually deep sleep
- // intialize touchpad
+ // reset touch peripheral
peripherals_touch_reset();
peripherals_touch_never_reset(true);
- peripherals_touch_init(touch_channel);
- // wait for touch data to reset
- mp_hal_delay_ms(10);
+ for (uint8_t i = 1; i <= 14; i++) {
+ if ((touch_channel_mask & 1 << i) != 0) {
+ touch_pad_t touch_channel = (touch_pad_t)i;
+ // intialize touchpad
+ peripherals_touch_init(touch_channel);
- // configure trigger threshold
- uint32_t touch_value;
- touch_pad_read_benchmark(touch_channel, &touch_value);
- touch_pad_set_thresh(touch_channel, touch_value * 0.1); //10%
+ // wait for touch data to reset
+ mp_hal_delay_ms(10);
+
+ // configure trigger threshold
+ uint32_t touch_value;
+ touch_pad_read_benchmark(touch_channel, &touch_value);
+ touch_pad_set_thresh(touch_channel, touch_value * 0.1); //10%
+ }
+ }
// configure touch interrupt
touch_pad_timeout_set(true, SOC_TOUCH_PAD_THRESHOLD_MAX);
touch_pad_isr_register(touch_interrupt, NULL, TOUCH_PAD_INTR_MASK_ALL);
- touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE | TOUCH_PAD_INTR_MASK_TIMEOUT);
+ touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE);
}
void alarm_touch_touchalarm_prepare_for_deep_sleep(void) {
- // intialize touchpad
+ if (!touch_channel_mask) {
+ return;
+ }
+
+ touch_pad_t touch_channel = TOUCH_PAD_MAX;
+ for (uint8_t i = 1; i <= 14; i++) {
+ if ((touch_channel_mask & 1 << i) != 0) {
+ touch_channel = (touch_pad_t)i;
+ break;
+ }
+ }
+
+ // reset touch peripheral
peripherals_touch_never_reset(false);
peripherals_touch_reset();
+
+ // intialize touchpad
peripherals_touch_init(touch_channel);
// configure touchpad for sleep
@@ -148,6 +174,6 @@ bool alarm_touch_touchalarm_woke_us_up(void) {
void alarm_touch_touchalarm_reset(void) {
woke_up = false;
- touch_channel = TOUCH_PAD_MAX;
+ touch_channel_mask = 0;
peripherals_touch_never_reset(false);
}
diff --git a/ports/esp32s2/common-hal/audiobusio/I2SOut.c b/ports/esp32s2/common-hal/audiobusio/I2SOut.c
new file mode 100644
index 000000000..86322be86
--- /dev/null
+++ b/ports/esp32s2/common-hal/audiobusio/I2SOut.c
@@ -0,0 +1,126 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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 <stdint.h>
+#include <string.h>
+
+#include "mpconfigport.h"
+
+#include "bindings/espidf/__init__.h"
+
+// Some boards don't implement I2SOut, so suppress any routines from here.
+#if CIRCUITPY_AUDIOBUSIO_I2SOUT
+
+#include "extmod/vfs_fat.h"
+#include "py/gc.h"
+#include "py/mperrno.h"
+#include "py/runtime.h"
+#include "common-hal/audiobusio/I2SOut.h"
+#include "shared-bindings/audiobusio/I2SOut.h"
+#include "shared-bindings/audiocore/RawSample.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "supervisor/shared/translate.h"
+
+#include "driver/i2s.h"
+
+// Caller validates that pins are free.
+void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self,
+ const mcu_pin_obj_t* bit_clock, const mcu_pin_obj_t* word_select,
+ const mcu_pin_obj_t* data, bool left_justified) {
+
+ port_i2s_allocate_init(&self->peripheral, left_justified);
+
+ i2s_pin_config_t i2s_pin_config = {
+ .bck_io_num = bit_clock->number,
+ .ws_io_num = word_select->number,
+ .data_out_num = data->number,
+ .data_in_num = I2S_PIN_NO_CHANGE,
+ };
+ CHECK_ESP_RESULT(i2s_set_pin(self->peripheral.instance, &i2s_pin_config));
+ self->bit_clock = bit_clock;
+ self->word_select = word_select;
+ self->data = data;
+}
+
+bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t* self) {
+ return self->peripheral.instance == -1;
+}
+
+void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self) {
+ if (common_hal_audiobusio_i2sout_deinited(self)) {
+ return;
+ }
+
+ if (self->bit_clock) {
+ reset_pin_number(self->bit_clock->number);
+ }
+ self->bit_clock = NULL;
+
+ if (self->word_select) {
+ reset_pin_number(self->word_select->number);
+ }
+ self->word_select = NULL;
+
+ if (self->data) {
+ reset_pin_number(self->data->number);
+ }
+ self->data = NULL;
+
+ if (self->peripheral.instance >= 0) {
+ port_i2s_reset_instance(self->peripheral.instance);
+ }
+ self->peripheral.instance = -1;
+}
+
+void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self,
+ mp_obj_t sample, bool loop) {
+ if (common_hal_audiobusio_i2sout_get_playing(self)) {
+ common_hal_audiobusio_i2sout_stop(self);
+ }
+ port_i2s_play(&self->peripheral, sample, loop);
+}
+
+void common_hal_audiobusio_i2sout_pause(audiobusio_i2sout_obj_t* self) {
+ port_i2s_pause(&self->peripheral);
+}
+
+void common_hal_audiobusio_i2sout_resume(audiobusio_i2sout_obj_t* self) {
+ port_i2s_resume(&self->peripheral);
+}
+
+bool common_hal_audiobusio_i2sout_get_paused(audiobusio_i2sout_obj_t* self) {
+ return port_i2s_paused(&self->peripheral);
+}
+
+void common_hal_audiobusio_i2sout_stop(audiobusio_i2sout_obj_t* self) {
+ port_i2s_stop(&self->peripheral);
+}
+
+bool common_hal_audiobusio_i2sout_get_playing(audiobusio_i2sout_obj_t* self) {
+ return port_i2s_playing(&self->peripheral);
+}
+
+#endif // CIRCUITPY_AUDIOBUSIO_I2SOUT
diff --git a/ports/esp32s2/common-hal/audiobusio/I2SOut.h b/ports/esp32s2/common-hal/audiobusio/I2SOut.h
new file mode 100644
index 000000000..891e9af67
--- /dev/null
+++ b/ports/esp32s2/common-hal/audiobusio/I2SOut.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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.
+ */
+
+#pragma once
+
+#include "supervisor/background_callback.h"
+#include "common-hal/microcontroller/Pin.h"
+
+#include "common-hal/audiobusio/__init__.h"
+
+// Some boards don't implement I2SOut, so suppress any routines from here.
+#if CIRCUITPY_AUDIOBUSIO_I2SOUT
+
+typedef struct {
+ mp_obj_base_t base;
+ i2s_t peripheral;
+ const mcu_pin_obj_t *bit_clock;
+ const mcu_pin_obj_t *word_select;
+ const mcu_pin_obj_t *data;
+} audiobusio_i2sout_obj_t;
+
+#endif
diff --git a/ports/esp32s2/common-hal/audiobusio/PDMIn.c b/ports/esp32s2/common-hal/audiobusio/PDMIn.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/esp32s2/common-hal/audiobusio/PDMIn.c
diff --git a/ports/esp32s2/common-hal/audiobusio/PDMIn.h b/ports/esp32s2/common-hal/audiobusio/PDMIn.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/esp32s2/common-hal/audiobusio/PDMIn.h
diff --git a/ports/esp32s2/common-hal/audiobusio/__init__.c b/ports/esp32s2/common-hal/audiobusio/__init__.c
new file mode 100644
index 000000000..01c77c531
--- /dev/null
+++ b/ports/esp32s2/common-hal/audiobusio/__init__.c
@@ -0,0 +1,245 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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 <string.h>
+
+#include "py/runtime.h"
+
+#include "common-hal/audiobusio/__init__.h"
+#include "bindings/espidf/__init__.h"
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "shared-module/audiocore/__init__.h"
+
+#define I2S_QUEUE_SIZE (3)
+
+static i2s_t *i2s_instance[I2S_NUM_MAX];
+static QueueHandle_t i2s_queues[I2S_NUM_MAX];
+static TaskHandle_t i2s_tasks[I2S_NUM_MAX];
+
+static int8_t port_i2s_allocate(void) {
+#if defined(I2S_NUM_1)
+ if(!i2s_instance[1]) return 1;
+#endif
+ if(!i2s_instance[0]) return 0;
+
+ mp_raise_RuntimeError(translate("Peripheral in use"));
+}
+
+void port_i2s_reset_instance(int i) {
+ assert(i >= 0 && i < I2S_NUM_MAX);
+ if (i2s_tasks[i]) {
+ vTaskDelete(i2s_tasks[i]);
+ }
+ i2s_tasks[i] = NULL;
+
+ (void)i2s_driver_uninstall(i);
+ i2s_instance[i] = NULL;
+}
+
+void i2s_reset(void) {
+ for (int i=0; i < I2S_NUM_MAX; i++) {
+ port_i2s_reset_instance(i);
+ }
+}
+
+static void i2s_fill_buffer(i2s_t *self) {
+ if (self->instance < 0 || self->instance >= I2S_NUM_MAX) {
+ return;
+ }
+#define STACK_BUFFER_SIZE (512)
+ int16_t signed_samples[STACK_BUFFER_SIZE / sizeof(int16_t)];
+
+ if (!self->playing || self->paused || !self->sample || self->stopping) {
+ memset(signed_samples, 0, sizeof(signed_samples));
+
+ size_t bytes_written = 0;
+ do {
+ CHECK_ESP_RESULT(i2s_write(self->instance, signed_samples, sizeof(signed_samples), &bytes_written, 0));
+ } while (bytes_written != 0);
+ return;
+ }
+ while (!self->stopping) {
+ if (self->sample_data == self->sample_end) {
+ uint32_t sample_buffer_length;
+ audioio_get_buffer_result_t get_buffer_result =
+ audiosample_get_buffer(self->sample, false, 0,
+ &self->sample_data, &sample_buffer_length);
+ self->sample_end = self->sample_data + sample_buffer_length;
+ if (get_buffer_result == GET_BUFFER_DONE) {
+ if (self->loop) {
+ audiosample_reset_buffer(self->sample, false, 0);
+ } else {
+ self->stopping = true;
+ break;
+ }
+ }
+ if (get_buffer_result == GET_BUFFER_ERROR || sample_buffer_length == 0) {
+ self->stopping = true;
+ break;
+ }
+ }
+ size_t bytes_written = 0;
+ size_t bytecount = self->sample_end - self->sample_data;
+ if (self->samples_signed && self->channel_count == 2) {
+ if (self->bytes_per_sample == 2) {
+ CHECK_ESP_RESULT(i2s_write(self->instance, self->sample_data, bytecount, &bytes_written, 0));
+ } else {
+ CHECK_ESP_RESULT(i2s_write_expand(self->instance, self->sample_data, bytecount, 8, 16, &bytes_written, 0));
+ }
+ } else {
+ const size_t bytes_per_output_frame = 4;
+ size_t bytes_per_input_frame = self->channel_count * self->bytes_per_sample;
+ size_t framecount = MIN(STACK_BUFFER_SIZE / bytes_per_output_frame, bytecount / bytes_per_input_frame);
+ if (self->samples_signed) {
+ assert(self->channel_count == 1);
+ if (self->bytes_per_sample == 1) {
+ audiosample_convert_s8m_s16s(signed_samples, (int8_t*)(void*)self->sample_data, framecount);
+ } else {
+ audiosample_convert_s16m_s16s(signed_samples, (int16_t*)(void*)self->sample_data, framecount);
+ }
+ } else {
+ if (self->channel_count == 1) {
+ if (self->bytes_per_sample == 1) {
+ audiosample_convert_u8m_s16s(signed_samples, (uint8_t*)(void*)self->sample_data, framecount);
+ } else {
+ audiosample_convert_u16m_s16s(signed_samples, (uint16_t*)(void*)self->sample_data, framecount);
+ }
+ } else {
+ if (self->bytes_per_sample == 1) {
+ audiosample_convert_u8s_s16s(signed_samples, (uint8_t*)(void*)self->sample_data, framecount);
+ } else {
+ audiosample_convert_u16s_s16s(signed_samples, (uint16_t*)(void*)self->sample_data, framecount);
+ }
+ }
+ }
+ size_t expanded_bytes_written = 0;
+ CHECK_ESP_RESULT(i2s_write(self->instance, signed_samples, bytes_per_output_frame*framecount, &expanded_bytes_written, 0));
+ assert(expanded_bytes_written % 4 == 0);
+ bytes_written = expanded_bytes_written / bytes_per_output_frame * bytes_per_input_frame;
+ }
+ self->sample_data += bytes_written;
+ // We have filled the DMA buffer
+ if (!bytes_written) {
+ break;
+ }
+ }
+}
+
+static void i2s_callback_fun(void *self_in) {
+ i2s_t *self = self_in;
+ i2s_fill_buffer(self);
+}
+
+static void i2s_event_task(void *self_in) {
+ i2s_t *self = self_in;
+ while(true) {
+ i2s_event_type_t event;
+ BaseType_t result = xQueueReceive(i2s_queues[self->instance], &event, portMAX_DELAY);
+ if (result && event == I2S_EVENT_TX_DONE) {
+ background_callback_add(&self->callback, i2s_callback_fun, self_in);
+ }
+ }
+}
+
+void port_i2s_allocate_init(i2s_t *self, bool left_justified) {
+ self->instance = port_i2s_allocate();
+
+ i2s_config_t i2s_config = {
+ .mode = I2S_MODE_MASTER | I2S_MODE_TX,
+ .sample_rate = 44100,
+ .bits_per_sample = 16,
+ .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
+ .communication_format = left_justified ? I2S_COMM_FORMAT_STAND_I2S : I2S_COMM_FORMAT_STAND_I2S,
+ .dma_buf_count = 2,
+ .dma_buf_len = 128, // in _frames_, so 128 is 512 bytes per dma buf
+ .use_apll = false,
+ };
+ CHECK_ESP_RESULT(i2s_driver_install(self->instance, &i2s_config, I2S_QUEUE_SIZE, &i2s_queues[self->instance]));
+
+ if (!xTaskCreate(i2s_event_task, "I2S_task", 3 * configMINIMAL_STACK_SIZE, self, CONFIG_PTHREAD_TASK_PRIO_DEFAULT, &i2s_tasks[self->instance])) {
+ mp_raise_OSError_msg(translate("xTaskCreate failed"));
+ }
+ i2s_instance[self->instance] = self;
+
+}
+
+
+void port_i2s_play(i2s_t *self, mp_obj_t sample, bool loop) {
+ self->sample = sample;
+ self->loop = loop;
+ self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8;
+ self->channel_count = audiosample_channel_count(sample);
+ bool single_buffer;
+ bool samples_signed;
+ uint32_t max_buffer_length;
+ uint8_t spacing;
+ audiosample_get_buffer_structure(sample, false, &single_buffer, &samples_signed,
+ &max_buffer_length, &spacing);
+ self->samples_signed = samples_signed;
+ self->playing = true;
+ self->paused = false;
+ self->stopping = false;
+ self->sample_data = self->sample_end = NULL;
+ // We always output stereo so output twice as many bits.
+ // uint16_t bits_per_sample_output = bits_per_sample * 2;
+
+ audiosample_reset_buffer(self->sample, false, 0);
+
+ CHECK_ESP_RESULT(i2s_set_sample_rates(self->instance, audiosample_sample_rate(sample)));
+
+ background_callback_add(&self->callback, i2s_callback_fun, self);
+}
+
+bool port_i2s_playing(i2s_t *self) {
+ return self->playing && !self->stopping;
+}
+
+bool port_i2s_paused(i2s_t *self) {
+ return self->paused;
+}
+
+void port_i2s_stop(i2s_t *self) {
+ self->sample = NULL;
+ self->paused = false;
+ self->playing = false;
+ self->stopping = false;
+}
+
+void port_i2s_pause(i2s_t *self) {
+ if (!self->paused) {
+ self->paused = true;
+ CHECK_ESP_RESULT(i2s_stop(self->instance));
+ }
+}
+
+void port_i2s_resume(i2s_t *self) {
+ if (self->paused) {
+ self->paused = false;
+ CHECK_ESP_RESULT(i2s_start(self->instance));
+ }
+}
diff --git a/ports/esp32s2/common-hal/audiobusio/__init__.h b/ports/esp32s2/common-hal/audiobusio/__init__.h
new file mode 100644
index 000000000..7709735da
--- /dev/null
+++ b/ports/esp32s2/common-hal/audiobusio/__init__.h
@@ -0,0 +1,61 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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.
+ */
+
+#pragma once
+
+#include "py/obj.h"
+
+#include "supervisor/background_callback.h"
+
+#include "driver/i2s.h"
+
+typedef struct {
+ mp_obj_t *sample;
+ bool left_justified;
+ bool loop;
+ bool paused;
+ bool playing;
+ bool stopping;
+ bool samples_signed;
+ int8_t bytes_per_sample;
+ int8_t channel_count;
+ int8_t instance;
+ uint16_t buffer_length;
+ uint8_t *sample_data, *sample_end;
+ i2s_config_t i2s_config;
+ background_callback_t callback;
+} i2s_t;
+
+
+void port_i2s_allocate_init(i2s_t *self, bool left_justified);
+void port_i2s_reset_instance(int i);
+void i2s_reset(void);
+void port_i2s_play(i2s_t *self, mp_obj_t sample, bool loop);
+void port_i2s_stop(i2s_t *self);
+bool port_i2s_playing(i2s_t *self);
+bool port_i2s_paused(i2s_t *self);
+void port_i2s_pause(i2s_t *self);
+void port_i2s_resume(i2s_t *self);
diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c
index 32c5fc72f..5e943f8fd 100644
--- a/ports/esp32s2/common-hal/socketpool/Socket.c
+++ b/ports/esp32s2/common-hal/socketpool/Socket.c
@@ -178,7 +178,7 @@ mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* se
struct sockaddr_in source_addr;
socklen_t socklen = sizeof(source_addr);
- int bytes_received = lwip_recvfrom(self->num, buf, len - 1, 0, (struct sockaddr *)&source_addr, &socklen);
+ int bytes_received = lwip_recvfrom(self->num, buf, len, 0, (struct sockaddr *)&source_addr, &socklen);
memcpy((void *)ip, (void*)&source_addr.sin_addr.s_addr, sizeof source_addr.sin_addr.s_addr);
*port = source_addr.sin_port;
@@ -186,10 +186,9 @@ mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* se
if (bytes_received < 0) {
mp_raise_BrokenPipeError();
return 0;
- } else {
- buf[bytes_received] = 0; // Null-terminate whatever we received
- return bytes_received;
}
+
+ return bytes_received;
}
void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self) {
diff --git a/ports/esp32s2/common-hal/wifi/Network.c b/ports/esp32s2/common-hal/wifi/Network.c
index 2674df065..b6eb6bb43 100644
--- a/ports/esp32s2/common-hal/wifi/Network.c
+++ b/ports/esp32s2/common-hal/wifi/Network.c
@@ -54,3 +54,37 @@ mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self) {
// 2 instead of strlen(cstr) as this gives us only the country-code
return mp_obj_new_str(cstr, 2);
}
+
+mp_obj_t common_hal_wifi_network_get_authmode(wifi_network_obj_t *self) {
+ const char* authmode = "";
+ switch (self->record.authmode) {
+ case WIFI_AUTH_OPEN:
+ authmode = "OPEN";
+ break;
+ case WIFI_AUTH_WEP:
+ authmode = "WEP";
+ break;
+ case WIFI_AUTH_WPA_PSK:
+ authmode = "WPA_PSK";
+ break;
+ case WIFI_AUTH_WPA2_PSK:
+ authmode = "WPA2_PSK";
+ break;
+ case WIFI_AUTH_WPA_WPA2_PSK:
+ authmode = "WPA_WPA2_PSK";
+ break;
+ case WIFI_AUTH_WPA2_ENTERPRISE:
+ authmode = "WPA2_ENTERPRISE";
+ break;
+ case WIFI_AUTH_WPA3_PSK:
+ authmode = "WPA3_PSK";
+ break;
+ case WIFI_AUTH_WPA2_WPA3_PSK:
+ authmode = "WPA2_WPA3_PSK";
+ break;
+ default:
+ authmode = "UNKNOWN";
+ break;
+ }
+ return mp_obj_new_str(authmode, strlen(authmode));
+}
diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c
index e9f374a06..930230088 100644
--- a/ports/esp32s2/common-hal/wifi/Radio.c
+++ b/ports/esp32s2/common-hal/wifi/Radio.c
@@ -168,11 +168,11 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t
} while ((bits & (WIFI_CONNECTED_BIT | WIFI_DISCONNECTED_BIT)) == 0 && !mp_hal_is_interrupted());
if ((bits & WIFI_DISCONNECTED_BIT) != 0) {
if (self->last_disconnect_reason == WIFI_REASON_AUTH_FAIL) {
- return WIFI_RADIO_ERROR_AUTH;
+ return WIFI_RADIO_ERROR_AUTH_FAIL;
} else if (self->last_disconnect_reason == WIFI_REASON_NO_AP_FOUND) {
return WIFI_RADIO_ERROR_NO_AP_FOUND;
}
- return WIFI_RADIO_ERROR_UNKNOWN;
+ return self->last_disconnect_reason;
}
return WIFI_RADIO_ERROR_NONE;
}
diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c
index 08d7a164f..b8e8f731b 100644
--- a/ports/esp32s2/common-hal/wifi/__init__.c
+++ b/ports/esp32s2/common-hal/wifi/__init__.c
@@ -65,11 +65,9 @@ static void event_handler(void* arg, esp_event_base_t event_base,
uint8_t reason = d->reason;
ESP_LOGW(TAG, "reason %d 0x%02x", reason, reason);
if (radio->retries_left > 0 &&
- (reason == WIFI_REASON_AUTH_EXPIRE ||
- reason == WIFI_REASON_NOT_AUTHED ||
- reason == WIFI_REASON_ASSOC_EXPIRE ||
- reason == WIFI_REASON_CONNECTION_FAIL ||
- reason == WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT)) {
+ reason != WIFI_REASON_AUTH_FAIL &&
+ reason != WIFI_REASON_NO_AP_FOUND &&
+ reason != WIFI_REASON_ASSOC_LEAVE) {
radio->retries_left--;
ESP_LOGI(TAG, "Retrying connect. %d retries remaining", radio->retries_left);
esp_wifi_connect();
diff --git a/ports/esp32s2/esp-idf-config/sdkconfig-debug.defaults b/ports/esp32s2/esp-idf-config/sdkconfig-debug.defaults
index f45f6ae9f..b108532aa 100644
--- a/ports/esp32s2/esp-idf-config/sdkconfig-debug.defaults
+++ b/ports/esp32s2/esp-idf-config/sdkconfig-debug.defaults
@@ -10,4 +10,7 @@ CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y
# CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT is not set
# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set
-# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set \ No newline at end of file
+# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set
+CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG=y
+CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y
+CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y \ No newline at end of file
diff --git a/ports/esp32s2/esp_error.c b/ports/esp32s2/esp_error.c
new file mode 100644
index 000000000..57bc51528
--- /dev/null
+++ b/ports/esp32s2/esp_error.c
@@ -0,0 +1,91 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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 "esp_error.h"
+#include "py/runtime.h"
+
+#include "bindings/espidf/__init__.h"
+
+void raise_esp_error(esp_err_t err) {
+ const compressed_string_t *msg = NULL;
+ const mp_obj_type_t * exception_type = &mp_type_espidf_IDFError;
+ switch(err) {
+ case ESP_FAIL:
+ msg = translate("Generic Failure");
+ break;
+ case ESP_ERR_NO_MEM:
+ exception_type = &mp_type_espidf_MemoryError;
+ msg = translate("Out of memory");
+ break;
+ case ESP_ERR_INVALID_ARG:
+ msg = translate("Invalid argument");
+ break;
+ case ESP_ERR_INVALID_STATE:
+ msg = translate("Invalid state");
+ break;
+ case ESP_ERR_INVALID_SIZE:
+ msg = translate("Invalid size");
+ break;
+ case ESP_ERR_NOT_FOUND:
+ msg = translate("Requested resource not found");
+ break;
+ case ESP_ERR_NOT_SUPPORTED:
+ msg = translate("Operation or feature not supported");
+ break;
+ case ESP_ERR_TIMEOUT:
+ msg = translate("Operation timed out");
+ break;
+ case ESP_ERR_INVALID_RESPONSE:
+ msg = translate("Received response was invalid");
+ break;
+ case ESP_ERR_INVALID_CRC:
+ msg = translate("CRC or checksum was invalid");
+ break;
+ case ESP_ERR_INVALID_VERSION:
+ msg = translate("Version was invalid");
+ break;
+ case ESP_ERR_INVALID_MAC:
+ msg = translate("MAC address was invalid");
+ break;
+ }
+ if (msg) {
+ mp_raise_msg(exception_type, msg);
+ }
+
+ const char *group = "ESP-IDF";
+
+ // tests must be in descending order
+ MP_STATIC_ASSERT( ESP_ERR_FLASH_BASE > ESP_ERR_MESH_BASE );
+ MP_STATIC_ASSERT( ESP_ERR_MESH_BASE > ESP_ERR_WIFI_BASE );
+ if(err >= ESP_ERR_FLASH_BASE) {
+ group = "Flash";
+ } else if (err >= ESP_ERR_MESH_BASE) {
+ group = "Mesh";
+ } else if (err >= ESP_ERR_WIFI_BASE) {
+ group = "WiFi";
+ }
+ mp_raise_msg_varg(exception_type, translate("%s error 0x%x"), group, err);
+}
diff --git a/ports/esp32s2/mpconfigport.h b/ports/esp32s2/mpconfigport.h
index db7393d8e..9c0fd9da3 100644
--- a/ports/esp32s2/mpconfigport.h
+++ b/ports/esp32s2/mpconfigport.h
@@ -32,6 +32,7 @@
#define MICROPY_PY_UJSON (1)
#define MICROPY_USE_INTERNAL_PRINTF (0)
+#define MICROPY_PY_SYS_PLATFORM "Espressif ESP32-S2"
#include "py/circuitpy_mpconfig.h"
diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk
index 2ad8afb51..562c60998 100644
--- a/ports/esp32s2/mpconfigport.mk
+++ b/ports/esp32s2/mpconfigport.mk
@@ -15,7 +15,11 @@ LONGINT_IMPL = MPZ
# These modules are implemented in ports/<port>/common-hal:
CIRCUITPY_FULL_BUILD = 1
CIRCUITPY_ALARM = 1
-CIRCUITPY_AUDIOBUSIO = 0
+CIRCUITPY_AUDIOCORE = 1
+CIRCUITPY_AUDIOMP3 = 0
+CIRCUITPY_AUDIOBUSIO = 1
+CIRCUITPY_AUDIOBUSIO_PDMIN = 0
+CIRCUITPY_AUDIOBUSIO_I2SOUT = 1
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_CANIO = 1
CIRCUITPY_COUNTIO = 1
diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c
index 213473b8d..6491e7430 100644
--- a/ports/esp32s2/supervisor/port.c
+++ b/ports/esp32s2/supervisor/port.c
@@ -61,6 +61,10 @@
#include "components/soc/soc/esp32s2/include/soc/cache_memory.h"
#include "components/soc/soc/esp32s2/include/soc/rtc_cntl_reg.h"
+#if CIRCUITPY_AUDIOBUSIO
+#include "common-hal/audiobusio/__init__.h"
+#endif
+
#define HEAP_SIZE (48 * 1024)
uint32_t* heap;
@@ -107,6 +111,20 @@ safe_mode_t port_init(void) {
heap = NULL;
never_reset_module_internal_pins();
+ #if defined(DEBUG)
+ // debug UART
+ common_hal_never_reset_pin(&pin_GPIO43);
+ common_hal_never_reset_pin(&pin_GPIO44);
+ #endif
+
+ #if defined(DEBUG) || defined(ENABLE_JTAG)
+ // JTAG
+ common_hal_never_reset_pin(&pin_GPIO39);
+ common_hal_never_reset_pin(&pin_GPIO40);
+ common_hal_never_reset_pin(&pin_GPIO41);
+ common_hal_never_reset_pin(&pin_GPIO42);
+ #endif
+
#ifdef CONFIG_SPIRAM
heap = (uint32_t*) (DRAM0_CACHE_ADDRESS_HIGH - CONFIG_SPIRAM_SIZE);
heap_size = CONFIG_SPIRAM_SIZE / sizeof(uint32_t);
@@ -153,6 +171,10 @@ void reset_port(void) {
ps2_reset();
#endif
+#if CIRCUITPY_AUDIOBUSIO
+ i2s_reset();
+#endif
+
#if CIRCUITPY_PULSEIO
esp32s2_peripherals_rmt_reset();
pulsein_reset();
@@ -275,10 +297,14 @@ void port_disable_tick(void) {
esp_timer_stop(_tick_timer);
}
-void sleep_timer_cb(void* arg) {
+void port_wake_main_task() {
xTaskNotifyGive(circuitpython_task);
}
+void sleep_timer_cb(void* arg) {
+ port_wake_main_task();
+}
+
void port_interrupt_after_ticks(uint32_t ticks) {
uint64_t timeout_us = ticks * 1000000ull / 1024;
if (esp_timer_start_once(_sleep_timer, timeout_us) != ESP_OK) {
diff --git a/ports/nrf/boards/TG-Watch02A/board.c b/ports/nrf/boards/TG-Watch/board.c
index 781793328..781793328 100644
--- a/ports/nrf/boards/TG-Watch02A/board.c
+++ b/ports/nrf/boards/TG-Watch/board.c
diff --git a/ports/nrf/boards/TG-Watch02A/mpconfigboard.h b/ports/nrf/boards/TG-Watch/mpconfigboard.h
index 9b8a31858..07a607b3d 100644
--- a/ports/nrf/boards/TG-Watch02A/mpconfigboard.h
+++ b/ports/nrf/boards/TG-Watch/mpconfigboard.h
@@ -27,10 +27,15 @@
#include "nrfx/hal/nrf_gpio.h"
-#define MICROPY_HW_BOARD_NAME "TG-Techie's TG-Watch02A"
+#define MICROPY_HW_BOARD_NAME "TG-Watch"
#define MICROPY_HW_MCU_NAME "nRF52840"
-#define MICROPY_HW_LED_STATUS (&pin_P0_07)
+#define MICROPY_HW_NEOPIXEL (&pin_P0_16)
+#define MICROPY_HW_LED_STATUS (&pin_P1_15)
+
+// TG-Gui requires a deeper call stack than normal CircuitPython
+#define CIRCUITPY_PYSTACK_SIZE 8192 // 1536 is the normal size, (32 bytes/frame * 48 frames)
+#define BOARD_HAS_CRYSTAL 0
#if QSPI_FLASH_FILESYSTEM
#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 17)
@@ -48,8 +53,6 @@
#define SPI_FLASH_CS_PIN &pin_P0_20
#endif
-#define BOARD_HAS_CRYSTAL 0
-
#define DEFAULT_I2C_BUS_SCL (&pin_P0_11)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_12)
diff --git a/ports/nrf/boards/TG-Watch02A/mpconfigboard.mk b/ports/nrf/boards/TG-Watch/mpconfigboard.mk
index 4f5899fa7..f1aac6d71 100644
--- a/ports/nrf/boards/TG-Watch02A/mpconfigboard.mk
+++ b/ports/nrf/boards/TG-Watch/mpconfigboard.mk
@@ -1,7 +1,7 @@
USB_VID = 0x239A
USB_PID = 0x80DB
-USB_PRODUCT = "TG-Watch02A"
-USB_MANUFACTURER = "TG-Tech"
+USB_PRODUCT = "TG-Watch"
+USB_MANUFACTURER = "TG-Techie"
MCU_CHIP = nrf52840
@@ -11,9 +11,14 @@ EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q128JV_SQ"
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ST7789
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Shapes
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ProgressBar
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LSM6DS
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FocalTouch
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DS3231
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LC709203F
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DRV2605
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BLE
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center
diff --git a/ports/nrf/boards/TG-Watch/pins.c b/ports/nrf/boards/TG-Watch/pins.c
new file mode 100644
index 000000000..275b89b22
--- /dev/null
+++ b/ports/nrf/boards/TG-Watch/pins.c
@@ -0,0 +1,74 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+
+ /* default ports */
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_14) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_13) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_25) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_24) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_12) },
+
+ /* TG-Watch specific pins */
+ { MP_ROM_QSTR(MP_QSTR_VBUS_PRESENT), MP_ROM_PTR(&pin_P1_04) },
+ { MP_ROM_QSTR(MP_QSTR_HAPTIC_ENABLE), MP_ROM_PTR(&pin_P1_06) },
+ { MP_ROM_QSTR(MP_QSTR_HAPTIC_INT), MP_ROM_PTR(&pin_P1_07) },
+ { MP_ROM_QSTR(MP_QSTR_CTP_INT), MP_ROM_PTR(&pin_P1_05) },
+ { MP_ROM_QSTR(MP_QSTR_CTP_RST), MP_ROM_PTR(&pin_P1_03) },
+ { MP_ROM_QSTR(MP_QSTR_TFT_RST), MP_ROM_PTR(&pin_P1_01) },
+
+ { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_P1_12) },
+ { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_P1_13) },
+ { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_P1_14) },
+
+ { MP_ROM_QSTR(MP_QSTR_ACCEL_INT1), MP_ROM_PTR(&pin_P1_11) },
+ { MP_ROM_QSTR(MP_QSTR_ACCEL_INT2), MP_ROM_PTR(&pin_P1_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_BATTERY_DIV), MP_ROM_PTR(&pin_P0_29) },
+
+ { MP_ROM_QSTR(MP_QSTR_RTC_INT), MP_ROM_PTR(&pin_P0_27) },
+ { MP_ROM_QSTR(MP_QSTR_RTC_RST), MP_ROM_PTR(&pin_P0_26) },
+ { MP_ROM_QSTR(MP_QSTR_CHRG_STAT), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_BACKLIGHT), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR_BAT_INT), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_SMC_RST), MP_ROM_PTR(&pin_P0_04) },
+
+ /* nrf52840 compatible pins */
+ { MP_ROM_QSTR(MP_QSTR__A0), MP_ROM_PTR(&pin_P0_04) },
+ { MP_ROM_QSTR(MP_QSTR__A1), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR__A2), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR__A3), MP_ROM_PTR(&pin_P0_28) },
+ { MP_ROM_QSTR(MP_QSTR__A4), MP_ROM_PTR(&pin_P0_02) },
+ { MP_ROM_QSTR(MP_QSTR__A5), MP_ROM_PTR(&pin_P0_03) },
+
+ { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR__VOLTAGE_MONITOR), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR__BATTERY), MP_ROM_PTR(&pin_P0_29) },
+
+ { MP_ROM_QSTR(MP_QSTR__SWITCH), MP_ROM_PTR(&pin_P1_02) },
+
+ { MP_ROM_QSTR(MP_QSTR__NFC1), MP_ROM_PTR(&pin_P0_09) },
+ { MP_ROM_QSTR(MP_QSTR__NFC2), MP_ROM_PTR(&pin_P0_10) },
+
+ { MP_ROM_QSTR(MP_QSTR__D2), MP_ROM_PTR(&pin_P0_10) },
+ { MP_ROM_QSTR(MP_QSTR__D5), MP_ROM_PTR(&pin_P1_08) },
+ { MP_ROM_QSTR(MP_QSTR__D6), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR__D9), MP_ROM_PTR(&pin_P0_26) },
+ { MP_ROM_QSTR(MP_QSTR__D10), MP_ROM_PTR(&pin_P0_27) },
+ { MP_ROM_QSTR(MP_QSTR__D11), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR__D12), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR__D13), MP_ROM_PTR(&pin_P1_09) },
+
+ { MP_ROM_QSTR(MP_QSTR__NEOPIXEL), MP_ROM_PTR(&pin_P0_16) },
+};
+
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/boards/TG-Watch02A/pins.c b/ports/nrf/boards/TG-Watch02A/pins.c
deleted file mode 100644
index 582d954ec..000000000
--- a/ports/nrf/boards/TG-Watch02A/pins.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "shared-bindings/board/__init__.h"
-
-STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
-
- /*Port and bus pins*/
- { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_14) },
- { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_13) },
- { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_15) },
-
- { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) },
- { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_12) },
-
- { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
- { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
- { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
-
- /*TG-Watch02A specific pins*/
-
- //tft / display pins
- { MP_ROM_QSTR(MP_QSTR_BACKLIGHT), MP_ROM_PTR(&pin_P0_07) },
- { MP_ROM_QSTR(MP_QSTR_DISP_PWR), MP_ROM_PTR(&pin_P0_05) },
- { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_P1_14) },
- { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_P1_12) },
- { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_P1_01) },
-
- //cap touch screen
- { MP_ROM_QSTR(MP_QSTR_CTP_RESET), MP_ROM_PTR(&pin_P1_03) },
- { MP_ROM_QSTR(MP_QSTR_CTP_INT), MP_ROM_PTR(&pin_P1_05) },
-
- //power / battery
- { MP_ROM_QSTR(MP_QSTR_CHRG_STAT), MP_ROM_PTR(&pin_P0_06) },
- { MP_ROM_QSTR(MP_QSTR_BAT_VDIV), MP_ROM_PTR(&pin_P0_29) },
- { MP_ROM_QSTR(MP_QSTR_VBUS_PRESENT), MP_ROM_PTR(&pin_P1_04) },
-
- //sensors / outputs
- { MP_ROM_QSTR(MP_QSTR_RTC_RESET), MP_ROM_PTR(&pin_P0_26) },
- { MP_ROM_QSTR(MP_QSTR_RTC_INT), MP_ROM_PTR(&pin_P0_27) },
-
- { MP_ROM_QSTR(MP_QSTR_ACCEL_INT1), MP_ROM_PTR(&pin_P1_11) },
- { MP_ROM_QSTR(MP_QSTR_ACCEL_INT2), MP_ROM_PTR(&pin_P1_10) },
-
- { MP_ROM_QSTR(MP_QSTR_HAPTIC_INT), MP_ROM_PTR(&pin_P1_07) },
- { MP_ROM_QSTR(MP_QSTR_HAPTIC_ENABLE), MP_ROM_PTR(&pin_P1_06) },
-
- //smc pins
- { MP_ROM_QSTR(MP_QSTR_SMC_RESET), MP_ROM_PTR(&pin_P0_08) },
- { MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_P1_08) },
- { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P1_09) },
-};
-
-MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/boards/pca10100/mpconfigboard.mk b/ports/nrf/boards/pca10100/mpconfigboard.mk
index 86ba65454..76d15e608 100644
--- a/ports/nrf/boards/pca10100/mpconfigboard.mk
+++ b/ports/nrf/boards/pca10100/mpconfigboard.mk
@@ -15,6 +15,7 @@ CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_NEOPIXEL_WRITE = 0
CIRCUITPY_NVM = 0
CIRCUITPY_PIXELBUF = 0
diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk
index dd6b1fbfd..4eb6c98c7 100644
--- a/ports/nrf/boards/simmel/mpconfigboard.mk
+++ b/ports/nrf/boards/simmel/mpconfigboard.mk
@@ -16,6 +16,7 @@ CIRCUITPY_AUDIOMP3 = 0
CIRCUITPY_BUSIO = 1
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FRAMEBUFFERIO = 0
+CIRCUITPY_MSGPACK = 0
CIRCUITPY_GAMEPAD = 0
CIRCUITPY_NEOPIXEL_WRITE = 0
CIRCUITPY_NVM = 0
diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c
index 53a40f9a6..10794c16a 100644
--- a/ports/nrf/common-hal/_bleio/Adapter.c
+++ b/ports/nrf/common-hal/_bleio/Adapter.c
@@ -469,7 +469,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t*
ble_drv_add_event_handler(scan_on_ble_evt, self->scan_results);
- uint32_t nrf_timeout = SEC_TO_UNITS(timeout, UNIT_10_MS);
+ uint32_t nrf_timeout = SEC_TO_UNITS(timeout, UNIT_10_MS) + 0.5f;
if (nrf_timeout > UINT16_MAX) {
// 0xffff / 100
mp_raise_ValueError(translate("timeout must be < 655.35 secs"));
@@ -479,15 +479,15 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t*
mp_raise_ValueError(translate("non-zero timeout must be > 0.01"));
}
- if (nrf_timeout) {
+ if (nrf_timeout == 0) {
nrf_timeout = BLE_GAP_SCAN_TIMEOUT_UNLIMITED;
}
ble_gap_scan_params_t scan_params = {
.extended = extended,
- .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS),
+ .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS) + 0.5f,
.timeout = nrf_timeout,
- .window = SEC_TO_UNITS(window, UNIT_0_625_MS),
+ .window = SEC_TO_UNITS(window, UNIT_0_625_MS) + 0.5f,
.scan_phys = BLE_GAP_PHY_1MBPS,
.active = active
};
@@ -553,7 +553,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre
.window = MSEC_TO_UNITS(100, UNIT_0_625_MS),
.scan_phys = BLE_GAP_PHY_1MBPS,
// timeout of 0 means no timeout
- .timeout = SEC_TO_UNITS(timeout, UNIT_10_MS),
+ .timeout = SEC_TO_UNITS(timeout, UNIT_10_MS) + 0.5f,
};
ble_gap_conn_params_t conn_params = {
@@ -696,7 +696,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
}
ble_gap_adv_params_t adv_params = {
- .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS),
+ .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS) + 0.5f,
.properties.type = adv_type,
.duration = SEC_TO_UNITS(timeout, UNIT_10_MS),
.filter_policy = BLE_GAP_ADV_FP_ANY,
diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c
index 57c481448..c0f0372c3 100644
--- a/ports/nrf/common-hal/_bleio/Characteristic.c
+++ b/ports/nrf/common-hal/_bleio/Characteristic.c
@@ -132,13 +132,6 @@ size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *sel
}
void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) {
- if (self->fixed_length && bufinfo->len != self->max_length) {
- mp_raise_ValueError(translate("Value length != required fixed length"));
- }
- if (bufinfo->len > self->max_length) {
- mp_raise_ValueError(translate("Value length > max_length"));
- }
-
// Do GATT operations only if this characteristic has been added to a registered service.
if (self->handle != BLE_GATT_HANDLE_INVALID) {
@@ -148,6 +141,14 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self,
common_hal_bleio_gattc_write(self->handle, conn_handle, bufinfo,
(self->props & CHAR_PROP_WRITE_NO_RESPONSE));
} else {
+ // Validate data length for local characteristics only.
+ if (self->fixed_length && bufinfo->len != self->max_length) {
+ mp_raise_ValueError(translate("Value length != required fixed length"));
+ }
+ if (bufinfo->len > self->max_length) {
+ mp_raise_ValueError(translate("Value length > max_length"));
+ }
+
// Always write the value locally even if no connections are active.
// conn_handle is ignored for non-system attributes, so we use BLE_CONN_HANDLE_INVALID.
common_hal_bleio_gatts_write(self->handle, BLE_CONN_HANDLE_INVALID, bufinfo);
diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c
index 4f747bf97..36fda0bb3 100644
--- a/ports/nrf/common-hal/_bleio/Connection.c
+++ b/ports/nrf/common-hal/_bleio/Connection.c
@@ -522,7 +522,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio
common_hal_bleio_characteristic_construct(
characteristic, m_char_discovery_service, gattc_char->handle_value, uuid,
props, SECURITY_MODE_OPEN, SECURITY_MODE_OPEN,
- GATT_MAX_DATA_LENGTH, false, // max_length, fixed_length: values may not matter for gattc
+ GATT_MAX_DATA_LENGTH, false, // max_length, fixed_length: values don't matter for gattc
mp_const_empty_bytes);
mp_obj_list_append(MP_OBJ_FROM_PTR(m_char_discovery_service->characteristic_list),
diff --git a/ports/nrf/common-hal/_bleio/Descriptor.c b/ports/nrf/common-hal/_bleio/Descriptor.c
index 9e9110723..d848659fc 100644
--- a/ports/nrf/common-hal/_bleio/Descriptor.c
+++ b/ports/nrf/common-hal/_bleio/Descriptor.c
@@ -73,13 +73,6 @@ size_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self, uint8
}
void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo) {
- if (self->fixed_length && bufinfo->len != self->max_length) {
- mp_raise_ValueError(translate("Value length != required fixed length"));
- }
- if (bufinfo->len > self->max_length) {
- mp_raise_ValueError(translate("Value length > max_length"));
- }
-
// Do GATT operations only if this descriptor has been registered.
if (self->handle != BLE_GATT_HANDLE_INVALID) {
uint16_t conn_handle = bleio_connection_get_conn_handle(self->characteristic->service->connection);
@@ -87,6 +80,14 @@ void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buff
// false means WRITE_REQ, not write-no-response
common_hal_bleio_gattc_write(self->handle, conn_handle, bufinfo, false);
} else {
+ // Validate data length for local descriptors only.
+ if (self->fixed_length && bufinfo->len != self->max_length) {
+ mp_raise_ValueError(translate("Value length != required fixed length"));
+ }
+ if (bufinfo->len > self->max_length) {
+ mp_raise_ValueError(translate("Value length > max_length"));
+ }
+
common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo);
}
}
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index 4bfb13c6a..305c0549d 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -318,3 +318,5 @@ $(BUILD)/libaxtls.a: $(TOP)/lib/axtls/README | $(OBJ_DIRS)
$(TOP)/lib/axtls/README:
@echo "You cloned without --recursive, fetching submodules for you."
(cd $(TOP); git submodule update --init --recursive)
+
+$(BUILD)/supervisor/shared/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h