Skip to content

Commit f45a6d7

Browse files
committed
Merge remote-tracking branch 'origin/main' into merge-1.18
2 parents a0fa536 + 1c3e03d commit f45a6d7

File tree

73 files changed

+1189
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1189
-158
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,9 @@
277277
[submodule "ports/stm/st_driver/stm32f4xx_hal_driver"]
278278
path = ports/stm/st_driver/stm32f4xx_hal_driver
279279
url = https://github.com/adafruit/stm32f4xx_hal_driver.git
280+
[submodule "frozen/Adafruit_CircuitPython_PortalBase"]
281+
path = frozen/Adafruit_CircuitPython_PortalBase
282+
url = https://github.com/adafruit/Adafruit_CircuitPython_PortalBase.git
283+
[submodule "frozen/Adafruit_CircuitPython_FakeRequests"]
284+
path = frozen/Adafruit_CircuitPython_FakeRequests
285+
url = https://github.com/adafruit/Adafruit_CircuitPython_FakeRequests.git

locale/circuitpython.pot

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,16 @@ msgstr ""
24272427
msgid "Unhandled ESP TLS error %d %d %x %d"
24282428
msgstr ""
24292429

2430+
#: ports/espressif/common-hal/_bleio/__init__.c
2431+
#, c-format
2432+
msgid "Unknown BLE error at %s:%d: %d"
2433+
msgstr ""
2434+
2435+
#: ports/espressif/common-hal/_bleio/__init__.c
2436+
#, c-format
2437+
msgid "Unknown BLE error: %d"
2438+
msgstr ""
2439+
24302440
#: shared-bindings/wifi/Radio.c
24312441
#, c-format
24322442
msgid "Unknown failure %d"
@@ -2498,12 +2508,14 @@ msgstr ""
24982508
msgid "Update Failed"
24992509
msgstr ""
25002510

2511+
#: ports/espressif/common-hal/_bleio/Characteristic.c
25012512
#: ports/espressif/common-hal/_bleio/Descriptor.c
25022513
#: ports/nrf/common-hal/_bleio/Characteristic.c
25032514
#: ports/nrf/common-hal/_bleio/Descriptor.c
25042515
msgid "Value length != required fixed length"
25052516
msgstr ""
25062517

2518+
#: ports/espressif/common-hal/_bleio/Characteristic.c
25072519
#: ports/espressif/common-hal/_bleio/Descriptor.c
25082520
#: ports/nrf/common-hal/_bleio/Characteristic.c
25092521
#: ports/nrf/common-hal/_bleio/Descriptor.c
@@ -3788,6 +3800,7 @@ msgstr ""
37883800
msgid "non-Device in %q"
37893801
msgstr ""
37903802

3803+
#: ports/espressif/common-hal/_bleio/Connection.c
37913804
#: ports/nrf/common-hal/_bleio/Connection.c
37923805
msgid "non-UUID found in service_uuids_whitelist"
37933806
msgstr ""

main.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ STATIC void cleanup_after_vm(supervisor_allocation *heap, mp_obj_t exception) {
301301

302302
STATIC void print_code_py_status_message(safe_mode_t safe_mode) {
303303
if (autoreload_is_enabled()) {
304-
serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n"));
304+
serial_write_compressed(
305+
translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n"));
305306
} else {
306307
serial_write_compressed(translate("Auto-reload is off.\n"));
307308
}
@@ -401,7 +402,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
401402
// the options because it can be treated like any other reason-for-stickiness bit. The
402403
// source is different though: it comes from the options that will apply to the next run,
403404
// while the rest of next_code_options is what applied to this run.
404-
if (next_code_allocation != NULL && (((next_code_info_t *)next_code_allocation->ptr)->options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET)) {
405+
if (next_code_allocation != NULL &&
406+
(((next_code_info_t *)next_code_allocation->ptr)->options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET)) {
405407
next_code_options |= SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET;
406408
}
407409

@@ -527,28 +529,38 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
527529
// Sleep until our next interrupt.
528530
#if CIRCUITPY_ALARM
529531
if (result.return_code & PYEXEC_DEEP_SLEEP) {
530-
// Make sure we have been awake long enough for USB to connect (enumeration delay).
531-
int64_t connecting_delay_ticks = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - port_get_raw_ticks(NULL);
532-
// Until it's safe to decide whether we're real/fake sleeping
532+
const bool awoke_from_true_deep_sleep =
533+
common_hal_mcu_processor_get_reset_reason() == RESET_REASON_DEEP_SLEEP_ALARM;
534+
533535
if (fake_sleeping) {
534536
// This waits until a pretend deep sleep alarm occurs. They are set
535537
// during common_hal_alarm_set_deep_sleep_alarms. On some platforms
536538
// it may also return due to another interrupt, that's why we check
537539
// for deep sleep alarms above. If it wasn't a deep sleep alarm,
538540
// then we'll idle here again.
539541
common_hal_alarm_pretending_deep_sleep();
540-
} else if (connecting_delay_ticks < 0) {
541-
// Entering deep sleep (may be fake or real.)
542+
}
543+
// The first time we go into a deep sleep, make sure we have been awake long enough
544+
// for USB to connect (enumeration delay), or for the BLE workflow to start.
545+
// We wait CIRCUITPY_WORKFLOW_CONNECTION_SLEEP_DELAY seconds after a restart.
546+
// But if we woke up from a real deep sleep, don't wait for connection. The user will need to
547+
// do a hard reset to get out of the real deep sleep.
548+
else if (awoke_from_true_deep_sleep ||
549+
port_get_raw_ticks(NULL) > CIRCUITPY_WORKFLOW_CONNECTION_SLEEP_DELAY * 1024) {
550+
// OK to start sleeping, real or fake.
542551
status_led_deinit();
543552
deinit_rxtx_leds();
544553
board_deinit();
545-
if (!supervisor_workflow_active()) {
554+
555+
// Continue with true deep sleep even if workflow is available.
556+
if (awoke_from_true_deep_sleep || !supervisor_workflow_active()) {
546557
// Enter true deep sleep. When we wake up we'll be back at the
547558
// top of main(), not in this loop.
548559
common_hal_alarm_enter_deep_sleep();
549560
// Does not return.
550561
} else {
551-
serial_write_compressed(translate("Pretending to deep sleep until alarm, CTRL-C or file write.\n"));
562+
serial_write_compressed(
563+
translate("Pretending to deep sleep until alarm, CTRL-C or file write.\n"));
552564
fake_sleeping = true;
553565
}
554566
} else {

ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ CHIP_FAMILY = samd51
99
QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C"
1111
LONGINT_IMPL = MPZ
12+
13+
# Include these Python libraries in firmware.
14+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase
15+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
16+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI
17+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
18+
19+
CIRCUITPY_SHARPDISPLAY=0
20+
CIRCUITPY_SDCARDIO=0
21+
CIRCUITPY_BLEIO_HCI=0
22+
CIRCUITPY_BLEIO=0

ports/atmel-samd/boards/pyportal/mpconfigboard.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ CHIP_FAMILY = samd51
99
QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ, GD25Q64C"
1111
LONGINT_IMPL = MPZ
12+
13+
# Include these Python libraries in firmware.
14+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase
15+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
16+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI
17+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
18+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text
19+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FakeRequests

ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ CHIP_FAMILY = samd51
99
QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ, GD25Q64C"
1111
LONGINT_IMPL = MPZ
12+
13+
# Include these Python libraries in firmware.
14+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase
15+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
16+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI
17+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
18+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text
19+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FakeRequests

ports/espressif/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ ifneq ($(CIRCUITPY_USB),0)
268268
SRC_C += lib/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c
269269
endif
270270

271+
ifneq ($(CIRCUITPY_BLEIO),0)
272+
SRC_C += common-hal/_bleio/ble_events.c
273+
endif
274+
271275
SRC_COMMON_HAL_EXPANDED = \
272276
$(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
273277
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \

ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ uint8_t display_init_sequence[] = {
7171

7272

7373
void board_init(void) {
74-
// Never reset the I2C/TFT power pin because doing so will reset the display.
75-
// Instead, on reset set the default value and free the pin for user use.
76-
// Relying on the normal pin reset would briefly float/pull the pin that
77-
// could lead to a power brownout.
78-
common_hal_never_reset_pin(&pin_GPIO21);
79-
80-
reset_board();
81-
8274
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
8375
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
8476
bus->base.type = &displayio_fourwire_type;
@@ -99,7 +91,6 @@ void board_init(void) {
9991
// workaround as board_init() is called before reset_port() in main.c
10092
pwmout_reset();
10193

102-
10394
common_hal_displayio_display_construct(
10495
display,
10596
bus,
@@ -138,12 +129,18 @@ bool board_requests_safe_mode(void) {
138129
return false;
139130
}
140131

141-
void reset_board(void) {
142-
// Turn on TFT and I2C
143-
gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT);
144-
gpio_set_level(21, true);
132+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
133+
// Override the I2C/TFT power pin reset to prevent resetting the display.
134+
if (pin_number == 21) {
135+
// Turn on TFT and I2C
136+
gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT);
137+
gpio_set_level(21, true);
138+
return true;
139+
}
140+
return false;
141+
}
145142

146-
free_pin_number(21);
143+
void reset_board(void) {
147144
}
148145

149146
void board_deinit(void) {

ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4343
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) },
4444
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO34) },
4545

46-
{ MP_ROM_QSTR(MP_QSTR_I2C_TFT_POWER), MP_ROM_PTR(&pin_GPIO21) },
46+
{ MP_ROM_QSTR(MP_QSTR_TFT_I2C_POWER), MP_ROM_PTR(&pin_GPIO21) },
4747

4848
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },
4949
{ MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) },

ports/espressif/boards/adafruit_funhouse/mpconfigboard.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ CIRCUITPY_ESP_FLASH_FREQ=40m
1717
CIRCUITPY_ESP_FLASH_SIZE=4MB
1818

1919
CIRCUITPY_MODULE=wrover
20+
21+
# Include these Python libraries in firmware.
22+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase
23+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FakeRequests
24+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
25+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
26+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text

ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,25 @@ void reset_board(void) {
172172

173173
}
174174

175+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
176+
// Pin 16 is speaker enable and it's pulled down on the board. We don't want
177+
// to pull it high because then we'll compete with the external pull down.
178+
// So, reset without any pulls internally.
179+
if (pin_number == 16) {
180+
gpio_config_t cfg = {
181+
.pin_bit_mask = BIT64(16),
182+
.mode = GPIO_MODE_DISABLE,
183+
// The pin is externally pulled down, so we don't need to pull it.
184+
.pull_up_en = false,
185+
.pull_down_en = false,
186+
.intr_type = GPIO_INTR_DISABLE,
187+
};
188+
gpio_config(&cfg);
189+
return true;
190+
}
191+
return false;
192+
}
193+
175194
void board_deinit(void) {
176195
displayio_epaperdisplay_obj_t *display = &displays[0].epaper_display;
177196
if (display->base.type == &displayio_epaperdisplay_type) {

ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ CIRCUITPY_ESP_FLASH_FREQ=40m
1717
CIRCUITPY_ESP_FLASH_SIZE=4MB
1818

1919
CIRCUITPY_MODULE=wrover
20+
21+
# Include these Python libraries in firmware.
22+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase
23+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FakeRequests
24+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
25+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
26+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text
27+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH

ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@
5050

5151
#define DOUBLE_TAP_PIN (&pin_GPIO10)
5252

53+
#ifdef DEBUG
5354
#define DEBUG_UART_RX (&pin_GPIO16)
5455
#define DEBUG_UART_TX (&pin_GPIO5)
56+
#endif

0 commit comments

Comments
 (0)