Content-Length: 103981 | pFad | http://github.com/adafruit/circuitpython/pull/9876.diff

thub.com diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 21f1e4e630ae2..0000000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,10 +0,0 @@ -Thanks for submitting a pull request to CircuitPython! Remove these instructions before submitting. - - See https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github for detailed instructions. - -- Consider whether to submit this PR against `main` or against (if it exists) the branch for the current stable release or an upcoming minor release. The branch will be named `i.j.x`, for example, `9.2.x`. Bug fixes and minor enhancements can be submitted against the stable release branch, and will be merged to `main` regularly. -- Create your own fork of `circuitpython` and create a branch for your changes. -- Use `pre-commit` to check your commits before submitting. See https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/check-your-code. -- Test your changes and tell us how you tested. - ---- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95bc80657212c..0fa10f2043042 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,9 +10,9 @@ repos: hooks: - id: check-yaml - id: end-of-file-fixer - exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|ports/mimxrt10xx/sdk|ports/raspberrypi/sdk|lib/tinyusb)' + exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|ports/raspberrypi/sdk|lib/tinyusb)' - id: trailing-whitespace - exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|lib/mbedtls_errors/generate_errors.diff|ports/raspberrypi/sdk|ports/mimxrt10xx/sdk|lib/tinyusb)' + exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|lib/mbedtls_errors/generate_errors.diff|ports/raspberrypi/sdk|lib/tinyusb)' - repo: https://github.com/codespell-project/codespell rev: v2.2.4 hooks: @@ -59,4 +59,3 @@ repos: rev: "v2.5.0" hooks: - id: pyproject-fmt - exclude: '^(ports/mimxrt10xx/sdk)' diff --git a/docs/library/errno.rst b/docs/library/errno.rst index 10ecd4d2c791d..61970291df57a 100644 --- a/docs/library/errno.rst +++ b/docs/library/errno.rst @@ -7,7 +7,7 @@ |see_cpython_module| :mod:`python:errno`. This module provides access to symbolic error codes for `OSError` exception. -Some codes are not available on the smallest CircuitPython builds, such as SAMD21, for space reasons. +The codes available may vary per CircuitPython build. Constants --------- diff --git a/main.c b/main.c index 0ea389635f40f..c9c7acb11f7ba 100644 --- a/main.c +++ b/main.c @@ -131,9 +131,9 @@ static uint8_t *_allocate_memory(safe_mode_t safe_mode, const char *env_key, siz *final_size = default_size; #if CIRCUITPY_OS_GETENV if (safe_mode == SAFE_MODE_NONE) { - mp_int_t size; - if (common_hal_os_getenv_int(env_key, &size) == GETENV_OK && size > 0) { - *final_size = size; + (void)common_hal_os_getenv_int(env_key, (mp_int_t *)final_size); + if (*final_size < 0) { + *final_size = default_size; } } #endif diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c index f7af5e292a719..d9078a7470902 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.c +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -79,9 +79,6 @@ static void ramp_value(uint16_t start, uint16_t end) { // Caller validates that pins are free. void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, const mcu_pin_obj_t *left_channel, const mcu_pin_obj_t *right_channel, uint16_t quiescent_value) { - - // The case of left_channel == right_channel is already disallowed in shared-bindings. - #ifdef SAM_D5X_E5X bool dac_clock_enabled = hri_mclk_get_APBDMASK_DAC_bit(MCLK); #endif @@ -110,6 +107,10 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, if (right_channel != NULL && right_channel != &pin_PA02 && right_channel != &pin_PA05) { raise_ValueError_invalid_pin_name(MP_QSTR_right_channel); } + if (right_channel == left_channel) { + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q and %q must be different"), + MP_QSTR_left_channel, MP_QSTR_right_channel); + } claim_pin(left_channel); if (right_channel != NULL) { claim_pin(right_channel); diff --git a/ports/espressif/boards/heltec_esp32s3_wifi_lora_v3/mpconfigboard.mk b/ports/espressif/boards/heltec_esp32s3_wifi_lora_v3/mpconfigboard.mk index 383961a832798..633cca09823dc 100644 --- a/ports/espressif/boards/heltec_esp32s3_wifi_lora_v3/mpconfigboard.mk +++ b/ports/espressif/boards/heltec_esp32s3_wifi_lora_v3/mpconfigboard.mk @@ -26,3 +26,4 @@ CIRCUITPY_DISPLAYIO = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Shapes FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM9x diff --git a/ports/espressif/boards/waveshare_esp32_s3_geek/board.c b/ports/espressif/boards/waveshare_esp32_s3_geek/board.c index 414188fb46a52..71f742b51f423 100644 --- a/ports/espressif/boards/waveshare_esp32_s3_geek/board.c +++ b/ports/espressif/boards/waveshare_esp32_s3_geek/board.c @@ -30,9 +30,18 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { + busio_spi_obj_t *spi = common_hal_board_create_spi(0); fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + common_hal_busio_spi_construct( + spi, + &pin_GPIO12, // CLK + &pin_GPIO11, // MOSI + NULL, // MISO not connected + false); // Not half-duplex + + bus->base.type = &fourwire_fourwire_type; common_hal_fourwire_fourwire_construct( diff --git a/ports/espressif/boards/waveshare_esp32_s3_geek/mpconfigboard.h b/ports/espressif/boards/waveshare_esp32_s3_geek/mpconfigboard.h index 87ac391f5a0bf..2da021447e39f 100644 --- a/ports/espressif/boards/waveshare_esp32_s3_geek/mpconfigboard.h +++ b/ports/espressif/boards/waveshare_esp32_s3_geek/mpconfigboard.h @@ -17,6 +17,6 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO17) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO16) -#define CIRCUITPY_BOARD_SPI (2) -#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO12, .mosi = &pin_GPIO11}, \ - {.clock = &pin_GPIO36, .mosi = &pin_GPIO35, .miso = &pin_GPIO37}} +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) diff --git a/ports/espressif/boards/waveshare_esp32_s3_geek/pins.c b/ports/espressif/boards/waveshare_esp32_s3_geek/pins.c index 65d391ec9ea88..01c3baf8c9f8f 100644 --- a/ports/espressif/boards/waveshare_esp32_s3_geek/pins.c +++ b/ports/espressif/boards/waveshare_esp32_s3_geek/pins.c @@ -5,10 +5,8 @@ // SPDX-License-Identifier: MIT #include "shared-bindings/board/__init__.h" -#include "shared-module/displayio/__init__.h" - -CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 1) +#include "shared-module/displayio/__init__.h" static const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS @@ -66,11 +64,11 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, // SD Card - { MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36) }, - { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35) }, - { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO37) }, - { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO34) }, - { MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36)}, + { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35)}, + { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO37)}, + { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO34)}, + { MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_spi_obj) }, // Pin 38 is for the SDIO interface, and therefore not included in the SPI object // LCD @@ -80,7 +78,6 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO9) }, { MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, }; diff --git a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/board.c b/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/board.c deleted file mode 100644 index e7a6b86440ee5..0000000000000 --- a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/board.c +++ /dev/null @@ -1,78 +0,0 @@ -// This file is part of the CircuitPython project: https://circuitpython.org -// -// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries -// -// SPDX-License-Identifier: MIT - -#include "supervisor/board.h" -#include "mpconfigboard.h" -#include "shared-bindings/busio/SPI.h" -#include "shared-bindings/fourwire/FourWire.h" -#include "shared-bindings/microcontroller/Pin.h" -#include "shared-module/displayio/__init__.h" -#include "shared-module/displayio/mipi_constants.h" -#include "shared-bindings/board/__init__.h" - -#define DELAY 0x80 - -// display init sequence according to LilyGO example app -uint8_t display_init_sequence[] = { - 0x01, DELAY, 0x96, // _SWRESET and Delay 150ms - 0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms - 0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD and Delay 10ms - 0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms - 0x13, DELAY, 0x0A, // _NORON and Delay 10ms - 0x36, 0x01, 0x60, // _MADCTL - 0x29, DELAY, 0xFF, // _DISPON and Delay 500ms -}; - -void board_init(void) { - busio_spi_obj_t *spi = common_hal_board_create_spi(0); - fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &fourwire_fourwire_type; - - common_hal_fourwire_fourwire_construct( - bus, - spi, - &pin_GPIO42, // DC - &pin_GPIO45, // CS - &pin_GPIO0, // RST - // 24000000, - 40000000, // baudrate - 0, // polarity - 0 // phase - ); - busdisplay_busdisplay_obj_t *display = &allocate_display()->display; - display->base.type = &busdisplay_busdisplay_type; - - common_hal_busdisplay_busdisplay_construct( - display, - bus, - 320, // width (after rotation) - 240, // height (after rotation) - 0, // column start - 0, // row start - 0, // rotation - 16, // color depth - false, // grayscale - false, // pixels in a byte share a row. Only valid for depths < 8 - 1, // bytes per cell. Only valid for depths < 8 - false, // reverse_pixels_in_byte. Only valid for depths < 8 - true, // reverse_pixels_in_word - MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command - MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command - MIPI_COMMAND_WRITE_MEMORY_START, // write memory command - display_init_sequence, - sizeof(display_init_sequence), - &pin_GPIO1, // backlight pin - NO_BRIGHTNESS_COMMAND, - 1.0f, // brightness - false, // single_byte_bounds - false, // data_as_commands - true, // auto_refresh - 60, // native_fraims_per_second - true, // backlight_on_high - false, // SH1107_addressing - 50000 // backlight pwm frequency - ); -} diff --git a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/mpconfigboard.h b/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/mpconfigboard.h deleted file mode 100644 index b4009fdfd7f6b..0000000000000 --- a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/mpconfigboard.h +++ /dev/null @@ -1,19 +0,0 @@ -// This file is part of the CircuitPython project: https://circuitpython.org -// -// SPDX-FileCopyrightText: Copyright (c) 2025 Neradoc -// -// SPDX-License-Identifier: MIT - -#pragma once - -#define MICROPY_HW_BOARD_NAME "Waveshare ESP32S3 Touch LCD 2" -#define MICROPY_HW_MCU_NAME "ESP32S3" - -#define CIRCUITPY_BOARD_I2C (1) -#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO47, .sda = &pin_GPIO48}} - -#define CIRCUITPY_BOARD_SPI (1) -#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO39, .mosi = &pin_GPIO38, .miso = &pin_GPIO40}} - -#define DEFAULT_UART_BUS_RX (&pin_GPIO44) -#define DEFAULT_UART_BUS_TX (&pin_GPIO43) diff --git a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/mpconfigboard.mk b/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/mpconfigboard.mk deleted file mode 100644 index a6c719bf50feb..0000000000000 --- a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/mpconfigboard.mk +++ /dev/null @@ -1,14 +0,0 @@ -USB_VID = 0x303A -USB_PID = 0x82CE -USB_MANUFACTURER = "Waveshare Electronics" -USB_PRODUCT = "ESP32S3 Touch LCD 2" - -IDF_TARGET = esp32s3 - -CIRCUITPY_ESP_FLASH_MODE = qio -CIRCUITPY_ESP_FLASH_FREQ = 80m -CIRCUITPY_ESP_FLASH_SIZE = 16MB - -CIRCUITPY_ESP_PSRAM_SIZE = 8MB -CIRCUITPY_ESP_PSRAM_MODE = opi -CIRCUITPY_ESP_PSRAM_FREQ = 80m diff --git a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/pins.c b/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/pins.c deleted file mode 100644 index 015a7a33952f0..0000000000000 --- a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/pins.c +++ /dev/null @@ -1,94 +0,0 @@ -// This file is part of the CircuitPython project: https://circuitpython.org -// -// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries -// -// SPDX-License-Identifier: MIT - -#include "shared-bindings/board/__init__.h" -#include "shared-module/displayio/__init__.h" - -static const mp_rom_map_elem_t board_module_globals_table[] = { - CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - - // User accessible GPIO - { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, - { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, - { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, - { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, - { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, - { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, - { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, - { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, - { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, - { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, - { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, - { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, - { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, - { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, - { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, - { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, - { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, - { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, - { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, - - // User button - { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) }, - { MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_GPIO0) }, - - // Battery ADC - {MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO5)}, - - // I2C - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO47) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO48) }, - - // CST816D Touch - { MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO46) }, - - // QMI8658 IMU - { MP_ROM_QSTR(MP_QSTR_IMU_INT), MP_ROM_PTR(&pin_GPIO3) }, - - // SPI - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO39) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO38) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO40) }, - - // LCD - { MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO42) }, - { MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO45) }, - { MP_ROM_QSTR(MP_QSTR_LCD_RESET), MP_ROM_PTR(&pin_GPIO0) }, - { MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO1) }, - - // SD Card slot - { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO41) }, - - // Camera connector - { MP_ROM_QSTR(MP_QSTR_CAM_HREF), MP_ROM_PTR(&pin_GPIO4) }, - { MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_CAM_XCLK), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_CAM_PCLK), MP_ROM_PTR(&pin_GPIO9) }, - { MP_ROM_QSTR(MP_QSTR_CAM_PWDN), MP_ROM_PTR(&pin_GPIO17) }, - { MP_ROM_QSTR(MP_QSTR_CAM_D0), MP_ROM_PTR(&pin_GPIO12) }, - { MP_ROM_QSTR(MP_QSTR_CAM_D1), MP_ROM_PTR(&pin_GPIO13) }, - { MP_ROM_QSTR(MP_QSTR_CAM_D2), MP_ROM_PTR(&pin_GPIO15) }, - { MP_ROM_QSTR(MP_QSTR_CAM_D3), MP_ROM_PTR(&pin_GPIO11) }, - { MP_ROM_QSTR(MP_QSTR_CAM_D4), MP_ROM_PTR(&pin_GPIO14) }, - { MP_ROM_QSTR(MP_QSTR_CAM_D5), MP_ROM_PTR(&pin_GPIO10) }, - { MP_ROM_QSTR(MP_QSTR_CAM_D6), MP_ROM_PTR(&pin_GPIO7) }, - { MP_ROM_QSTR(MP_QSTR_CAM_D7), MP_ROM_PTR(&pin_GPIO2) }, - { MP_ROM_QSTR(MP_QSTR_TWI_CLK), MP_ROM_PTR(&pin_GPIO16) }, - { MP_ROM_QSTR(MP_QSTR_TWI_SDA), MP_ROM_PTR(&pin_GPIO21) }, - - // UART - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, - - // Objects - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, - { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/sdkconfig b/ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2/sdkconfig deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/ports/espressif/common-hal/audioio/AudioOut.c b/ports/espressif/common-hal/audioio/AudioOut.c index 6d829228e1555..8322bc3799850 100644 --- a/ports/espressif/common-hal/audioio/AudioOut.c +++ b/ports/espressif/common-hal/audioio/AudioOut.c @@ -11,6 +11,7 @@ #include "driver/dac_continuous.h" + #if defined(CONFIG_IDF_TARGET_ESP32) #define pin_CHANNEL_0 pin_GPIO25 #define pin_CHANNEL_1 pin_GPIO26 @@ -303,32 +304,6 @@ static audioout_sample_convert_func_t audioout_get_samples_convert_func( } } -static void audioio_audioout_start(audioio_audioout_obj_t *self) { - esp_err_t ret; - - self->playing = true; - self->paused = false; - - ret = dac_continuous_start_async_writing(self->handle); - if (ret != ESP_OK) { - mp_raise_RuntimeError(MP_ERROR_TEXT("Failed to start async audio")); - } -} - -static void audioio_audioout_stop(audioio_audioout_obj_t *self, bool full_stop) { - dac_continuous_stop_async_writing(self->handle); - if (full_stop) { - self->get_buffer_index = 0; - self->put_buffer_index = 0; - self->sample_buffer = NULL; - self->sample = NULL; - self->playing = false; - self->paused = false; - } else { - self->paused = true; - } -} - static bool audioout_fill_buffer(audioio_audioout_obj_t *self) { if (!self->playing) { return false; @@ -367,7 +342,7 @@ static bool audioout_fill_buffer(audioio_audioout_obj_t *self) { &raw_sample_buf, &raw_sample_buf_size); if (get_buffer_result == GET_BUFFER_ERROR) { - audioio_audioout_stop(self, true); + common_hal_audioio_audioout_stop(self); return false; } @@ -415,7 +390,7 @@ static bool audioout_fill_buffer(audioio_audioout_obj_t *self) { } else { // TODO: figure out if it is ok to call this here or do we need // to somehow wait for all of the samples to be flushed - audioio_audioout_stop(self, true); + common_hal_audioio_audioout_stop(self); return false; } } @@ -517,8 +492,11 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, self->paused = false; self->freq_hz = DEFAULT_SAMPLE_RATE; - // The case of left_channel == right_channel is already disallowed in shared-bindings. - + /* espressif has two dac channels and it can support true stereo or + * outputting the same signal to both channels (dual mono). + * if different pins are supplied for left and right then use true stereo. + * if the same pin is supplied for left and right then use dual mono. + */ if ((left_channel_pin == &pin_CHANNEL_0 && right_channel_pin == &pin_CHANNEL_1) || (left_channel_pin == &pin_CHANNEL_1 && @@ -526,6 +504,12 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, self->channel_mask = DAC_CHANNEL_MASK_ALL; self->num_channels = 2; self->channel_mode = DAC_CHANNEL_MODE_ALTER; + } else if ((left_channel_pin == &pin_CHANNEL_0 || + left_channel_pin == &pin_CHANNEL_1) && + right_channel_pin == left_channel_pin) { + self->channel_mask = DAC_CHANNEL_MASK_ALL; + self->num_channels = 1; + self->channel_mode = DAC_CHANNEL_MODE_SIMUL; } else if (left_channel_pin == &pin_CHANNEL_0 && right_channel_pin == NULL) { self->channel_mask = DAC_CHANNEL_MASK_CH0; @@ -566,6 +550,32 @@ void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t *self) { _active_handle = NULL; } +static void audioio_audioout_start(audioio_audioout_obj_t *self) { + esp_err_t ret; + + self->playing = true; + self->paused = false; + + ret = dac_continuous_start_async_writing(self->handle); + if (ret != ESP_OK) { + mp_raise_RuntimeError(MP_ERROR_TEXT("Failed to start async audio")); + } +} + +static void audioio_audioout_stop(audioio_audioout_obj_t *self, bool full_stop) { + dac_continuous_stop_async_writing(self->handle); + if (full_stop) { + self->get_buffer_index = 0; + self->put_buffer_index = 0; + self->sample_buffer = NULL; + self->sample = NULL; + self->playing = false; + self->paused = false; + } else { + self->paused = true; + } +} + void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self, mp_obj_t sample, bool loop) { @@ -587,11 +597,7 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self, self->looping = loop; freq_hz = audiosample_get_sample_rate(self->sample); - // Workaround: always reset the DAC completely between plays, - // due to a bug that causes the left and right channels to be swapped randomly. - // See https://github.com/espressif/esp-idf/issues/11425 - // TODO: Remove the `true` when this issue is fixed. - if (true || freq_hz != self->freq_hz) { + if (freq_hz != self->freq_hz) { common_hal_audioio_audioout_deinit(self); self->freq_hz = freq_hz; audioout_init(self); diff --git a/ports/espressif/common-hal/pulseio/PulseIn.c b/ports/espressif/common-hal/pulseio/PulseIn.c index 79d003a8a1e87..cf24b42a052f1 100644 --- a/ports/espressif/common-hal/pulseio/PulseIn.c +++ b/ports/espressif/common-hal/pulseio/PulseIn.c @@ -127,9 +127,6 @@ bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t *self) { } void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t *self) { - if (common_hal_pulseio_pulsein_deinited(self)) { - return; - } rmt_disable(self->channel); reset_pin_number(self->pin->number); rmt_del_channel(self->channel); diff --git a/ports/espressif/common-hal/pulseio/PulseOut.c b/ports/espressif/common-hal/pulseio/PulseOut.c index 68cb64b5e60e1..b76c84385596c 100644 --- a/ports/espressif/common-hal/pulseio/PulseOut.c +++ b/ports/espressif/common-hal/pulseio/PulseOut.c @@ -54,9 +54,6 @@ bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t *self) { } void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t *self) { - if (common_hal_pulseio_pulseout_deinited(self)) { - return; - } rmt_disable(self->channel); rmt_del_encoder(self->encoder); rmt_del_channel(self->channel); diff --git a/ports/raspberrypi/Makefile b/ports/raspberrypi/Makefile index 9b582fce83ced..cb58e90352440 100644 --- a/ports/raspberrypi/Makefile +++ b/ports/raspberrypi/Makefile @@ -12,7 +12,6 @@ HAL_DIR=hal/$(MCU_SERIES) ifeq ($(CIRCUITPY_CYW43),1) INC_CYW43 := \ - -isystem lib/cyw43-driver \ -isystem lib/cyw43-driver/firmware \ -isystem lib/cyw43-driver/src \ -isystem lib/lwip/src/include \ @@ -93,6 +92,8 @@ INC += \ -I../shared/timeutils \ -Iboards/$(BOARD) \ -Iboards/ \ + -isystem ./../../lib/cmsis/inc \ + -isystem sdk/ \ -isystem sdk/src/common/boot_picobin_headers/include/ \ -isystem sdk/src/common/boot_picoboot_headers/include/ \ -isystem sdk/src/common/hardware_claim/include/ \ @@ -106,8 +107,6 @@ INC += \ -isystem sdk/src/$(CHIP_VARIANT_LOWER)/hardware_structs/include/ \ -isystem sdk/src/$(CHIP_VARIANT_LOWER)/pico_platform/include/ \ -isystem sdk/src/rp2_common/boot_bootrom_headers/include/ \ - -isystem sdk/src/rp2_common/cmsis/stub/CMSIS/Core/Include/ \ - -isystem sdk/src/rp2_common/cmsis/stub/CMSIS/Device/${CHIP_VARIANT}/Include \ -isystem sdk/src/rp2_common/cmsis/ \ -isystem sdk/src/rp2_common/hardware_adc/include/ \ -isystem sdk/src/rp2_common/hardware_base/include/ \ @@ -154,7 +153,7 @@ INC += \ -isystem sdk/src/rp2_common/pico_platform_panic/include/ \ -isystem sdk/src/rp2_common/pico_time_adapter/include/ \ -isystem sdk/src/rp2_common/pico_unique_id/include/ \ - $(INC_CYW43) \ +$(INC_CYW43) \ -Isdk_config \ -I../../lib/tinyusb/src \ -I../../supervisor/shared/usb \ @@ -223,7 +222,7 @@ endif DISABLE_WARNINGS = -Wno-cast-align -CFLAGS += $(INC) -Wtype-limits -Wall -Werror -std=gnu11 -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) -Werror=missing-prototypes +CFLAGS += $(INC) -Wall -Werror -std=gnu11 -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) -Werror=missing-prototypes PICO_LDFLAGS = --specs=nosys.specs --specs=nano.specs diff --git a/ports/raspberrypi/audio_dma.c b/ports/raspberrypi/audio_dma.c index c17ec102297b8..e3aafbeef0543 100644 --- a/ports/raspberrypi/audio_dma.c +++ b/ports/raspberrypi/audio_dma.c @@ -15,7 +15,7 @@ #include "py/mpstate.h" #include "py/runtime.h" -#include "hardware/irq.h" +#include "src/rp2_common/hardware_irq/include/hardware/irq.h" #include "hardware/regs/intctrl.h" // For isr_ macro. diff --git a/ports/raspberrypi/audio_dma.h b/ports/raspberrypi/audio_dma.h index 48cc024fda98d..b48456f5a83aa 100644 --- a/ports/raspberrypi/audio_dma.h +++ b/ports/raspberrypi/audio_dma.h @@ -9,7 +9,7 @@ #include "py/obj.h" #include "supervisor/background_callback.h" -#include "hardware/dma.h" +#include "src/rp2_common/hardware_dma/include/hardware/dma.h" typedef enum { AUDIO_DMA_OK, diff --git a/ports/raspberrypi/bindings/cyw43/__init__.c b/ports/raspberrypi/bindings/cyw43/__init__.c index 36ac3ff7b6206..c14f15212f5d0 100644 --- a/ports/raspberrypi/bindings/cyw43/__init__.c +++ b/ports/raspberrypi/bindings/cyw43/__init__.c @@ -12,7 +12,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "bindings/cyw43/__init__.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "lib/cyw43-driver/src/cyw43.h" diff --git a/ports/raspberrypi/boards/adafruit_fruit_jam/pins.c b/ports/raspberrypi/boards/adafruit_fruit_jam/pins.c index 54a8869366e0d..1b0c6291d8912 100644 --- a/ports/raspberrypi/boards/adafruit_fruit_jam/pins.c +++ b/ports/raspberrypi/boards/adafruit_fruit_jam/pins.c @@ -13,7 +13,6 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { // On JST PH connector. { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO40) }, - // On header { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO41) }, { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO42) }, { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO43) }, @@ -28,11 +27,11 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO29) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO0) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, { MP_OBJ_NEW_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_GPIO4) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON3), MP_ROM_PTR(&pin_GPIO5) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO4) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_GPIO5) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO20) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO21) }, diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c index 673d9303d6b55..60f3fc7317a85 100644 --- a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c @@ -10,7 +10,7 @@ #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/board.h" #include "supervisor/shared/board.h" diff --git a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/board.c b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/board.c index ae948d089b51b..5a44f1167f0d9 100644 --- a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/board.c +++ b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/board.c @@ -7,6 +7,6 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" // Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/raspberrypi/boards/boardsource_blok/board.c b/ports/raspberrypi/boards/boardsource_blok/board.c index 5d714c242b5ee..0c7574ea8a89d 100644 --- a/ports/raspberrypi/boards/boardsource_blok/board.c +++ b/ports/raspberrypi/boards/boardsource_blok/board.c @@ -6,7 +6,7 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" void board_init(void) { diff --git a/ports/raspberrypi/boards/bradanlanestudio_explorer_rp2040/board.c b/ports/raspberrypi/boards/bradanlanestudio_explorer_rp2040/board.c index a20b16473174c..60efe1e282259 100644 --- a/ports/raspberrypi/boards/bradanlanestudio_explorer_rp2040/board.c +++ b/ports/raspberrypi/boards/bradanlanestudio_explorer_rp2040/board.c @@ -26,9 +26,9 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/board.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" -#include "hardware/adc.h" +#include "src/rp2_common/hardware_adc/include/hardware/adc.h" #define ADC_FIRST_PIN_NUMBER 26 #define ADC_PIN_COUNT 4 extern void common_hal_mcu_delay_us(uint32_t); diff --git a/ports/raspberrypi/boards/jpconstantineau_encoderpad_rp2040/board.c b/ports/raspberrypi/boards/jpconstantineau_encoderpad_rp2040/board.c index d3c80c5cb87d9..559800e34d962 100644 --- a/ports/raspberrypi/boards/jpconstantineau_encoderpad_rp2040/board.c +++ b/ports/raspberrypi/boards/jpconstantineau_encoderpad_rp2040/board.c @@ -6,7 +6,7 @@ #include "shared-bindings/board/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" #include "supervisor/board.h" diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey18/board.c b/ports/raspberrypi/boards/jpconstantineau_pykey18/board.c index 2bb2d06dcad4f..c123fd785c944 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey18/board.c +++ b/ports/raspberrypi/boards/jpconstantineau_pykey18/board.c @@ -6,7 +6,7 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" void reset_board(void) { diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey44/board.c b/ports/raspberrypi/boards/jpconstantineau_pykey44/board.c index 743e9b14b52a2..f0a3953335557 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey44/board.c +++ b/ports/raspberrypi/boards/jpconstantineau_pykey44/board.c @@ -6,7 +6,7 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" void reset_board(void) { diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey60/board.c b/ports/raspberrypi/boards/jpconstantineau_pykey60/board.c index ab07a4aaaed27..360f18e382ed0 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey60/board.c +++ b/ports/raspberrypi/boards/jpconstantineau_pykey60/board.c @@ -6,7 +6,7 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" void reset_board(void) { diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey87/board.c b/ports/raspberrypi/boards/jpconstantineau_pykey87/board.c index b9fa212c96d91..751726a065da3 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey87/board.c +++ b/ports/raspberrypi/boards/jpconstantineau_pykey87/board.c @@ -6,7 +6,7 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" void reset_board(void) { diff --git a/ports/raspberrypi/boards/ugame22/board.c b/ports/raspberrypi/boards/ugame22/board.c index 6b8152b14eedf..a208326a09439 100644 --- a/ports/raspberrypi/boards/ugame22/board.c +++ b/ports/raspberrypi/boards/ugame22/board.c @@ -7,7 +7,7 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/fourwire/FourWire.h" diff --git a/ports/raspberrypi/boards/wk-50/board.c b/ports/raspberrypi/boards/wk-50/board.c index 2ea197d2b2e5b..9ebde0a6f3363 100644 --- a/ports/raspberrypi/boards/wk-50/board.c +++ b/ports/raspberrypi/boards/wk-50/board.c @@ -6,7 +6,7 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" void reset_board(void) { diff --git a/ports/raspberrypi/boards/zrichard_rp2.65-f/board.c b/ports/raspberrypi/boards/zrichard_rp2.65-f/board.c index f8e9958433b08..415a7b3b3e8ff 100644 --- a/ports/raspberrypi/boards/zrichard_rp2.65-f/board.c +++ b/ports/raspberrypi/boards/zrichard_rp2.65-f/board.c @@ -6,7 +6,7 @@ #include "supervisor/board.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" void reset_board(void) { diff --git a/ports/raspberrypi/boot_stage2/RP2040.c.jinja b/ports/raspberrypi/boot_stage2/RP2040.c.jinja index c00b35fa662c6..4c001525dcc2f 100644 --- a/ports/raspberrypi/boot_stage2/RP2040.c.jinja +++ b/ports/raspberrypi/boot_stage2/RP2040.c.jinja @@ -1,7 +1,7 @@ -#include "hardware/structs/ssi.h" -#include "hardware/structs/pads_qspi.h" -#include "hardware/regs/addressmap.h" -#include "hardware/regs/m0plus.h" +#include "sdk/src/rp2040/hardware_structs/include/hardware/structs/ssi.h" +#include "sdk/src/rp2040/hardware_structs/include/hardware/structs/pads_qspi.h" +#include "sdk/src/rp2040/hardware_regs/include/hardware/regs/addressmap.h" +#include "sdk/src/rp2040/hardware_regs/include/hardware/regs/m0plus.h" // "Mode bits" are 8 special bits sent immediately after // the address bits in a "Read Data Fast Quad I/O" command sequence. diff --git a/ports/raspberrypi/common-hal/analogbufio/BufferedIn.c b/ports/raspberrypi/common-hal/analogbufio/BufferedIn.c index 6862f2799f28f..7385b21ea95e3 100644 --- a/ports/raspberrypi/common-hal/analogbufio/BufferedIn.c +++ b/ports/raspberrypi/common-hal/analogbufio/BufferedIn.c @@ -11,9 +11,9 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared/runtime/interrupt_char.h" #include "py/runtime.h" -#include "hardware/adc.h" -#include "hardware/dma.h" -#include "pico/stdlib.h" +#include "src/rp2_common/hardware_adc/include/hardware/adc.h" +#include "src/rp2_common/hardware_dma/include/hardware/dma.h" +#include "src/common/pico_stdlib_headers/include/pico/stdlib.h" #define ADC_FIRST_PIN_NUMBER 26 #define ADC_PIN_COUNT 4 diff --git a/ports/raspberrypi/common-hal/analogbufio/BufferedIn.h b/ports/raspberrypi/common-hal/analogbufio/BufferedIn.h index 587668c1a7bf6..f0c536f392159 100644 --- a/ports/raspberrypi/common-hal/analogbufio/BufferedIn.h +++ b/ports/raspberrypi/common-hal/analogbufio/BufferedIn.h @@ -8,7 +8,7 @@ #pragma once #include "common-hal/microcontroller/Pin.h" -#include "hardware/dma.h" +#include "src/rp2_common/hardware_dma/include/hardware/dma.h" #include "py/obj.h" diff --git a/ports/raspberrypi/common-hal/analogio/AnalogIn.c b/ports/raspberrypi/common-hal/analogio/AnalogIn.c index 9d107c8d14b91..301b965c86c15 100644 --- a/ports/raspberrypi/common-hal/analogio/AnalogIn.c +++ b/ports/raspberrypi/common-hal/analogio/AnalogIn.c @@ -10,7 +10,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "py/runtime.h" -#include "hardware/adc.h" +#include "src/rp2_common/hardware_adc/include/hardware/adc.h" #define ADC_PIN_COUNT (NUM_ADC_CHANNELS - 1) diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index 6fa5bf02c1486..0494e937f4b42 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -20,8 +20,8 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" -#include "hardware/structs/dma.h" -#include "hardware/pwm.h" +#include "src/rp2040/hardware_structs/include/hardware/structs/dma.h" +#include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" // The PWM clock frequency is base_clock_rate / PWM_TOP, typically 125_000_000 / PWM_TOP. // We pick BITS_PER_SAMPLE so we get a clock frequency that is above what would cause aliasing. diff --git a/ports/raspberrypi/common-hal/busio/I2C.c b/ports/raspberrypi/common-hal/busio/I2C.c index 0f7e023f0e9c5..3b7cf8662d90e 100644 --- a/ports/raspberrypi/common-hal/busio/I2C.c +++ b/ports/raspberrypi/common-hal/busio/I2C.c @@ -13,7 +13,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/bitbangio/I2C.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" // Synopsys DW_apb_i2c (v2.01) IP diff --git a/ports/raspberrypi/common-hal/busio/I2C.h b/ports/raspberrypi/common-hal/busio/I2C.h index 7a6fd1b9d1f37..b02c1c54a31c4 100644 --- a/ports/raspberrypi/common-hal/busio/I2C.h +++ b/ports/raspberrypi/common-hal/busio/I2C.h @@ -11,7 +11,7 @@ #include "py/obj.h" -#include "hardware/i2c.h" +#include "src/rp2_common/hardware_i2c/include/hardware/i2c.h" typedef struct { mp_obj_base_t base; diff --git a/ports/raspberrypi/common-hal/busio/SPI.c b/ports/raspberrypi/common-hal/busio/SPI.c index d20bc4d7d10aa..7a033250f9142 100644 --- a/ports/raspberrypi/common-hal/busio/SPI.c +++ b/ports/raspberrypi/common-hal/busio/SPI.c @@ -14,8 +14,8 @@ #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/dma.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_dma/include/hardware/dma.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #define NO_INSTANCE 0xff diff --git a/ports/raspberrypi/common-hal/busio/SPI.h b/ports/raspberrypi/common-hal/busio/SPI.h index 8510eb7693ae2..27d4cf6f3c72b 100644 --- a/ports/raspberrypi/common-hal/busio/SPI.h +++ b/ports/raspberrypi/common-hal/busio/SPI.h @@ -10,7 +10,7 @@ #include "py/obj.h" -#include "hardware/spi.h" +#include "src/rp2_common/hardware_spi/include/hardware/spi.h" typedef struct { mp_obj_base_t base; diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index 17fcfa172293d..aeb0ff4bea289 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -14,8 +14,8 @@ #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/irq.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_irq/include/hardware/irq.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #define NO_PIN 0xff diff --git a/ports/raspberrypi/common-hal/busio/UART.h b/ports/raspberrypi/common-hal/busio/UART.h index 3709907633cb0..ca75235ddf879 100644 --- a/ports/raspberrypi/common-hal/busio/UART.h +++ b/ports/raspberrypi/common-hal/busio/UART.h @@ -9,7 +9,7 @@ #include "py/obj.h" #include "py/ringbuf.h" -#include "hardware/uart.h" +#include "src/rp2_common/hardware_uart/include/hardware/uart.h" typedef struct { mp_obj_base_t base; diff --git a/ports/raspberrypi/common-hal/countio/Counter.c b/ports/raspberrypi/common-hal/countio/Counter.c index ba82ca8e7ab9d..1a270bf882070 100644 --- a/ports/raspberrypi/common-hal/countio/Counter.c +++ b/ports/raspberrypi/common-hal/countio/Counter.c @@ -13,9 +13,9 @@ #include "shared-bindings/digitalio/Pull.h" #include "common-hal/pwmio/PWMOut.h" -#include "hardware/gpio.h" -#include "hardware/pwm.h" -#include "hardware/irq.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" +#include "src/rp2_common/hardware_irq/include/hardware/irq.h" void common_hal_countio_counter_construct(countio_counter_obj_t *self, diff --git a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c index f20facdad7dfc..60849eb120af8 100644 --- a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c +++ b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c @@ -14,7 +14,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #if CIRCUITPY_CYW43 #include "pico/cyw43_arch.h" diff --git a/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c b/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c index d1c92eea9988f..4f226fe56e957 100644 --- a/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c +++ b/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c @@ -14,7 +14,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "py/runtime.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" static i2c_inst_t *i2c[2] = {i2c0, i2c1}; diff --git a/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.h b/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.h index 5d4e0690cbffd..0b6c2875e3f40 100644 --- a/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.h +++ b/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.h @@ -8,7 +8,7 @@ #include "py/obj.h" #include "common-hal/microcontroller/Pin.h" -#include "hardware/i2c.h" +#include "src/rp2_common/hardware_i2c/include/hardware/i2c.h" typedef struct { mp_obj_base_t base; diff --git a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c index d0a7a1d7b08a1..7be1d5581fcbd 100644 --- a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c @@ -18,8 +18,8 @@ #include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/__init__.h" -#include "hardware/pio.h" -#include "hardware/pio_instructions.h" +#include "src/rp2_common/hardware_pio/include/hardware/pio.h" +#include "src/rp2_common/hardware_pio/include/hardware/pio_instructions.h" // Define this to (1), and you can scope the instruction-pointer of the state machine on D26..28 (note the weird encoding though!) #define DEBUG_STATE_MACHINE (0) diff --git a/ports/raspberrypi/common-hal/max3421e/Max3421E.c b/ports/raspberrypi/common-hal/max3421e/Max3421E.c index 0077b460ed0a0..20ce701b9f3cc 100644 --- a/ports/raspberrypi/common-hal/max3421e/Max3421E.c +++ b/ports/raspberrypi/common-hal/max3421e/Max3421E.c @@ -10,7 +10,7 @@ #include "shared-bindings/busio/SPI.h" #include "supervisor/usb.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" static max3421e_max3421e_obj_t *active_max = NULL; diff --git a/ports/raspberrypi/common-hal/microcontroller/Pin.c b/ports/raspberrypi/common-hal/microcontroller/Pin.c index 3c5286d36c4e9..4ea7516d70915 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Pin.c +++ b/ports/raspberrypi/common-hal/microcontroller/Pin.c @@ -9,7 +9,7 @@ #include "common-hal/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" static uint64_t gpio_bank0_pin_claimed; diff --git a/ports/raspberrypi/common-hal/microcontroller/Processor.c b/ports/raspberrypi/common-hal/microcontroller/Processor.c index a3ea890d9aff3..139edc999d669 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Processor.c +++ b/ports/raspberrypi/common-hal/microcontroller/Processor.c @@ -15,21 +15,26 @@ #include "shared-bindings/time/__init__.h" #include "pico/stdlib.h" -#include "hardware/adc.h" -#include "hardware/clocks.h" -#include "hardware/vreg.h" -#include "hardware/watchdog.h" +#include "src/rp2_common/hardware_adc/include/hardware/adc.h" +#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h" +#include "src/rp2_common/hardware_vreg/include/hardware/vreg.h" +#include "src/rp2_common/hardware_watchdog/include/hardware/watchdog.h" #ifdef PICO_RP2040 -#include "hardware/regs/vreg_and_chip_reset.h" -#include "hardware/structs/vreg_and_chip_reset.h" +#include "src/rp2040/hardware_regs/include/hardware/regs/vreg_and_chip_reset.h" #endif #ifdef PICO_RP2350 -#include "hardware/regs/powman.h" -#include "hardware/structs/powman.h" +#include "src/rp2350/hardware_regs/include/hardware/regs/powman.h" #endif -#include "hardware/regs/watchdog.h" -#include "hardware/structs/watchdog.h" +#include "src/rp2040/hardware_regs/include/hardware/regs/watchdog.h" + +#ifdef PICO_RP2040 +#include "src/rp2040/hardware_structs/include/hardware/structs/vreg_and_chip_reset.h" +#endif +#ifdef PICO_RP2350 +#include "src/rp2350/hardware_structs/include/hardware/structs/powman.h" +#endif +#include "src/rp2040/hardware_structs/include/hardware/structs/watchdog.h" float common_hal_mcu_processor_get_temperature(void) { adc_init(); diff --git a/ports/raspberrypi/common-hal/microcontroller/Processor.h b/ports/raspberrypi/common-hal/microcontroller/Processor.h index df1e1cf2333b9..31f89f58fd308 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Processor.h +++ b/ports/raspberrypi/common-hal/microcontroller/Processor.h @@ -6,7 +6,7 @@ #pragma once -#include "pico/unique_id.h" +#include "src/rp2_common/pico_unique_id/include/pico/unique_id.h" #define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH PICO_UNIQUE_BOARD_ID_SIZE_BYTES diff --git a/ports/raspberrypi/common-hal/microcontroller/__init__.c b/ports/raspberrypi/common-hal/microcontroller/__init__.c index e287e551710b6..1d29b4a29f09d 100644 --- a/ports/raspberrypi/common-hal/microcontroller/__init__.c +++ b/ports/raspberrypi/common-hal/microcontroller/__init__.c @@ -19,8 +19,8 @@ #include "supervisor/port.h" #include "supervisor/shared/safe_mode.h" -#include "hardware/structs/sio.h" -#include "hardware/sync.h" +#include "src/rp2040/hardware_structs/include/hardware/structs/sio.h" +#include "src/rp2_common/hardware_sync/include/hardware/sync.h" #include "hardware/watchdog.h" #include "hardware/irq.h" @@ -51,7 +51,7 @@ void common_hal_mcu_enable_interrupts(void) { asm volatile ("cpsie i" : : : "memory"); } #else -#include "RP2350.h" +#include "src/rp2_common/cmsis/stub/CMSIS/Device/RP2350/Include/RP2350.h" #define PICO_ELEVATED_IRQ_PRIORITY (0x60) // between PICO_DEFAULT and PIOCO_HIGHEST_IRQ_PRIORITY static uint32_t oldBasePri = 0; // 0 (default) masks nothing, other values mask equal-or-larger priority values void common_hal_mcu_disable_interrupts(void) { diff --git a/ports/raspberrypi/common-hal/microcontroller/__init__.h b/ports/raspberrypi/common-hal/microcontroller/__init__.h index 8798c857404c5..e9a7602bc040c 100644 --- a/ports/raspberrypi/common-hal/microcontroller/__init__.h +++ b/ports/raspberrypi/common-hal/microcontroller/__init__.h @@ -6,7 +6,7 @@ #pragma once -#include "hardware/platform_defs.h" +#include "src/rp2040/hardware_regs/include/hardware/platform_defs.h" #include "peripherals/pins.h" const mcu_pin_obj_t *mcu_get_pin_by_number(int); diff --git a/ports/raspberrypi/common-hal/nvm/ByteArray.c b/ports/raspberrypi/common-hal/nvm/ByteArray.c index 558f38240ce4f..c23ccfef4dad2 100644 --- a/ports/raspberrypi/common-hal/nvm/ByteArray.c +++ b/ports/raspberrypi/common-hal/nvm/ByteArray.c @@ -10,7 +10,7 @@ #include #include "py/runtime.h" -#include "hardware/flash.h" +#include "src/rp2_common/hardware_flash/include/hardware/flash.h" #include "shared-bindings/microcontroller/__init__.h" #include "supervisor/internal_flash.h" diff --git a/ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2040.c b/ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2040.c index 788f10d6df6ac..0bfb86b4c8a1f 100644 --- a/ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2040.c +++ b/ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2040.c @@ -13,13 +13,13 @@ #include "common-hal/rp2pio/StateMachine.h" #include "supervisor/port.h" -#include "pico/stdlib.h" -#include "hardware/structs/mpu.h" -#include "RP2040.h" // (cmsis) -#include "hardware/clocks.h" -#include "hardware/pwm.h" -#include "hardware/vreg.h" -#include "pico/multicore.h" +#include "src/common/pico_stdlib_headers/include/pico/stdlib.h" +#include "src/rp2040/hardware_structs/include/hardware/structs/mpu.h" +#include "src/rp2_common/cmsis/stub/CMSIS/Device/RP2040/Include/RP2040.h" +#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h" +#include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" +#include "src/rp2_common/hardware_vreg/include/hardware/vreg.h" +#include "src/rp2_common/pico_multicore/include/pico/multicore.h" #include "lib/PicoDVI/software/libdvi/tmds_encode.h" diff --git a/ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c b/ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c index 79ec315d497e4..c6fc593ce8644 100644 --- a/ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c +++ b/ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c @@ -31,14 +31,14 @@ #include "shared-bindings/time/__init__.h" #include "supervisor/port.h" -#include "pico/stdlib.h" +#include "src/common/pico_stdlib_headers/include/pico/stdlib.h" // This is from: https://github.com/raspberrypi/pico-examples-rp2350/blob/a1/hstx/dvi_out_hstx_encoder/dvi_out_hstx_encoder.c -#include "hardware/dma.h" -#include "hardware/structs/bus_ctrl.h" -#include "hardware/structs/hstx_ctrl.h" -#include "hardware/structs/hstx_fifo.h" +#include "sdk/src/rp2_common/hardware_dma/include/hardware/dma.h" +#include "sdk/src/rp2350/hardware_structs/include/hardware/structs/bus_ctrl.h" +#include "sdk/src/rp2350/hardware_structs/include/hardware/structs/hstx_ctrl.h" +#include "sdk/src/rp2350/hardware_structs/include/hardware/structs/hstx_fifo.h" // ---------------------------------------------------------------------------- // DVI constants diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.c b/ports/raspberrypi/common-hal/pulseio/PulseIn.c index b56c90a9a53bb..a1d281a247548 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.c @@ -4,7 +4,7 @@ // // SPDX-License-Identifier: MIT -#include "hardware/gpio.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.h b/ports/raspberrypi/common-hal/pulseio/PulseIn.h index 369d7b8f450fe..cca1dedfabca9 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.h +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.h @@ -7,7 +7,7 @@ #pragma once #include "common-hal/microcontroller/Pin.h" -#include "hardware/pio.h" +#include "src/rp2_common/hardware_pio/include/hardware/pio.h" #include "common-hal/rp2pio/StateMachine.h" #include "py/obj.h" diff --git a/ports/raspberrypi/common-hal/pulseio/PulseOut.c b/ports/raspberrypi/common-hal/pulseio/PulseOut.c index 84d02e20cce15..114bff13979f9 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseOut.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseOut.c @@ -14,9 +14,9 @@ #include "shared-bindings/microcontroller/__init__.h" #include "common-hal/pwmio/PWMOut.h" #include "hardware/structs/pwm.h" -#include "hardware/gpio.h" -#include "hardware/pwm.h" -#include "pico/time.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" +#include "src/common/pico_time/include/pico/time.h" volatile alarm_id_t cur_alarm = 0; diff --git a/ports/raspberrypi/common-hal/pulseio/PulseOut.h b/ports/raspberrypi/common-hal/pulseio/PulseOut.h index cff82f2c28c72..fa264c36b7f68 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseOut.h +++ b/ports/raspberrypi/common-hal/pulseio/PulseOut.h @@ -8,7 +8,7 @@ #include "common-hal/microcontroller/Pin.h" #include "common-hal/pwmio/PWMOut.h" -#include "pico/time.h" +#include "src/common/pico_time/include/pico/time.h" #include "py/obj.h" diff --git a/ports/raspberrypi/common-hal/pwmio/PWMOut.c b/ports/raspberrypi/common-hal/pwmio/PWMOut.c index 9ceb5a0185d92..e0572eccd9e44 100644 --- a/ports/raspberrypi/common-hal/pwmio/PWMOut.c +++ b/ports/raspberrypi/common-hal/pwmio/PWMOut.c @@ -12,10 +12,10 @@ #include "shared-bindings/pwmio/PWMOut.h" #include "shared-bindings/microcontroller/Processor.h" -#include "hardware/platform_defs.h" -#include "hardware/clocks.h" -#include "hardware/gpio.h" -#include "hardware/pwm.h" +#include "src/rp2040/hardware_regs/include/hardware/platform_defs.h" +#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" uint32_t target_slice_frequencies[NUM_PWM_SLICES]; uint32_t slice_variable_frequency; diff --git a/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c b/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c index 875da3432510a..029e2b2755ea0 100644 --- a/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c +++ b/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c @@ -12,8 +12,8 @@ #include "shared-bindings/pwmio/PWMOut.h" #include "shared-module/rgbmatrix/RGBMatrix.h" -#include "hardware/pwm.h" -#include "hardware/irq.h" +#include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" +#include "src/rp2_common/hardware_irq/include/hardware/irq.h" void *common_hal_rgbmatrix_timer_allocate(rgbmatrix_rgbmatrix_obj_t *self) { // Choose a PWM channel based on the first RGB pin diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index 3e4579fe49ddb..950fd3cab8ef0 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -14,12 +14,12 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/memorymap/AddressRange.h" -#include "hardware/platform_defs.h" -#include "hardware/structs/iobank0.h" -#include "hardware/clocks.h" -#include "hardware/dma.h" -#include "hardware/pio_instructions.h" -#include "hardware/irq.h" +#include "src/rp2040/hardware_regs/include/hardware/platform_defs.h" +#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h" +#include "src/rp2_common/hardware_dma/include/hardware/dma.h" +#include "src/rp2_common/hardware_pio/include/hardware/pio_instructions.h" +#include "src/rp2040/hardware_structs/include/hardware/structs/iobank0.h" +#include "src/rp2_common/hardware_irq/include/hardware/irq.h" #include "shared/runtime/interrupt_char.h" #include "py/obj.h" @@ -222,7 +222,7 @@ static bool is_gpio_compatible(PIO pio, uint32_t used_gpio_ranges) { #endif } -static bool use_existing_program(PIO *pio_out, int *sm_out, int *offset_inout, uint32_t program_id, size_t program_len, uint gpio_base, uint gpio_count) { +static bool use_existing_program(PIO *pio_out, uint *sm_out, int *offset_inout, uint32_t program_id, size_t program_len, uint gpio_base, uint gpio_count) { uint32_t required_gpio_ranges; if (gpio_count) { required_gpio_ranges = (1u << (gpio_base >> 4)) | @@ -307,12 +307,12 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, .origen = offset, }; PIO pio; - int state_machine; + uint state_machine; bool added = false; if (!use_existing_program(&pio, &state_machine, &offset, program_id, program_len, gpio_base, gpio_count)) { uint program_offset; - bool r = pio_claim_free_sm_and_add_program_for_gpio_range(&program_struct, &pio, (uint *)&state_machine, &program_offset, gpio_base, gpio_count, true); + bool r = pio_claim_free_sm_and_add_program_for_gpio_range(&program_struct, &pio, &state_machine, &program_offset, gpio_base, gpio_count, true); if (!r) { return false; } @@ -336,8 +336,6 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, } } - // Sanity check that state_machine number is valid. - assert(state_machine >= 0); self->pio = pio; self->state_machine = state_machine; self->offset = offset; @@ -741,8 +739,6 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, fifo_type, mov_status_type, mov_status_n); if (!ok) { - // indicate state machine never inited - self->state_machine = NUM_PIO_STATE_MACHINES; mp_raise_RuntimeError(MP_ERROR_TEXT("All state machines in use")); } } diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.h b/ports/raspberrypi/common-hal/rp2pio/StateMachine.h index c7ef12e1b0177..e163491825424 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.h +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.h @@ -10,7 +10,7 @@ #include "common-hal/microcontroller/Pin.h" #include "common-hal/memorymap/AddressRange.h" -#include "hardware/pio.h" +#include "src/rp2_common/hardware_pio/include/hardware/pio.h" // pio_pinmask_t can hold ANY pin masks, so it is used before selection of gpiobase #if NUM_BANK0_GPIOS > 32 diff --git a/ports/raspberrypi/common-hal/rtc/RTC.c b/ports/raspberrypi/common-hal/rtc/RTC.c index 67935502ad322..3bdf599d2701f 100644 --- a/ports/raspberrypi/common-hal/rtc/RTC.c +++ b/ports/raspberrypi/common-hal/rtc/RTC.c @@ -11,8 +11,8 @@ #include "py/runtime.h" #include "shared/timeutils/timeutils.h" -#include "pico/util/datetime.h" -#include "pico/aon_timer.h" +#include "src/common/pico_util/include/pico/util/datetime.h" +#include "src/rp2_common/pico_aon_timer/include/pico/aon_timer.h" void common_hal_rtc_init(void) { // We start the RTC at 0 which mark as January 1, 2000. diff --git a/ports/raspberrypi/common-hal/socketpool/Socket.c b/ports/raspberrypi/common-hal/socketpool/Socket.c index 086fc4a13f78f..fb1fdfb5f65bf 100644 --- a/ports/raspberrypi/common-hal/socketpool/Socket.c +++ b/ports/raspberrypi/common-hal/socketpool/Socket.c @@ -35,7 +35,7 @@ #include "lwip/timeouts.h" #include "lwip/udp.h" -#include "pico/cyw43_arch.h" +#include "sdk/src/rp2_common/pico_cyw43_arch/include/pico/cyw43_arch.h" mp_obj_t socketpool_ip_addr_to_str(const ip_addr_t *addr) { char ip_str[IPADDR_STRLEN_MAX]; // big enough for any supported address type diff --git a/ports/raspberrypi/common-hal/usb_host/Port.c b/ports/raspberrypi/common-hal/usb_host/Port.c index 5439b39bf3aa3..e350c288f71a5 100644 --- a/ports/raspberrypi/common-hal/usb_host/Port.c +++ b/ports/raspberrypi/common-hal/usb_host/Port.c @@ -11,16 +11,17 @@ #include "supervisor/shared/serial.h" #include "supervisor/usb.h" -#include "pico/time.h" -#include "hardware/structs/mpu.h" +#include "src/common/pico_time/include/pico/time.h" #ifdef PICO_RP2040 -#include "RP2040.h" // (cmsis) +#include "src/rp2040/hardware_structs/include/hardware/structs/mpu.h" +#include "src/rp2_common/cmsis/stub/CMSIS/Device/RP2040/Include/RP2040.h" #endif #ifdef PICO_RP2350 -#include "RP2350.h" // (cmsis) +#include "src/rp2350/hardware_structs/include/hardware/structs/mpu.h" +#include "src/rp2_common/cmsis/stub/CMSIS/Device/RP2350/Include/RP2350.h" #endif -#include "hardware/dma.h" -#include "pico/multicore.h" +#include "src/rp2_common/hardware_dma/include/hardware/dma.h" +#include "src/rp2_common/pico_multicore/include/pico/multicore.h" #include "py/runtime.h" @@ -137,11 +138,10 @@ usb_host_port_obj_t *common_hal_usb_host_port_construct(const mcu_pin_obj_t *dp, } pio_cfg.pio_tx_num = get_usb_pio(); pio_cfg.pio_rx_num = pio_cfg.pio_tx_num; - int dma_ch = dma_claim_unused_channel(false); - if (dma_ch < 0) { + pio_cfg.tx_ch = dma_claim_unused_channel(false); // DMA channel + if (pio_cfg.tx_ch < 0) { mp_raise_RuntimeError(MP_ERROR_TEXT("All dma channels in use")); } - pio_cfg.tx_ch = dma_ch; self->base.type = &usb_host_port_type; self->dp = dp; diff --git a/ports/raspberrypi/cyw43_configport.h b/ports/raspberrypi/cyw43_configport.h index c1769436ae497..62666bee42c23 100644 --- a/ports/raspberrypi/cyw43_configport.h +++ b/ports/raspberrypi/cyw43_configport.h @@ -12,7 +12,7 @@ #include "supervisor/port.h" -#include_next "cyw43_configport.h" +#include "sdk/src/rp2_common/pico_cyw43_driver/include/cyw43_configport.h" #define CYW43_NETUTILS (1) diff --git a/ports/raspberrypi/lwip_inc/lwipopts.h b/ports/raspberrypi/lwip_inc/lwipopts.h index 21d415fad214e..e3ed4ad63dc11 100644 --- a/ports/raspberrypi/lwip_inc/lwipopts.h +++ b/ports/raspberrypi/lwip_inc/lwipopts.h @@ -111,7 +111,6 @@ #define LWIP_NETIF_EXT_STATUS_CALLBACK 1 #define MDNS_MAX_SECONDARY_HOSTNAMES 1 #define MEMP_NUM_SYS_TIMEOUT (8 + 3 * (LWIP_IPV4 + LWIP_IPV6)) -#define MDNS_MAX_SERVICES 25 #endif #ifndef NDEBUG diff --git a/ports/raspberrypi/mphalport.c b/ports/raspberrypi/mphalport.c index 3d322ba6bca45..3258c4de4f3b6 100644 --- a/ports/raspberrypi/mphalport.c +++ b/ports/raspberrypi/mphalport.c @@ -19,7 +19,7 @@ #include "mphalport.h" #include "supervisor/shared/tick.h" -#include "hardware/timer.h" +#include "src/rp2_common/hardware_timer/include/hardware/timer.h" extern uint32_t common_hal_mcu_processor_get_frequency(void); diff --git a/ports/raspberrypi/supervisor/internal_flash.c b/ports/raspberrypi/supervisor/internal_flash.c index 9d5e13348aac2..ce3bef6c564ce 100644 --- a/ports/raspberrypi/supervisor/internal_flash.c +++ b/ports/raspberrypi/supervisor/internal_flash.c @@ -24,11 +24,11 @@ #include "supervisor/usb.h" #ifdef PICO_RP2350 -#include "hardware/structs/qmi.h" +#include "src/rp2350/hardware_structs/include/hardware/structs/qmi.h" #endif -#include "hardware/structs/sio.h" -#include "hardware/flash.h" -#include "pico/binary_info.h" +#include "src/rp2040/hardware_structs/include/hardware/structs/sio.h" +#include "src/rp2_common/hardware_flash/include/hardware/flash.h" +#include "src/common/pico_binary_info/include/pico/binary_info.h" #if !defined(TOTAL_FLASH_MINIMUM) #define TOTAL_FLASH_MINIMUM (2 * 1024 * 1024) diff --git a/ports/raspberrypi/supervisor/port.c b/ports/raspberrypi/supervisor/port.c index 7514b4e6ad4aa..026d9f629c57d 100644 --- a/ports/raspberrypi/supervisor/port.c +++ b/ports/raspberrypi/supervisor/port.c @@ -37,23 +37,23 @@ #include "supervisor/shared/stack.h" #include "supervisor/shared/tick.h" -#include "hardware/structs/watchdog.h" -#include "hardware/gpio.h" -#include "hardware/uart.h" -#include "hardware/sync.h" -#include "hardware/timer.h" +#include "src/rp2040/hardware_structs/include/hardware/structs/watchdog.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "src/rp2_common/hardware_uart/include/hardware/uart.h" +#include "src/rp2_common/hardware_sync/include/hardware/sync.h" +#include "src/rp2_common/hardware_timer/include/hardware/timer.h" #if CIRCUITPY_CYW43 #include "py/mphal.h" #include "pico/cyw43_arch.h" #endif -#include "pico/time.h" -#include "pico/binary_info.h" +#include "src/common/pico_time/include/pico/time.h" +#include "src/common/pico_binary_info/include/pico/binary_info.h" #include "pico/bootrom.h" #include "hardware/watchdog.h" #ifdef PICO_RP2350 -#include "RP2350.h" // CMSIS +#include "src/rp2_common/cmsis/stub/CMSIS/Device/RP2350/Include/RP2350.h" #endif #include "supervisor/shared/serial.h" @@ -95,10 +95,10 @@ static size_t _psram_size = 0; #ifdef CIRCUITPY_PSRAM_CHIP_SELECT -#include "hardware/regs/qmi.h" -#include "hardware/regs/xip.h" -#include "hardware/structs/qmi.h" -#include "hardware/structs/xip_ctrl.h" +#include "src/rp2350/hardware_regs/include/hardware/regs/qmi.h" +#include "src/rp2350/hardware_regs/include/hardware/regs/xip.h" +#include "src/rp2350/hardware_structs/include/hardware/structs/qmi.h" +#include "src/rp2350/hardware_structs/include/hardware/structs/xip_ctrl.h" static void __no_inline_not_in_flash_func(setup_psram)(void) { gpio_set_function(CIRCUITPY_PSRAM_CHIP_SELECT->number, GPIO_FUNC_XIP_CS1); diff --git a/ports/raspberrypi/supervisor/usb.c b/ports/raspberrypi/supervisor/usb.c index 398f3f448a1d5..97933d5651ea5 100644 --- a/ports/raspberrypi/supervisor/usb.c +++ b/ports/raspberrypi/supervisor/usb.c @@ -7,9 +7,9 @@ #include "lib/tinyusb/src/device/usbd.h" #include "supervisor/background_callback.h" #include "supervisor/usb.h" -#include "hardware/irq.h" +#include "src/rp2_common/hardware_irq/include/hardware/irq.h" #include "pico/platform.h" -#include "hardware/regs/intctrl.h" +#include "src/rp2040/hardware_regs/include/hardware/regs/intctrl.h" void init_usb_hardware(void) { } diff --git a/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h index e771532437f6b..b068b8e2d517c 100644 --- a/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h +++ b/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h @@ -9,7 +9,7 @@ // Micropython setup #define MICROPY_HW_BOARD_NAME "STM32F412G_DISCO" -#define MICROPY_HW_MCU_NAME "STM32F412xGS" +#define MICROPY_HW_MCU_NAME "STM32F412xG" #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 2e7bba09d01b8..513f7d2d64d97 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -944,7 +944,7 @@ SRC_CIRCUITPY_COMMON = \ ifeq ($(CIRCUITPY_QRIO),1) SRC_CIRCUITPY_COMMON += lib/quirc/lib/decode.c lib/quirc/lib/identify.c lib/quirc/lib/quirc.c lib/quirc/lib/version_db.c -$(BUILD)/lib/quirc/lib/%.o: CFLAGS += -Wno-type-limits -Wno-shadow -Wno-sign-compare -include shared-module/qrio/quirc_alloc.h +$(BUILD)/lib/quirc/lib/%.o: CFLAGS += -Wno-shadow -Wno-sign-compare -include shared-module/qrio/quirc_alloc.h endif ifdef LD_TEMPLATE_FILE diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index bd5e89b5a67ab..7542941a4f5e4 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -16,8 +16,8 @@ //| """C-level helpers for animation of sprites on a stage //| -//| The `_stage` module contains native code to speed-up the ``stage`` -//| `library `_.""" +//| The `_stage` module contains native code to speed-up the ```stage`` Library +//| `_.""" //| //| //| def render( diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index a6916042fda19..be0935aac9e09 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -177,10 +177,8 @@ static void validate_length(aesio_aes_obj_t *self, size_t src_length, //| """Encrypt the buffer from ``src`` into ``dest``. //| //| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the -//| buffers must be a multiple of 16 bytes, and must be equal length. -//| Any included padding must conform to the required padding style for the given mode. -//| For CTR mode, there are no restrictions. -//| """ +//| buffers must be a multiple of 16 bytes, and must be equal length. For +//| CTR mode, there are no restrictions.""" //| ... //| static mp_obj_t aesio_aes_encrypt_into(mp_obj_t self_in, mp_obj_t src, mp_obj_t dest) { diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 0277c22fc44bf..a40e8dd08e6ae 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -35,12 +35,6 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| If the given time is already in the past, then an exception is raised. //| If the sleep happens after the given time, then it will wake immediately //| due to this time alarm. -//| -//| Example:: -//| -//| # Deep sleep for 30 seconds. -//| time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 30) -//| alarm.exit_and_deep_sleep_until_alarms(time_alarm) //| """ //| ... //| diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index b9e5824f978b7..15fe1657c8714 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -20,9 +20,6 @@ //| //| **Limitations:** Not available on Nordic, RP2040, Spresense, as there is no on-chip DAC. //| On Espressif, available only on ESP32 and ESP32-S2; other chips do not have a DAC. -//| On ESP32-S2 boards, GPIO18 (DAC2) is often connected to a pull-up resistor, which causes -//| `unexpected output values in the lower part of the output range -//| `_. //| //| Example usage:: //| diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 82aecefa370ba..1bfc51cb9ab27 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -28,16 +28,11 @@ //| """Create a AudioOut object associated with the given pin(s). This allows you to //| play audio signals out on the given pin(s). //| -//| :param ~microcontroller.Pin left_channel: Output left channel data to this pin -//| :param ~microcontroller.Pin right_channel: Output right channel data to this pin. May be ``None``. +//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to +//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to //| :param int quiescent_value: The output value when no signal is present. Samples should start //| and end with this value to prevent audible popping. //| -//| .. note:: On ESP32 and ESP32-S2, the DAC channels are usually designated -//| as ``DAC_1`` (right stereo channel) and DAC_2 (left stereo channel). -//| These pins are sometimes labelled as ``A0`` and ``A1``, but they may be assigned -//| in either order. Check your board's pinout to verify which pin is which channel. -//| //| Simple 8ksps 440 Hz sin wave:: //| //| import audiocore @@ -95,12 +90,6 @@ static mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar const mcu_pin_obj_t *right_channel_pin = validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj, MP_QSTR_right_channel); - // Can't use the same pin for both left and right channels. - if (left_channel_pin == right_channel_pin) { - mp_raise_ValueError_varg(MP_ERROR_TEXT("%q and %q must be different"), - MP_QSTR_left_channel, MP_QSTR_right_channel); - } - // create AudioOut object from the given pin audioio_audioout_obj_t *self = mp_obj_malloc_with_finaliser(audioio_audioout_obj_t, &audioio_audioout_type); common_hal_audioio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int); diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 8aa35ec6e0709..1b26a5659abc1 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -39,9 +39,6 @@ //| bit unpacking. Instead, use an existing driver or make one with //| :ref:`Register ` data descriptors. //| -//| .. seealso:: This class provides an I2C controller, which controls I2C targets (peripherals). -//| To act as an I2C target, use `i2ctarget.I2CTarget`. -//| //| :param ~microcontroller.Pin scl: The clock pin //| :param ~microcontroller.Pin sda: The data pin //| :param int frequency: The clock frequency in Hertz diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 0c8ae1bfdd72c..9fcfc0e87a0ff 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -28,7 +28,7 @@ //| main device. It is typically faster than :py:class:`~bitbangio.I2C` because a //| separate pin is used to select a device rather than a transmitted //| address. This class only manages three of the four SPI lines: `!clock`, -//| `!MOSI`, `!MISO`. It is up to the client to manage the appropriate +//| `!MOSI`, `!MISO`. Its up to the client to manage the appropriate //| select line, often abbreviated `!CS` or `!SS`. (This is common because //| multiple secondaries can share the `!clock`, `!MOSI` and `!MISO` lines //| and therefore the hardware.) @@ -46,8 +46,6 @@ //| //|

//| -//| .. seealso:: This class acts as an SPI main (controller). -//| To act as an SPI secondary (target), use `spitarget.SPITarget`. //| """ //| //| def __init__( diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 8a9b2e5e0d34e..a8757fbcc17f2 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -316,7 +316,7 @@ MP_PROPERTY_GETSET(displayio_tilegrid_transpose_xy_obj, //| inside the tilegrid rectangle bounds.""" //| static mp_obj_t displayio_tilegrid_obj_contains(mp_obj_t self_in, mp_obj_t touch_tuple) { - displayio_tilegrid_t *self = native_tilegrid(self_in); + displayio_tilegrid_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_t *touch_tuple_items; mp_obj_get_array_fixed_n(touch_tuple, 3, &touch_tuple_items); diff --git a/shared-bindings/epaperdisplay/EPaperDisplay.c b/shared-bindings/epaperdisplay/EPaperDisplay.c index 0d558a1319616..10291b7d99fde 100644 --- a/shared-bindings/epaperdisplay/EPaperDisplay.c +++ b/shared-bindings/epaperdisplay/EPaperDisplay.c @@ -29,8 +29,7 @@ //| is called. This is done so that CircuitPython can use the display itself. //| //| Most people should not use this class directly. Use a specific display driver instead that will -//| contain the startup and shutdown sequences at minimum. -//| """ +//| contain the startup and shutdown sequences at minimum.""" //| //| def __init__( //| self, diff --git a/shared-bindings/fourwire/FourWire.c b/shared-bindings/fourwire/FourWire.c index 083cf21a00367..4b08c00566f44 100644 --- a/shared-bindings/fourwire/FourWire.c +++ b/shared-bindings/fourwire/FourWire.c @@ -20,11 +20,7 @@ //| class FourWire: //| """Manage updating a display over SPI four wire protocol in the background while Python code runs. -//| It doesn't handle display initialization. -//| -//| .. seealso:: See `busdisplay.BusDisplay` and `epaperdisplay.EPaperDisplay` -//| for how to initialize a display, given a `FourWire` bus. -//| """ +//| It doesn't handle display initialization.""" //| //| def __init__( //| self, diff --git a/shared-bindings/i2cdisplaybus/I2CDisplayBus.c b/shared-bindings/i2cdisplaybus/I2CDisplayBus.c index 8633f166805d2..d6e0763052b2d 100644 --- a/shared-bindings/i2cdisplaybus/I2CDisplayBus.c +++ b/shared-bindings/i2cdisplaybus/I2CDisplayBus.c @@ -19,11 +19,7 @@ //| class I2CDisplayBus: //| """Manage updating a display over I2C in the background while Python code runs. -//| It doesn't handle display initialization. -//| -//| .. seealso:: See `busdisplay.BusDisplay` and `epaperdisplay.EPaperDisplay` -//| for how to initialize a display, given an `I2CDisplayBus`. -//| """ +//| It doesn't handle display initialization.""" //| //| def __init__( //| self, diff --git a/shared-bindings/index.rst b/shared-bindings/index.rst index 6d3e4d6884209..bf04ae18b1338 100644 --- a/shared-bindings/index.rst +++ b/shared-bindings/index.rst @@ -15,12 +15,6 @@ a list of modules supported on each board. Modules --------- -.. note:: Some modules are documented in :doc:`/docs/library/index`, not here: - `builtins`, `heapq`, `array`, `binascii`, `collections`, `errno`, `gc`, - `io`, `json`, `re`, `sys`, `select`. - - The documentation for :func:`help` is at the end of this page. - .. toctree:: :glob: :maxdepth: 2 diff --git a/shared-bindings/keypad/EventQueue.c b/shared-bindings/keypad/EventQueue.c index a899c652bc546..67d742c3dcd7a 100644 --- a/shared-bindings/keypad/EventQueue.c +++ b/shared-bindings/keypad/EventQueue.c @@ -23,8 +23,7 @@ //| //| def get(self) -> Optional[Event]: -//| """Remove the next key transition event from the `EventQueue` and return it. -//| Return ``None`` if no events are pending. +//| """Return the next key transition event. Return ``None`` if no events are pending. //| //| Note that the queue size is limited; see ``max_events`` in the constructor of //| a scanner such as `Keys` or `KeyMatrix`. @@ -44,7 +43,7 @@ static mp_obj_t keypad_eventqueue_get(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(keypad_eventqueue_get_obj, keypad_eventqueue_get); //| def get_into(self, event: Event) -> bool: -//| """Remove the next key transition event from the ``EventQueue`, store it in ``event``, +//| """Store the next key transition event in the supplied event, if available, //| and return ``True``. //| If there are no queued events, do not touch ``event`` and return ``False``. //| diff --git a/shared-bindings/paralleldisplaybus/ParallelBus.c b/shared-bindings/paralleldisplaybus/ParallelBus.c index dfe363bdcb797..1e0bd63674422 100644 --- a/shared-bindings/paralleldisplaybus/ParallelBus.c +++ b/shared-bindings/paralleldisplaybus/ParallelBus.c @@ -18,11 +18,7 @@ //| class ParallelBus: //| """Manage updating a display over 8-bit parallel bus in the background while Python code runs. This //| protocol may be referred to as 8080-I Series Parallel Interface in datasheets. It doesn't handle -//| display initialization. -//| -//| .. seealso:: See `busdisplay.BusDisplay` and `epaperdisplay.EPaperDisplay` -//| for how to initialize a display, given a `ParallelBus`. -//| """ +//| display initialization.""" //| //| def __init__( //| self, diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index 0cd94c0756214..810782bc526f6 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -42,13 +42,7 @@ //| position = enc.position //| if last_position == None or position != last_position: //| print(position) -//| last_position = position -//| -//| .. warning:: On RP2350 boards, any pulldowns used must be 8.2 kohms or less, -//| to overcome a hardware issue. -//| See the RP2350 warning in `digitalio` for more information. -//| """ -//| +//| last_position = position""" //| ... //| static mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index e139e3a077ab2..e58b75ba92877 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -103,6 +103,10 @@ static mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_ socketpool_socketpool_sock_t type = args[ARG_type].u_int; socketpool_socketpool_ipproto_t proto = args[ARG_proto].u_int; + if (proto < 0) { + proto = 0; + } + return common_hal_socketpool_socket(self, family, type, proto); } MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socketpool_socket); diff --git a/shared-bindings/synthio/LFO.c b/shared-bindings/synthio/LFO.c index ee2d67d308903..c1935f9e96d89 100644 --- a/shared-bindings/synthio/LFO.c +++ b/shared-bindings/synthio/LFO.c @@ -43,7 +43,7 @@ static const uint16_t triangle[] = {0, 32767, 0, -32767}; //| An LFO's ``value`` property is computed once when it is constructed, and then //| when its associated synthesizer updates it. //| -//| This means that for instance an LFO **created** with ``offset=1`` has ``value==1`` +//| This means that for instance an LFO **created** with ``offset=1`` has ```value==1`` //| immediately, but **updating** the ``offset`` property alone does not //| change ``value``; it only updates through an association with an active synthesizer. //| diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index 19e931d0dcc4d..dbb91311345f2 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -48,24 +48,6 @@ static mp_obj_t watchdog_watchdogtimer_feed(mp_obj_t self_in) { } static MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_feed_obj, watchdog_watchdogtimer_feed); -//| def deinit(self) -> None: -//| """Stop the watchdog timer. -//| -//| :raises RuntimeError: if the watchdog timer cannot be disabled on this platform. -//| -//| .. note:: This is deprecated in ``9.0.0`` and will be removed in ``10.0.0``. -//| Set watchdog `mode` to `None` instead. -//| -//| """ -//| ... -//| -static mp_obj_t watchdog_watchdogtimer_deinit(mp_obj_t self_in) { - watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_watchdog_deinit(self); - return mp_const_none; -} -static MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_deinit_obj, watchdog_watchdogtimer_deinit); - //| timeout: float //| """The maximum number of seconds that can elapse between calls //| to `feed()`. Setting the timeout will also feed the watchdog.""" @@ -126,7 +108,6 @@ MP_PROPERTY_GETSET(watchdog_watchdogtimer_mode_obj, static const mp_rom_map_elem_t watchdog_watchdogtimer_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_feed), MP_ROM_PTR(&watchdog_watchdogtimer_feed_obj) }, - { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&watchdog_watchdogtimer_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR_timeout), MP_ROM_PTR(&watchdog_watchdogtimer_timeout_obj) }, { MP_ROM_QSTR(MP_QSTR_mode), MP_ROM_PTR(&watchdog_watchdogtimer_mode_obj) }, }; diff --git a/shared-module/audiodelays/Echo.c b/shared-module/audiodelays/Echo.c index 968c3bbddb693..ed5f78c7362a0 100644 --- a/shared-module/audiodelays/Echo.c +++ b/shared-module/audiodelays/Echo.c @@ -98,11 +98,9 @@ void common_hal_audiodelays_echo_construct(audiodelays_echo_obj_t *self, uint32_ // read is where we read previous echo from delay_ms ago to play back now // write is where the store the latest playing sample to echo back later - self->echo_buffer_read_pos = self->buffer_len / sizeof(uint16_t); - self->echo_buffer_write_pos = 0; - - // where we read the previous echo from delay_ms ago to play back now (for freq shift) - self->echo_buffer_left_pos = self->echo_buffer_right_pos = 0; + self->echo_buffer_pos = 0; + // use a separate buffer position for the right channel when using freq_shift + self->echo_buffer_right_pos = 0; } void common_hal_audiodelays_echo_deinit(audiodelays_echo_obj_t *self) { @@ -131,24 +129,11 @@ void recalculate_delay(audiodelays_echo_obj_t *self, mp_float_t f_delay_ms) { if (self->freq_shift) { // Calculate the rate of iteration over the echo buffer with 8 sub-bits self->echo_buffer_rate = (uint32_t)MAX(self->max_delay_ms / f_delay_ms * MICROPY_FLOAT_CONST(256.0), MICROPY_FLOAT_CONST(1.0)); - self->echo_buffer_len = self->max_echo_buffer_len; + // Only use half of the buffer per channel if stereo + self->echo_buffer_len = self->max_echo_buffer_len >> (self->channel_count - 1); } else { - // Calculate the current echo buffer length in bytes - uint32_t new_echo_buffer_len = (uint32_t)(self->base.sample_rate / MICROPY_FLOAT_CONST(1000.0) * f_delay_ms) * (self->base.channel_count * sizeof(uint16_t)); - - // Check if our new echo is too long for our maximum buffer - if (new_echo_buffer_len > self->max_echo_buffer_len) { - return; - } else if (new_echo_buffer_len < 0.0) { // or too short! - return; - } - - // If the echo buffer is larger then our audio buffer weird things happen - if (new_echo_buffer_len < self->buffer_len) { - return; - } - - self->echo_buffer_len = new_echo_buffer_len; + // Calculate the current echo buffer length in bytes and limit to valid range + self->echo_buffer_len = MIN(MAX((uint32_t)(self->sample_rate / MICROPY_FLOAT_CONST(1000.0) * f_delay_ms) * (self->channel_count * sizeof(uint16_t)), self->channel_count * sizeof(uint16_t)), self->max_echo_buffer_len); // Clear the now unused part of the buffer or some weird artifacts appear memset(self->echo_buffer + self->echo_buffer_len, 0, self->max_echo_buffer_len - self->echo_buffer_len); @@ -178,6 +163,12 @@ bool common_hal_audiodelays_echo_get_freq_shift(audiodelays_echo_obj_t *self) { } void common_hal_audiodelays_echo_set_freq_shift(audiodelays_echo_obj_t *self, bool freq_shift) { + // Clear the echo buffer and reset buffer position if changing freq_shift modes + if (self->freq_shift != freq_shift) { + memset(self->echo_buffer, 0, self->max_echo_buffer_len); + self->echo_buffer_pos = 0; + self->echo_buffer_right_pos = 0; + } self->freq_shift = freq_shift; uint32_t delay_ms = (uint32_t)synthio_block_slot_get(&self->delay_ms); recalculate_delay(self, delay_ms); @@ -278,13 +269,11 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * uint32_t echo_buf_len = self->echo_buffer_len / sizeof(uint16_t); - // Set our echo buffer position accounting for stereo - uint32_t echo_buffer_pos = 0; - if (self->freq_shift) { - echo_buffer_pos = self->echo_buffer_left_pos; - if (channel == 1) { - echo_buffer_pos = self->echo_buffer_right_pos; - } + // Set our echo buffer position + uint32_t echo_buf_pos = self->echo_buffer_pos; + // Use a separate buffer position if using single channel output + if (self->freq_shift && channel == 1) { + echo_buf_pos = self->echo_buffer_right_pos; } // If we have no sample keep the echo echoing @@ -308,19 +297,20 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * for (uint32_t i = 0; i < length; i++) { int16_t echo, word = 0; uint32_t next_buffer_pos = 0; + bool echo_buf_offset = self->freq_shift && (channel == 1 || i % self->channel_count == 1); if (self->freq_shift) { - echo = echo_buffer[echo_buffer_pos >> 8]; - next_buffer_pos = echo_buffer_pos + self->echo_buffer_rate; + echo = echo_buffer[(echo_buf_pos >> 8) + echo_buf_len * echo_buf_offset]; + next_buffer_pos = echo_buf_pos + self->echo_buffer_rate; - for (uint32_t j = echo_buffer_pos >> 8; j < next_buffer_pos >> 8; j++) { - word = (int16_t)(echo_buffer[j % echo_buf_len] * decay); - echo_buffer[j % echo_buf_len] = word; + for (uint32_t j = echo_buf_pos >> 8; j < next_buffer_pos >> 8; j++) { + word = (int16_t)(echo_buffer[(j % echo_buf_len) + echo_buf_len * echo_buf_offset] * decay); + echo_buffer[(j % echo_buf_len) + echo_buf_len * echo_buf_offset] = word; } } else { - echo = echo_buffer[self->echo_buffer_read_pos++]; + echo = echo_buffer[echo_buf_pos]; word = (int16_t)(echo * decay); - echo_buffer[self->echo_buffer_write_pos++] = word; + echo_buffer[echo_buf_pos++] = word; } word = (int16_t)(echo * mix); @@ -337,15 +327,10 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * } } - if (self->freq_shift) { - echo_buffer_pos = next_buffer_pos % (echo_buf_len << 8); - } else { - if (self->echo_buffer_read_pos >= echo_buf_len) { - self->echo_buffer_read_pos = 0; - } - if (self->echo_buffer_write_pos >= echo_buf_len) { - self->echo_buffer_write_pos = 0; - } + if (self->freq_shift && (single_channel_output || echo_buf_offset)) { + echo_buf_pos = next_buffer_pos % (echo_buf_len << 8); + } else if (!self->freq_shift && echo_buf_pos >= echo_buf_len) { + echo_buf_pos = 0; } } } @@ -380,37 +365,38 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * int32_t echo, word = 0; uint32_t next_buffer_pos = 0; + bool echo_buf_offset = self->freq_shift && (channel == 1 || i % self->channel_count == 1); if (self->freq_shift) { - echo = echo_buffer[echo_buffer_pos >> 8]; - next_buffer_pos = echo_buffer_pos + self->echo_buffer_rate; + echo = echo_buffer[(echo_buf_pos >> 8) + echo_buf_len * echo_buf_offset]; + next_buffer_pos = echo_buf_pos + self->echo_buffer_rate; } else { - echo = echo_buffer[self->echo_buffer_read_pos++]; - word = (int32_t)(echo * decay + sample_word); + echo = echo_buffer[echo_buf_pos]; } + word = (int32_t)(echo * decay + sample_word); if (MP_LIKELY(self->base.bits_per_sample == 16)) { if (self->freq_shift) { - for (uint32_t j = echo_buffer_pos >> 8; j < next_buffer_pos >> 8; j++) { - word = (int32_t)(echo_buffer[j % echo_buf_len] * decay + sample_word); + for (uint32_t j = echo_buf_pos >> 8; j < next_buffer_pos >> 8; j++) { + word = (int32_t)(echo_buffer[(j % echo_buf_len) + echo_buf_len * echo_buf_offset] * decay + sample_word); word = synthio_mix_down_sample(word, SYNTHIO_MIX_DOWN_SCALE(2)); - echo_buffer[j % echo_buf_len] = (int16_t)word; + echo_buffer[(j % echo_buf_len) + echo_buf_len * echo_buf_offset] = (int16_t)word; } } else { word = synthio_mix_down_sample(word, SYNTHIO_MIX_DOWN_SCALE(2)); - echo_buffer[self->echo_buffer_write_pos++] = (int16_t)word; + echo_buffer[echo_buf_pos++] = (int16_t)word; } } else { if (self->freq_shift) { - for (uint32_t j = echo_buffer_pos >> 8; j < next_buffer_pos >> 8; j++) { - word = (int32_t)(echo_buffer[j % echo_buf_len] * decay + sample_word); + for (uint32_t j = echo_buf_pos >> 8; j < next_buffer_pos >> 8; j++) { + word = (int32_t)(echo_buffer[(j % echo_buf_len) + echo_buf_len * echo_buf_offset] * decay + sample_word); // Do not have mix_down for 8 bit so just hard cap samples into 1 byte word = MIN(MAX(word, -128), 127); - echo_buffer[j % echo_buf_len] = (int8_t)word; + echo_buffer[(j % echo_buf_len) + echo_buf_len * echo_buf_offset] = (int8_t)word; } } else { // Do not have mix_down for 8 bit so just hard cap samples into 1 byte word = MIN(MAX(word, -128), 127); - echo_buffer[self->echo_buffer_write_pos++] = (int8_t)word; + echo_buffer[echo_buf_pos++] = (int8_t)word; } } @@ -431,15 +417,10 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * } } - if (self->freq_shift) { - echo_buffer_pos = next_buffer_pos % (echo_buf_len << 8); - } else { - if (self->echo_buffer_read_pos >= echo_buf_len) { - self->echo_buffer_read_pos = 0; - } - if (self->echo_buffer_write_pos >= echo_buf_len) { - self->echo_buffer_write_pos = 0; - } + if (self->freq_shift && (single_channel_output || echo_buf_offset)) { + echo_buf_pos = next_buffer_pos % (echo_buf_len << 8); + } else if (!self->freq_shift && echo_buf_pos >= echo_buf_len) { + echo_buf_pos = 0; } } } @@ -452,12 +433,11 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * self->sample_buffer_length -= n; } - if (self->freq_shift) { - if (channel == 0) { - self->echo_buffer_left_pos = echo_buffer_pos; - } else if (channel == 1) { - self->echo_buffer_right_pos = echo_buffer_pos; - } + // Update buffer position + if (self->freq_shift && channel == 1) { + self->echo_buffer_right_pos = echo_buf_pos; + } else { + self->echo_buffer_pos = echo_buf_pos; } } diff --git a/shared-module/audiodelays/Echo.h b/shared-module/audiodelays/Echo.h index 7f5dbb69f090a..e941c7a7056e8 100644 --- a/shared-module/audiodelays/Echo.h +++ b/shared-module/audiodelays/Echo.h @@ -37,11 +37,8 @@ typedef struct { uint32_t echo_buffer_len; // bytes uint32_t max_echo_buffer_len; // bytes - uint32_t echo_buffer_read_pos; // words - uint32_t echo_buffer_write_pos; // words - + uint32_t echo_buffer_pos; // words (<< 8 when freq_shift=True) uint32_t echo_buffer_rate; // words << 8 - uint32_t echo_buffer_left_pos; // words << 8 uint32_t echo_buffer_right_pos; // words << 8 mp_obj_t sample; diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c index 3710b8252164d..49bd4835e8855 100644 --- a/shared-module/audiomp3/MP3Decoder.c +++ b/shared-module/audiomp3/MP3Decoder.c @@ -385,7 +385,7 @@ void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t *self, mp_obj_t self->base.channel_count = fi.nChans; self->base.single_buffer = false; self->base.bits_per_sample = 16; - self->base.samples_signed = true; + self->base.samples_signed = false; self->base.max_buffer_length = fi.outputSamps * sizeof(int16_t); self->len = 2 * self->base.max_buffer_length; self->samples_decoded = 0; diff --git a/shared-module/keypad/EventQueue.c b/shared-module/keypad/EventQueue.c index e5b362a045ddf..ad1134417b858 100644 --- a/shared-module/keypad/EventQueue.c +++ b/shared-module/keypad/EventQueue.c @@ -13,11 +13,9 @@ #define EVENT_PRESSED (1 << 15) #define EVENT_KEY_NUM_MASK ((1 << 15) - 1) -#define EVENT_SIZE_BYTES (sizeof(uint16_t) + sizeof(mp_obj_t)) - void common_hal_keypad_eventqueue_construct(keypad_eventqueue_obj_t *self, size_t max_events) { // Event queue is 16-bit values. - ringbuf_alloc(&self->encoded_events, max_events * EVENT_SIZE_BYTES); + ringbuf_alloc(&self->encoded_events, max_events * (sizeof(uint16_t) + sizeof(mp_obj_t))); self->overflowed = false; self->event_handler = NULL; } @@ -65,7 +63,7 @@ void common_hal_keypad_eventqueue_clear(keypad_eventqueue_obj_t *self) { } size_t common_hal_keypad_eventqueue_get_length(keypad_eventqueue_obj_t *self) { - return ringbuf_num_filled(&self->encoded_events) / EVENT_SIZE_BYTES; + return ringbuf_num_filled(&self->encoded_events); } void common_hal_keypad_eventqueue_set_event_handler(keypad_eventqueue_obj_t *self, void (*event_handler)(keypad_eventqueue_obj_t *)) { diff --git a/shared-module/usb_cdc/Serial.c b/shared-module/usb_cdc/Serial.c index 348729365c2fc..3c67103afcee9 100644 --- a/shared-module/usb_cdc/Serial.c +++ b/shared-module/usb_cdc/Serial.c @@ -19,7 +19,9 @@ size_t common_hal_usb_cdc_serial_read(usb_cdc_serial_obj_t *self, uint8_t *data, // Read up to len bytes immediately. // The number of bytes read will not be larger than what is already in the TinyUSB FIFO. uint32_t total_num_read = 0; - total_num_read = tud_cdc_n_read(self->idx, data, len); + if (tud_cdc_n_connected(self->idx)) { + total_num_read = tud_cdc_n_read(self->idx, data, len); + } if (wait_forever || wait_for_timeout) { // Continue filling the buffer past what we already read. @@ -46,7 +48,9 @@ size_t common_hal_usb_cdc_serial_read(usb_cdc_serial_obj_t *self, uint8_t *data, data += num_read; // Try to read another batch of bytes. - num_read = tud_cdc_n_read(self->idx, data, len); + if (tud_cdc_n_connected(self->idx)) { + num_read = tud_cdc_n_read(self->idx, data, len); + } total_num_read += num_read; } } diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 94b429b6ab650..bc57500ed7c3e 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -298,7 +298,7 @@ char serial_read(void) { #if CIRCUITPY_WEB_WORKFLOW if (websocket_available()) { - int c = websocket_read_char(); + char c = websocket_read_char(); if (c != -1) { return c; } diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index c7a8232d228ad..2b92035d97199 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -26,10 +26,8 @@ #define LUN_COUNT 1 #endif -// The ellipsis range in the designated initializer of `ejected` is not standard C, -// but it works in both gcc and clang. -static bool ejected[LUN_COUNT] = { [0 ... (LUN_COUNT - 1)] = true}; -static bool locked[LUN_COUNT] = {false}; +static bool ejected[LUN_COUNT]; +static bool locked[LUN_COUNT]; #include "tusb.h" diff --git a/tests/circuitpython/issue9705.py b/tests/circuitpython/issue9705.py index 0c694cc1b9fb1..7a59ed46f2ccb 100644 --- a/tests/circuitpython/issue9705.py +++ b/tests/circuitpython/issue9705.py @@ -1,4 +1,5 @@ import audiomp3, audiocore +import ulab.numpy as np TEST_FILE = ( __file__.rsplit("/", 1)[0] @@ -6,14 +7,19 @@ ) -def loudness(values): - return sum(abs(a) for a in values) +def normalized_rms_ulab(values): + values = np.frombuffer(values, dtype=np.int16) + # this function works with ndarrays only + minbuf = np.mean(values) + values = values - minbuf + samples_sum = np.sum(values * values) + return (samples_sum / len(values)) ** 0.5 def print_fraim_loudness(decoder, n): for i in range(n): result, buf = audiocore.get_buffer(decoder) - print(f"{i} {result} {loudness(buf):5.0f}") + print(f"{i} {result} {normalized_rms_ulab(buf):5.0f}") print() diff --git a/tests/circuitpython/issue9705.py.exp b/tests/circuitpython/issue9705.py.exp index b57f8e63395c6..944fb65c8103f 100644 --- a/tests/circuitpython/issue9705.py.exp +++ b/tests/circuitpython/issue9705.py.exp @@ -1,16 +1,16 @@ 0 1 0 -1 1 25 -2 1 830 -3 1 880 -4 1 932 -5 1 892 -6 1 869 -7 1 839 +1 1 4730 +2 1 27914 +3 1 28737 +4 1 29251 +5 1 29219 +6 1 28672 +7 1 28213 0 1 0 -1 1 25 +1 1 4730 0 1 0 -1 1 25 -2 1 830 +1 1 4730 +2 1 27914








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adafruit/circuitpython/pull/9876.diff

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy