From 68ac14b3097291ba3c2f0c7edc61f93beebc783d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Mar 2021 09:29:01 -0600 Subject: [PATCH 1/9] StateMachine: Add in_available property I named the property `in_available` because it is similar to pyserial. However, it indicates the number of words in the fifo, not the number of bytes. --- .../bindings/rp2pio/StateMachine.c | 21 ++++++++++++++++++- .../bindings/rp2pio/StateMachine.h | 1 + .../common-hal/rp2pio/StateMachine.c | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 444e00ace3..e242889252 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -548,6 +548,24 @@ const mp_obj_property_t rp2pio_statemachine_rxstall_obj = { (mp_obj_t)&mp_const_none_obj}, }; +//| in_waiting: int +//| """The number of words available to readinto""" +//| + +STATIC mp_obj_t rp2pio_statemachine_obj_get_in_waiting(mp_obj_t self_in) { + rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_rp2pio_statemachine_get_in_waiting(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_in_waiting_obj, rp2pio_statemachine_obj_get_in_waiting); + +const mp_obj_property_t rp2pio_statemachine_in_waiting_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&rp2pio_statemachine_get_in_waiting_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + STATIC const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&rp2pio_statemachine_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, @@ -563,7 +581,8 @@ STATIC const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_write_readinto), MP_ROM_PTR(&rp2pio_statemachine_write_readinto_obj) }, { MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&rp2pio_statemachine_frequency_obj) }, - { MP_ROM_QSTR(MP_QSTR_rxstall), MP_ROM_PTR(&rp2pio_statemachine_rxstall_obj) } + { MP_ROM_QSTR(MP_QSTR_rxstall), MP_ROM_PTR(&rp2pio_statemachine_rxstall_obj) }, + { MP_ROM_QSTR(MP_QSTR_in_waiting), MP_ROM_PTR(&rp2pio_statemachine_in_waiting_obj) }, }; STATIC MP_DEFINE_CONST_DICT(rp2pio_statemachine_locals_dict, rp2pio_statemachine_locals_dict_table); diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.h b/ports/raspberrypi/bindings/rp2pio/StateMachine.h index 36e44f1918..229e37ca70 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.h +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.h @@ -69,5 +69,6 @@ void common_hal_rp2pio_statemachine_set_frequency(rp2pio_statemachine_obj_t* sel bool common_hal_rp2pio_statemachine_get_rxstall(rp2pio_statemachine_obj_t* self); void common_hal_rp2pio_statemachine_clear_rxfifo(rp2pio_statemachine_obj_t *self); +size_t common_hal_rp2pio_statemachine_get_in_waiting(rp2pio_statemachine_obj_t *self); #endif // MICROPY_INCLUDED_RASPBERRYPI_BINDINGS_RP2PIO_STATEMACHINE_H diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index e81d721c61..6a115d9c63 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -728,3 +728,8 @@ void common_hal_rp2pio_statemachine_clear_rxfifo(rp2pio_statemachine_obj_t *self } self->pio->fdebug = stall_mask; } + +size_t common_hal_rp2pio_statemachine_get_in_waiting(rp2pio_statemachine_obj_t *self) { + uint8_t level = pio_sm_get_rx_fifo_level(self->pio, self->state_machine); + return level; +} From ff62b0d2c020cffb910ad15e81897b41e92380fa Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Mar 2021 10:03:31 -0600 Subject: [PATCH 2/9] StateMachine: Add pull up/down for inputs --- .../bindings/rp2pio/StateMachine.c | 9 ++++++- .../bindings/rp2pio/StateMachine.h | 2 +- .../common-hal/audiobusio/I2SOut.c | 1 + .../raspberrypi/common-hal/audiobusio/PDMIn.c | 1 + .../common-hal/neopixel_write/__init__.c | 1 + .../common-hal/rp2pio/StateMachine.c | 24 +++++++++++++++++++ .../common-hal/rp2pio/StateMachine.h | 3 +++ 7 files changed, 39 insertions(+), 2 deletions(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index e242889252..90fd7f95e7 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -69,6 +69,8 @@ //| initial_out_pin_direction: int = 0xffffffff, //| first_in_pin: Optional[microcontroller.Pin] = None, //| in_pin_count: int = 1, +//| pull_in_pin_up: int = 0, +//| pull_in_pin_down: int = 0, //| first_set_pin: Optional[microcontroller.Pin] = None, //| set_pin_count: int = 1, //| initial_set_pin_state: int = 0, @@ -99,6 +101,8 @@ //| :param int initial_out_pin_direction: the initial output direction for out pins starting at first_out_pin //| :param ~microcontroller.Pin first_in_pin: the first pin to use with the IN instruction //| :param int in_pin_count: the count of consecutive pins to use with IN starting at first_in_pin +//| :param int pull_in_pin_up: a 1-bit in this mask sets pull up on the corresponding in pin +//| :param int pull_in_pin_down: a 1-bit in this mask sets pull up on the corresponding in pin. Setting both pulls enables a "bus keep" function, i.e. a weak pull to whatever is current high/low state of GPIO. //| :param ~microcontroller.Pin first_set_pin: the first pin to use with the SET instruction //| :param int set_pin_count: the count of consecutive pins to use with SET starting at first_set_pin //| :param int initial_set_pin_state: the initial output value for set pins starting at first_set_pin @@ -133,6 +137,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n enum { ARG_program, ARG_frequency, ARG_init, ARG_first_out_pin, ARG_out_pin_count, ARG_initial_out_pin_state, ARG_initial_out_pin_direction, ARG_first_in_pin, ARG_in_pin_count, + ARG_pull_in_pin_up, ARG_pull_in_pin_down, ARG_first_set_pin, ARG_set_pin_count, ARG_initial_set_pin_state, ARG_initial_set_pin_direction, ARG_first_sideset_pin, ARG_sideset_pin_count, ARG_initial_sideset_pin_state, ARG_initial_sideset_pin_direction, ARG_exclusive_pin_use, @@ -151,6 +156,8 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_first_in_pin, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_in_pin_count, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, + { MP_QSTR_pull_in_pin_up, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_pull_in_pin_down, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_first_set_pin, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_set_pin_count, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, @@ -233,7 +240,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n args[ARG_frequency].u_int, init_bufinfo.buf, init_bufinfo.len / 2, first_out_pin, args[ARG_out_pin_count].u_int, args[ARG_initial_out_pin_state].u_int, args[ARG_initial_out_pin_direction].u_int, - first_in_pin, args[ARG_in_pin_count].u_int, + first_in_pin, args[ARG_in_pin_count].u_int, args[ARG_pull_in_pin_up].u_int, args[ARG_pull_in_pin_down].u_int, first_set_pin, args[ARG_set_pin_count].u_int, args[ARG_initial_set_pin_state].u_int, args[ARG_initial_set_pin_direction].u_int, first_sideset_pin, args[ARG_sideset_pin_count].u_int, args[ARG_initial_sideset_pin_state].u_int, args[ARG_initial_sideset_pin_direction].u_int, args[ARG_exclusive_pin_use].u_bool, diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.h b/ports/raspberrypi/bindings/rp2pio/StateMachine.h index 229e37ca70..d17b4b0b50 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.h +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.h @@ -41,7 +41,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, size_t frequency, const uint16_t* init, size_t init_len, const mcu_pin_obj_t * first_out_pin, uint8_t out_pin_count, uint32_t initial_out_pin_state, uint32_t initial_out_pin_direction, - const mcu_pin_obj_t * first_in_pin, uint8_t in_pin_count, + const mcu_pin_obj_t * first_in_pin, uint8_t in_pin_count, uint32_t pull_pin_up, uint32_t pull_pin_down, const mcu_pin_obj_t * first_set_pin, uint8_t set_pin_count, uint32_t initial_set_pin_state, uint32_t initial_set_pin_direction, const mcu_pin_obj_t * first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction, bool exclusive_pin_use, diff --git a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c index 83a443834e..fa5852fce5 100644 --- a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c +++ b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c @@ -122,6 +122,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self, NULL, 0, data, 1, 0, 0xffffffff, // out pin NULL, 0, // in pins + 0, 0, // in pulls NULL, 0, 0, 0x1f, // set pins bit_clock, 2, 0, 0x1f, // sideset pins true, // exclusive pin use diff --git a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c index ffe09326f3..6aee8b4df3 100644 --- a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c +++ b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c @@ -68,6 +68,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self, NULL, 0, NULL, 1, 0, 0xffffffff, // out pin data_pin, 1, // in pins + 0, 0, // in pulls NULL, 0, 0, 0x1f, // set pins clock_pin, 1, 0, 0x1f, // sideset pins true, // exclusive pin use diff --git a/ports/raspberrypi/common-hal/neopixel_write/__init__.c b/ports/raspberrypi/common-hal/neopixel_write/__init__.c index 1f0b71ca09..b57cb2bdea 100644 --- a/ports/raspberrypi/common-hal/neopixel_write/__init__.c +++ b/ports/raspberrypi/common-hal/neopixel_write/__init__.c @@ -67,6 +67,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, NULL, 0, // init program NULL, 1, // out NULL, 1, // in + 0, 0, // in pulls NULL, 1, // set digitalinout->pin, 1, // sideset 0, pins_we_use, // initial pin state diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index 6a115d9c63..78eb6e1e5a 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -53,6 +53,17 @@ STATIC uint32_t _current_sm_pins[NUM_PIOS][NUM_PIO_STATE_MACHINES]; STATIC PIO pio_instances[2] = {pio0, pio1}; +static void rp2pio_statemachine_set_pull(uint32_t pull_pin_up, uint32_t pull_pin_down, uint32_t pins_we_use) { + for (int i=0; ipio, state_machine, initial_pin_state, pins_we_use); pio_sm_set_pindirs_with_mask(self->pio, state_machine, initial_pin_direction, pins_we_use); + rp2pio_statemachine_set_pull(pull_pin_up, pull_pin_down, pins_we_use); self->initial_pin_state = initial_pin_state; self->initial_pin_direction = initial_pin_direction; + self->pull_pin_up = pull_pin_up; + self->pull_pin_down = pull_pin_down; for (size_t pin_number = 0; pin_number < TOTAL_GPIO_COUNT; pin_number++) { if ((pins_we_use & (1 << pin_number)) == 0) { @@ -302,6 +317,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, const uint16_t* init, size_t init_len, const mcu_pin_obj_t * first_out_pin, uint8_t out_pin_count, uint32_t initial_out_pin_state, uint32_t initial_out_pin_direction, const mcu_pin_obj_t * first_in_pin, uint8_t in_pin_count, + uint32_t pull_pin_up, uint32_t pull_pin_down, const mcu_pin_obj_t * first_set_pin, uint8_t set_pin_count, uint32_t initial_set_pin_state, uint32_t initial_set_pin_direction, const mcu_pin_obj_t * first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction, bool exclusive_pin_use, @@ -444,12 +460,19 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, initial_pin_state = (initial_pin_state & ~sideset_mask) | mask_and_rotate(first_sideset_pin, sideset_pin_count, initial_sideset_pin_state); initial_pin_direction = (initial_pin_direction & ~sideset_mask) | mask_and_rotate(first_sideset_pin, sideset_pin_count, initial_sideset_pin_direction); + // Deal with pull up/downs + uint32_t pull_up = mask_and_rotate(first_in_pin, in_pin_count, pull_pin_up); + uint32_t pull_down = mask_and_rotate(first_in_pin, in_pin_count, pull_pin_down); + if (initial_pin_direction & (pull_up | pull_down)) { + mp_raise_ValueError(translate("pull masks conflict with direction masks")); + } bool ok = rp2pio_statemachine_construct(self, program, program_len, frequency, init, init_len, first_out_pin, out_pin_count, first_in_pin, in_pin_count, + pull_up, pull_down, first_set_pin, set_pin_count, first_sideset_pin, sideset_pin_count, initial_pin_state, initial_pin_direction, @@ -470,6 +493,7 @@ void common_hal_rp2pio_statemachine_restart(rp2pio_statemachine_obj_t *self) { uint32_t pins_we_use = _current_sm_pins[pio_index][self->state_machine]; pio_sm_set_pins_with_mask(self->pio, self->state_machine, self->initial_pin_state, pins_we_use); pio_sm_set_pindirs_with_mask(self->pio, self->state_machine, self->initial_pin_direction, pins_we_use); + rp2pio_statemachine_set_pull(self->pull_pin_up, self->pull_pin_down, pins_we_use); common_hal_rp2pio_statemachine_run(self, self->init, self->init_len); pio_sm_set_enabled(self->pio, self->state_machine, true); } diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.h b/ports/raspberrypi/common-hal/rp2pio/StateMachine.h index f084e09860..1a73a3ac7b 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.h +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.h @@ -40,6 +40,8 @@ typedef struct { size_t init_len; uint32_t initial_pin_state; uint32_t initial_pin_direction; + uint32_t pull_pin_up; + uint32_t pull_pin_down; bool in; bool out; bool wait_for_txstall; @@ -59,6 +61,7 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, const uint16_t* init, size_t init_len, const mcu_pin_obj_t * first_out_pin, uint8_t out_pin_count, const mcu_pin_obj_t * first_in_pin, uint8_t in_pin_count, + uint32_t pull_pin_up, uint32_t pull_pin_down, const mcu_pin_obj_t * first_set_pin, uint8_t set_pin_count, const mcu_pin_obj_t * first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_pin_state, uint32_t initial_pin_direction, From bd01d31542f1d83797ecb2ac4a4a16ba0235a988 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Mar 2021 11:13:55 -0600 Subject: [PATCH 3/9] rp2pio: Add pins_are_sequential This can be used where the standard API calls for a list of pins, to check that they satisfy the requirements of the rp2pio state machine, e.g., ```python def __init__(self, pin_a, pin_b): if not rp2pio.pins_are_sequential([pin_a, pin_b]): raise ValueError("Pins must be sequential") ``` --- ports/raspberrypi/bindings/rp2pio/__init__.c | 15 +++++++ ports/raspberrypi/bindings/rp2pio/__init__.h | 29 ++++++++++++ .../raspberrypi/common-hal/rp2pio/__init__.c | 44 ++++++++++++++++++- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 ports/raspberrypi/bindings/rp2pio/__init__.h diff --git a/ports/raspberrypi/bindings/rp2pio/__init__.c b/ports/raspberrypi/bindings/rp2pio/__init__.c index dd5808cd5e..7eab423e9e 100644 --- a/ports/raspberrypi/bindings/rp2pio/__init__.c +++ b/ports/raspberrypi/bindings/rp2pio/__init__.c @@ -28,13 +28,28 @@ #include "py/runtime.h" #include "bindings/rp2pio/StateMachine.h" +#include "bindings/rp2pio/__init__.h" //| """Hardware interface to RP2 series' programmable IO (PIO) peripheral.""" //| +//| def pins_are_sequential(pins: List[microcontroller.Pin]) -> bool: +//| """Return True if the pins have sequential GPIO numbers, False otherwise""" +//| ... +//| +STATIC mp_obj_t rp2pio_pins_are_sequential(const mp_obj_t pins) { + size_t len; + mp_obj_t *items; + mp_obj_get_array(pins, &len, &items); + return mp_obj_new_bool(common_hal_rp2pio_pins_are_sequential(len, items)); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_pins_are_sequential_obj, rp2pio_pins_are_sequential); + STATIC const mp_rom_map_elem_t rp2pio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_rp2pio) }, { MP_ROM_QSTR(MP_QSTR_StateMachine), MP_ROM_PTR(&rp2pio_statemachine_type) }, + { MP_ROM_QSTR(MP_QSTR_pins_are_sequential), MP_ROM_PTR(&rp2pio_pins_are_sequential_obj) }, }; STATIC MP_DEFINE_CONST_DICT(rp2pio_module_globals, rp2pio_module_globals_table); diff --git a/ports/raspberrypi/bindings/rp2pio/__init__.h b/ports/raspberrypi/bindings/rp2pio/__init__.h new file mode 100644 index 0000000000..89dc7ff98f --- /dev/null +++ b/ports/raspberrypi/bindings/rp2pio/__init__.h @@ -0,0 +1,29 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +bool common_hal_rp2pio_pins_are_sequential(size_t len, mp_obj_t *items); diff --git a/ports/raspberrypi/common-hal/rp2pio/__init__.c b/ports/raspberrypi/common-hal/rp2pio/__init__.c index 21699dfa36..5ad52c751c 100644 --- a/ports/raspberrypi/common-hal/rp2pio/__init__.c +++ b/ports/raspberrypi/common-hal/rp2pio/__init__.c @@ -1 +1,43 @@ -// Nothing yet. +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "bindings/rp2pio/__init__.h" + +bool common_hal_rp2pio_pins_are_sequential(size_t len, mp_obj_t *items) { + if(len == 0) { + return true; + } + mcu_pin_obj_t *last_pin = validate_obj_is_pin(items[0]); + for(int i=1; inumber != last_pin->number + 1) { + return false; + } + } + return true; +} From c023ec03fff59bae159469645edbe2662da8820f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Mar 2021 12:28:06 -0600 Subject: [PATCH 4/9] PDMIn: Add missing deinit call --- ports/raspberrypi/common-hal/audiobusio/PDMIn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c index 6aee8b4df3..8836602712 100644 --- a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c +++ b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c @@ -93,6 +93,7 @@ void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t* self) { if (common_hal_audiobusio_pdmin_deinited(self)) { return; } + return common_hal_rp2pio_statemachine_deinit(&self->state_machine); } uint8_t common_hal_audiobusio_pdmin_get_bit_depth(audiobusio_pdmin_obj_t* self) { From bc14ed31f659ade034ac78a8ce3e19831e9e7000 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Mar 2021 12:28:46 -0600 Subject: [PATCH 5/9] StateMachine.h: Add header for declaration of mcu_pin_obj_t typedef --- ports/raspberrypi/common-hal/rp2pio/StateMachine.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.h b/ports/raspberrypi/common-hal/rp2pio/StateMachine.h index 1a73a3ac7b..f40db61ea3 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.h +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.h @@ -29,6 +29,7 @@ #include "py/obj.h" +#include "common-hal/microcontroller/Pin.h" #include "src/rp2_common/hardware_pio/include/hardware/pio.h" typedef struct { From c9dea3d72deac11309987654b0751b8cf07cbf57 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Mar 2021 14:23:06 -0600 Subject: [PATCH 6/9] make translate --- locale/circuitpython.pot | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 2e31d5dfc1..afff80687e 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -1042,10 +1042,6 @@ msgstr "" msgid "Group already used" msgstr "" -#: shared-module/displayio/Group.c -msgid "Group full" -msgstr "" - #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1787,6 +1783,10 @@ msgid "" "constructor" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3743,6 +3743,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "pull masks conflict with direction masks" +msgstr "" + #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "pull_threshold must be between 1 and 32" msgstr "" From 2ab13d6d1ee7dfde93c3fe164d09cbd91b7e68f8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Mar 2021 15:52:31 -0600 Subject: [PATCH 7/9] bump xtensa cache timestamp again --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a3f1a8d27..7fa2953b37 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -475,7 +475,7 @@ jobs: id: idf-cache with: path: ${{ github.workspace }}/.idf_tools - key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210303 + key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210304 - name: Clone IDF submodules run: | (cd $IDF_PATH && git submodule update --init) From 2ae1e7de61485bc9167996a63c32bf7b14c4c80c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 Mar 2021 09:00:03 -0600 Subject: [PATCH 8/9] WIPrp2040: Implement IncrementalEncoder Any two consecutive pins can be used for an IncrementalEncoder Testing performed: Put a synthesized (few hundred counts per second) quadrature signal into GP2/3 and read the encoder out. Performed filesystem operations at the same time to stress test it. The reasons for not using common_hal_rp2pio_statemachine_readinto are commented on. --- .../bindings/rp2pio/StateMachine.h | 2 + .../common-hal/rotaryio/IncrementalEncoder.c | 170 ++++++++++++++++++ .../common-hal/rotaryio/IncrementalEncoder.h | 40 +++++ .../common-hal/rotaryio/__init__.c | 1 + .../common-hal/rotaryio/__init__.h | 0 .../common-hal/rp2pio/StateMachine.c | 42 +++++ ports/raspberrypi/mpconfigport.mk | 3 +- 7 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c create mode 100644 ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h create mode 100644 ports/raspberrypi/common-hal/rotaryio/__init__.c create mode 100644 ports/raspberrypi/common-hal/rotaryio/__init__.h diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.h b/ports/raspberrypi/bindings/rp2pio/StateMachine.h index d17b4b0b50..3a0d4290d5 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.h +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.h @@ -71,4 +71,6 @@ bool common_hal_rp2pio_statemachine_get_rxstall(rp2pio_statemachine_obj_t* self) void common_hal_rp2pio_statemachine_clear_rxfifo(rp2pio_statemachine_obj_t *self); size_t common_hal_rp2pio_statemachine_get_in_waiting(rp2pio_statemachine_obj_t *self); +void common_hal_rp2pio_statemachine_set_interrupt_handler(rp2pio_statemachine_obj_t *self, void(*handler)(void*), void *arg, int mask); + #endif // MICROPY_INCLUDED_RASPBERRYPI_BINDINGS_RP2PIO_STATEMACHINE_H diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c new file mode 100644 index 0000000000..b2225991d6 --- /dev/null +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c @@ -0,0 +1,170 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" + +#include +#include "common-hal/rotaryio/IncrementalEncoder.h" +#include "bindings/rp2pio/__init__.h" +#include "bindings/rp2pio/StateMachine.h" + +STATIC const uint16_t encoder[] = { + // again: + // in pins, 2 + 0x4002, + // mov x, isr + 0xa026, + // jmp x!=y, push_data + 0x00a5, + // mov isr, null + 0xa0c3, + // jmp again + 0x0000, + // push_data: + // push + 0x8020, + // mov y, x + 0xa041, +}; + +STATIC const uint16_t encoder_init[] = { + // set y, 31 + 0xe05f, +}; + +STATIC void incrementalencoder_interrupt_handler(void *self_in); + +void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t* self, + const mcu_pin_obj_t* pin_a, const mcu_pin_obj_t* pin_b) { + mp_obj_t pins[] = {MP_OBJ_FROM_PTR(pin_a), MP_OBJ_FROM_PTR(pin_b)}; + if (!common_hal_rp2pio_pins_are_sequential(2, pins)) { + mp_raise_RuntimeError(translate("Pins must be sequential")); + } + + self->position = 0; + self->quarter_count = 0; + + common_hal_rp2pio_statemachine_construct(&self->state_machine, + encoder, MP_ARRAY_SIZE(encoder), + 1000000, + encoder_init, MP_ARRAY_SIZE(encoder_init), // init + NULL, 1, 0, 0xffffffff, // out pin + pin_a, 2, // in pins + 3, 0, // in pulls + NULL, 0, 0, 0x1f, // set pins + NULL, 0, 0, 0x1f, // sideset pins + true, // exclusive pin use + false, 32, false, // out settings + false, // Wait for txstall + false, 32, false); // in settings + + common_hal_rp2pio_statemachine_run(&self->state_machine, encoder_init, MP_ARRAY_SIZE(encoder_init)); + + // We're guaranteed by the init code that some output will be available promptly + uint8_t state; + common_hal_rp2pio_statemachine_readinto(&self->state_machine, &state, 1, 1); + // Top two bits of self->last_state don't matter, because they'll be gone as soon as + // interrupt handler is called. + self->last_state = state & 3; + + common_hal_rp2pio_statemachine_set_interrupt_handler(&self->state_machine, incrementalencoder_interrupt_handler, self, PIO_IRQ0_INTF_SM0_RXNEMPTY_BITS); +} + +bool common_hal_rotaryio_incrementalencoder_deinited(rotaryio_incrementalencoder_obj_t* self) { + return common_hal_rp2pio_statemachine_deinited(&self->state_machine); +} + +void common_hal_rotaryio_incrementalencoder_deinit(rotaryio_incrementalencoder_obj_t* self) { + if (common_hal_rotaryio_incrementalencoder_deinited(self)) { + return; + } + common_hal_rp2pio_statemachine_deinit(&self->state_machine); +} + +mp_int_t common_hal_rotaryio_incrementalencoder_get_position(rotaryio_incrementalencoder_obj_t* self) { + return self->position; +} + +void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t* self, + mp_int_t new_position) { + self->position = new_position; +} + +STATIC void incrementalencoder_interrupt_handler(void *self_in) { + rotaryio_incrementalencoder_obj_t* self = self_in; + // This table also works for detent both at 11 and 00 + // For 11 at detent: + // Turning cw: 11->01->00->10->11 + // Turning ccw: 11->10->00->01->11 + // For 00 at detent: + // Turning cw: 00->10->11->10->00 + // Turning ccw: 00->01->11->10->00 + + // index table by state + #define BAD 7 + static const int8_t transitions[16] = { + 0, // 00 -> 00 no movement + -1, // 00 -> 01 3/4 ccw (11 detent) or 1/4 ccw (00 at detent) + +1, // 00 -> 10 3/4 cw or 1/4 cw + BAD, // 00 -> 11 non-Gray-code transition + +1, // 01 -> 00 2/4 or 4/4 cw + 0, // 01 -> 01 no movement + BAD, // 01 -> 10 non-Gray-code transition + -1, // 01 -> 11 4/4 or 2/4 ccw + -1, // 10 -> 00 2/4 or 4/4 ccw + BAD, // 10 -> 01 non-Gray-code transition + 0, // 10 -> 10 no movement + +1, // 10 -> 11 4/4 or 2/4 cw + BAD, // 11 -> 00 non-Gray-code transition + +1, // 11 -> 01 1/4 or 3/4 cw + -1, // 11 -> 10 1/4 or 3/4 ccw + 0, // 11 -> 11 no movement + }; + + while (common_hal_rp2pio_statemachine_get_in_waiting(&self->state_machine)) { + // Bypass all the logic of StateMachine.c:_transfer, we need something + // very simple and fast for an interrupt! + uint8_t new = self->state_machine.pio->rxf[self->state_machine.state_machine]; + + // Shift the old AB bits to the "old" position, and set the new AB bits. + self->last_state = (self->last_state & 0x3) << 2 | (new & 0x3); + + int8_t quarter_incr = transitions[self->last_state]; + if (quarter_incr == BAD) { + // Missed a transition. We don't know which way we're going, so do nothing. + return; + } + + self->quarter_count += quarter_incr; + if (self->quarter_count >= 4) { + self->position += 1; + self->quarter_count = 0; + } else if (self->quarter_count <= -4) { + self->position -= 1; + self->quarter_count = 0; + } + } +} diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h new file mode 100644 index 0000000000..ff5c874c83 --- /dev/null +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "common-hal/rp2pio/StateMachine.h" +#include "common-hal/microcontroller/Pin.h" + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + rp2pio_statemachine_obj_t state_machine; + uint8_t last_state:4; // + int8_t quarter_count:4; // count intermediate transitions between detents + mp_int_t position; +} rotaryio_incrementalencoder_obj_t; diff --git a/ports/raspberrypi/common-hal/rotaryio/__init__.c b/ports/raspberrypi/common-hal/rotaryio/__init__.c new file mode 100644 index 0000000000..0aae79c26a --- /dev/null +++ b/ports/raspberrypi/common-hal/rotaryio/__init__.c @@ -0,0 +1 @@ +// No rotaryio module functions. diff --git a/ports/raspberrypi/common-hal/rotaryio/__init__.h b/ports/raspberrypi/common-hal/rotaryio/__init__.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index 78eb6e1e5a..672cd4d3cf 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -27,6 +27,7 @@ #include "bindings/rp2pio/StateMachine.h" #include "common-hal/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "src/rp2040/hardware_regs/include/hardware/platform_defs.h" @@ -52,6 +53,11 @@ STATIC uint32_t _current_pins[NUM_PIOS]; STATIC uint32_t _current_sm_pins[NUM_PIOS][NUM_PIO_STATE_MACHINES]; STATIC PIO pio_instances[2] = {pio0, pio1}; +typedef void (*interrupt_handler_type)(void*); +STATIC interrupt_handler_type _interrupt_handler[NUM_PIOS][NUM_PIO_STATE_MACHINES]; +STATIC void *_interrupt_arg[NUM_PIOS][NUM_PIO_STATE_MACHINES]; + +STATIC void rp2pio_statemachine_interrupt_handler(void); static void rp2pio_statemachine_set_pull(uint32_t pull_pin_up, uint32_t pull_pin_down, uint32_t pins_we_use) { for (int i=0; iinte0 &= ~((PIO_IRQ0_INTF_SM0_RXNEMPTY_BITS | PIO_IRQ0_INTF_SM0_TXNFULL_BITS | PIO_IRQ0_INTF_SM0_BITS) << sm); pio_sm_unclaim(pio, sm); } @@ -535,6 +542,10 @@ void common_hal_rp2pio_statemachine_set_frequency(rp2pio_statemachine_obj_t* sel void rp2pio_statemachine_deinit(rp2pio_statemachine_obj_t *self, bool leave_pins) { uint8_t sm = self->state_machine; uint8_t pio_index = pio_get_index(self->pio); + common_hal_mcu_disable_interrupts(); + _interrupt_arg[pio_index][sm] = NULL; + _interrupt_handler[pio_index][sm] = NULL; + common_hal_mcu_enable_interrupts(); _never_reset[pio_index][sm] = false; _reset_statemachine(self->pio, sm, leave_pins); self->state_machine = NUM_PIO_STATE_MACHINES; @@ -757,3 +768,34 @@ size_t common_hal_rp2pio_statemachine_get_in_waiting(rp2pio_statemachine_obj_t * uint8_t level = pio_sm_get_rx_fifo_level(self->pio, self->state_machine); return level; } + +void common_hal_rp2pio_statemachine_set_interrupt_handler(rp2pio_statemachine_obj_t *self, void(*handler)(void*), void *arg, int mask) { + uint8_t pio_index = pio_get_index(self->pio); + uint8_t sm = self->state_machine; + + common_hal_mcu_disable_interrupts(); + uint32_t inte = self->pio->inte0; + inte &= ~((PIO_IRQ0_INTF_SM0_RXNEMPTY_BITS | PIO_IRQ0_INTF_SM0_TXNFULL_BITS | PIO_IRQ0_INTF_SM0_BITS) << sm); + inte |= (mask << sm); + self->pio->inte0 = inte; + _interrupt_arg[pio_index][sm] = arg; + _interrupt_handler[pio_index][sm] = handler; + irq_set_exclusive_handler(PIO0_IRQ_0 + 2 * pio_index, rp2pio_statemachine_interrupt_handler); + irq_set_enabled(PIO0_IRQ_0 + 2 * pio_index, true); + common_hal_mcu_enable_interrupts(); +} + +STATIC void rp2pio_statemachine_interrupt_handler(void) { + for (size_t pio_index = 0; pio_index < NUM_PIOS; pio_index++) { + PIO pio = pio_instances[pio_index]; + for (size_t sm = 0; sm < NUM_PIO_STATE_MACHINES; sm++) { + if (!_interrupt_handler[pio_index][sm]) { + continue; + } + uint32_t intf = (PIO_IRQ0_INTF_SM0_RXNEMPTY_BITS | PIO_IRQ0_INTF_SM0_TXNFULL_BITS | PIO_IRQ0_INTF_SM0_BITS) << sm; + if (pio->ints0 & intf) { + _interrupt_handler[pio_index][sm](_interrupt_arg[pio_index][sm]); + } + } + } +} diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index 4c149cb2b8..00aae80a0b 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -28,13 +28,14 @@ CIRCUITPY_FULL_BUILD = 1 CIRCUITPY_BITOPS = 1 CIRCUITPY_PWMIO = 1 CIRCUITPY_RGBMATRIX = 1 +CIRCUITPY_ROTARYIO = 1 # Things that need to be implemented. +# (Remember to remove any comment when changing a 0 to a 1, make gets confused otherwise) CIRCUITPY_FREQUENCYIO = 0 # Use PWM interally CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_NVM = 1 CIRCUITPY_PULSEIO = 0 # Use PIO interally -CIRCUITPY_ROTARYIO = 0 # Use PIO interally CIRCUITPY_WATCHDOG = 1 # Audio via PWM From cd1f19020fefd024c4aeef6a26ea61a11c26ab27 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 Mar 2021 12:59:55 -0600 Subject: [PATCH 9/9] raspberrypi: move landmine Makefile comments --- ports/raspberrypi/mpconfigport.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index 00aae80a0b..03de6ce5ee 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -31,11 +31,12 @@ CIRCUITPY_RGBMATRIX = 1 CIRCUITPY_ROTARYIO = 1 # Things that need to be implemented. -# (Remember to remove any comment when changing a 0 to a 1, make gets confused otherwise) -CIRCUITPY_FREQUENCYIO = 0 # Use PWM interally +# Use PWM interally +CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_NVM = 1 -CIRCUITPY_PULSEIO = 0 # Use PIO interally +# Use PIO interally +CIRCUITPY_PULSEIO = 0 CIRCUITPY_WATCHDOG = 1 # Audio via PWM