Skip to content

Commit 8ed7b11

Browse files
authored
Merge branch 'main' into uzlib-module
2 parents 9d67e62 + 87e59a4 commit 8ed7b11

File tree

481 files changed

+11235
-3599
lines changed

Some content is hidden

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

481 files changed

+11235
-3599
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ jobs:
7272
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --emit native
7373
working-directory: tests
7474
- name: mpy Tests
75-
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --mpy-cross-flags='-mcache-lookup-bc' --via-mpy -d basics float micropython
75+
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --via-mpy -d basics float micropython
7676
working-directory: tests
7777
- name: Native mpy Tests
78-
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --mpy-cross-flags='-mcache-lookup-bc' --via-mpy --emit native -d basics float micropython
78+
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --via-mpy --emit native -d basics float micropython
7979
working-directory: tests
8080
- name: Build native modules
8181
run: |

.github/workflows/ports_windows.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ on:
55
pull_request:
66
paths:
77
- '.github/workflows/*.yml'
8-
- 'tools/**'
9-
- 'py/**'
108
- 'extmod/**'
119
- 'lib/**'
10+
- 'mpy-cross/**'
1211
- 'ports/unix/**'
1312
- 'ports/windows/**'
13+
- 'py/**'
14+
- 'requirements*.txt'
15+
- 'tools/**'
1416

1517
concurrency:
1618
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -64,7 +66,7 @@ jobs:
6466
pip install wheel
6567
# requirements_dev.txt doesn't install on windows. (with msys2 python)
6668
# instead, pick a subset for what we want to do
67-
pip install cascadetoml jinja2 typer intelhex
69+
pip install cascadetoml jinja2 typer click intelhex
6870
# check that installed packages work....?
6971
which python; python --version; python -c "import cascadetoml"
7072
which python3; python3 --version; python3 -c "import cascadetoml"

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@
145145
url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git
146146
[submodule "ports/espressif/esp-idf"]
147147
path = ports/espressif/esp-idf
148-
url = https://github.com/adafruit/esp-idf.git
149-
branch = circuitpython-v4.4
148+
url = https://github.com/espressif/esp-idf.git
149+
branch = release/v4.4
150150
[submodule "ports/espressif/certificates/nina-fw"]
151151
path = ports/espressif/certificates/nina-fw
152152
url = https://github.com/adafruit/nina-fw.git

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2021 Damien P. George
3+
Copyright (c) 2013-2022 Damien P. George
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/library/binascii.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ Functions
3636
Encode binary data in base64 format, as in `RFC 3548
3737
<https://tools.ietf.org/html/rfc3548.html>`_. Returns the encoded data
3838
followed by a newline character, as a bytes object.
39+
40+
.. function:: crc32(data, value=0, /)
41+
42+
Compute CRC-32, the 32-bit checksum of the bytes in *data* starting with an
43+
initial CRC of *value*. The default initial CRC is 0. The algorithm is
44+
consistent with the ZIP file checksum.

docs/library/framebuf.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ For example::
2121
import framebuf
2222

2323
# FrameBuffer needs 2 bytes for every RGB565 pixel
24-
fbuf = framebuf.FrameBuffer(bytearray(10 * 100 * 2), 10, 100, framebuf.RGB565)
24+
fbuf = framebuf.FrameBuffer(bytearray(100 * 10 * 2), 100, 10, framebuf.RGB565)
2525

2626
fbuf.fill(0)
2727
fbuf.text('MicroPython!', 0, 0, 0xffff)
28-
fbuf.hline(0, 10, 96, 0xffff)
28+
fbuf.hline(0, 9, 96, 0xffff)
2929

3030
Constructors
3131
------------

docs/library/sys.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ Constants
8080

8181
A mutable list of directories to search for imported modules.
8282

83+
.. admonition:: Difference to CPython
84+
:class: attention
85+
86+
On MicroPython, an entry with the value ``".frozen"`` will indicate that import
87+
should search :term:`frozen modules <frozen module>` at that point in the search.
88+
If no frozen module is found then search will *not* look for a directory called
89+
``.frozen``, instead it will continue with the next entry in ``sys.path``.
90+
8391
.. data:: platform
8492

8593
The platform that CircuitPython is running on. For OS/RTOS ports, this is

extmod/extmod.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ set(MICROPY_SOURCE_EXTMOD
1010
${MICROPY_EXTMOD_DIR}/machine_i2c.c
1111
${MICROPY_EXTMOD_DIR}/machine_mem.c
1212
${MICROPY_EXTMOD_DIR}/machine_pulse.c
13+
${MICROPY_EXTMOD_DIR}/machine_pwm.c
1314
${MICROPY_EXTMOD_DIR}/machine_signal.c
1415
${MICROPY_EXTMOD_DIR}/machine_spi.c
1516
${MICROPY_EXTMOD_DIR}/modbluetooth.c
1617
${MICROPY_EXTMOD_DIR}/modbtree.c
1718
${MICROPY_EXTMOD_DIR}/modframebuf.c
19+
${MICROPY_EXTMOD_DIR}/modnetwork.c
1820
${MICROPY_EXTMOD_DIR}/modonewire.c
1921
${MICROPY_EXTMOD_DIR}/moduasyncio.c
2022
${MICROPY_EXTMOD_DIR}/modubinascii.c
@@ -23,9 +25,11 @@ set(MICROPY_SOURCE_EXTMOD
2325
${MICROPY_EXTMOD_DIR}/moduhashlib.c
2426
${MICROPY_EXTMOD_DIR}/moduheapq.c
2527
${MICROPY_EXTMOD_DIR}/modujson.c
28+
${MICROPY_EXTMOD_DIR}/moduplatform.c
2629
${MICROPY_EXTMOD_DIR}/modurandom.c
2730
${MICROPY_EXTMOD_DIR}/modure.c
2831
${MICROPY_EXTMOD_DIR}/moduselect.c
32+
${MICROPY_EXTMOD_DIR}/modusocket.c
2933
${MICROPY_EXTMOD_DIR}/modussl_axtls.c
3034
${MICROPY_EXTMOD_DIR}/modussl_mbedtls.c
3135
${MICROPY_EXTMOD_DIR}/modutimeq.c

extmod/modonewire.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "py/obj.h"
1010
#include "py/mphal.h"
1111

12+
#if MICROPY_PY_ONEWIRE
13+
1214
/******************************************************************************/
1315
// Low-level 1-Wire routines
1416

@@ -139,3 +141,5 @@ const mp_obj_module_t mp_module_onewire = {
139141
.base = { &mp_type_module },
140142
.globals = (mp_obj_dict_t *)&onewire_module_globals,
141143
};
144+
145+
#endif // MICROPY_PY_ONEWIRE

extmod/moduasyncio.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#include "py/pairheap.h"
3030
#include "py/mphal.h"
3131

32+
#if CIRCUITPY && !(defined(__unix__) || defined(__APPLE__))
33+
#include "shared-bindings/supervisor/__init__.h"
34+
#endif
35+
3236
#if MICROPY_PY_UASYNCIO
3337

3438
// Used when task cannot be guaranteed to be non-NULL.
@@ -59,10 +63,12 @@ STATIC const mp_obj_type_t task_queue_type;
5963
STATIC const mp_obj_type_t task_type;
6064

6165
STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
66+
STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);
6267

6368
/******************************************************************************/
6469
// Ticks for task ordering in pairing heap
6570

71+
#if !CIRCUITPY || (defined(__unix__) || defined(__APPLE__))
6672
STATIC mp_obj_t ticks(void) {
6773
return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1));
6874
}
@@ -74,6 +80,20 @@ STATIC mp_int_t ticks_diff(mp_obj_t t1_in, mp_obj_t t0_in) {
7480
- MICROPY_PY_UTIME_TICKS_PERIOD / 2;
7581
return diff;
7682
}
83+
#else
84+
#define _TICKS_PERIOD (1lu << 29)
85+
#define _TICKS_MAX (_TICKS_PERIOD - 1)
86+
#define _TICKS_HALFPERIOD (_TICKS_PERIOD >> 1)
87+
88+
#define ticks() supervisor_ticks_ms()
89+
90+
STATIC mp_int_t ticks_diff(mp_obj_t t1_in, mp_obj_t t0_in) {
91+
mp_uint_t t0 = MP_OBJ_SMALL_INT_VALUE(t0_in);
92+
mp_uint_t t1 = MP_OBJ_SMALL_INT_VALUE(t1_in);
93+
mp_int_t diff = ((t1 - t0 + _TICKS_HALFPERIOD) & _TICKS_MAX) - _TICKS_HALFPERIOD;
94+
return diff;
95+
}
96+
#endif
7797

7898
STATIC int task_lt(mp_pairheap_t *n1, mp_pairheap_t *n2) {
7999
mp_obj_task_t *t1 = (mp_obj_task_t *)n1;
@@ -225,6 +245,11 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
225245
}
226246
STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_cancel_obj, task_cancel);
227247

248+
STATIC mp_obj_t task_await(mp_obj_t self_in) {
249+
return task_getiter(self_in, NULL);
250+
}
251+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_await_obj, task_await);
252+
228253
STATIC void task_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
229254
mp_obj_task_t *self = MP_OBJ_TO_PTR(self_in);
230255
if (dest[0] == MP_OBJ_NULL) {
@@ -243,6 +268,9 @@ STATIC void task_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
243268
dest[1] = self_in;
244269
} else if (attr == MP_QSTR_ph_key) {
245270
dest[0] = self->ph_key;
271+
} else if (attr == MP_QSTR___await__) {
272+
dest[0] = MP_OBJ_FROM_PTR(&task_await_obj);
273+
dest[1] = self_in;
246274
}
247275
} else if (dest[1] != MP_OBJ_NULL) {
248276
// Store
@@ -301,7 +329,11 @@ STATIC const mp_obj_type_t task_type = {
301329
// C-level uasyncio module
302330

303331
STATIC const mp_rom_map_elem_t mp_module_uasyncio_globals_table[] = {
332+
#if CIRCUITPY
333+
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__asyncio) },
334+
#else
304335
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__uasyncio) },
336+
#endif
305337
{ MP_ROM_QSTR(MP_QSTR_TaskQueue), MP_ROM_PTR(&task_queue_type) },
306338
{ MP_ROM_QSTR(MP_QSTR_Task), MP_ROM_PTR(&task_type) },
307339
};
@@ -312,4 +344,6 @@ const mp_obj_module_t mp_module_uasyncio = {
312344
.globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals,
313345
};
314346

347+
MP_REGISTER_MODULE(MP_QSTR__asyncio, mp_module_uasyncio, MICROPY_PY_UASYNCIO);
348+
315349
#endif // MICROPY_PY_UASYNCIO

0 commit comments

Comments
 (0)