summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2021-01-12 09:23:07 -0600
committerJeff Epler <jepler@gmail.com>2021-01-12 09:23:07 -0600
commit1ca29ec47c9f51589faa151b659dfd1dd4a349ef (patch)
tree0a2e35b45a52e85f258cc522615e37965b0453d3 /ports
parente20c65d8f044cb9522cd1a7f4a3030efefa77cbb (diff)
parent047708e36e67beee14771120296cdf758f00601d (diff)
Merge remote-tracking branch 'origin/main' into audioout-esp32
Diffstat (limited to 'ports')
-rw-r--r--ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk2
-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/qtpy_m0_haxpress/mpconfigboard.mk1
-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/pwmio/PWMOut.c7
-rw-r--r--ports/atmel-samd/supervisor/port.c8
-rw-r--r--ports/cxd56/boards/spresense/mpconfigboard.mk2
-rw-r--r--ports/esp32s2/README.md84
-rw-r--r--ports/esp32s2/README.rst94
-rw-r--r--ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c4
-rw-r--r--ports/esp32s2/boards/unexpectedmaker_feathers2/board.c8
-rw-r--r--ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h4
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Pin.c45
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Pin.h4
-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.c2
-rw-r--r--ports/esp32s2/common-hal/wifi/__init__.c21
-rw-r--r--ports/esp32s2/mpconfigport.h1
-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/supervisor/port.c2
31 files changed, 237 insertions, 119 deletions
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 5389fc89a..505f5c145 100644
--- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
@@ -15,12 +15,14 @@ LONGINT_IMPL = MPZ
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
+CIRCUITPY_MSGPACK = 0
MICROPY_PY_ASYNC_AWAIT = 0
SUPEROPT_GC = 0
CFLAGS_INLINE_LIMIT = 55
# Include these Python libraries in firmware.
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk
index 31e10d736..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
@@ -25,6 +26,7 @@ CFLAGS_INLINE_LIMIT = 50
# Include these Python libraries in firmware.
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Crickit
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk
index 36b49b0ee..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
@@ -26,6 +27,7 @@ SUPEROPT_GC = 0
CFLAGS_INLINE_LIMIT = 55
# Include these Python libraries in firmware.
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
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/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/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/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 7d02789e8..02b9e3874 100644
--- a/ports/atmel-samd/supervisor/port.c
+++ b/ports/atmel-samd/supervisor/port.c
@@ -429,9 +429,11 @@ 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(uint32_t* overflow_count) {
+static uint32_t _get_count(uint64_t* overflow_count) {
#ifdef SAM_D5X_E5X
while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COUNTSYNC | RTC_MODE0_SYNCBUSY_COUNT)) != 0) {}
#endif
@@ -500,7 +502,7 @@ void RTC_Handler(void) {
}
uint64_t port_get_raw_ticks(uint8_t* subticks) {
- uint32_t overflow_count;
+ uint64_t overflow_count;
uint32_t current_ticks = _get_count(&overflow_count);
if (subticks != NULL) {
*subticks = (current_ticks % 16) * 2;
@@ -537,9 +539,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/README.md b/ports/esp32s2/README.md
deleted file mode 100644
index f5a2bfe5c..000000000
--- a/ports/esp32s2/README.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# Circuitpython on ESP32-S2 #
-
-This port adds the ESP32-S2 line of modules from Espressif to Circuitpython. ESP32-S2 modules are low power, single-core Wi-Fi microcontroller SoCs designed for IoT applications.
-
-## How this port is organized: ##
-
-- **bindings/** contains some required bindings to the ESP-IDF for exceptions and memory.
-- **boards/** contains the configuration files for each development board and breakout available on the port.
-- **common-hal/** contains the port-specific module implementations, used by shared-module and shared-bindings.
-- **esp-idf/** contains the Espressif IoT development framework installation, including all the drivers for the port.
-- **modules/** contains information specific to certain ESP32-S2 hardware modules, such as the pins used for flash and RAM on the WROVER and WROOM.
-- **peripherals/** contains peripheral setup files and peripheral mapping information, sorted by family and sub-variant. Most files in this directory can be generated with the python scripts in **tools/**.
-- **supervisor/** contains port-specific implementations of internal flash, serial and USB, as well as the **port.c** file, which initializes the port at startup.
-- **tools/** includes useful python scripts for debugging and other purposes.
-
-At the root level, refer to **mpconfigboard.h** and **mpconfigport.mk** for port specific settings and a list of enabled circuitpython modules.
-
-## Connecting to the ESP32-S2 ##
-
-The USB port built into ESP32-S2 boards such as the Saola is not the native USB of the board, but a debugging and programming interface. The actual ESP32-S2 native USB which exposes the Circuitpython drive and CDC connection is located on IO pins 19 and 20:
-
-| GPIO | USB |
-| ---- | ----------- |
-| 20 | D+ (green) |
-| 19 | D- (white) |
-| GND | GND (black) |
-| 5V | +5V (red) |
-
-Connect these pins using a [USB adapter](https://www.adafruit.com/product/4090) or [breakout cable](https://www.adafruit.com/product/4448) to access the Circuitpython drive.
-
-## Building and flashing ##
-
-Before building or flashing the ESP32-S2, you must [install the esp-idf](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html). This must be re-done every time the esp-idf is updated, but not every time you build. Run `cd ports/esp32s2` from `circuitpython/` to move to the esp32s2 port root, and run:
-
-```
-./esp-idf/install.sh
-```
-
-After this initial installation, you must add the esp-idf tools to your path. You must also do this **any time you open a new bash environment for building or flashing**:
-
-```
-. esp-idf/export.sh
-```
-
-When Circuitpython updates the ESP-IDF to a new release, you may need to run this installation process again. The exact commands used may also vary based on your bash environment.
-
-Building boards such as the Saola is typically done through `make flash`. The default port is `tty.SLAB_USBtoUART`, which will only work on certain Mac setups. On most machines, both Mac and Linux, you will need to set the port yourself by running `ls /dev/tty.usb*` and selecting the one that only appears when your development board is plugged in. An example make command with the port setting is as follows:
-
-```
-make BOARD=espressif_saola_1_wrover flash PORT=/dev/tty.usbserial-1421120
-```
-
-## Debugging ##
-
-The ESP32-S2 supports JTAG debugging over OpenOCD using a JLink or other probe hardware. The official tutorials can be found on the Espressif website [here](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/jtag-debugging/index.html), but they are mostly for the ESP32-S2 Kaluga, which has built-in debugging.
-
-OpenOCD is automatically installed and added to your bash environment during the esp-idf installation and setup process. You can double check that it is installed by using `openocd --version`, as per the tutorial. Attach the JTAG probe pins according to the [instructions](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/jtag-debugging/configure-other-jtag.html) for JTAG debugging on boards that do not contain an integrated debugger.
-
-Once the debugger is connected physically, you must run OpenOCD with attached configuration files specifying the **interface** (your debugger probe) and either a **target** or a **board** (targets are for SoCs only, and can be used when a full board configuration file doesn't exist). You can find the path location of these files by checking the `OPENOCD_SCRIPTS` environmental variable by running `echo $OPENOCD_SCRIPTS` in bash. Interfaces will be in the `interface/` directory, and targets and boards in the `target/` and `board/` directories, respectively.
-
-**Note:** Unfortunately, there are no board files for the esp32-s2 other than the Kaluga, and the included `target/esp32s2.cfg` target file will not work by default on the Jlink for boards like the Saola 1, as the default speed is incorrect. In addition, these files are covered under the GPL and cannot be included in Circuitpython. Thus, you must make a copy of the esp32s2.cfg file yourself and add the following line manually, under `transport select jtag` at the start of the file:
-
-```
-adapter_khz 1000
-```
-
-Once this is complete, your final OpenOCD command may look something like this:
-
-`openocd -f interface/jlink.cfg -f SOMEPATH/copied-esp32s2-saola-1.cfg`
-
-Where `SOMEPATH` is the location of your copied configuration file (this can be placed in the port/boards director with a prefix to ignore it with `.gitignore`, for instance). Interface, target and board config files sourced from espressif only need their paths from the $OPENOCD_SCRIPTS location, you don't need to include their full path. Once OpenOCD is running, connect to GDB with:
-
-`xtensa-esp32s2-elf-gdb build-espressif_saola_1_wrover/firmware.elf`
-
-And follow the Espressif GDB tutorial [instructions](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/jtag-debugging/using-debugger.html) for connecting, or add them to your `gdbinit`:
-
-```
-target remote :3333
-set remote hardware-watchpoint-limit 2
-mon reset halt
-flushregs
-thb app_main
-c
-```
diff --git a/ports/esp32s2/README.rst b/ports/esp32s2/README.rst
new file mode 100644
index 000000000..827aba41b
--- /dev/null
+++ b/ports/esp32s2/README.rst
@@ -0,0 +1,94 @@
+Circuitpython on ESP32-S2
+=======================================
+
+This port adds the ESP32-S2 line of modules from Espressif to Circuitpython. ESP32-S2 modules are low power, single-core Wi-Fi microcontroller SoCs designed for IoT applications.
+
+How this port is organized:
+---------------------------------------
+
+- **bindings/** contains some required bindings to the ESP-IDF for exceptions and memory.
+- **boards/** contains the configuration files for each development board and breakout available on the port.
+- **common-hal/** contains the port-specific module implementations, used by shared-module and shared-bindings.
+- **esp-idf/** contains the Espressif IoT development framework installation, including all the drivers for the port.
+- **modules/** contains information specific to certain ESP32-S2 hardware modules, such as the pins used for flash and RAM on the WROVER and WROOM.
+- **peripherals/** contains peripheral setup files and peripheral mapping information, sorted by family and sub-variant. Most files in this directory can be generated with the python scripts in **tools/**.
+- **supervisor/** contains port-specific implementations of internal flash, serial and USB, as well as the **port.c** file, which initializes the port at startup.
+- **tools/** includes useful python scripts for debugging and other purposes.
+
+At the root level, refer to **mpconfigboard.h** and **mpconfigport.mk** for port specific settings and a list of enabled circuitpython modules.
+
+Connecting to the ESP32-S2
+---------------------------------------
+
+The USB port built into ESP32-S2 boards such as the Saola is not the native USB of the board, but a debugging and programming interface. The actual ESP32-S2 native USB which exposes the Circuitpython drive and CDC connection is located on IO pins 19 and 20:
+
+.. csv-table::
+ :header: GPIO, USB
+
+ 20, "D+ (green)"
+ 19, "D- (white)"
+ GND, "GND (black)"
+ 5V, "+5V (red)"
+
+Connect these pins using a `USB adapter <https://www.adafruit.com/product/4090>`_ or `breakout cable <https://www.adafruit.com/product/4448>`_ to access the Circuitpython drive.
+
+Building and flashing
+---------------------------------------
+
+Before building or flashing the ESP32-S2, you must `install the esp-idf <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html>`_. This must be re-done every time the esp-idf is updated, but not every time you build. Run ``cd ports/esp32s2`` from ``circuitpython/`` to move to the esp32s2 port root, and run:
+
+.. code-block::
+
+ ./esp-idf/install.sh
+
+After this initial installation, you must add the esp-idf tools to your path. You must also do this **any time you open a new bash environment for building or flashing**:
+
+.. code-block::
+
+ . esp-idf/export.sh
+
+When Circuitpython updates the ESP-IDF to a new release, you may need to run this installation process again. The exact commands used may also vary based on your bash environment.
+
+Building boards such as the Saola is typically done through ``make flash``. The default port is ``tty.SLAB_USBtoUART``, which will only work on certain Mac setups. On most machines, both Mac and Linux, you will need to set the port yourself by running ``ls /dev/tty.usb*`` and selecting the one that only appears when your development board is plugged in. An example make command with the port setting is as follows:
+
+.. code-block::
+
+ make BOARD=espressif_saola_1_wrover flash PORT=/dev/tty.usbserial-1421120
+
+Debugging
+---------------------------------------
+
+The ESP32-S2 supports JTAG debugging over OpenOCD using a JLink or other probe hardware. The official tutorials can be found on the Espressif website `here <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/jtag-debugging/index.html>`_, but they are mostly for the ESP32-S2 Kaluga, which has built-in debugging.
+
+OpenOCD is automatically installed and added to your bash environment during the esp-idf installation and setup process. You can double check that it is installed by using ``openocd --version``, as per the tutorial. Attach the JTAG probe pins according to the `instructions for JTAG debugging <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/jtag-debugging/configure-other-jtag.html>`_ on boards that do not contain an integrated debugger.
+
+Once the debugger is connected physically, you must run OpenOCD with attached configuration files specifying the **interface** (your debugger probe) and either a **target** or a **board** (targets are for SoCs only, and can be used when a full board configuration file doesn't exist). You can find the path location of these files by checking the ``OPENOCD_SCRIPTS`` environmental variable by running ``echo $OPENOCD_SCRIPTS`` in bash. Interfaces will be in the ``interface/`` directory, and targets and boards in the ``target/`` and ``board/`` directories, respectively.
+
+**Note:** Unfortunately, there are no board files for the esp32-s2 other than the Kaluga, and the included ``target/esp32s2.cfg`` target file will not work by default on the Jlink for boards like the Saola 1, as the default speed is incorrect. In addition, these files are covered under the GPL and cannot be included in Circuitpython. Thus, you must make a copy of the esp32s2.cfg file yourself and add the following line manually, under ``transport select jtag`` at the start of the file:
+
+.. code-block::
+
+ adapter_khz 1000
+
+Once this is complete, your final OpenOCD command may look something like this:
+
+.. code-block::
+
+ openocd -f interface/jlink.cfg -f SOMEPATH/copied-esp32s2-saola-1.cfg
+
+Where ``SOMEPATH`` is the location of your copied configuration file (this can be placed in the port/boards directory with a prefix to ignore it with ``.gitignore``, for instance). Interface, target and board config files sourced from espressif only need their paths from the $OPENOCD_SCRIPTS location, you don't need to include their full path. Once OpenOCD is running, connect to GDB with:
+
+.. code-block::
+
+ xtensa-esp32s2-elf-gdb build-espressif_saola_1_wrover/firmware.elf
+
+And follow the Espressif GDB tutorial `instructions for connecting <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/jtag-debugging/using-debugger.html>`_, or add them to your ``gdbinit``:
+
+.. code-block::
+
+ target remote :3333
+ set remote hardware-watchpoint-limit 2
+ mon reset halt
+ flushregs
+ thb app_main
+ c
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 0cefb6dfb..645dc12a1 100644
--- a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c
+++ b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c
@@ -49,6 +49,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ 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].epaper_display)}
+ { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)},
+
+ { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_GPIO9) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c b/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c
index d8fd3a0a2..ac08190a5 100644
--- a/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c
+++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c
@@ -27,6 +27,8 @@
#include "supervisor/board.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
+#include "components/driver/include/driver/gpio.h"
+#include "components/soc/include/hal/gpio_hal.h"
void board_init(void) {
// USB
@@ -47,6 +49,12 @@ void board_init(void) {
common_hal_never_reset_pin(&pin_GPIO30);
common_hal_never_reset_pin(&pin_GPIO31);
common_hal_never_reset_pin(&pin_GPIO32);
+
+
+ // Add LDO2 to never reset list, set to output and enable
+ common_hal_never_reset_pin(&pin_GPIO21);
+ gpio_set_direction(pin_GPIO21.number, GPIO_MODE_DEF_OUTPUT);
+ gpio_set_level(pin_GPIO21.number, true);
}
bool board_requests_safe_mode(void) {
diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h b/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h
index e100ac118..6b1a0c4aa 100644
--- a/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h
+++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h
@@ -34,8 +34,8 @@
#define AUTORESET_DELAY_MS 500
-// #define MICROPY_HW_APA102_MOSI (&pin_GPIO40)
-// #define MICROPY_HW_APA102_SCK (&pin_GPIO45)
+#define MICROPY_HW_APA102_MOSI (&pin_GPIO40)
+#define MICROPY_HW_APA102_SCK (&pin_GPIO45)
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8)
diff --git a/ports/esp32s2/common-hal/microcontroller/Pin.c b/ports/esp32s2/common-hal/microcontroller/Pin.c
index fca89ce8e..6889720e8 100644
--- a/ports/esp32s2/common-hal/microcontroller/Pin.c
+++ b/ports/esp32s2/common-hal/microcontroller/Pin.c
@@ -37,13 +37,14 @@
#ifdef MICROPY_HW_NEOPIXEL
bool neopixel_in_use;
#endif
+#ifdef MICROPY_HW_APA102_MOSI
+bool apa102_sck_in_use;
+bool apa102_mosi_in_use;
+#endif
STATIC uint32_t never_reset_pins[2];
STATIC uint32_t in_use[2];
-bool apa102_mosi_in_use;
-bool apa102_sck_in_use;
-
STATIC void floating_gpio_reset(gpio_num_t pin_number) {
// This is the same as gpio_reset_pin(), but without the pullup.
// Note that gpio_config resets the iomatrix to GPIO_FUNC as well.
@@ -86,6 +87,20 @@ void reset_pin_number(gpio_num_t pin_number) {
return;
}
#endif
+ #ifdef MICROPY_HW_APA102_MOSI
+ if (pin_number == MICROPY_HW_APA102_MOSI->number ||
+ pin_number == MICROPY_HW_APA102_SCK->number) {
+ apa102_mosi_in_use = apa102_mosi_in_use && pin_number != MICROPY_HW_APA102_MOSI->number;
+ apa102_sck_in_use = apa102_sck_in_use && pin_number != MICROPY_HW_APA102_SCK->number;
+ if (!apa102_sck_in_use && !apa102_mosi_in_use) {
+ rgb_led_status_init();
+ }
+ return;
+ }
+ #endif
+
+
+
}
void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
@@ -110,6 +125,11 @@ void reset_all_pins(void) {
#ifdef MICROPY_HW_NEOPIXEL
neopixel_in_use = false;
#endif
+ #ifdef MICROPY_HW_APA102_MOSI
+ apa102_sck_in_use = false;
+ apa102_mosi_in_use = false;
+ #endif
+
}
void claim_pin(const mcu_pin_obj_t* pin) {
@@ -119,6 +139,15 @@ void claim_pin(const mcu_pin_obj_t* pin) {
neopixel_in_use = true;
}
#endif
+ #ifdef MICROPY_HW_APA102_MOSI
+ if (pin == MICROPY_HW_APA102_MOSI) {
+ apa102_mosi_in_use = true;
+ }
+ if (pin == MICROPY_HW_APA102_SCK) {
+ apa102_sck_in_use = true;
+ }
+ #endif
+
}
void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
@@ -131,10 +160,18 @@ bool pin_number_is_free(gpio_num_t pin_number) {
return !neopixel_in_use;
}
#endif
+ #ifdef MICROPY_HW_APA102_MOSI
+ if (pin_number == MICROPY_HW_APA102_MOSI->number) {
+ return !apa102_mosi_in_use;
+ }
+ if (pin_number == MICROPY_HW_APA102_SCK->number) {
+ return !apa102_sck_in_use;
+ }
+ #endif
uint8_t offset = pin_number / 32;
uint32_t mask = 1 << (pin_number % 32);
- return (never_reset_pins[offset] & mask) == 0 && (in_use[offset] & mask) == 0;
+ return (in_use[offset] & mask) == 0;
}
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
diff --git a/ports/esp32s2/common-hal/microcontroller/Pin.h b/ports/esp32s2/common-hal/microcontroller/Pin.h
index f6c008703..65f57a82d 100644
--- a/ports/esp32s2/common-hal/microcontroller/Pin.h
+++ b/ports/esp32s2/common-hal/microcontroller/Pin.h
@@ -31,8 +31,10 @@
#include "peripherals/pins.h"
-extern bool apa102_mosi_in_use;
+#ifdef MICROPY_HW_APA102_MOSI
extern bool apa102_sck_in_use;
+extern bool apa102_mosi_in_use;
+#endif
#ifdef MICROPY_HW_NEOPIXEL
extern bool neopixel_in_use;
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 3bc2258a4..e9f374a06 100644
--- a/ports/esp32s2/common-hal/wifi/Radio.c
+++ b/ports/esp32s2/common-hal/wifi/Radio.c
@@ -55,8 +55,6 @@ static void start_station(wifi_radio_obj_t *self) {
esp_wifi_set_mode(next_mode);
self->sta_mode = 1;
-
- esp_wifi_set_config(WIFI_MODE_STA, &self->sta_config);
}
bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self) {
diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c
index 8de377537..08d7a164f 100644
--- a/ports/esp32s2/common-hal/wifi/__init__.c
+++ b/ports/esp32s2/common-hal/wifi/__init__.c
@@ -47,23 +47,23 @@ static void event_handler(void* arg, esp_event_base_t event_base,
if (event_base == WIFI_EVENT) {
switch (event_id) {
case WIFI_EVENT_SCAN_DONE:
- ESP_EARLY_LOGW(TAG, "scan");
+ ESP_LOGW(TAG, "scan");
xEventGroupSetBits(radio->event_group_handle, WIFI_SCAN_DONE_BIT);
break;
case WIFI_EVENT_STA_START:
- ESP_EARLY_LOGW(TAG, "start");
+ ESP_LOGW(TAG, "start");
break;
case WIFI_EVENT_STA_STOP:
- ESP_EARLY_LOGW(TAG, "stop");
+ ESP_LOGW(TAG, "stop");
break;
case WIFI_EVENT_STA_CONNECTED:
- ESP_EARLY_LOGW(TAG, "connected");
+ ESP_LOGW(TAG, "connected");
break;
case WIFI_EVENT_STA_DISCONNECTED: {
- ESP_EARLY_LOGW(TAG, "disconnected");
+ ESP_LOGW(TAG, "disconnected");
wifi_event_sta_disconnected_t* d = (wifi_event_sta_disconnected_t*) event_data;
uint8_t reason = d->reason;
- ESP_EARLY_LOGW(TAG, "reason %d 0x%02x", reason, 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 ||
@@ -71,24 +71,27 @@ static void event_handler(void* arg, esp_event_base_t event_base,
reason == WIFI_REASON_CONNECTION_FAIL ||
reason == WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT)) {
radio->retries_left--;
- ESP_EARLY_LOGI(TAG, "Retrying connect. %d retries remaining", radio->retries_left);
+ ESP_LOGI(TAG, "Retrying connect. %d retries remaining", radio->retries_left);
esp_wifi_connect();
return;
}
radio->last_disconnect_reason = reason;
xEventGroupSetBits(radio->event_group_handle, WIFI_DISCONNECTED_BIT);
+ break;
}
// Cases to handle later.
// case WIFI_EVENT_STA_AUTHMODE_CHANGE:
- default:
+ default: {
+ ESP_LOGW(TAG, "event %d 0x%02x", event_id, event_id);
break;
+ }
}
}
if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
- ESP_EARLY_LOGW(TAG, "got ip");
+ ESP_LOGW(TAG, "got ip");
radio->retries_left = radio->starting_retries;
xEventGroupSetBits(radio->event_group_handle, WIFI_CONNECTED_BIT);
}
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/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/supervisor/port.c b/ports/nrf/supervisor/port.c
index 00485d858..78bb20ce6 100644
--- a/ports/nrf/supervisor/port.c
+++ b/ports/nrf/supervisor/port.c
@@ -276,7 +276,7 @@ uint32_t port_get_saved_word(void) {
uint64_t port_get_raw_ticks(uint8_t* subticks) {
common_hal_mcu_disable_interrupts();
uint32_t rtc = nrfx_rtc_counter_get(&rtc_instance);
- uint32_t overflow_count = overflow_tracker.overflowed_ticks;
+ uint64_t overflow_count = overflow_tracker.overflowed_ticks;
common_hal_mcu_enable_interrupts();
if (subticks != NULL) {