8000 Merge remote-tracking branch 'origin/main' into fs_stub_build_fix · domdfcoding/circuitpython@b8d0aad · GitHub
[go: up one dir, main page]

Skip to content

Commit b8d0aad

Browse files
committed
Merge remote-tracking branch 'origin/main' into fs_stub_build_fix
2 parents f7fd168 + 359d8e5 commit b8d0aad

File tree

13 files changed

+40
-56
lines changed

13 files changed

+40
-56
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ jobs:
400400
id: idf-cache
401401
with:
402402
path: ${{ github.workspace }}/.idf_tools
403-
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/espressif/esp-idf/HEAD') }}-20210923
403+
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/espressif/esp-idf/HEAD') }}-20220404
404404
- name: Clone IDF submodules
405405
run: |
406406
(cd $IDF_PATH && git submodule update --init)

.github/workflows/ports_windows.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ jobs:
6666
pip install wheel
6767
# requirements_dev.txt doesn't install on windows. (with msys2 python)
6868
# instead, pick a subset for what we want to do
69-
# Undo the pin of typer & click when undoing it in requirements-dev.txt
70-
pip install cascadetoml jinja2 typer==0.4.0 click==8.0.4 intelhex
69+
pip install cascadetoml jinja2 typer click intelhex
7170
# check that installed packages work....?
7271
which python; python --version; python -c "import cascadetoml"
7372
which python3; python3 --version; python3 -c "import cascadetoml"

ports/atmel-samd/supervisor/port.c

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ static void rtc_init(void) {
247247
RTC_MODE0_CTRLA_COUNTSYNC;
248248
#endif
249249

250-
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_OVF;
251250

252251
// Set all peripheral interrupt priorities to the lowest priority by default.
253252
for (uint16_t i = 0; i < PERIPH_COUNT_IRQn; i++) {
@@ -501,45 +500,34 @@ uint32_t port_get_saved_word(void) {
501500
// TODO: Move this to an RTC backup register so we can preserve it when only the BACKUP power domain
502501
// is enabled.
503502
static volatile uint64_t overflowed_ticks = 0;
503+
static uint32_t rtc_old_count;
504504

505505
static uint32_t _get_count(uint64_t *overflow_count) {
506-
while (1) {
507-
// Disable interrupts so we can grab the count and the overflow atomically.
508-
common_hal_mcu_disable_interrupts();
509-
510-
#ifdef SAM_D5X_E5X
511-
while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COUNTSYNC | RTC_MODE0_SYNCBUSY_COUNT)) != 0) {
512-
}
513-
#endif
514-
// SAMD21 does continuous sync so we don't need to wait here.
515-
516-
uint32_t count = RTC->MODE0.COUNT.reg;
517-
if (overflow_count != NULL) {
518-
*overflow_count = overflowed_ticks;
519-
}
520-
521-
bool overflow_pending = RTC->MODE0.INTFLAG.bit.OVF;
A3E2
522-
523-
common_hal_mcu_enable_interrupts();
506+
#ifdef SAM_D5X_E5X
507+
while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COUNTSYNC | RTC_MODE0_SYNCBUSY_COUNT)) != 0) {
508+
}
509+
#endif
510+
// SAMD21 does continuous sync so we don't need to wait here.
524511

525-
if (!overflow_pending) {
526-
return count;
527-
}
512+
uint32_t count = RTC->MODE0.COUNT.reg;
513+
if (count < rtc_old_count) {
514+
// Our RTC is 32 bits and we're clocking it at 16.384khz which is 16 (2 ** 4) subticks per
515+
// tick.
516+
overflowed_ticks += (1L << (32 - 4));
517+
}
518+
rtc_old_count = count;
528519

529-
// Try again if overflow hasn't been processed yet.
520+
if (overflow_count != NULL) {
521+
*overflow_count = overflowed_ticks;
530522
}
523+
524+
return count;
531525
}
532526

533527
volatile bool _woken_up;
534528

535529
void RTC_Handler(void) {
536530
uint32_t intflag = RTC->MODE0.INTFLAG.reg;
537-
if (intflag & RTC_MODE0_INTFLAG_OVF) {
538-
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_OVF;
539-
// Our RTC is 32 bits and we're clocking it at 16.384khz which is 16 (2 ** 4) subticks per
540-
// tick.
541-
overflowed_ticks += (1L << (32 - 4));
542-
}
543531
#ifdef SAM_D5X_E5X
544532
if (intflag & RTC_MODE0_INTFLAG_PER2) {
545533
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_PER2;

ports/nrf/common-hal/pwmio/PWMOut.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ STATIC void reset_single_pwmout(uint8_t i) {
108108

109109
for (int ch = 0; ch < CHANNELS_PER_PWM; ch++) {
110110
pwm_seq[i][ch] = (1 << 15); // polarity = 0
111+
pwm->PSEL.OUT[ch] = 0xFFFFFFFF; // disconnnect from I/O
111112
}
112113
}
113114

ports/raspberrypi/common-hal/busio/UART.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static void shared_callback(busio_uart_obj_t *self) {
8585
_copy_into_ringbuf(&self->ringbuf, self->uart);
8686
// We always clear the interrupt so it doesn't continue to fire because we
8787
// may not have read everything available.
88-
uart_get_hw(self->uart)->icr = UART_UARTICR_RXIC_BITS;
88+
uart_get_hw(self->uart)->icr = UART_UARTICR_RXIC_BITS | UART_UARTICR_RTIC_BITS;
8989
}
9090

9191
static void uart0_callback(void) {

py/ringbuf.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "ringbuf.h"
2929

3030
bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity) {
31-
r->heap = false;
3231
r->buf = buf;
3332
r->size = capacity;
3433
r->iget = r->iput = 0;
@@ -40,17 +39,15 @@ bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity) {
4039
// size of the buffer is one greater than that, due to how the buffer
4140
// handles empty and full statuses.
4241
bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived) {
43-
r->heap = true;
4442
r->buf = gc_alloc(capacity + 1, false, long_lived);
4543
r->size = capacity + 1;
4644
r->iget = r->iput = 0;
4745
return r->buf != NULL;
4846
}
4947

5048
void ringbuf_free(ringbuf_t *r) {
51-
if (r->heap) {
52-
gc_free(r->buf);
53-
}
49+
// Free buf by letting gc take care of it. If the VM has finished already,
50+
// this will be safe.
5451
r->buf = (uint8_t *)NULL;
5552
r->size = 0;
5653
ringbuf_clear(r);

py/ringbuf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ typedef struct _ringbuf_t {
3737
uint32_t size;
3838
uint32_t iget;
3939
uint32_t iput;
40-
bool heap;
4140
} ringbuf_t;
4241

4342
// Note that the capacity of the buffer is N-1!

py/vm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,8 @@ unwind_jump:;
739739
obj = mp_getiter(obj, iter_buf);
740740
if (obj != MP_OBJ_FROM_PTR(iter_buf)) {
741741
// Iterator didn't use the stack so indicate that with MP_OBJ_NULL.
742-
sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] = MP_OBJ_NULL;
743-
sp[-MP_OBJ_ITER_BUF_NSLOTS + 2] = obj;
742+
*(sp - MP_OBJ_ITER_BUF_NSLOTS + 1) = MP_OBJ_NULL;
743+
*(sp - MP_OBJ_ITER_BUF_NSLOTS + 2) = obj;
744744
}
745745
DISPATCH();
746746
}
@@ -751,8 +751,8 @@ unwind_jump:;
751751
DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward
752752
code_state->sp = sp;
753753
mp_obj_t obj;
754-
if (sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] == MP_OBJ_NULL) {
755-
obj = sp[-MP_OBJ_ITER_BUF_NSLOTS + 2];
754+
if (*(sp - MP_OBJ_ITER_BUF_NSLOTS + 1) == MP_OBJ_NULL) {
755+
obj = *(sp - MP_OBJ_ITER_BUF_NSLOTS + 2);
756756
} else {
757757
obj = MP_OBJ_FROM_PTR(&sp[-MP_OBJ_ITER_BUF_NSLOTS + 1]);
758758
}

shared-bindings/usb_hid/Device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args
103103
mp_obj_t descriptor = mp_obj_new_bytearray(descriptor_bufinfo.len, descriptor_bufinfo.buf);
104104

105105
const mp_int_t usage_page_arg = args[ARG_usage_page].u_int;
106-
mp_arg_validate_int_range(usage_page_arg, 1, 255, MP_QSTR_usage_page);
107-
const uint8_t usage_page = usage_page_arg;
106+
mp_arg_validate_int_range(usage_page_arg, 1, 0xFFFF, MP_QSTR_usage_page);
107+
const uint16_t usage_page = usage_page_arg;
108108

109109
const mp_int_t usage_arg = args[ARG_usage].u_int;
110-
mp_arg_validate_int_range(usage_arg, 1, 255, MP_QSTR_usage_page);
111-
const uint8_t usage = usage_arg;
110+
mp_arg_validate_int_range(usage_arg, 1, 0xFFFF, MP_QSTR_usage_page);
111+
const uint16_t usage = usage_arg;
112112

113113
mp_obj_t report_ids = args[ARG_report_ids].u_obj;
114114
mp_obj_t in_report_lengths = args[ARG_in_report_lengths].u_obj;

shared-bindings/usb_hid/Device.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434
extern const mp_obj_type_t usb_hid_device_type;
3535

36-
void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t report_descriptor, uint8_t usage_page, uint8_t usage, size_t report_ids_count,uint8_t *report_ids, uint8_t *in_report_lengths, uint8_t *out_report_lengths);
36+
void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t report_descriptor, uint16_t usage_page, uint16_t usage, size_t report_ids_count,uint8_t *report_ids, uint8_t *in_report_lengths, uint8_t *out_report_lengths);
3737
void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t *report, uint8_t len, uint8_t report_id);
3838
mp_obj_t common_hal_usb_hid_device_get_last_received_report(usb_hid_device_obj_t *self, uint8_t report_id);
39-
uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self);
40-
uint8_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self);
39+
uint16_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self);
40+
uint16_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self);
4141
uint8_t common_hal_usb_hid_device_validate_report_id(usb_hid_device_obj_t *self, mp_int_t report_id);
4242

4343
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_HID_DEVICE_H

shared-module/audiomp3/MP3Decoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t *
364364
}
365365

366366
self->samples_decoded += *buffer_length / sizeof(int16_t);
367-
return GET_BUFFER_MORE_DATA;
367+
return mp3file_find_sync_word(self) ? GET_BUFFER_MORE_DATA : GET_BUFFER_DONE;
368368
}
369369

370370
void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t *self, bool single_channel_output,

shared-module/usb_hid/Device.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ uint8_t common_hal_usb_hid_device_validate_report_id(usb_hid_device_obj_t *self,
186186
return (uint8_t)report_id_arg;
187187
}
188188

189-
void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t report_descriptor, uint8_t usage_page, uint8_t usage, size_t num_report_ids, uint8_t *report_ids, uint8_t *in_report_lengths, uint8_t *out_report_lengths) {
189+
void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t report_descriptor, uint16_t usage_page, uint16_t usage, size_t num_report_ids, uint8_t *report_ids, uint8_t *in_report_lengths, uint8_t *out_report_lengths) {
190190
if (num_report_ids > CIRCUITPY_USB_HID_MAX_REPORT_IDS_PER_DESCRIPTOR) {
191191
mp_raise_ValueError_varg(translate("More than %d report ids not supported"),
192192
CIRCUITPY_USB_HID_MAX_REPORT_IDS_PER_DESCRIPTOR);
@@ -211,11 +211,11 @@ void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t re
211211
memcpy(self->out_report_lengths, out_report_lengths, num_report_ids);
212212
}
213213

214-
uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self) {
214+
uint16_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self) {
215215
return self->usage_page;
216216
}
217217

218-
uint8_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self) {
218+
uint16_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self) {
219219
return self->usage;
220220
}
221221

shared-module/usb_hid/Device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ typedef struct {
4242
uint8_t report_ids[CIRCUITPY_USB_HID_MAX_REPORT_IDS_PER_DESCRIPTOR];
4343
uint8_t in_report_lengths[CIRCUITPY_USB_HID_MAX_REPORT_IDS_PER_DESCRIPTOR];
4444
uint8_t out_report_lengths[CIRCUITPY_USB_HID_MAX_REPORT_IDS_PER_DESCRIPTOR];
45-
uint8_t usage_page;
46-
uint8_t usage;
45+
uint16_t usage_page;
46+
uint16_t usage;
4747
uint8_t num_report_ids;
4848
} usb_hid_device_obj_t;
4949

0 commit comments

Comments
 (0)
0