Skip to content

Commit 34cb5f6

Browse files
authored
Merge branch 'main' into async-samd21
2 parents 55fbbdc + c395e1f commit 34cb5f6

File tree

1,167 files changed

+22961
-18246
lines changed

Some content is hidden

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

1,167 files changed

+22961
-18246
lines changed

.codespell/ignore-words.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ deques
2020
extint
2121
shs
2222
pass-thru
23+
numer
24+
arithmetics
25+
ftbfs
26+
straightaway

.git-blame-ignore-revs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
#all: Reformat remaining C code that doesn't have a space after a comma.
2+
5b700b0af90591d6b1a2c087bb8de6b7f1bfdd2d
3+
4+
# ports: Reformat more C and Python source code.
5+
5c32111fa0e31e451b0f1666bdf926be2fdfd82c
6+
7+
# all: Update Python formatting to latest Black version 22.1.0.
8+
ab2923dfa1174dc177f0a90cb00a7e4ff87958d2
9+
10+
# all: Update Python formatting to latest Black version 21.12b0.
11+
3770fab33449a5dadf8eb06edfae0767e75320a6
12+
113
# tools/gen-cpydiff.py: Fix formatting of doc strings for new Black.
214
0f78c36c5aa458a954eed39a46942209107a553e
315

.github/workflows/run-tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,11 @@ jobs:
5555
run: |
5656
make -C examples/natmod/features1
5757
make -C examples/natmod/features2
58-
make -C examples/natmod/btree
59-
make -C examples/natmod/framebuf
6058
make -C examples/natmod/uheapq
6159
make -C examples/natmod/urandom
6260
make -C examples/natmod/ure
6361
make -C examples/natmod/uzlib
6462
- name: Test native modules
6563
if: matrix.test == 'all'
66-
run: ./run-natmodtests.py extmod/{btree*,framebuf*,uheapq*,ure*,uzlib*}.py
64+
run: ./run-natmodtests.py extmod/{uheapq*,ure*,uzlib*}.py
6765
working-directory: tests

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,7 @@
341341
[submodule "frozen/Adafruit_CircuitPython_Wave"]
342342
path = frozen/Adafruit_CircuitPython_Wave
343343
url = http://github.com/adafruit/Adafruit_CircuitPython_Wave.git
344+
[submodule "ports/raspberrypi/lib/Pico-PIO-USB"]
345+
path = ports/raspberrypi/lib/Pico-PIO-USB
346+
url = https://github.com/sekigon-gonnoc/Pico-PIO-USB.git
347+
branch = main

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ litex alpha
235235
mimxrt10xx alpha
236236
nrf stable
237237
raspberrypi stable
238-
efr32 alpha
238+
silabs (efr32) alpha
239239
stm ``F4`` stable | ``others`` beta
240240
unix alpha
241241
================ ============================================================

conf.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from sphinx.transforms import SphinxTransform
3131
from docutils import nodes
3232
from sphinx import addnodes
33+
from sphinx.ext import intersphinx
3334

3435
tools_describe = str(pathlib.Path(__file__).parent / "tools/describe")
3536

@@ -440,8 +441,10 @@ def autoapi_prepare_jinja_env(jinja_env):
440441

441442

442443
# Example configuration for intersphinx: refer to the Python standard library.
443-
intersphinx_mapping = {"cpython": ('https://docs.python.org/3/', None),
444-
"register": ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None)}
444+
intersphinx_mapping = {"python": ('https://docs.python.org/3/', None),
445+
"register": ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),
446+
"mcp2515": ('https://circuitpython.readthedocs.io/projects/mcp2515/en/latest/', None),
447+
"typing": ('https://circuitpython.readthedocs.io/projects/adafruit-circuitpython-typing/en/latest/', None)}
445448

446449
# Adapted from sphinxcontrib-redirects
447450
from sphinx.builders import html as builders
@@ -483,6 +486,26 @@ def generate_redirects(app):
483486
with open(redirected_filename, 'w') as f:
484487
f.write(TEMPLATE % urllib.parse.quote(to_path, '#/'))
485488

489+
def adafruit_typing_workaround(app, env, node, contnode):
490+
# Sphinx marks a requesting node that uses circuitpython-typing
491+
# as looking for a "class" definition, but unfortunately
492+
# Sphinx doesn't recognize TypeAlias based types usefully from
493+
# the typing library.
494+
# (see: https://github.com/sphinx-doc/sphinx/issues/8934)
495+
# Instead, it categorizes these types as "data".
496+
# (see: python -m sphinx.ext.intersphinx \
497+
# https://docs.circuitpython.org/projects/adafruit-circuitpython-typing/en/latest/objects.inv)
498+
# This workaround traps missing references, checks if
499+
# they are likely to be in the circuitpython_typing package,
500+
# and changes the requesting type from "class" to "data" if
501+
# needed, and re-tries the reference resolver.
502+
ref = node.get("reftarget", None)
503+
if ref and ref.startswith("circuitpython_typing."):
504+
dtype = node.get("reftype", None)
505+
if dtype != "data":
506+
node.attributes.update({"reftype": "data"})
507+
return intersphinx.missing_reference(app, env, node, contnode)
508+
486509

487510
class CoreModuleTransform(SphinxTransform):
488511
default_priority = 870
@@ -519,4 +542,5 @@ def setup(app):
519542
app.add_js_file("filter.js")
520543
app.add_config_value('redirects_file', 'redirects', 'env')
521544
app.connect('builder-inited', generate_redirects)
545+
app.connect('missing-reference', adafruit_typing_workaround)
522546
app.add_transform(CoreModuleTransform)

devices/ble_hci/common-hal/_bleio/Adapter.c

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,23 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
8282

8383
// Generic Access Service setup.
8484

85-
bleio_uuid_obj_t *generic_access_service_uuid = m_new_obj(bleio_uuid_obj_t);
86-
generic_access_service_uuid->base.type = &bleio_uuid_type;
85+
bleio_uuid_obj_t *generic_access_service_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
8786
common_hal_bleio_uuid_construct(generic_access_service_uuid, 0x1800, NULL);
8887

89-
bleio_uuid_obj_t *device_name_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
90-
device_name_characteristic_uuid->base.type = &bleio_uuid_type;
88+
bleio_uuid_obj_t *device_name_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
9189
common_hal_bleio_uuid_construct(device_name_characteristic_uuid, 0x2A00, NULL);
9290

93-
bleio_uuid_obj_t *appearance_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
94-
appearance_characteristic_uuid->base.type = &bleio_uuid_type;
91+
bleio_uuid_obj_t *appearance_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
9592
common_hal_bleio_uuid_construct(appearance_characteristic_uuid, 0x2A01, NULL);
9693

9794
// Not implemented:
9895
// Peripheral Preferred Connection Parameters
9996
// Central Address Resolution
10097

101-
bleio_service_obj_t *generic_access_service = m_new_obj(bleio_service_obj_t);
102-
generic_access_service->base.type = &bleio_service_type;
98+
bleio_service_obj_t *generic_access_service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
10399
common_hal_bleio_service_construct(generic_access_service, generic_access_service_uuid, false);
104100

105-
adapter->device_name_characteristic = m_new_obj(bleio_characteristic_obj_t);
106-
adapter->device_name_characteristic->base.type = &bleio_characteristic_type;
101+
adapter->device_name_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
107102

108103
char generic_name[] = { 'C', 'I', 'R', 'C', 'U', 'I', 'T', 'P', 'Y', 'n', 'n', 'n', 'n' };
109104
mp_buffer_info_t generic_name_bufinfo = {
@@ -132,8 +127,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
132127
.len = sizeof(zero_16),
133128
};
134129

135-
adapter->appearance_characteristic = m_new_obj(bleio_characteristic_obj_t);
136-
adapter->appearance_characteristic->base.type = &bleio_characteristic_type;
130+
adapter->appearance_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
137131

138132
common_hal_bleio_characteristic_construct(
139133
adapter->appearance_characteristic,
@@ -151,20 +145,16 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
151145

152146
// Generic Attribute Service setup.
153147

154-
bleio_uuid_obj_t *generic_attribute_service_uuid = m_new_obj(bleio_uuid_obj_t);
155-
generic_attribute_service_uuid->base.type = &bleio_uuid_type;
148+
bleio_uuid_obj_t *generic_attribute_service_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
156149
common_hal_bleio_uuid_construct(generic_attribute_service_uuid, 0x1801, NULL);
157150

158-
bleio_uuid_obj_t *service_changed_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
159-
service_changed_characteristic_uuid->base.type = &bleio_uuid_type;
151+
bleio_uuid_obj_t *service_changed_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
160152
common_hal_bleio_uuid_construct(service_changed_characteristic_uuid, 0x2A05, NULL);
161153

162-
bleio_service_obj_t *generic_attribute_service = m_new_obj(bleio_service_obj_t);
163-
generic_attribute_service->base.type = &bleio_service_type;
154+
bleio_service_obj_t *generic_attribute_service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
164155
common_hal_bleio_service_construct(generic_attribute_service, generic_attribute_service_uuid, false);
165156

166-
adapter->service_changed_characteristic = m_new_obj(bleio_characteristic_obj_t);
167-
adapter->service_changed_characteristic->base.type = &bleio_characteristic_type;
157+
adapter->service_changed_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
168158

169159
uint32_t zero_32 = 0;
170160
mp_buffer_info_t zero_32_value = {
@@ -416,8 +406,7 @@ bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *s
416406
bt_addr_t addr;
417407
hci_check_error(hci_read_bd_addr(&addr));
418408

419-
bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t);
420-
address->base.type = &bleio_address_type;
409+
bleio_address_obj_t *address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type);
421410

422411
common_hal_bleio_address_construct(address, addr.val, BT_ADDR_LE_PUBLIC);
423412
return address;
@@ -490,7 +479,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t
490479
self->scan_results = shared_module_bleio_new_scanresults(buffer_size, prefixes, prefix_length, minimum_rssi);
491480

492481
// size_t max_packet_size = extended ? BLE_GAP_SCAN_BUFFER_EXTENDED_MAX_SUPPORTED : BLE_GAP_SCAN_BUFFER_MAX;
493-
// uint8_t *raw_data = m_malloc(sizeof(ble_data_t) + max_packet_size, false);
482+
// uint8_t *raw_data = m_malloc(sizeof(ble_data_t) + max_packet_size);
494483
// ble_data_t * sd_data = (ble_data_t *) raw_data;
495484
// self->scan_results->common_hal_data = sd_data;
496485
// sd_data->len = max_packet_size;

devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffe
5555
self->characteristic = characteristic;
5656
self->timeout_ms = timeout * 1000;
5757
// This is a macro.
58-
// true means long-lived, so it won't be moved.
59-
ringbuf_alloc(&self->ringbuf, buffer_size, true);
58+
ringbuf_alloc(&self->ringbuf, buffer_size);
6059

6160
bleio_characteristic_set_observer(characteristic, self);
6261
}

devices/ble_hci/common-hal/_bleio/Connection.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
453453
// for (size_t i = 0; i < response->count; ++i) {
454454
// ble_gattc_service_t *gattc_service = &response->services[i];
455455

456-
// bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
457-
// service->base.type = &bleio_service_type;
456+
// bleio_service_obj_t *service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
458457

459458
// // Initialize several fields at once.
460459
// bleio_service_from_connection(service, bleio_connection_new_from_internal(connection));
@@ -466,8 +465,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
466465

467466
// if (gattc_service->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
468467
// // Known service UUID.
469-
// bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
470-
// uuid->base.type = &bleio_uuid_type;
468+
// bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
471469
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid);
472470
// service->uuid = uuid;
473471
// } else {
@@ -491,15 +489,14 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
491489
// for (size_t i = 0; i < response->count; ++i) {
492490
// ble_gattc_char_t *gattc_char = &response->chars[i];
493491

494-
// bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t);
495-
// characteristic->base.type = &bleio_characteristic_type;
492+
// bleio_characteristic_obj_t *characteristic =
493+
// mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
496494

497495
// bleio_uuid_obj_t *uuid = NULL;
498496

499497
// if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
500498
// // Known characteristic UUID.
501-
// uuid = m_new_obj(bleio_uuid_obj_t);
502-
// uuid->base.type = &bleio_uuid_type;
499+
// uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
503500
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid);
504501
// } else {
505502
// // The discovery response contained a 128-bit UUID that has not yet been registered with the
@@ -557,15 +554,13 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
557554
// break;
558555
// }
559556

560-
// bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t);
561-
// descriptor->base.type = &bleio_descriptor_type;
557+
// bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type);
562558

563559
// bleio_uuid_obj_t *uuid = NULL;
564560

565561
// if (gattc_desc->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
566562
// // Known descriptor UUID.
567-
// uuid = m_new_obj(bleio_uuid_obj_t);
568-
// uuid->base.type = &bleio_uuid_type;
563+
// uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
569564
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_desc->uuid);
570565
// } else {
571566
// // The discovery response contained a 128-bit UUID that has not yet been registered with the
@@ -750,8 +745,7 @@ mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *interna
750745
if (internal->connection_obj != mp_const_none) {
751746
return internal->connection_obj;
752747
}
753-
bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t);
754-
connection->base.type = &bleio_connection_type;
748+
bleio_connection_obj_t *connection = mp_obj_malloc(bleio_connection_obj_t, &bleio_connection_type);
755749
connection->connection = internal;
756750
internal->connection_obj = connection;
757751

0 commit comments

Comments
 (0)