mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 08:55:36 +00:00
Merge remote-tracking branch 'origin/dev' into jesserockz-2026-405
# Conflicts: # esphome/components/online_image/__init__.py
This commit is contained in:
@@ -32,7 +32,7 @@ runs:
|
||||
# detects the activated venv via ``VIRTUAL_ENV`` so the venv layout
|
||||
# downstream jobs rely on is preserved.
|
||||
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
||||
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
|
||||
with:
|
||||
enable-cache: true
|
||||
# Pin uv version so the action does not have to fetch the
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
- name: Set up uv
|
||||
# ``--system`` (below) installs into the setup-python interpreter;
|
||||
# no venv is created or restored by this workflow.
|
||||
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
||||
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
|
||||
with:
|
||||
enable-cache: true
|
||||
# Pin uv version so the action does not have to fetch the
|
||||
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
# detects the activated venv via ``VIRTUAL_ENV`` so downstream jobs
|
||||
# that ``. venv/bin/activate`` see an identical layout.
|
||||
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
||||
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
|
||||
with:
|
||||
enable-cache: true
|
||||
# Pin uv version so the action does not have to fetch the
|
||||
@@ -112,7 +112,7 @@ jobs:
|
||||
script/build_codeowners.py --check
|
||||
script/build_language_schema.py --check
|
||||
script/generate-esp32-boards.py --check
|
||||
script/generate-rp2040-boards.py --check
|
||||
script/generate-rp2-boards.py --check
|
||||
script/ci_check_duplicate_test_ids.py
|
||||
|
||||
import-time:
|
||||
@@ -171,7 +171,7 @@ jobs:
|
||||
# install step (order-of-magnitude faster on cold boots,
|
||||
# with its own wheel cache). actions/setup-python still
|
||||
# provides the interpreter.
|
||||
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
||||
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
|
||||
with:
|
||||
enable-cache: true
|
||||
# Pin uv version so the action does not have to fetch the
|
||||
@@ -372,7 +372,7 @@ jobs:
|
||||
- name: Set up uv
|
||||
# Only needed on cache miss to populate the venv.
|
||||
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
||||
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
|
||||
with:
|
||||
enable-cache: true
|
||||
# Pin uv version so the action does not have to fetch the
|
||||
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
# setup-python interpreter so subsequent ``pre-commit`` /
|
||||
# ``script/run-in-env.py`` steps find the deps without a
|
||||
# ``uv run`` prefix.
|
||||
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
||||
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
|
||||
with:
|
||||
enable-cache: true
|
||||
# Pin uv version so the action does not have to fetch the
|
||||
|
||||
@@ -427,13 +427,14 @@ This document provides essential context for AI models interacting with this pro
|
||||
|
||||
When a PR's only edits to a component are `validate.*.yaml` files (no source changes, no `test.*.yaml` changes, and the component isn't pulled in as a dependency of another changed component), CI skips the compile stage for that component entirely and only runs config validation. This is decided in `script/determine-jobs.py` via `_component_change_is_validate_only` and surfaced as the `validate_only_components` output that the `test-build-components-split` job consumes.
|
||||
|
||||
* **Test Grouping with Packages:** Components that use shared bus packages can be grouped together in CI to reduce build count. **Never define buses (uart, i2c, spi, modbus) directly in test YAML files** — always use packages from `test_build_components/common/`:
|
||||
* **Test Grouping with Packages:** Components that use shared bus packages can be grouped together in CI to reduce build count. **Never define buses (uart, i2c, spi, modbus) directly in test YAML files** — always use packages from `test_build_components/common/`.
|
||||
|
||||
All includes in test files must go through dict-style `packages:` so that batch grouping works correctly — the grouping scripts only understand dict-style packages. Never use list-style packages (`packages: [- !include ...]`) or top-level merge keys (`<<: !include common.yaml`). Bus packages are keyed by the bus name; the component's `common.yaml` is keyed by the component name (e.g. `cst328: !include common.yaml`):
|
||||
```yaml
|
||||
# test.esp32-idf.yaml — use packages for buses
|
||||
# test.esp32-idf.yaml — everything included via named packages
|
||||
packages:
|
||||
uart: !include ../../test_build_components/common/uart_115200/esp32-idf.yaml
|
||||
|
||||
<<: !include common.yaml
|
||||
my_component: !include common.yaml
|
||||
```
|
||||
```yaml
|
||||
# common.yaml — component config only, NO bus definitions
|
||||
|
||||
+1
-1
@@ -427,7 +427,7 @@ esphome/components/rf_bridge/* @jesserockz
|
||||
esphome/components/rgbct/* @jesserockz
|
||||
esphome/components/ring_buffer/* @kahrendt
|
||||
esphome/components/router/speaker/* @kahrendt
|
||||
esphome/components/rp2040/* @jesserockz
|
||||
esphome/components/rp2/* @jesserockz
|
||||
esphome/components/rp2040_ble/* @bdraco
|
||||
esphome/components/rp2040_pio_led_strip/* @Papa-DMan
|
||||
esphome/components/rp2040_pwm/* @jesserockz
|
||||
|
||||
+5
-5
@@ -355,7 +355,7 @@ def choose_upload_log_host(
|
||||
bootsel_permission_error = False
|
||||
if (
|
||||
purpose == Purpose.UPLOADING
|
||||
and CORE.is_rp2040
|
||||
and CORE.is_rp2
|
||||
and (picotool := _find_picotool()) is not None
|
||||
):
|
||||
bootsel = detect_rp2040_bootsel(picotool)
|
||||
@@ -402,7 +402,7 @@ def choose_upload_log_host(
|
||||
# Show helpful BOOTSEL instructions for RP2040 when no BOOTSEL device is found
|
||||
if (
|
||||
purpose == Purpose.UPLOADING
|
||||
and CORE.is_rp2040
|
||||
and CORE.is_rp2
|
||||
and not any(get_port_type(opt[1]) == PortType.BOOTSEL for opt in options)
|
||||
):
|
||||
if bootsel_permission_error:
|
||||
@@ -985,7 +985,7 @@ def upload_using_platformio(config: ConfigType, port: str) -> int:
|
||||
# RP2040 platform-raspberrypi build recipe expects firmware.bin.signed for
|
||||
# the upload target, but 'nobuild' skips the build phase that creates it.
|
||||
# Create it here so the upload doesn't fail.
|
||||
if CORE.is_rp2040:
|
||||
if CORE.is_rp2:
|
||||
idedata = toolchain.get_idedata(config)
|
||||
build_dir = Path(idedata.firmware_elf_path).parent
|
||||
firmware_bin = build_dir / "firmware.bin"
|
||||
@@ -1173,7 +1173,7 @@ def upload_program(
|
||||
if CORE.is_esp32 or CORE.is_esp8266:
|
||||
file = getattr(args, "file", None)
|
||||
exit_code = upload_using_esptool(config, host, file, args.upload_speed)
|
||||
elif CORE.is_rp2040 or CORE.is_libretiny:
|
||||
elif CORE.is_rp2 or CORE.is_libretiny:
|
||||
exit_code = upload_using_platformio(config, host)
|
||||
# else: Unknown target platform, exit_code remains 1
|
||||
|
||||
@@ -1647,7 +1647,7 @@ def command_run(args: ArgsProtocol, config: ConfigType) -> int | None:
|
||||
|
||||
# After BOOTSEL upload, wait for a new serial port to appear
|
||||
# so it shows up in the log chooser
|
||||
if successful_device is None and CORE.is_rp2040:
|
||||
if successful_device is None and CORE.is_rp2:
|
||||
_wait_for_serial_port(known_ports=pre_upload_ports)
|
||||
# If exactly one new serial port appeared, use it directly
|
||||
serial_ports = get_serial_ports()
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Importing `esphome.loader` here installs the component-alias
|
||||
# ``sys.meta_path`` finder before any submodule lookup runs. Without this,
|
||||
# `from esphome.components import <legacy_alias>` from a fresh interpreter
|
||||
# can race the finder install and raise ImportError, since the legacy
|
||||
# alias dir no longer exists on disk.
|
||||
from esphome import loader as _loader # noqa: F401
|
||||
|
||||
@@ -227,12 +227,12 @@ ESP32_VARIANT_ADC2_PIN_TO_CHANNEL = {
|
||||
|
||||
def validate_adc_pin(value):
|
||||
if str(value).upper() == "VCC":
|
||||
if CORE.is_rp2040:
|
||||
if CORE.is_rp2:
|
||||
return pins.internal_gpio_input_pin_schema(29)
|
||||
return cv.only_on([PLATFORM_ESP8266])("VCC")
|
||||
|
||||
if str(value).upper() == "TEMPERATURE":
|
||||
return cv.only_on_rp2040("TEMPERATURE")
|
||||
return cv.only_on_rp2("TEMPERATURE")
|
||||
|
||||
if CORE.is_esp32:
|
||||
conf = pins.internal_gpio_input_pin_schema(value)
|
||||
@@ -261,11 +261,11 @@ def validate_adc_pin(value):
|
||||
raise cv.Invalid("ESP8266: Only pin A0 (GPIO17) supports ADC")
|
||||
return conf
|
||||
|
||||
if CORE.is_rp2040:
|
||||
if CORE.is_rp2:
|
||||
conf = pins.internal_gpio_input_pin_schema(value)
|
||||
number = conf[CONF_NUMBER]
|
||||
if number not in (26, 27, 28, 29):
|
||||
raise cv.Invalid("RP2040: Only pins 26, 27, 28 and 29 support ADC")
|
||||
raise cv.Invalid("RP2: Only pins 26, 27, 28 and 29 support ADC")
|
||||
return conf
|
||||
|
||||
if CORE.is_libretiny:
|
||||
|
||||
@@ -123,9 +123,9 @@ class ADCSensor final : public sensor::Sensor, public PollingComponent, public v
|
||||
void set_autorange(bool autorange) { this->autorange_ = autorange; }
|
||||
#endif // USE_ESP32
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
void set_is_temperature() { this->is_temperature_ = true; }
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
|
||||
protected:
|
||||
uint8_t sample_count_{1};
|
||||
@@ -152,9 +152,9 @@ class ADCSensor final : public sensor::Sensor, public PollingComponent, public v
|
||||
static adc_oneshot_unit_handle_t shared_adc_handles[2];
|
||||
#endif // USE_ESP32
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
bool is_temperature_{false};
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
|
||||
#ifdef USE_ZEPHYR
|
||||
const struct adc_dt_spec *channel_ = nullptr;
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include "adc_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace esphome::adc {
|
||||
|
||||
static const char *const TAG = "adc.rp2040";
|
||||
static const char *const TAG = "adc.rp2";
|
||||
|
||||
void ADCSensor::setup() {
|
||||
static bool initialized = false;
|
||||
@@ -102,4 +102,4 @@ float ADCSensor::sample() {
|
||||
|
||||
} // namespace esphome::adc
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -201,7 +201,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
PlatformFramework.ESP32_IDF,
|
||||
},
|
||||
"adc_sensor_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||
"adc_sensor_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||
"adc_sensor_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
|
||||
"adc_sensor_libretiny.cpp": {
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
|
||||
@@ -300,7 +300,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
CONF_LISTEN_BACKLOG,
|
||||
esp8266=1, # Limited RAM (~40KB free), LWIP raw sockets
|
||||
esp32=4, # More RAM (520KB), BSD sockets
|
||||
rp2040=1, # Limited RAM (264KB), LWIP raw sockets like ESP8266
|
||||
rp2=1, # Limited RAM (264KB), LWIP raw sockets like ESP8266
|
||||
bk72xx=4, # Moderate RAM, BSD-style sockets
|
||||
rtl87xx=4, # Moderate RAM, BSD-style sockets
|
||||
host=4, # Abundant resources
|
||||
@@ -311,7 +311,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
CONF_MAX_CONNECTIONS,
|
||||
esp8266=4, # ~40KB free RAM, each connection uses ~500-1000 bytes
|
||||
esp32=5, # 520KB RAM available
|
||||
rp2040=4, # 264KB RAM but LWIP constraints
|
||||
rp2=4, # 264KB RAM but LWIP constraints
|
||||
bk72xx=5, # Moderate RAM
|
||||
rtl87xx=5, # Moderate RAM
|
||||
host=8, # Abundant resources
|
||||
@@ -326,7 +326,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
CONF_MAX_SEND_QUEUE,
|
||||
esp8266=4, # Limited RAM, need to fail fast
|
||||
esp32=8, # More RAM, can buffer more
|
||||
rp2040=8, # Moderate RAM
|
||||
rp2=8, # Moderate RAM
|
||||
bk72xx=8, # Moderate RAM
|
||||
nrf52=8, # Moderate RAM
|
||||
rtl87xx=8, # Moderate RAM
|
||||
|
||||
@@ -1759,7 +1759,7 @@ bool APIConnection::send_device_info_response_() {
|
||||
// Manufacturer string - define once, handle ESP8266 PROGMEM separately
|
||||
#if defined(USE_ESP8266) || defined(USE_ESP32)
|
||||
#define ESPHOME_MANUFACTURER "Espressif"
|
||||
#elif defined(USE_RP2040)
|
||||
#elif defined(USE_RP2)
|
||||
#define ESPHOME_MANUFACTURER "Raspberry Pi"
|
||||
#elif defined(USE_BK72XX)
|
||||
#define ESPHOME_MANUFACTURER "Beken"
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifdef USE_ESP32_CRASH_HANDLER
|
||||
#include "esphome/components/esp32/crash_handler.h"
|
||||
#endif
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
#include "esphome/components/rp2040/crash_handler.h"
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
#include "esphome/components/rp2/crash_handler.h"
|
||||
#endif
|
||||
#ifdef USE_ESP8266_CRASH_HANDLER
|
||||
#include "esphome/components/esp8266/crash_handler.h"
|
||||
@@ -279,8 +279,8 @@ class APIConnection final : public APIServerConnectionBase {
|
||||
esp32::crash_handler_log();
|
||||
esp32::crash_handler_clear();
|
||||
#endif
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
rp2040::crash_handler_log();
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
rp2::crash_handler_log();
|
||||
#endif
|
||||
#ifdef USE_ESP8266_CRASH_HANDLER
|
||||
esp8266::crash_handler_log();
|
||||
|
||||
@@ -13,7 +13,7 @@ def AUTO_LOAD() -> list[str]:
|
||||
if (
|
||||
not CORE.is_esp32
|
||||
and not CORE.is_esp8266
|
||||
and not CORE.is_rp2040
|
||||
and not CORE.is_rp2
|
||||
and not CORE.is_libretiny
|
||||
):
|
||||
return ["socket"]
|
||||
@@ -37,7 +37,7 @@ async def to_code(config):
|
||||
elif CORE.is_esp8266:
|
||||
# https://github.com/ESP32Async/ESPAsyncTCP
|
||||
cg.add_library("ESP32Async/ESPAsyncTCP", "2.0.0")
|
||||
elif CORE.is_rp2040:
|
||||
elif CORE.is_rp2:
|
||||
# https://github.com/ayushsharma82/RPAsyncTCP
|
||||
# RPAsyncTCP is a drop-in replacement for AsyncTCP_RP2040W with better
|
||||
# ESPAsyncWebServer compatibility
|
||||
@@ -47,6 +47,6 @@ async def to_code(config):
|
||||
|
||||
def FILTER_SOURCE_FILES() -> list[str]:
|
||||
# Exclude socket implementation for platforms that use AsyncTCP libraries
|
||||
if CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2040 or CORE.is_libretiny:
|
||||
if CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2 or CORE.is_libretiny:
|
||||
return ["async_tcp_socket.cpp"]
|
||||
return []
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#elif defined(USE_ESP8266)
|
||||
// Use ESPAsyncTCP library for ESP8266 (always Arduino)
|
||||
#include <ESPAsyncTCP.h>
|
||||
#elif defined(USE_RP2040)
|
||||
#elif defined(USE_RP2)
|
||||
// Use RPAsyncTCP library for RP2040
|
||||
#include <RPAsyncTCP.h>
|
||||
#else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "async_tcp_socket.h"
|
||||
|
||||
#if !defined(USE_ESP32) && !defined(USE_ESP8266) && !defined(USE_RP2040) && !defined(USE_LIBRETINY) && \
|
||||
#if !defined(USE_ESP32) && !defined(USE_ESP8266) && !defined(USE_RP2) && !defined(USE_LIBRETINY) && \
|
||||
(defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS))
|
||||
|
||||
#include "esphome/components/network/util.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#if !defined(USE_ESP32) && !defined(USE_ESP8266) && !defined(USE_RP2040) && !defined(USE_LIBRETINY) && \
|
||||
#if !defined(USE_ESP32) && !defined(USE_ESP8266) && !defined(USE_RP2) && !defined(USE_LIBRETINY) && \
|
||||
(defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS))
|
||||
|
||||
#include "esphome/components/socket/socket.h"
|
||||
|
||||
@@ -379,9 +379,17 @@ void BluetoothProxy::bluetooth_set_connection_params(const api::BluetoothSetConn
|
||||
}
|
||||
|
||||
void BluetoothProxy::subscribe_api_connection(api::APIConnection *api_connection, uint32_t flags) {
|
||||
if (this->api_connection_ != nullptr) {
|
||||
ESP_LOGE(TAG, "Only one API subscription is allowed at a time");
|
||||
return;
|
||||
if (this->api_connection_ != nullptr && this->api_connection_ != api_connection) {
|
||||
// A previous subscriber still holds the slot. This is almost always a stale
|
||||
// connection from a client that dropped without a clean disconnect and has
|
||||
// not yet hit the keepalive timeout; rejecting the new subscriber would
|
||||
// silently starve it of advertisements until it reconnects, so the newest
|
||||
// subscriber wins instead.
|
||||
char old_peername[socket::SOCKADDR_STR_LEN];
|
||||
char new_peername[socket::SOCKADDR_STR_LEN];
|
||||
ESP_LOGW(TAG, "Subscription from %s (%s) replaces %s (%s)", api_connection->get_name(),
|
||||
api_connection->get_peername_to(new_peername), this->api_connection_->get_name(),
|
||||
this->api_connection_->get_peername_to(old_peername));
|
||||
}
|
||||
this->api_connection_ = api_connection;
|
||||
this->parent_->recalculate_advertisement_parser_types();
|
||||
|
||||
@@ -13,7 +13,7 @@ from esphome.const import (
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
PLATFORM_RTL87XX,
|
||||
PlatformFramework,
|
||||
)
|
||||
@@ -54,7 +54,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
@@ -105,7 +105,7 @@ async def to_code(config):
|
||||
if config[CONF_COMPRESSION] == "gzip":
|
||||
cg.add_define("USE_CAPTIVE_PORTAL_GZIP")
|
||||
|
||||
if CORE.using_arduino and (CORE.is_esp8266 or CORE.is_libretiny or CORE.is_rp2040):
|
||||
if CORE.using_arduino and (CORE.is_esp8266 or CORE.is_libretiny or CORE.is_rp2):
|
||||
cg.add_library("DNSServer", None)
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
},
|
||||
"debug_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||
"debug_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||
"debug_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||
"debug_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
|
||||
"debug_libretiny.cpp": {
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "debug_component.h"
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include <Arduino.h>
|
||||
@@ -9,8 +9,8 @@
|
||||
#else
|
||||
#include <hardware/structs/vreg_and_chip_reset.h>
|
||||
#endif
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
#include "esphome/components/rp2040/crash_handler.h"
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
#include "esphome/components/rp2/crash_handler.h"
|
||||
#endif
|
||||
namespace esphome::debug {
|
||||
|
||||
@@ -41,8 +41,8 @@ const char *DebugComponent::get_reset_reason_(std::span<char, RESET_REASON_BUFFE
|
||||
|
||||
if (watchdog_caused_reboot()) {
|
||||
bool handled = false;
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
if (rp2040::crash_handler_has_data()) {
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
if (rp2::crash_handler_has_data()) {
|
||||
pos = buf_append_str(buf, size, pos, "Crash (HardFault)|");
|
||||
handled = true;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace esphome {
|
||||
uint32_t random_uint32() { return os_random(); }
|
||||
bool random_bytes(uint8_t *data, size_t len) { return os_get_random(data, len) == 0; }
|
||||
|
||||
// ESP8266 Mutex is defined inline as a no-op in helpers.h when USE_ESP8266 (or USE_RP2040) is set,
|
||||
// ESP8266 Mutex is defined inline as a no-op in helpers.h when USE_ESP8266 (or USE_RP2) is set,
|
||||
// independent of the ESPHOME_THREAD_SINGLE thread model define.
|
||||
|
||||
IRAM_ATTR InterruptLock::InterruptLock() { state_ = xt_rsil(15); }
|
||||
|
||||
@@ -126,7 +126,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
CONF_PORT,
|
||||
esp8266=8266,
|
||||
esp32=3232,
|
||||
rp2040=2040,
|
||||
rp2=2040,
|
||||
bk72xx=8892,
|
||||
ln882x=8820,
|
||||
rtl87xx=8892,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "esphome/components/ota/ota_backend.h"
|
||||
#include "esphome/components/ota/ota_backend_esp8266.h"
|
||||
#include "esphome/components/ota/ota_backend_arduino_libretiny.h"
|
||||
#include "esphome/components/ota/ota_backend_arduino_rp2040.h"
|
||||
#include "esphome/components/ota/ota_backend_arduino_rp2.h"
|
||||
#include "esphome/components/ota/ota_backend_esp_idf.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/hal.h"
|
||||
|
||||
@@ -179,9 +179,11 @@ _ALWAYS_EXTERNAL_IDF_COMPONENTS = {"LAN8670", "ENC28J60"}
|
||||
|
||||
# ESP32-only SPI ethernet types (W5100 is RP2040-only, no ESP-IDF driver)
|
||||
SPI_ETHERNET_TYPES = {"W5500", "DM9051", "ENC28J60"}
|
||||
# RP2040-supported ethernet types (SPI and PIO QSPI)
|
||||
RP2040_ETHERNET_TYPES = {"W5100", "W5500", "W6100", "W6300", "ENC28J60"}
|
||||
_RP2040_SPI_LIBRARIES = {
|
||||
# RP2-supported ethernet types (SPI and PIO QSPI). Applies to the whole
|
||||
# RP2 family (RP2040 and RP2350); the chip-specific W5100 caveat in the
|
||||
# comment above is about ESP-IDF driver coverage, not the RP2 platform.
|
||||
RP2_ETHERNET_TYPES = {"W5100", "W5500", "W6100", "W6300", "ENC28J60"}
|
||||
_RP2_SPI_LIBRARIES = {
|
||||
"W5100": "lwIP_w5100",
|
||||
"W5500": "lwIP_w5500",
|
||||
"ENC28J60": "lwIP_enc28j60",
|
||||
@@ -361,10 +363,10 @@ def _validate(config):
|
||||
f"{config[CONF_TYPE]} PHY requires RMII interface and is only supported "
|
||||
f"on ESP32 classic and ESP32-P4, not {variant}"
|
||||
)
|
||||
elif CORE.is_rp2040 and config[CONF_TYPE] not in RP2040_ETHERNET_TYPES:
|
||||
elif CORE.is_rp2 and config[CONF_TYPE] not in RP2_ETHERNET_TYPES:
|
||||
raise cv.Invalid(
|
||||
f"Only {', '.join(sorted(RP2040_ETHERNET_TYPES))} are supported on RP2040, "
|
||||
f"not {config[CONF_TYPE]}"
|
||||
f"Only {', '.join(sorted(RP2_ETHERNET_TYPES))} are supported on the RP2 "
|
||||
f"platform, not {config[CONF_TYPE]}"
|
||||
)
|
||||
return config
|
||||
|
||||
@@ -459,7 +461,7 @@ SPI_SCHEMA = cv.All(
|
||||
}
|
||||
),
|
||||
),
|
||||
cv.only_on([Platform.ESP32, Platform.RP2040]),
|
||||
cv.only_on([Platform.ESP32, Platform.RP2]),
|
||||
_validate_spi_interface,
|
||||
)
|
||||
|
||||
@@ -473,13 +475,13 @@ CONFIG_SCHEMA = cv.All(
|
||||
"JL1101": RMII_SCHEMA,
|
||||
"KSZ8081": RMII_SCHEMA,
|
||||
"KSZ8081RNA": RMII_SCHEMA,
|
||||
"W5100": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2040])),
|
||||
"W5100": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2])),
|
||||
"W5500": SPI_SCHEMA,
|
||||
"OPENETH": cv.All(BASE_SCHEMA, cv.only_on([Platform.ESP32])),
|
||||
"DM9051": SPI_SCHEMA,
|
||||
"ENC28J60": SPI_SCHEMA,
|
||||
"W6100": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2040])),
|
||||
"W6300": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2040])),
|
||||
"W6100": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2])),
|
||||
"W6300": cv.All(SPI_SCHEMA, cv.only_on([Platform.RP2])),
|
||||
"LAN8670": RMII_SCHEMA,
|
||||
"GENERIC": GENERIC_SCHEMA,
|
||||
"YT8531": GENERIC_SCHEMA,
|
||||
@@ -537,7 +539,7 @@ async def to_code(config):
|
||||
|
||||
if CORE.is_esp32:
|
||||
await _to_code_esp32(var, config)
|
||||
elif CORE.is_rp2040:
|
||||
elif CORE.is_rp2:
|
||||
await _to_code_rp2040(var, config)
|
||||
|
||||
cg.add(var.set_type(ETHERNET_TYPES[config[CONF_TYPE]]))
|
||||
@@ -670,7 +672,7 @@ async def _to_code_rp2040(var: cg.Pvariable, config: ConfigType) -> None:
|
||||
cg.add(var.set_reset_pin(config[CONF_RESET_PIN]))
|
||||
|
||||
cg.add_define("USE_ETHERNET_SPI")
|
||||
cg.add_library(_RP2040_SPI_LIBRARIES[config[CONF_TYPE]], None)
|
||||
cg.add_library(_RP2_SPI_LIBRARIES[config[CONF_TYPE]], None)
|
||||
|
||||
|
||||
def _final_validate_rmii_pins(config: ConfigType) -> None:
|
||||
@@ -752,7 +754,7 @@ _platform_filter = filter_source_files_from_platform(
|
||||
PlatformFramework.ESP32_IDF,
|
||||
PlatformFramework.ESP32_ARDUINO,
|
||||
},
|
||||
"ethernet_component_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||
"ethernet_component_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
|
||||
"esp_eth_phy_jl1101.c": {
|
||||
PlatformFramework.ESP32_IDF,
|
||||
PlatformFramework.ESP32_ARDUINO,
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C" eth_esp32_emac_config_t eth_esp32_emac_default_config(void);
|
||||
#endif
|
||||
#endif // USE_ESP32
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
#if defined(USE_ETHERNET_W5500)
|
||||
#include <W5500lwIP.h>
|
||||
#elif defined(USE_ETHERNET_W5100)
|
||||
@@ -182,14 +182,14 @@ class EthernetComponent final : public Component {
|
||||
#endif // USE_ETHERNET_SPI
|
||||
#endif // USE_ESP32
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
void set_clk_pin(uint8_t clk_pin);
|
||||
void set_miso_pin(uint8_t miso_pin);
|
||||
void set_mosi_pin(uint8_t mosi_pin);
|
||||
void set_cs_pin(uint8_t cs_pin);
|
||||
void set_interrupt_pin(int8_t interrupt_pin);
|
||||
void set_reset_pin(int8_t reset_pin);
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
|
||||
#ifdef USE_ETHERNET_IP_STATE_LISTENERS
|
||||
void add_ip_state_listener(EthernetIPStateListener *listener) { this->ip_state_listeners_.push_back(listener); }
|
||||
@@ -272,7 +272,7 @@ class EthernetComponent final : public Component {
|
||||
esp_eth_phy_t *phy_{nullptr};
|
||||
#endif // USE_ESP32
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
static constexpr uint32_t LINK_CHECK_INTERVAL = 500; // ms between link/IP polls
|
||||
#if defined(USE_ETHERNET_W5100)
|
||||
static constexpr uint32_t RESET_DELAY_MS = 150; // W5100S PLL lock time
|
||||
@@ -301,7 +301,7 @@ class EthernetComponent final : public Component {
|
||||
uint8_t cs_pin_;
|
||||
int8_t interrupt_pin_{-1};
|
||||
int8_t reset_pin_{-1};
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
|
||||
// Common members
|
||||
#ifdef USE_ETHERNET_MANUAL_IP
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
#include "ethernet_component.h"
|
||||
|
||||
#if defined(USE_ETHERNET) && defined(USE_RP2040)
|
||||
#if defined(USE_ETHERNET) && defined(USE_RP2)
|
||||
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include "esphome/components/rp2040/gpio.h"
|
||||
#include "esphome/components/rp2/gpio.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include <lwip/dns.h>
|
||||
@@ -29,7 +29,7 @@ void EthernetComponent::setup() {
|
||||
|
||||
// Toggle reset pin if configured
|
||||
if (this->reset_pin_ >= 0) {
|
||||
rp2040::RP2040GPIOPin reset_pin;
|
||||
rp2::RP2GPIOPin reset_pin;
|
||||
reset_pin.set_pin(this->reset_pin_);
|
||||
reset_pin.set_flags(gpio::FLAG_OUTPUT);
|
||||
reset_pin.setup();
|
||||
@@ -380,4 +380,4 @@ void EthernetComponent::disable() {
|
||||
|
||||
} // namespace esphome::ethernet
|
||||
|
||||
#endif // USE_ETHERNET && USE_RP2040
|
||||
#endif // USE_ETHERNET && USE_RP2
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#if !defined(USE_RP2040) && !defined(USE_HOST)
|
||||
#if !defined(USE_RP2) && !defined(USE_HOST)
|
||||
|
||||
namespace esphome::factory_reset {
|
||||
|
||||
@@ -73,4 +73,4 @@ void FactoryResetComponent::setup() {
|
||||
|
||||
} // namespace esphome::factory_reset
|
||||
|
||||
#endif // !defined(USE_RP2040) && !defined(USE_HOST)
|
||||
#endif // !defined(USE_RP2) && !defined(USE_HOST)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/preferences.h"
|
||||
#if !defined(USE_RP2040) && !defined(USE_HOST)
|
||||
#if !defined(USE_RP2) && !defined(USE_HOST)
|
||||
|
||||
#ifdef USE_ESP32
|
||||
#include <esp_system.h>
|
||||
@@ -32,4 +32,4 @@ class FactoryResetComponent final : public Component {
|
||||
|
||||
} // namespace esphome::factory_reset
|
||||
|
||||
#endif // !defined(USE_RP2040) && !defined(USE_HOST)
|
||||
#endif // !defined(USE_RP2) && !defined(USE_HOST)
|
||||
|
||||
@@ -47,7 +47,7 @@ CONFIG_SCHEMA = (
|
||||
host=True,
|
||||
ln882x=False,
|
||||
nrf52=True,
|
||||
rp2040=True,
|
||||
rp2=True,
|
||||
rtl87xx=False,
|
||||
): cv.boolean,
|
||||
cv.Optional(CONF_INTERRUPT_TYPE, default="ANY"): cv.enum(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <cstring>
|
||||
#include "hmac_sha256.h"
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_HOST)
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_HOST)
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
namespace esphome::hmac_sha256 {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_HOST)
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_HOST)
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ def validate_url(value):
|
||||
def validate_ssl_verification(config):
|
||||
error_message = ""
|
||||
|
||||
if CORE.is_rp2040 and config[CONF_VERIFY_SSL]:
|
||||
if CORE.is_rp2 and config[CONF_VERIFY_SSL]:
|
||||
error_message = "ESPHome does not support certificate verification on RP2040"
|
||||
|
||||
if (
|
||||
@@ -96,7 +96,7 @@ def _declare_request_class(value):
|
||||
return cv.declare_id(HttpRequestHost)(value)
|
||||
if CORE.is_esp32:
|
||||
return cv.declare_id(HttpRequestIDF)(value)
|
||||
if CORE.is_esp8266 or CORE.is_rp2040:
|
||||
if CORE.is_esp8266 or CORE.is_rp2:
|
||||
return cv.declare_id(HttpRequestArduino)(value)
|
||||
return NotImplementedError
|
||||
|
||||
@@ -118,7 +118,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
),
|
||||
cv.Optional(CONF_VERIFY_SSL, default=True): cv.boolean,
|
||||
cv.Optional(CONF_WATCHDOG_TIMEOUT): cv.All(
|
||||
cv.Any(cv.only_on_esp32, cv.only_on_rp2040),
|
||||
cv.Any(cv.only_on_esp32, cv.only_on_rp2),
|
||||
cv.positive_not_null_time_period,
|
||||
cv.positive_time_period_milliseconds,
|
||||
),
|
||||
@@ -144,7 +144,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
esp8266_arduino=cv.Version(2, 5, 1),
|
||||
esp32_arduino=cv.Version(0, 0, 0),
|
||||
esp_idf=cv.Version(0, 0, 0),
|
||||
rp2040_arduino=cv.Version(0, 0, 0),
|
||||
rp2_arduino=cv.Version(0, 0, 0),
|
||||
host=cv.Version(0, 0, 0),
|
||||
),
|
||||
validate_ssl_verification,
|
||||
@@ -204,7 +204,7 @@ async def to_code(config):
|
||||
)
|
||||
if CORE.is_esp8266:
|
||||
cg.add_library("ESP8266HTTPClient", None)
|
||||
if CORE.is_rp2040 and CORE.using_arduino:
|
||||
if CORE.is_rp2 and CORE.using_arduino:
|
||||
cg.add_library("HTTPClient", None)
|
||||
if CORE.is_host:
|
||||
if IS_MACOS:
|
||||
@@ -368,7 +368,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
"http_request_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||
"http_request_arduino.cpp": {
|
||||
PlatformFramework.ESP8266_ARDUINO,
|
||||
PlatformFramework.RP2040_ARDUINO,
|
||||
PlatformFramework.RP2_ARDUINO,
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
PlatformFramework.LN882X_ARDUINO,
|
||||
|
||||
@@ -72,7 +72,7 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::perform(const std::string &ur
|
||||
|
||||
bool status = container->client_.begin(*stream_ptr, url.c_str());
|
||||
|
||||
#elif defined(USE_RP2040)
|
||||
#elif defined(USE_RP2)
|
||||
if (secure) {
|
||||
container->client_.setInsecure();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#if defined(USE_ARDUINO) && !defined(USE_ESP32)
|
||||
|
||||
#if defined(USE_RP2040)
|
||||
#if defined(USE_RP2)
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClient.h>
|
||||
#endif
|
||||
|
||||
@@ -36,7 +36,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
esp8266_arduino=cv.Version(2, 5, 1),
|
||||
esp32_arduino=cv.Version(0, 0, 0),
|
||||
esp_idf=cv.Version(0, 0, 0),
|
||||
rp2040_arduino=cv.Version(0, 0, 0),
|
||||
rp2_arduino=cv.Version(0, 0, 0),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ from esphome.const import (
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_HOST,
|
||||
PLATFORM_NRF52,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
PlatformFramework,
|
||||
)
|
||||
from esphome.core import CORE, CoroPriority, coroutine_with_priority
|
||||
@@ -130,7 +130,7 @@ def validate_config(config):
|
||||
return cv.require_framework_version(
|
||||
esp_idf=cv.Version(5, 4, 2), esp32_arduino=cv.Version(3, 2, 1)
|
||||
)(config)
|
||||
if CORE.is_rp2040:
|
||||
if CORE.is_rp2:
|
||||
sda_controller = _rp2040_i2c_controller(config[CONF_SDA])
|
||||
scl_controller = _rp2040_i2c_controller(config[CONF_SCL])
|
||||
if sda_controller != scl_controller:
|
||||
@@ -171,7 +171,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
CONF_SDA,
|
||||
esp32="SDA",
|
||||
esp8266="SDA",
|
||||
rp2040="SDA",
|
||||
rp2="SDA",
|
||||
nrf52="SDA",
|
||||
): pins.internal_gpio_pin_number,
|
||||
cv.SplitDefault(CONF_SDA_PULLUP_ENABLED, esp32=True): cv.All(
|
||||
@@ -181,7 +181,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
CONF_SCL,
|
||||
esp32="SCL",
|
||||
esp8266="SCL",
|
||||
rp2040="SCL",
|
||||
rp2="SCL",
|
||||
nrf52="SCL",
|
||||
): pins.internal_gpio_pin_number,
|
||||
cv.SplitDefault(CONF_SCL_PULLUP_ENABLED, esp32=True): cv.All(
|
||||
@@ -191,7 +191,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
CONF_FREQUENCY,
|
||||
esp32="50kHz",
|
||||
esp8266="50kHz",
|
||||
rp2040="50kHz",
|
||||
rp2="50kHz",
|
||||
nrf52="100kHz",
|
||||
host="50kHz",
|
||||
): cv.All(
|
||||
@@ -219,7 +219,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
[
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
PLATFORM_NRF52,
|
||||
PLATFORM_HOST,
|
||||
]
|
||||
@@ -233,7 +233,7 @@ def _final_validate(config):
|
||||
full_config = fv.full_config.get()[CONF_I2C]
|
||||
if CORE.using_zephyr and len(full_config) > 1:
|
||||
raise cv.Invalid("Second i2c is not implemented on Zephyr yet")
|
||||
if CORE.is_rp2040:
|
||||
if CORE.is_rp2:
|
||||
if len(full_config) > 2:
|
||||
raise cv.Invalid(
|
||||
"The maximum number of I2C interfaces for RP2040/RP2350 is 2"
|
||||
@@ -443,7 +443,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
{
|
||||
"i2c_bus_arduino.cpp": {
|
||||
PlatformFramework.ESP8266_ARDUINO,
|
||||
PlatformFramework.RP2040_ARDUINO,
|
||||
PlatformFramework.RP2_ARDUINO,
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
PlatformFramework.LN882X_ARDUINO,
|
||||
|
||||
@@ -19,7 +19,7 @@ void ArduinoI2CBus::setup() {
|
||||
|
||||
#if defined(USE_ESP8266)
|
||||
wire_ = new TwoWire(); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
#elif defined(USE_RP2040)
|
||||
#elif defined(USE_RP2)
|
||||
// Select Wire instance based on pin assignment, not definition order.
|
||||
// I2C controller = (gpio / 2) % 2: even pairs (0-1,4-5,...) → I2C0, odd pairs (2-3,6-7,...) → I2C1
|
||||
// RP2040 datasheet Table 2 (section 1.4.3): https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
|
||||
@@ -41,7 +41,7 @@ void ArduinoI2CBus::setup() {
|
||||
}
|
||||
|
||||
void ArduinoI2CBus::set_pins_and_clock_() {
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
wire_->setSDA(this->sda_pin_);
|
||||
wire_->setSCL(this->scl_pin_);
|
||||
wire_->begin();
|
||||
@@ -52,7 +52,7 @@ void ArduinoI2CBus::set_pins_and_clock_() {
|
||||
#if defined(USE_ESP8266)
|
||||
// https://github.com/esp8266/Arduino/blob/master/libraries/Wire/Wire.h
|
||||
wire_->setClockStretchLimit(timeout_); // unit: us
|
||||
#elif defined(USE_RP2040)
|
||||
#elif defined(USE_RP2)
|
||||
// https://github.com/earlephilhower/ArduinoCore-API/blob/e37df85425e0ac020bfad226d927f9b00d2e0fb7/api/Stream.h
|
||||
wire_->setTimeout(timeout_ / 1000); // unit: ms
|
||||
#endif
|
||||
@@ -70,7 +70,7 @@ void ArduinoI2CBus::dump_config() {
|
||||
if (timeout_ > 0) {
|
||||
#if defined(USE_ESP8266)
|
||||
ESP_LOGCONFIG(TAG, " Timeout: %u us", this->timeout_);
|
||||
#elif defined(USE_RP2040)
|
||||
#elif defined(USE_RP2)
|
||||
ESP_LOGCONFIG(TAG, " Timeout: %u ms", this->timeout_ / 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
#include "internal_temperature.h"
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace esphome::internal_temperature {
|
||||
|
||||
static const char *const TAG = "internal_temperature.rp2040";
|
||||
static const char *const TAG = "internal_temperature.rp2";
|
||||
|
||||
void InternalTemperatureSensor::update() {
|
||||
float temperature = NAN;
|
||||
@@ -28,4 +28,4 @@ void InternalTemperatureSensor::update() {
|
||||
|
||||
} // namespace esphome::internal_temperature
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -10,7 +10,7 @@ from esphome.const import (
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_NRF52,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_CELSIUS,
|
||||
PlatformFramework,
|
||||
@@ -34,7 +34,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.only_on(
|
||||
[
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_NRF52,
|
||||
PLATFORM_LN882X,
|
||||
@@ -58,7 +58,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
PlatformFramework.ESP32_ARDUINO,
|
||||
PlatformFramework.ESP32_IDF,
|
||||
},
|
||||
"internal_temperature_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||
"internal_temperature_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
|
||||
"internal_temperature_bk72xx.cpp": {
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
},
|
||||
|
||||
@@ -54,7 +54,7 @@ from esphome.const import (
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_NRF52,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
PLATFORM_RTL87XX,
|
||||
PlatformFramework,
|
||||
)
|
||||
@@ -154,7 +154,7 @@ HARDWARE_UART_TO_SERIAL = {
|
||||
UART2: cg.global_ns.Serial2,
|
||||
DEFAULT: cg.global_ns.Serial,
|
||||
},
|
||||
PLATFORM_RP2040: {
|
||||
PLATFORM_RP2: {
|
||||
UART0: cg.global_ns.Serial1,
|
||||
UART1: cg.global_ns.Serial2,
|
||||
USB_CDC: cg.global_ns.Serial,
|
||||
@@ -171,7 +171,7 @@ def uart_selection(value):
|
||||
return cv.one_of(*UART_SELECTION_ESP32[variant], upper=True)(value)
|
||||
if CORE.is_esp8266:
|
||||
return cv.one_of(*UART_SELECTION_ESP8266, upper=True)(value)
|
||||
if CORE.is_rp2040:
|
||||
if CORE.is_rp2:
|
||||
return cv.one_of(*UART_SELECTION_RP2040, upper=True)(value)
|
||||
if CORE.is_libretiny:
|
||||
family = get_libretiny_family()
|
||||
@@ -282,7 +282,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
esp32_s2=USB_CDC,
|
||||
esp32_s3=USB_SERIAL_JTAG,
|
||||
esp32_s31=USB_SERIAL_JTAG,
|
||||
rp2040=USB_CDC,
|
||||
rp2=USB_CDC,
|
||||
bk72xx=DEFAULT,
|
||||
ln882x=DEFAULT,
|
||||
rtl87xx=DEFAULT,
|
||||
@@ -292,7 +292,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
[
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
@@ -417,11 +417,7 @@ async def _late_logger_init(config: ConfigType) -> None:
|
||||
cg.add_define("USE_ESP8266_LOGGER_SERIAL1")
|
||||
enable_serial1()
|
||||
|
||||
if (
|
||||
(CORE.is_esp8266 or CORE.is_rp2040)
|
||||
and has_serial_logging
|
||||
and is_at_least_verbose
|
||||
):
|
||||
if (CORE.is_esp8266 or CORE.is_rp2) and has_serial_logging and is_at_least_verbose:
|
||||
debug_serial_port = HARDWARE_UART_TO_SERIAL[CORE.target_platform][
|
||||
config.get(CONF_HARDWARE_UART)
|
||||
]
|
||||
@@ -605,7 +601,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
},
|
||||
"logger_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||
"logger_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||
"logger_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||
"logger_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
|
||||
"logger_libretiny.cpp": {
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
|
||||
@@ -206,7 +206,7 @@ void Logger::set_baud_rate(uint32_t baud_rate) { this->baud_rate_ = baud_rate; }
|
||||
void Logger::set_log_level(const char *tag, uint8_t log_level) { this->log_levels_[tag] = log_level; }
|
||||
#endif
|
||||
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
|
||||
UARTSelection Logger::get_uart() const { return this->uart_; }
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
#if defined(USE_ESP8266)
|
||||
#include <HardwareSerial.h>
|
||||
#endif // USE_ESP8266
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
#include <HardwareSerial.h>
|
||||
#include <SerialUSB.h>
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
#endif // USE_ARDUINO
|
||||
|
||||
#ifdef USE_ESP32
|
||||
@@ -96,7 +96,7 @@ struct CStrCompare {
|
||||
// macOS allows up to 64 bytes, Linux up to 16
|
||||
static constexpr size_t THREAD_NAME_BUF_SIZE = 64;
|
||||
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
|
||||
/** Enum for logging UART selection
|
||||
*
|
||||
* Advanced configuration (pin selection, etc) is not supported.
|
||||
@@ -122,7 +122,7 @@ enum UARTSelection : uint8_t {
|
||||
UART_SELECTION_UART0_SWAP,
|
||||
#endif // USE_ESP8266
|
||||
};
|
||||
#endif // USE_ESP32 || USE_ESP8266 || USE_RP2040 || USE_LIBRETINY || USE_ZEPHYR
|
||||
#endif // USE_ESP32 || USE_ESP8266 || USE_RP2 || USE_LIBRETINY || USE_ZEPHYR
|
||||
|
||||
/**
|
||||
* @brief Logger component for all ESPHome logging.
|
||||
@@ -160,7 +160,7 @@ class Logger final : public Component {
|
||||
#ifdef USE_HOST
|
||||
void create_pthread_key() { pthread_key_create(&log_recursion_key_, nullptr); }
|
||||
#endif
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
|
||||
void set_uart_selection(UARTSelection uart_selection) { uart_ = uart_selection; }
|
||||
/// Get the UART used by the logger.
|
||||
UARTSelection get_uart() const;
|
||||
@@ -351,7 +351,7 @@ class Logger final : public Component {
|
||||
#endif
|
||||
// Group smaller types together at the end
|
||||
uint8_t current_level_{ESPHOME_LOG_LEVEL_VERY_VERBOSE};
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_ZEPHYR)
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2) || defined(USE_ZEPHYR)
|
||||
UARTSelection uart_{UART_SELECTION_UART0};
|
||||
#endif
|
||||
#ifdef USE_LIBRETINY
|
||||
@@ -505,8 +505,8 @@ class LoggerMessageTrigger final : public Trigger<uint8_t, const char *, const c
|
||||
#include "logger_esp32.h"
|
||||
#elif defined(USE_ESP8266)
|
||||
#include "logger_esp8266.h"
|
||||
#elif defined(USE_RP2040)
|
||||
#include "logger_rp2040.h"
|
||||
#elif defined(USE_RP2)
|
||||
#include "logger_rp2.h"
|
||||
#elif defined(USE_LIBRETINY)
|
||||
#include "logger_libretiny.h"
|
||||
#endif
|
||||
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
#include "logger.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
#include "esphome/components/rp2040/crash_handler.h"
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
#include "esphome/components/rp2/crash_handler.h"
|
||||
#endif
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
@@ -29,8 +29,8 @@ void Logger::pre_setup() {
|
||||
}
|
||||
global_logger = this;
|
||||
ESP_LOGI(TAG, "Log initialized");
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
rp2040::crash_handler_log();
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
rp2::crash_handler_log();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -50,4 +50,4 @@ const LogString *Logger::get_uart_selection_() {
|
||||
}
|
||||
|
||||
} // namespace esphome::logger
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
namespace esphome::logger {
|
||||
@@ -929,7 +929,7 @@ void lv_mem_init() {}
|
||||
|
||||
void lv_mem_deinit() {}
|
||||
|
||||
#if defined(USE_HOST) || defined(USE_RP2040) || defined(USE_ESP8266)
|
||||
#if defined(USE_HOST) || defined(USE_RP2) || defined(USE_ESP8266)
|
||||
void *lv_malloc_core(size_t size) {
|
||||
auto *ptr = malloc(size); // NOLINT
|
||||
if (ptr == nullptr) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace esphome::md5 {
|
||||
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2040) && !defined(USE_ESP32)
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_ESP32)
|
||||
void MD5Digest::init() {
|
||||
memset(this->digest_, 0, 16);
|
||||
MD5Init(&this->ctx_);
|
||||
@@ -14,7 +14,7 @@ void MD5Digest::init() {
|
||||
void MD5Digest::add(const uint8_t *data, size_t len) { MD5Update(&this->ctx_, data, len); }
|
||||
|
||||
void MD5Digest::calculate() { MD5Final(this->digest_, &this->ctx_); }
|
||||
#endif // USE_ARDUINO && !USE_RP2040
|
||||
#endif // USE_ARDUINO && !USE_RP2
|
||||
|
||||
#ifdef USE_ESP32
|
||||
void MD5Digest::init() {
|
||||
@@ -27,7 +27,7 @@ void MD5Digest::add(const uint8_t *data, size_t len) { esp_rom_md5_update(&this-
|
||||
void MD5Digest::calculate() { esp_rom_md5_final(this->digest_, &this->ctx_); }
|
||||
#endif // USE_ESP32
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
void MD5Digest::init() {
|
||||
memset(this->digest_, 0, 16);
|
||||
br_md5_init(&this->ctx_);
|
||||
@@ -36,7 +36,7 @@ void MD5Digest::init() {
|
||||
void MD5Digest::add(const uint8_t *data, size_t len) { br_md5_update(&this->ctx_, data, len); }
|
||||
|
||||
void MD5Digest::calculate() { br_md5_out(&this->ctx_, this->digest_); }
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
|
||||
#ifdef USE_HOST
|
||||
MD5Digest::~MD5Digest() {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#define MD5_CTX_TYPE md5_context_t
|
||||
#endif
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
#include <MD5Builder.h>
|
||||
#define MD5_CTX_TYPE br_md5_context
|
||||
#endif
|
||||
|
||||
@@ -70,11 +70,11 @@ def _require_network_interface(config: ConfigType) -> ConfigType:
|
||||
window. Reject at config time rather than silently producing a component
|
||||
that never initializes.
|
||||
"""
|
||||
if config.get(CONF_DISABLED) or not (CORE.is_esp8266 or CORE.is_rp2040):
|
||||
if config.get(CONF_DISABLED) or not (CORE.is_esp8266 or CORE.is_rp2):
|
||||
return config
|
||||
full_config = fv.full_config.get()
|
||||
has_wifi = "wifi" in full_config
|
||||
has_ethernet = CORE.is_rp2040 and "ethernet" in full_config
|
||||
has_ethernet = CORE.is_rp2 and "ethernet" in full_config
|
||||
if not (has_wifi or has_ethernet):
|
||||
options = "'wifi'" if CORE.is_esp8266 else "'wifi' or 'ethernet'"
|
||||
raise cv.Invalid(
|
||||
@@ -192,18 +192,18 @@ async def to_code(config):
|
||||
if CORE.using_arduino:
|
||||
if CORE.is_esp8266:
|
||||
cg.add_library("ESP8266mDNS", None)
|
||||
elif CORE.is_rp2040:
|
||||
elif CORE.is_rp2:
|
||||
cg.add_library("LEAmDNS", None)
|
||||
|
||||
# Subscribe to the network IP state listener(s) so MDNS.update() is only
|
||||
# scheduled during the probe+announce phase. Same on_ip_state() override
|
||||
# serves both WiFi and Ethernet (signatures match).
|
||||
if CORE.is_esp8266 or CORE.is_rp2040:
|
||||
if CORE.is_esp8266 or CORE.is_rp2:
|
||||
if "wifi" in CORE.config:
|
||||
from esphome.components import wifi
|
||||
|
||||
wifi.request_wifi_ip_state_listener()
|
||||
if CORE.is_rp2040 and "ethernet" in CORE.config:
|
||||
if CORE.is_rp2 and "ethernet" in CORE.config:
|
||||
from esphome.components import ethernet
|
||||
|
||||
ethernet.request_ethernet_ip_state_listener()
|
||||
@@ -274,7 +274,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
},
|
||||
"mdns_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||
"mdns_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||
"mdns_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||
"mdns_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
|
||||
"mdns_libretiny.cpp": {
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
|
||||
@@ -100,7 +100,7 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
|
||||
if (!friendly_name_empty) {
|
||||
txt_count++; // friendly_name
|
||||
}
|
||||
#if defined(USE_ESP8266) || defined(USE_ESP32) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_NRF52)
|
||||
#if defined(USE_ESP8266) || defined(USE_ESP32) || defined(USE_RP2) || defined(USE_LIBRETINY) || defined(USE_NRF52)
|
||||
txt_count++; // platform
|
||||
#endif
|
||||
#if defined(USE_WIFI) || defined(USE_ETHERNET) || defined(USE_OPENTHREAD)
|
||||
@@ -136,9 +136,9 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
|
||||
#elif defined(USE_ESP32)
|
||||
MDNS_STATIC_CONST_CHAR(PLATFORM_ESP32, "ESP32");
|
||||
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(PLATFORM_ESP32)});
|
||||
#elif defined(USE_RP2040)
|
||||
MDNS_STATIC_CONST_CHAR(PLATFORM_RP2040, "RP2040");
|
||||
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(PLATFORM_RP2040)});
|
||||
#elif defined(USE_RP2)
|
||||
MDNS_STATIC_CONST_CHAR(PLATFORM_RP2, "RP2");
|
||||
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(PLATFORM_RP2)});
|
||||
#elif defined(USE_LIBRETINY)
|
||||
txt_records.push_back({MDNS_STR(TXT_PLATFORM), MDNS_STR(lt_cpu_get_model_name())});
|
||||
#elif defined(USE_NRF52)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
// On ESP8266 and RP2040 the scheduler-backed MDNS.update() polling window is armed by
|
||||
// IP state listener events on whichever network interface is configured.
|
||||
#if (defined(USE_ESP8266) || defined(USE_RP2040)) && \
|
||||
#if (defined(USE_ESP8266) || defined(USE_RP2)) && \
|
||||
((defined(USE_WIFI) && defined(USE_WIFI_IP_STATE_LISTENERS)) || \
|
||||
(defined(USE_ETHERNET) && defined(USE_ETHERNET_IP_STATE_LISTENERS)))
|
||||
#include "esphome/components/network/ip_address.h"
|
||||
@@ -145,7 +145,7 @@ class MDNSComponent final : public Component
|
||||
#ifdef USE_MDNS_STORE_SERVICES
|
||||
StaticVector<MDNSService, MDNS_SERVICE_COUNT> services_{};
|
||||
#endif
|
||||
#if defined(USE_RP2040) && defined(USE_MDNS_EVENT_DRIVEN_POLLING)
|
||||
#if defined(USE_RP2) && defined(USE_MDNS_EVENT_DRIVEN_POLLING)
|
||||
// RP2040 defers MDNS.begin() until the first IP-up event; this tracks that.
|
||||
bool initialized_{false};
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "esphome/core/defines.h"
|
||||
#if defined(USE_RP2040) && defined(USE_MDNS)
|
||||
#if defined(USE_RP2) && defined(USE_MDNS)
|
||||
|
||||
#include "esphome/components/network/ip_address.h"
|
||||
#include "esphome/components/network/util.h"
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace esphome::mdns {
|
||||
|
||||
static void register_rp2040(MDNSComponent *, StaticVector<MDNSService, MDNS_SERVICE_COUNT> &services) {
|
||||
static void register_rp2(MDNSComponent *, StaticVector<MDNSService, MDNS_SERVICE_COUNT> &services) {
|
||||
MDNS.begin(App.get_name().c_str());
|
||||
|
||||
for (const auto &service : services) {
|
||||
@@ -82,7 +82,7 @@ void MDNSComponent::on_ip_state(const network::IPAddresses &ips, const network::
|
||||
return;
|
||||
}
|
||||
if (!this->initialized_) {
|
||||
this->setup_buffers_and_register_(register_rp2040);
|
||||
this->setup_buffers_and_register_(register_rp2);
|
||||
this->initialized_ = true;
|
||||
} else {
|
||||
MDNS.notifyAPChange();
|
||||
@@ -29,7 +29,7 @@ MODBUS_WRITE_REGISTER_TYPE = {
|
||||
MODBUS_REGISTER_TYPE = {
|
||||
**MODBUS_WRITE_REGISTER_TYPE,
|
||||
"discrete_input": ModbusRegisterType.DISCRETE_INPUT,
|
||||
"read": ModbusRegisterType.READ,
|
||||
"read": ModbusRegisterType.INPUT_REGISTER,
|
||||
}
|
||||
|
||||
SensorValueType_ns = modbus_helpers_ns.namespace("SensorValueType")
|
||||
|
||||
@@ -360,7 +360,7 @@ void ModbusServerHub::process_modbus_client_frame_(uint8_t address, uint8_t func
|
||||
return;
|
||||
}
|
||||
|
||||
ServerResponseStatus status;
|
||||
ResponseStatus status;
|
||||
uint8_t response_buffer[modbus::MAX_RAW_SIZE];
|
||||
const uint8_t *response_data = response_buffer;
|
||||
uint16_t response_len = 0;
|
||||
@@ -381,9 +381,9 @@ void ModbusServerHub::process_modbus_client_frame_(uint8_t address, uint8_t func
|
||||
}
|
||||
RegisterValues registers;
|
||||
if (static_cast<ModbusFunctionCode>(function_code) == ModbusFunctionCode::READ_HOLDING_REGISTERS) {
|
||||
status = device->on_modbus_read_holding_registers(start_address, number_of_registers, registers);
|
||||
status = device->on_read_holding_registers(start_address, number_of_registers, registers);
|
||||
} else {
|
||||
status = device->on_modbus_read_input_registers(start_address, number_of_registers, registers);
|
||||
status = device->on_read_input_registers(start_address, number_of_registers, registers);
|
||||
}
|
||||
|
||||
// A handler that returns an exception leaves registers partially filled, so check the exception
|
||||
@@ -436,7 +436,7 @@ void ModbusServerHub::process_modbus_client_frame_(uint8_t address, uint8_t func
|
||||
for (uint16_t i = 0; i < number_of_registers; i++) {
|
||||
registers.push_back(helpers::get_data<uint16_t>(data, values_offset + i * 2));
|
||||
}
|
||||
status = device->on_modbus_write_registers(start_address, registers);
|
||||
status = device->on_write_registers(start_address, registers);
|
||||
response_data = data; // echo the request header per Modbus 6.6, 6.12
|
||||
response_len = 4;
|
||||
break;
|
||||
|
||||
@@ -201,8 +201,9 @@ class ModbusClientDevice {
|
||||
using ModbusDevice ESPDEPRECATED("Use ModbusClientDevice instead. Removed in 2026.12.0",
|
||||
"2026.6.0") = ModbusClientDevice;
|
||||
|
||||
// Result of a server register handler: std::nullopt means success, otherwise the Modbus exception code to return.
|
||||
using ServerResponseStatus = std::optional<ModbusExceptionCode>;
|
||||
// Transaction status: std::nullopt on success, otherwise the Modbus exception code. Server handlers return it;
|
||||
// (future) client response callbacks receive it. Named without a side prefix so both directions share it.
|
||||
using ResponseStatus = std::optional<ModbusExceptionCode>;
|
||||
// Register values exchanged with server handlers, in host byte order. Sized at the larger of the two protocol
|
||||
// maxima (read = 125 / 0x7D, write = 123 / 0x7B); the per-direction count limit is enforced by the hub, not by
|
||||
// the capacity of this type.
|
||||
@@ -219,19 +220,19 @@ class ModbusServerDevice {
|
||||
ModbusServerDevice &operator=(ModbusServerDevice &&) = delete;
|
||||
void set_address(uint8_t address) { this->address_ = address; }
|
||||
uint8_t get_address() const { return this->address_; }
|
||||
virtual ServerResponseStatus on_modbus_read_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
RegisterValues ®isters) {
|
||||
virtual ResponseStatus on_read_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
RegisterValues ®isters) {
|
||||
return ModbusExceptionCode::ILLEGAL_FUNCTION;
|
||||
};
|
||||
virtual ServerResponseStatus on_modbus_read_input_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
RegisterValues ®isters) {
|
||||
return this->on_modbus_read_registers(start_address, number_of_registers, registers);
|
||||
virtual ResponseStatus on_read_input_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
RegisterValues ®isters) {
|
||||
return this->on_read_registers(start_address, number_of_registers, registers);
|
||||
};
|
||||
virtual ServerResponseStatus on_modbus_read_holding_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
RegisterValues ®isters) {
|
||||
return this->on_modbus_read_registers(start_address, number_of_registers, registers);
|
||||
virtual ResponseStatus on_read_holding_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
RegisterValues ®isters) {
|
||||
return this->on_read_registers(start_address, number_of_registers, registers);
|
||||
};
|
||||
virtual ServerResponseStatus on_modbus_write_registers(uint16_t start_address, const RegisterValues ®isters) {
|
||||
virtual ResponseStatus on_write_registers(uint16_t start_address, const RegisterValues ®isters) {
|
||||
return ModbusExceptionCode::ILLEGAL_FUNCTION;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
namespace esphome::modbus {
|
||||
|
||||
@@ -48,7 +49,11 @@ enum class ModbusRegisterType : uint8_t {
|
||||
COIL = 0x01,
|
||||
DISCRETE_INPUT = 0x02,
|
||||
HOLDING = 0x03,
|
||||
READ = 0x04,
|
||||
// Named INPUT_REGISTER (not INPUT) because Arduino cores define INPUT as a macro.
|
||||
INPUT_REGISTER = 0x04,
|
||||
// Remove before 2027.2.0
|
||||
READ ESPDEPRECATED("Use ModbusRegisterType::INPUT_REGISTER instead. Removed in 2027.2.0", "2026.7.0") =
|
||||
INPUT_REGISTER,
|
||||
};
|
||||
|
||||
// 7 MODBUS Exception Responses:
|
||||
|
||||
@@ -90,7 +90,7 @@ inline ModbusFunctionCode modbus_register_read_function(ModbusRegisterType reg_t
|
||||
return ModbusFunctionCode::READ_DISCRETE_INPUTS;
|
||||
case ModbusRegisterType::HOLDING:
|
||||
return ModbusFunctionCode::READ_HOLDING_REGISTERS;
|
||||
case ModbusRegisterType::READ:
|
||||
case ModbusRegisterType::INPUT_REGISTER:
|
||||
return ModbusFunctionCode::READ_INPUT_REGISTERS;
|
||||
default:
|
||||
return ModbusFunctionCode::INVALID;
|
||||
@@ -104,7 +104,7 @@ inline ModbusFunctionCode modbus_register_write_function(ModbusRegisterType reg_
|
||||
case ModbusRegisterType::HOLDING:
|
||||
return multiple ? ModbusFunctionCode::WRITE_MULTIPLE_REGISTERS : ModbusFunctionCode::WRITE_SINGLE_REGISTER;
|
||||
// These register types can't be written (per spec)
|
||||
case ModbusRegisterType::READ:
|
||||
case ModbusRegisterType::INPUT_REGISTER:
|
||||
case ModbusRegisterType::DISCRETE_INPUT:
|
||||
default:
|
||||
return ModbusFunctionCode::INVALID;
|
||||
|
||||
@@ -220,7 +220,7 @@ def function_code_to_register(function_code):
|
||||
"read_coils": ModbusRegisterType.COIL,
|
||||
"read_discrete_inputs": ModbusRegisterType.DISCRETE_INPUT,
|
||||
"read_holding_registers": ModbusRegisterType.HOLDING,
|
||||
"read_input_registers": ModbusRegisterType.READ,
|
||||
"read_input_registers": ModbusRegisterType.INPUT_REGISTER,
|
||||
"write_single_coil": ModbusRegisterType.COIL,
|
||||
"write_single_register": ModbusRegisterType.HOLDING,
|
||||
"write_multiple_coils": ModbusRegisterType.COIL,
|
||||
|
||||
@@ -27,9 +27,8 @@ ServerRegister *ModbusServer::find_containing_register_(uint32_t address) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
modbus::ServerResponseStatus ModbusServer::on_modbus_read_registers(uint16_t start_address,
|
||||
uint16_t number_of_registers,
|
||||
modbus::RegisterValues ®isters) {
|
||||
modbus::ResponseStatus ModbusServer::on_read_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
modbus::RegisterValues ®isters) {
|
||||
ESP_LOGV(TAG,
|
||||
"Received read holding/input registers for device 0x%X. Start address: 0x%X. Number of registers: 0x%X.",
|
||||
this->address_, start_address, number_of_registers);
|
||||
@@ -101,8 +100,8 @@ modbus::ServerResponseStatus ModbusServer::on_modbus_read_registers(uint16_t sta
|
||||
return {};
|
||||
}
|
||||
|
||||
modbus::ServerResponseStatus ModbusServer::on_modbus_write_registers(uint16_t start_address,
|
||||
const modbus::RegisterValues ®isters) {
|
||||
modbus::ResponseStatus ModbusServer::on_write_registers(uint16_t start_address,
|
||||
const modbus::RegisterValues ®isters) {
|
||||
// registers holds the values to write in host byte order; its size is the register count.
|
||||
ESP_LOGV(TAG, "Received write registers for device 0x%X. Start address: 0x%X. Number of registers: 0x%zX.",
|
||||
this->address_, start_address, registers.size());
|
||||
|
||||
@@ -102,11 +102,10 @@ class ModbusServer final : public Component, public modbus::ModbusServerDevice {
|
||||
/// Registers a server register with the controller. Called by esphomes code generator
|
||||
void add_server_register(ServerRegister *server_register) { server_registers_.push_back(server_register); }
|
||||
/// called when a modbus request (function code 0x03 or 0x04) was parsed without errors
|
||||
modbus::ServerResponseStatus on_modbus_read_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
modbus::RegisterValues ®isters) final;
|
||||
modbus::ResponseStatus on_read_registers(uint16_t start_address, uint16_t number_of_registers,
|
||||
modbus::RegisterValues ®isters) final;
|
||||
/// called when a modbus request (function code 0x06 or 0x10) was parsed without errors
|
||||
modbus::ServerResponseStatus on_modbus_write_registers(uint16_t start_address,
|
||||
const modbus::RegisterValues ®isters) final;
|
||||
modbus::ResponseStatus on_write_registers(uint16_t start_address, const modbus::RegisterValues ®isters) final;
|
||||
/// Called by esphome generated code to set the server courtesy response object
|
||||
void set_server_courtesy_response(const ServerCourtesyResponse &server_courtesy_response) {
|
||||
this->server_courtesy_response_ = server_courtesy_response;
|
||||
|
||||
@@ -319,7 +319,7 @@ bool MQTTComponent::send_discovery_() {
|
||||
device_info[MQTT_DEVICE_MODEL] = ESPHOME_BOARD;
|
||||
#if defined(USE_ESP8266) || defined(USE_ESP32)
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "Espressif";
|
||||
#elif defined(USE_RP2040)
|
||||
#elif defined(USE_RP2)
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "Raspberry Pi";
|
||||
#elif defined(USE_BK72XX)
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "Beken";
|
||||
|
||||
@@ -124,7 +124,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
esp32=False,
|
||||
esp8266=False,
|
||||
host=False,
|
||||
rp2040=False,
|
||||
rp2=False,
|
||||
nrf52=True,
|
||||
): cv.All(
|
||||
cv.boolean,
|
||||
@@ -135,7 +135,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
esp32_arduino=cv.Version(0, 0, 0),
|
||||
esp8266_arduino=cv.Version(0, 0, 0),
|
||||
host=cv.Version(0, 0, 0),
|
||||
rp2040_arduino=cv.Version(0, 0, 0),
|
||||
rp2_arduino=cv.Version(0, 0, 0),
|
||||
nrf52_zephyr=cv.Version(0, 0, 0),
|
||||
),
|
||||
cv.boolean_false,
|
||||
@@ -263,7 +263,7 @@ async def to_code(config):
|
||||
cg.add_build_flag("-DCONFIG_IPV6")
|
||||
if CORE.is_esp8266:
|
||||
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY")
|
||||
if CORE.is_rp2040:
|
||||
if CORE.is_rp2:
|
||||
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6")
|
||||
# Pvariable creation lives in a separate coroutine at NETWORK_SERVICES so it
|
||||
# emits after wifi/ethernet at COMMUNICATION. This keeps compile-time config
|
||||
|
||||
@@ -19,7 +19,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
},
|
||||
"nextion_upload_arduino.cpp": {
|
||||
PlatformFramework.ESP8266_ARDUINO,
|
||||
PlatformFramework.RP2040_ARDUINO,
|
||||
PlatformFramework.RP2_ARDUINO,
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
PlatformFramework.LN882X_ARDUINO,
|
||||
|
||||
@@ -233,7 +233,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
),
|
||||
cv.Optional(KEY_BOOTLOADER): cv.one_of(*BOOTLOADERS, lower=True),
|
||||
cv.Optional(CONF_DFU): _dfu_schema,
|
||||
cv.Optional(CONF_DCDC, default=True): cv.boolean,
|
||||
cv.Optional(CONF_DCDC): cv.boolean,
|
||||
cv.Optional(CONF_REG0): cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_VOLTAGE): cv.All(
|
||||
@@ -367,16 +367,17 @@ async def to_code(config: ConfigType) -> None:
|
||||
if dfu_config := config.get(CONF_DFU):
|
||||
CORE.add_job(_dfu_to_code, dfu_config)
|
||||
framework_ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
|
||||
if framework_ver < cv.Version(2, 9, 2):
|
||||
zephyr_add_prj_conf("BOARD_ENABLE_DCDC", config[CONF_DCDC])
|
||||
else:
|
||||
zephyr_add_overlay(
|
||||
f"""
|
||||
®1 {{
|
||||
regulator-initial-mode = <{"NRF5X_REG_MODE_DCDC" if config[CONF_DCDC] else "NRF5X_REG_MODE_LDO"}>;
|
||||
}};
|
||||
"""
|
||||
)
|
||||
if CONF_DCDC in config:
|
||||
if framework_ver < cv.Version(2, 9, 2):
|
||||
zephyr_add_prj_conf("BOARD_ENABLE_DCDC", config[CONF_DCDC])
|
||||
else:
|
||||
zephyr_add_overlay(
|
||||
f"""
|
||||
®1 {{
|
||||
regulator-initial-mode = <{"NRF5X_REG_MODE_DCDC" if config[CONF_DCDC] else "NRF5X_REG_MODE_LDO"}>;
|
||||
}};
|
||||
"""
|
||||
)
|
||||
|
||||
if reg0_config := config.get(CONF_REG0):
|
||||
value = VOLTAGE_LEVELS.index(reg0_config[CONF_VOLTAGE])
|
||||
|
||||
@@ -5,7 +5,7 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
from bleak import BleakScanner
|
||||
from bleak.exc import BleakDeviceNotFoundError
|
||||
from bleak.exc import BleakDBusError, BleakDeviceNotFoundError
|
||||
from smp.exceptions import SMPBadStartDelimiter
|
||||
from smpclient import SMPClient
|
||||
from smpclient.generics import error, success
|
||||
@@ -98,6 +98,12 @@ async def _smpmgr_upload(device: str, firmware: Path) -> None:
|
||||
await smp_client.connect()
|
||||
except BleakDeviceNotFoundError as exc:
|
||||
raise EsphomeError(f"Device {device} not found") from exc
|
||||
except BleakDBusError as exc:
|
||||
if "NotPermitted" in exc.dbus_error:
|
||||
raise EsphomeError(
|
||||
f"Cannot connect to {device}: Make sure the device is paired."
|
||||
) from exc
|
||||
raise EsphomeError(f"BLE error connecting to {device}: {exc}") from exc
|
||||
except SMPBLETransportException as exc:
|
||||
raise EsphomeError(f"Connection error with {device}") from exc
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ async def to_code(config):
|
||||
cg.add_define("USE_OTA")
|
||||
CORE.add_job(final_step)
|
||||
|
||||
if CORE.is_rp2040 and CORE.using_arduino:
|
||||
if CORE.is_rp2 and CORE.using_arduino:
|
||||
cg.add_library("Updater", None)
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
PlatformFramework.ESP32_IDF,
|
||||
},
|
||||
"ota_backend_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||
"ota_backend_arduino_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||
"ota_backend_arduino_rp2.cpp": {PlatformFramework.RP2_ARDUINO},
|
||||
"ota_backend_arduino_libretiny.cpp": {
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
|
||||
+13
-13
@@ -1,9 +1,9 @@
|
||||
#ifdef USE_ARDUINO
|
||||
#ifdef USE_RP2040
|
||||
#include "ota_backend_arduino_rp2040.h"
|
||||
#ifdef USE_RP2
|
||||
#include "ota_backend_arduino_rp2.h"
|
||||
#include "ota_backend.h"
|
||||
|
||||
#include "esphome/components/rp2040/preferences.h"
|
||||
#include "esphome/components/rp2/preferences.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
namespace esphome::ota {
|
||||
|
||||
static const char *const TAG = "ota.arduino_rp2040";
|
||||
static const char *const TAG = "ota.arduino_rp2";
|
||||
|
||||
std::unique_ptr<ArduinoRP2040OTABackend> make_ota_backend() { return make_unique<ArduinoRP2040OTABackend>(); }
|
||||
std::unique_ptr<ArduinoRP2OTABackend> make_ota_backend() { return make_unique<ArduinoRP2OTABackend>(); }
|
||||
|
||||
OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size, OTAType ota_type) {
|
||||
OTAResponseTypes ArduinoRP2OTABackend::begin(size_t image_size, OTAType ota_type) {
|
||||
if (ota_type != OTA_TYPE_UPDATE_APP) {
|
||||
return OTA_RESPONSE_ERROR_UNSUPPORTED_OTA_TYPE;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size, OTAType ota_t
|
||||
// web_server is not supported for RP2040, so this is not an issue.
|
||||
bool ret = Update.begin(image_size, U_FLASH);
|
||||
if (ret) {
|
||||
rp2040::preferences_prevent_write(true);
|
||||
rp2::preferences_prevent_write(true);
|
||||
return OTA_RESPONSE_OK;
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ OTAResponseTypes ArduinoRP2040OTABackend::begin(size_t image_size, OTAType ota_t
|
||||
return OTA_RESPONSE_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
void ArduinoRP2040OTABackend::set_update_md5(const char *md5) {
|
||||
void ArduinoRP2OTABackend::set_update_md5(const char *md5) {
|
||||
Update.setMD5(md5);
|
||||
this->md5_set_ = true;
|
||||
}
|
||||
|
||||
OTAResponseTypes ArduinoRP2040OTABackend::write(uint8_t *data, size_t len) {
|
||||
OTAResponseTypes ArduinoRP2OTABackend::write(uint8_t *data, size_t len) {
|
||||
size_t written = Update.write(data, len);
|
||||
if (written == len) {
|
||||
return OTA_RESPONSE_OK;
|
||||
@@ -59,7 +59,7 @@ OTAResponseTypes ArduinoRP2040OTABackend::write(uint8_t *data, size_t len) {
|
||||
return OTA_RESPONSE_ERROR_WRITING_FLASH;
|
||||
}
|
||||
|
||||
OTAResponseTypes ArduinoRP2040OTABackend::end() {
|
||||
OTAResponseTypes ArduinoRP2OTABackend::end() {
|
||||
// Use strict validation (false) when MD5 is set, lenient validation (true) when no MD5
|
||||
// This matches the behavior of the old web_server OTA implementation
|
||||
if (Update.end(!this->md5_set_)) {
|
||||
@@ -72,11 +72,11 @@ OTAResponseTypes ArduinoRP2040OTABackend::end() {
|
||||
return OTA_RESPONSE_ERROR_UPDATE_END;
|
||||
}
|
||||
|
||||
void ArduinoRP2040OTABackend::abort() {
|
||||
void ArduinoRP2OTABackend::abort() {
|
||||
Update.end();
|
||||
rp2040::preferences_prevent_write(false);
|
||||
rp2::preferences_prevent_write(false);
|
||||
}
|
||||
|
||||
} // namespace esphome::ota
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
#endif // USE_ARDUINO
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#ifdef USE_ARDUINO
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
#include "ota_backend.h"
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace esphome::ota {
|
||||
|
||||
class ArduinoRP2040OTABackend final {
|
||||
class ArduinoRP2OTABackend final {
|
||||
public:
|
||||
OTAResponseTypes begin(size_t image_size, OTAType ota_type = OTA_TYPE_UPDATE_APP);
|
||||
void set_update_md5(const char *md5);
|
||||
@@ -21,8 +21,8 @@ class ArduinoRP2040OTABackend final {
|
||||
bool md5_set_{false};
|
||||
};
|
||||
|
||||
std::unique_ptr<ArduinoRP2040OTABackend> make_ota_backend();
|
||||
std::unique_ptr<ArduinoRP2OTABackend> make_ota_backend();
|
||||
|
||||
} // namespace esphome::ota
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
#endif // USE_ARDUINO
|
||||
@@ -8,8 +8,8 @@
|
||||
#include "ota_backend_esp8266.h"
|
||||
#elif defined(USE_ESP32)
|
||||
#include "ota_backend_esp_idf.h"
|
||||
#elif defined(USE_RP2040)
|
||||
#include "ota_backend_arduino_rp2040.h"
|
||||
#elif defined(USE_RP2)
|
||||
#include "ota_backend_arduino_rp2.h"
|
||||
#elif defined(USE_LIBRETINY)
|
||||
#include "ota_backend_arduino_libretiny.h"
|
||||
#elif defined(USE_HOST)
|
||||
|
||||
@@ -118,7 +118,7 @@ CONFIG_SCHEMA = remote_base.validate_triggers(
|
||||
bk72xx="1000b",
|
||||
ln882x="1000b",
|
||||
rtl87xx="1000b",
|
||||
rp2040="1000b",
|
||||
rp2="1000b",
|
||||
): cv.validate_bytes,
|
||||
cv.Optional(CONF_FILTER, default="50us"): cv.All(
|
||||
cv.positive_time_period_microseconds,
|
||||
@@ -248,7 +248,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
PlatformFramework.LN882X_ARDUINO,
|
||||
PlatformFramework.RP2040_ARDUINO,
|
||||
PlatformFramework.RP2_ARDUINO,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#if defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
#if defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
|
||||
namespace esphome::remote_receiver {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace esphome::remote_receiver {
|
||||
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
struct RemoteReceiverComponentStore {
|
||||
static void gpio_intr(RemoteReceiverComponentStore *arg);
|
||||
|
||||
@@ -93,11 +93,11 @@ class RemoteReceiverComponent final : public remote_base::RemoteReceiverBase,
|
||||
std::string error_string_;
|
||||
#endif
|
||||
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || defined(USE_ESP32)
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2) || defined(USE_ESP32)
|
||||
RemoteReceiverComponentStore store_;
|
||||
#endif
|
||||
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
HighFrequencyLoopRequester high_freq_;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||
PlatformFramework.BK72XX_ARDUINO,
|
||||
PlatformFramework.RTL87XX_ARDUINO,
|
||||
PlatformFramework.LN882X_ARDUINO,
|
||||
PlatformFramework.RP2040_ARDUINO,
|
||||
PlatformFramework.RP2_ARDUINO,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
|
||||
#if defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
#if defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
|
||||
namespace esphome::remote_transmitter {
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class RemoteTransmitterComponent final : public remote_base::RemoteTransmitterBa
|
||||
|
||||
protected:
|
||||
void send_internal(uint32_t send_times, uint32_t send_wait) override;
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2) || (defined(USE_ESP32) && !SOC_RMT_SUPPORTED)
|
||||
void calculate_on_off_time_(uint32_t carrier_frequency, uint32_t *on_time_period, uint32_t *off_time_period);
|
||||
|
||||
void mark_(uint32_t on_time, uint32_t off_time, uint32_t usec);
|
||||
|
||||
@@ -21,7 +21,7 @@ from esphome.const import (
|
||||
KEY_FRAMEWORK_VERSION,
|
||||
KEY_TARGET_FRAMEWORK,
|
||||
KEY_TARGET_PLATFORM,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RP2,
|
||||
ThreadModel,
|
||||
)
|
||||
from esphome.core import (
|
||||
@@ -40,27 +40,34 @@ from .const import (
|
||||
KEY_BOARD,
|
||||
KEY_LWIP_OPTS,
|
||||
KEY_PIO_FILES,
|
||||
KEY_RP2040,
|
||||
KEY_RP2,
|
||||
KEY_VARIANT,
|
||||
MCU_TO_VARIANT,
|
||||
STANDARD_BOARDS,
|
||||
VARIANT_FRIENDLY,
|
||||
VARIANTS,
|
||||
rp2040_ns,
|
||||
rp2_ns,
|
||||
)
|
||||
|
||||
# force import gpio to register pin schema
|
||||
from .gpio import rp2040_pin_to_code # noqa: F401
|
||||
from .gpio import rp2_pin_to_code # noqa: F401
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
CODEOWNERS = ["@jesserockz"]
|
||||
AUTO_LOAD = ["preferences"]
|
||||
IS_TARGET_PLATFORM = True
|
||||
|
||||
# Legacy top-level YAML keys that route here. The framework
|
||||
# (esphome/loader.py + esphome/config.py) handles both the deprecation
|
||||
# warning and the key-rename pass; this declaration is the only place a
|
||||
# component needs to opt in. See ComponentManifest.aliases for details.
|
||||
ALIASES = ["rp2040"]
|
||||
ALIAS_REMOVAL_VERSION = "2027.7.0"
|
||||
|
||||
|
||||
def get_board() -> str:
|
||||
"""Return the configured board name."""
|
||||
return CORE.data[KEY_RP2040][KEY_BOARD]
|
||||
return CORE.data[KEY_RP2][KEY_BOARD]
|
||||
|
||||
|
||||
def board_has_wifi() -> bool:
|
||||
@@ -90,22 +97,22 @@ def board_id_has_wifi(board_id: str) -> bool:
|
||||
|
||||
|
||||
def set_core_data(config: ConfigType) -> ConfigType:
|
||||
CORE.data[KEY_RP2040] = {}
|
||||
CORE.data[KEY_CORE][KEY_TARGET_PLATFORM] = PLATFORM_RP2040
|
||||
CORE.data[KEY_RP2] = {}
|
||||
CORE.data[KEY_CORE][KEY_TARGET_PLATFORM] = PLATFORM_RP2
|
||||
CORE.data[KEY_CORE][KEY_TARGET_FRAMEWORK] = "arduino"
|
||||
CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] = cv.Version.parse(
|
||||
config[CONF_FRAMEWORK][CONF_VERSION]
|
||||
)
|
||||
CORE.data[KEY_RP2040][KEY_BOARD] = config[CONF_BOARD]
|
||||
CORE.data[KEY_RP2040][KEY_VARIANT] = config[CONF_VARIANT]
|
||||
CORE.data[KEY_RP2][KEY_BOARD] = config[CONF_BOARD]
|
||||
CORE.data[KEY_RP2][KEY_VARIANT] = config[CONF_VARIANT]
|
||||
|
||||
CORE.data[KEY_RP2040][KEY_PIO_FILES] = {}
|
||||
CORE.data[KEY_RP2][KEY_PIO_FILES] = {}
|
||||
|
||||
return config
|
||||
|
||||
|
||||
def get_rp2040_variant(core_obj: EsphomeCore | None = None) -> str:
|
||||
return (core_obj or CORE).data[KEY_RP2040][KEY_VARIANT]
|
||||
return (core_obj or CORE).data[KEY_RP2][KEY_VARIANT]
|
||||
|
||||
|
||||
def only_on_variant(
|
||||
@@ -121,7 +128,7 @@ def only_on_variant(
|
||||
unsupported = [unsupported]
|
||||
|
||||
def validator_(obj: Any) -> Any:
|
||||
if not CORE.is_rp2040:
|
||||
if not CORE.is_rp2:
|
||||
raise cv.Invalid(f"{msg_prefix} is only available on RP2040")
|
||||
variant = get_rp2040_variant()
|
||||
if supported is not None and variant not in supported:
|
||||
@@ -306,13 +313,18 @@ CONFIG_SCHEMA = cv.All(
|
||||
|
||||
@coroutine_with_priority(CoroPriority.PLATFORM)
|
||||
async def to_code(config):
|
||||
cg.add(rp2040_ns.setup_preferences())
|
||||
cg.add(rp2_ns.setup_preferences())
|
||||
|
||||
# Allow LDF to properly discover dependency including those in preprocessor
|
||||
# conditionals
|
||||
cg.add_platformio_option("lib_ldf_mode", "chain+")
|
||||
cg.add_platformio_option("lib_compat_mode", "strict")
|
||||
cg.add_platformio_option("board", config[CONF_BOARD])
|
||||
cg.add_build_flag("-DUSE_RP2")
|
||||
# USE_RP2040 kept defined as a backwards-compat alias for external
|
||||
# custom components that may still test for it. Internal code uses
|
||||
# USE_RP2 (the canonical name for the RP2 chip family — covers
|
||||
# RP2040, RP2350, and any future RP2-series chips).
|
||||
cg.add_build_flag("-DUSE_RP2040")
|
||||
cg.add_define("USE_NATIVE_64BIT_TIME")
|
||||
cg.set_cpp_standard("gnu++20")
|
||||
@@ -327,7 +339,8 @@ async def to_code(config):
|
||||
conf = config[CONF_FRAMEWORK]
|
||||
cg.add_platformio_option("framework", "arduino")
|
||||
cg.add_build_flag("-DUSE_ARDUINO")
|
||||
cg.add_build_flag("-DUSE_RP2040_FRAMEWORK_ARDUINO")
|
||||
cg.add_build_flag("-DUSE_RP2_FRAMEWORK_ARDUINO")
|
||||
cg.add_build_flag("-DUSE_RP2040_FRAMEWORK_ARDUINO") # back-compat alias
|
||||
# cg.add_build_flag("-DPICO_BOARD=pico_w")
|
||||
cg.add_platformio_option("platform", conf[CONF_PLATFORM_VERSION])
|
||||
cg.add_platformio_option(
|
||||
@@ -359,8 +372,12 @@ async def to_code(config):
|
||||
cg.RawExpression(f"VERSION_CODE({ver.major}, {ver.minor}, {ver.patch})"),
|
||||
)
|
||||
|
||||
cg.add_define("USE_RP2040_WATCHDOG_TIMEOUT", config[CONF_WATCHDOG_TIMEOUT])
|
||||
cg.add_define("USE_RP2040_CRASH_HANDLER")
|
||||
cg.add_define("USE_RP2_WATCHDOG_TIMEOUT", config[CONF_WATCHDOG_TIMEOUT])
|
||||
cg.add_define(
|
||||
"USE_RP2040_WATCHDOG_TIMEOUT", config[CONF_WATCHDOG_TIMEOUT]
|
||||
) # back-compat alias
|
||||
cg.add_define("USE_RP2_CRASH_HANDLER")
|
||||
cg.add_define("USE_RP2040_CRASH_HANDLER") # back-compat alias
|
||||
|
||||
_configure_lwip()
|
||||
|
||||
@@ -465,7 +482,7 @@ def _configure_lwip() -> None:
|
||||
}
|
||||
|
||||
# Store for copy_files() to generate the header
|
||||
CORE.data[KEY_RP2040][KEY_LWIP_OPTS] = lwip_defines
|
||||
CORE.data[KEY_RP2][KEY_LWIP_OPTS] = lwip_defines
|
||||
|
||||
# Add a pre-build extra script that injects our lwip_override directory
|
||||
# into CCFLAGS so our lwipopts.h shadows the framework's version.
|
||||
@@ -500,7 +517,7 @@ def _generate_lwipopts_h() -> None:
|
||||
"""
|
||||
from jinja2 import Environment
|
||||
|
||||
lwip_defines = CORE.data[KEY_RP2040].get(KEY_LWIP_OPTS)
|
||||
lwip_defines = CORE.data[KEY_RP2].get(KEY_LWIP_OPTS)
|
||||
if not lwip_defines:
|
||||
return
|
||||
|
||||
@@ -527,7 +544,7 @@ def add_pio_file(component: str, key: str, data: str):
|
||||
raise EsphomeError(
|
||||
f"[{component}] Invalid PIO key: {key}. Allowed characters: [{ascii_letters}{digits}_]\nPlease report an issue https://github.com/esphome/esphome/issues"
|
||||
) from e
|
||||
CORE.data[KEY_RP2040][KEY_PIO_FILES][key] = data
|
||||
CORE.data[KEY_RP2][KEY_PIO_FILES][key] = data
|
||||
|
||||
|
||||
def generate_pio_files() -> bool:
|
||||
@@ -536,7 +553,7 @@ def generate_pio_files() -> bool:
|
||||
shutil.rmtree(CORE.relative_build_path("src/pio"), ignore_errors=True)
|
||||
|
||||
includes: list[str] = []
|
||||
files = CORE.data[KEY_RP2040][KEY_PIO_FILES]
|
||||
files = CORE.data[KEY_RP2][KEY_PIO_FILES]
|
||||
if not files:
|
||||
return False
|
||||
for key, data in files.items():
|
||||
@@ -581,7 +598,7 @@ def copy_files():
|
||||
|
||||
|
||||
# RP2040 crash handler stacktrace decoding
|
||||
# Matches output from esphome/components/rp2040/crash_handler.cpp
|
||||
# Matches output from esphome/components/rp2/crash_handler.cpp
|
||||
_CRASH_RE = re.compile(r"CRASH DETECTED ON PREVIOUS BOOT")
|
||||
_CRASH_ADDR_RE = re.compile(
|
||||
r"(?:PC|LR|BT\d):\s+(0x[0-9a-fA-F]{8})\s+\((?:fault location|return address|stack backtrace)\)"
|
||||
@@ -1,14 +1,14 @@
|
||||
# Auto-generated by generate_boards.py — do not edit manually
|
||||
# To regenerate: python esphome/components/rp2040/generate_boards.py <arduino-pico-path>
|
||||
# To regenerate: python esphome/components/rp2/generate_boards.py <arduino-pico-path>
|
||||
|
||||
# arduino-pico maps pins >= {{ cyw43_gpio_offset }} to CYW43 wireless chip GPIOs
|
||||
CYW43_GPIO_OFFSET = {{ cyw43_gpio_offset }}
|
||||
CYW43_MAX_GPIO = {{ cyw43_max_gpio }}
|
||||
DEFAULT_MAX_PIN = {{ default_max_pin }}
|
||||
|
||||
RP2040_BASE_PINS = {}
|
||||
RP2_BASE_PINS = {}
|
||||
|
||||
RP2040_BOARD_PINS = {
|
||||
RP2_BOARD_PINS = {
|
||||
{%- for name, pins in board_pins %}
|
||||
{{ name | repr }}: {{ pins | format_pins }},
|
||||
{%- endfor %}
|
||||
@@ -23,3 +23,10 @@ BOARDS = {
|
||||
},
|
||||
{%- endfor %}
|
||||
}
|
||||
|
||||
# Deprecated: use RP2_BASE_PINS / RP2_BOARD_PINS instead. Kept as back-compat
|
||||
# aliases so external custom components / tooling that imported the legacy
|
||||
# names via the ``rp2040`` package alias keep working.
|
||||
# Scheduled for removal in 2027.7.0.
|
||||
RP2040_BASE_PINS = RP2_BASE_PINS
|
||||
RP2040_BOARD_PINS = RP2_BOARD_PINS
|
||||
@@ -1,14 +1,14 @@
|
||||
# Auto-generated by generate_boards.py — do not edit manually
|
||||
# To regenerate: python esphome/components/rp2040/generate_boards.py <arduino-pico-path>
|
||||
# To regenerate: python esphome/components/rp2/generate_boards.py <arduino-pico-path>
|
||||
|
||||
# arduino-pico maps pins >= 64 to CYW43 wireless chip GPIOs
|
||||
CYW43_GPIO_OFFSET = 64
|
||||
CYW43_MAX_GPIO = 66
|
||||
DEFAULT_MAX_PIN = 29
|
||||
|
||||
RP2040_BASE_PINS = {}
|
||||
RP2_BASE_PINS = {}
|
||||
|
||||
RP2040_BOARD_PINS = {
|
||||
RP2_BOARD_PINS = {
|
||||
"0xcb_helios": {
|
||||
"LED": 17,
|
||||
"MISO": 20,
|
||||
@@ -2299,3 +2299,10 @@ BOARDS = {
|
||||
"max_pin": 29,
|
||||
},
|
||||
}
|
||||
|
||||
# Deprecated: use RP2_BASE_PINS / RP2_BOARD_PINS instead. Kept as back-compat
|
||||
# aliases so external custom components / tooling that imported the legacy
|
||||
# names via the ``rp2040`` package alias keep working.
|
||||
# Scheduled for removal in 2027.7.0.
|
||||
RP2040_BASE_PINS = RP2_BASE_PINS
|
||||
RP2040_BOARD_PINS = RP2_BOARD_PINS
|
||||
@@ -2,7 +2,7 @@ import esphome.codegen as cg
|
||||
|
||||
KEY_BOARD = "board"
|
||||
KEY_LWIP_OPTS = "lwip_opts"
|
||||
KEY_RP2040 = "rp2040"
|
||||
KEY_RP2 = "rp2"
|
||||
KEY_PIO_FILES = "pio_files"
|
||||
KEY_VARIANT = "variant"
|
||||
|
||||
@@ -31,4 +31,4 @@ STANDARD_BOARDS = {
|
||||
VARIANT_RP2350: "rpipico2w",
|
||||
}
|
||||
|
||||
rp2040_ns = cg.esphome_ns.namespace("rp2040")
|
||||
rp2_ns = cg.esphome_ns.namespace("rp2")
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifdef USE_RP2
|
||||
|
||||
// HAL functions live in hal.cpp. core.cpp is intentionally empty for
|
||||
// rp2 — there is no extra component bootstrap to keep here.
|
||||
|
||||
#endif // USE_RP2
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <pico.h>
|
||||
|
||||
extern "C" unsigned long ulMainGetRunTimeCounterValue();
|
||||
|
||||
namespace esphome::rp2040 {} // namespace esphome::rp2040
|
||||
namespace esphome::rp2 {} // namespace esphome::rp2
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
|
||||
#include "crash_handler.h"
|
||||
#include "esphome/core/log.h"
|
||||
@@ -51,9 +51,9 @@ static inline bool is_code_addr(uint32_t val) {
|
||||
|
||||
static constexpr size_t MAX_BACKTRACE = 4;
|
||||
|
||||
namespace esphome::rp2040 {
|
||||
namespace esphome::rp2 {
|
||||
|
||||
static const char *const TAG = "rp2040.crash";
|
||||
static const char *const TAG = "rp2.crash";
|
||||
|
||||
// Placed in .noinit so BSS zero-init cannot race with crash_handler_read_and_clear().
|
||||
// The valid field is explicitly cleared in crash_handler_read_and_clear() instead.
|
||||
@@ -117,7 +117,7 @@ void crash_handler_log() {
|
||||
ESP_LOGE(TAG, "%s", hint);
|
||||
}
|
||||
|
||||
} // namespace esphome::rp2040
|
||||
} // namespace esphome::rp2
|
||||
|
||||
// --- HardFault handler ---
|
||||
// Overrides the weak isr_hardfault from arduino-pico's crt0.S.
|
||||
@@ -236,5 +236,5 @@ extern "C" void __attribute__((naked, used)) isr_hardfault() {
|
||||
: "i"(hard_fault_handler_c));
|
||||
}
|
||||
|
||||
#endif // USE_RP2040_CRASH_HANDLER
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2_CRASH_HANDLER
|
||||
#endif // USE_RP2
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
|
||||
namespace esphome::rp2040 {
|
||||
namespace esphome::rp2 {
|
||||
|
||||
/// Read crash data from watchdog scratch registers and clear them.
|
||||
void crash_handler_read_and_clear();
|
||||
@@ -17,7 +17,7 @@ void crash_handler_log();
|
||||
/// Returns true if crash data was found this boot.
|
||||
bool crash_handler_has_data();
|
||||
|
||||
} // namespace esphome::rp2040
|
||||
} // namespace esphome::rp2
|
||||
|
||||
#endif // USE_RP2040_CRASH_HANDLER
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2_CRASH_HANDLER
|
||||
#endif // USE_RP2
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
"""Generate boards.py from arduino-pico board definitions.
|
||||
|
||||
Usage: python esphome/components/rp2040/generate_boards.py <arduino-pico-path>
|
||||
Usage: python esphome/components/rp2/generate_boards.py <arduino-pico-path>
|
||||
"""
|
||||
|
||||
import json
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include "gpio.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace rp2040 {
|
||||
namespace rp2 {
|
||||
|
||||
static const char *const TAG = "rp2040";
|
||||
static const char *const TAG = "rp2";
|
||||
|
||||
static int flags_to_mode(gpio::Flags flags, uint8_t pin) {
|
||||
if (flags == gpio::FLAG_INPUT) { // NOLINT(bugprone-branch-clone)
|
||||
@@ -30,7 +30,7 @@ struct ISRPinArg {
|
||||
bool inverted;
|
||||
};
|
||||
|
||||
ISRInternalGPIOPin RP2040GPIOPin::to_isr() const {
|
||||
ISRInternalGPIOPin RP2GPIOPin::to_isr() const {
|
||||
auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
arg->pin = this->pin_;
|
||||
arg->inverted = this->inverted_;
|
||||
@@ -38,7 +38,7 @@ ISRInternalGPIOPin RP2040GPIOPin::to_isr() const {
|
||||
return ISRInternalGPIOPin((void *) arg);
|
||||
}
|
||||
|
||||
void RP2040GPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const {
|
||||
void RP2GPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const {
|
||||
PinStatus arduino_mode = LOW;
|
||||
switch (type) {
|
||||
case gpio::INTERRUPT_RISING_EDGE:
|
||||
@@ -60,25 +60,23 @@ void RP2040GPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::Inte
|
||||
|
||||
attachInterrupt(pin_, func, arduino_mode, arg);
|
||||
}
|
||||
void RP2040GPIOPin::pin_mode(gpio::Flags flags) {
|
||||
void RP2GPIOPin::pin_mode(gpio::Flags flags) {
|
||||
pinMode(pin_, flags_to_mode(flags, pin_)); // NOLINT
|
||||
}
|
||||
|
||||
size_t RP2040GPIOPin::dump_summary(char *buffer, size_t len) const {
|
||||
return snprintf(buffer, len, "GPIO%u", this->pin_);
|
||||
}
|
||||
size_t RP2GPIOPin::dump_summary(char *buffer, size_t len) const { return snprintf(buffer, len, "GPIO%u", this->pin_); }
|
||||
|
||||
bool RP2040GPIOPin::digital_read() {
|
||||
bool RP2GPIOPin::digital_read() {
|
||||
return bool(digitalRead(pin_)) != inverted_; // NOLINT
|
||||
}
|
||||
void RP2040GPIOPin::digital_write(bool value) {
|
||||
void RP2GPIOPin::digital_write(bool value) {
|
||||
digitalWrite(pin_, value != inverted_ ? 1 : 0); // NOLINT
|
||||
}
|
||||
void RP2040GPIOPin::detach_interrupt() const { detachInterrupt(pin_); }
|
||||
void RP2GPIOPin::detach_interrupt() const { detachInterrupt(pin_); }
|
||||
|
||||
} // namespace rp2040
|
||||
} // namespace rp2
|
||||
|
||||
using namespace rp2040;
|
||||
using namespace rp2;
|
||||
|
||||
bool IRAM_ATTR ISRInternalGPIOPin::digital_read() {
|
||||
auto *arg = reinterpret_cast<ISRPinArg *>(this->arg_);
|
||||
@@ -115,4 +113,4 @@ void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) {
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "esphome/core/hal.h"
|
||||
|
||||
namespace esphome::rp2040 {
|
||||
namespace esphome::rp2 {
|
||||
|
||||
class RP2040GPIOPin final : public InternalGPIOPin {
|
||||
class RP2GPIOPin final : public InternalGPIOPin {
|
||||
public:
|
||||
void set_pin(uint8_t pin) { pin_ = pin; }
|
||||
void set_inverted(bool inverted) { inverted_ = inverted; }
|
||||
@@ -32,6 +32,6 @@ class RP2040GPIOPin final : public InternalGPIOPin {
|
||||
gpio::Flags flags_{};
|
||||
};
|
||||
|
||||
} // namespace esphome::rp2040
|
||||
} // namespace esphome::rp2
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -16,22 +16,22 @@ from esphome.const import (
|
||||
from esphome.core import CORE
|
||||
|
||||
from . import boards
|
||||
from .const import KEY_BOARD, KEY_RP2040, rp2040_ns
|
||||
from .const import KEY_BOARD, KEY_RP2, rp2_ns
|
||||
|
||||
RP2040GPIOPin = rp2040_ns.class_("RP2040GPIOPin", cg.InternalGPIOPin)
|
||||
RP2GPIOPin = rp2_ns.class_("RP2GPIOPin", cg.InternalGPIOPin)
|
||||
|
||||
|
||||
def _lookup_pin(value):
|
||||
board = CORE.data[KEY_RP2040][KEY_BOARD]
|
||||
board_pins = boards.RP2040_BOARD_PINS.get(board, {})
|
||||
board = CORE.data[KEY_RP2][KEY_BOARD]
|
||||
board_pins = boards.RP2_BOARD_PINS.get(board, {})
|
||||
|
||||
while isinstance(board_pins, str):
|
||||
board_pins = boards.RP2040_BOARD_PINS[board_pins]
|
||||
board_pins = boards.RP2_BOARD_PINS[board_pins]
|
||||
|
||||
if value in board_pins:
|
||||
return board_pins[value]
|
||||
if value in boards.RP2040_BASE_PINS:
|
||||
return boards.RP2040_BASE_PINS[value]
|
||||
if value in boards.RP2_BASE_PINS:
|
||||
return boards.RP2_BASE_PINS[value]
|
||||
raise cv.Invalid(f"Cannot resolve pin name '{value}' for board {board}.")
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ def _board_max_virtual_pin(board):
|
||||
|
||||
def validate_gpio_pin(value):
|
||||
value = _translate_pin(value)
|
||||
board = CORE.data[KEY_RP2040][KEY_BOARD]
|
||||
board = CORE.data[KEY_RP2][KEY_BOARD]
|
||||
max_virtual = _board_max_virtual_pin(board)
|
||||
if max_virtual is not None and boards.CYW43_GPIO_OFFSET <= value <= max_virtual:
|
||||
return value
|
||||
@@ -72,7 +72,7 @@ def validate_gpio_pin(value):
|
||||
|
||||
|
||||
def validate_supports(value):
|
||||
board = CORE.data[KEY_RP2040][KEY_BOARD]
|
||||
board = CORE.data[KEY_RP2][KEY_BOARD]
|
||||
if (
|
||||
_board_max_virtual_pin(board) is None
|
||||
or value[CONF_NUMBER] < boards.CYW43_GPIO_OFFSET
|
||||
@@ -89,9 +89,9 @@ def validate_supports(value):
|
||||
return value
|
||||
|
||||
|
||||
RP2040_PIN_SCHEMA = cv.All(
|
||||
RP2_PIN_SCHEMA = cv.All(
|
||||
pins.gpio_base_schema(
|
||||
RP2040GPIOPin,
|
||||
RP2GPIOPin,
|
||||
validate_gpio_pin,
|
||||
modes=pins.GPIO_STANDARD_MODES + (CONF_ANALOG,),
|
||||
),
|
||||
@@ -99,8 +99,8 @@ RP2040_PIN_SCHEMA = cv.All(
|
||||
)
|
||||
|
||||
|
||||
@pins.PIN_SCHEMA_REGISTRY.register("rp2040", RP2040_PIN_SCHEMA)
|
||||
async def rp2040_pin_to_code(config):
|
||||
@pins.PIN_SCHEMA_REGISTRY.register("rp2", RP2_PIN_SCHEMA)
|
||||
async def rp2_pin_to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
num = config[CONF_NUMBER]
|
||||
cg.add(var.set_pin(num))
|
||||
@@ -1,23 +1,23 @@
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include "core.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
#include "crash_handler.h"
|
||||
#endif
|
||||
|
||||
#include "hardware/watchdog.h"
|
||||
|
||||
// Empty rp2040 namespace block to satisfy ci-custom's lint_namespace check.
|
||||
// Empty rp2 namespace block to satisfy ci-custom's lint_namespace check.
|
||||
// HAL functions live in namespace esphome (root) — they are not part of the
|
||||
// rp2040 component's API.
|
||||
namespace esphome::rp2040 {} // namespace esphome::rp2040
|
||||
// rp2 component's API.
|
||||
namespace esphome::rp2 {} // namespace esphome::rp2
|
||||
|
||||
namespace esphome {
|
||||
|
||||
// yield(), delay(), micros(), millis(), millis_64(), delayMicroseconds(),
|
||||
// arch_feed_wdt(), arch_get_cpu_cycle_count() inlined in components/rp2040/hal.h.
|
||||
// arch_feed_wdt(), arch_get_cpu_cycle_count() inlined in components/rp2/hal.h.
|
||||
void arch_restart() {
|
||||
watchdog_reboot(0, 0, 10);
|
||||
while (1) {
|
||||
@@ -26,11 +26,11 @@ void arch_restart() {
|
||||
}
|
||||
|
||||
void arch_init() {
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
rp2040::crash_handler_read_and_clear();
|
||||
#ifdef USE_RP2_CRASH_HANDLER
|
||||
rp2::crash_handler_read_and_clear();
|
||||
#endif
|
||||
#if USE_RP2040_WATCHDOG_TIMEOUT > 0
|
||||
watchdog_enable(USE_RP2040_WATCHDOG_TIMEOUT, false);
|
||||
#if USE_RP2_WATCHDOG_TIMEOUT > 0
|
||||
watchdog_enable(USE_RP2_WATCHDOG_TIMEOUT, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -38,4 +38,4 @@ uint32_t arch_get_cpu_freq_hz() { return RP2040::f_cpu(); }
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C" uint64_t time_us_64(void);
|
||||
extern "C" void watchdog_update(void);
|
||||
extern "C" unsigned long ulMainGetRunTimeCounterValue(void);
|
||||
|
||||
namespace esphome::rp2040 {}
|
||||
namespace esphome::rp2 {}
|
||||
|
||||
namespace esphome {
|
||||
|
||||
@@ -58,4 +58,4 @@ uint32_t arch_get_cpu_freq_hz();
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include "esphome/core/hal.h"
|
||||
|
||||
@@ -89,4 +89,4 @@ void get_mac_address_raw(uint8_t *mac) { // NOLINT(readability-non-const-parame
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace esphome::rp2 {
|
||||
|
||||
class RP2PreferenceBackend final {
|
||||
public:
|
||||
bool save(const uint8_t *data, size_t len);
|
||||
bool load(uint8_t *data, size_t len);
|
||||
|
||||
size_t offset = 0;
|
||||
uint32_t type = 0;
|
||||
};
|
||||
|
||||
class RP2Preferences;
|
||||
RP2Preferences *get_preferences();
|
||||
|
||||
} // namespace esphome::rp2
|
||||
|
||||
namespace esphome {
|
||||
using PreferenceBackend = rp2::RP2PreferenceBackend;
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_RP2
|
||||
+14
-14
@@ -1,4 +1,4 @@
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome::rp2040 {
|
||||
namespace esphome::rp2 {
|
||||
|
||||
static const char *const TAG = "preferences";
|
||||
|
||||
@@ -37,7 +37,7 @@ template<class It> uint8_t calculate_crc(It first, It last, uint32_t type) {
|
||||
return crc;
|
||||
}
|
||||
|
||||
bool RP2040PreferenceBackend::save(const uint8_t *data, size_t len) {
|
||||
bool RP2PreferenceBackend::save(const uint8_t *data, size_t len) {
|
||||
const size_t buffer_size = len + 1;
|
||||
if (buffer_size > PREF_MAX_BUFFER_SIZE)
|
||||
return false;
|
||||
@@ -58,7 +58,7 @@ bool RP2040PreferenceBackend::save(const uint8_t *data, size_t len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RP2040PreferenceBackend::load(uint8_t *data, size_t len) {
|
||||
bool RP2PreferenceBackend::load(uint8_t *data, size_t len) {
|
||||
const size_t buffer_size = len + 1;
|
||||
if (buffer_size > PREF_MAX_BUFFER_SIZE)
|
||||
return false;
|
||||
@@ -80,27 +80,27 @@ bool RP2040PreferenceBackend::load(uint8_t *data, size_t len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RP2040Preferences::RP2040Preferences() : eeprom_sector_(&_EEPROM_start) {}
|
||||
RP2Preferences::RP2Preferences() : eeprom_sector_(&_EEPROM_start) {}
|
||||
|
||||
void RP2040Preferences::setup() {
|
||||
void RP2Preferences::setup() {
|
||||
ESP_LOGVV(TAG, "Loading preferences from flash");
|
||||
memcpy(s_flash_storage, this->eeprom_sector_, RP2040_FLASH_STORAGE_SIZE);
|
||||
}
|
||||
|
||||
ESPPreferenceObject RP2040Preferences::make_preference(size_t length, uint32_t type) {
|
||||
ESPPreferenceObject RP2Preferences::make_preference(size_t length, uint32_t type) {
|
||||
uint32_t start = this->current_flash_offset;
|
||||
uint32_t end = start + length + 1;
|
||||
if (end > RP2040_FLASH_STORAGE_SIZE) {
|
||||
return {};
|
||||
}
|
||||
auto *pref = new RP2040PreferenceBackend(); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
auto *pref = new RP2PreferenceBackend(); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
pref->offset = start;
|
||||
pref->type = type;
|
||||
this->current_flash_offset = end;
|
||||
return ESPPreferenceObject(pref);
|
||||
}
|
||||
|
||||
bool RP2040Preferences::sync() {
|
||||
bool RP2Preferences::sync() {
|
||||
if (!s_flash_dirty)
|
||||
return true;
|
||||
if (s_prevent_write)
|
||||
@@ -121,7 +121,7 @@ bool RP2040Preferences::sync() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RP2040Preferences::reset() {
|
||||
bool RP2Preferences::reset() {
|
||||
ESP_LOGD(TAG, "Erasing storage");
|
||||
{
|
||||
InterruptLock lock;
|
||||
@@ -133,9 +133,9 @@ bool RP2040Preferences::reset() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static RP2040Preferences s_preferences; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static RP2Preferences s_preferences; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
RP2040Preferences *get_preferences() { return &s_preferences; }
|
||||
RP2Preferences *get_preferences() { return &s_preferences; }
|
||||
|
||||
void setup_preferences() {
|
||||
s_preferences.setup();
|
||||
@@ -143,10 +143,10 @@ void setup_preferences() {
|
||||
}
|
||||
void preferences_prevent_write(bool prevent) { s_prevent_write = prevent; }
|
||||
|
||||
} // namespace esphome::rp2040
|
||||
} // namespace esphome::rp2
|
||||
|
||||
namespace esphome {
|
||||
ESPPreferences *global_preferences; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
@@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
#ifdef USE_RP2040
|
||||
#ifdef USE_RP2
|
||||
|
||||
#include "esphome/core/preference_backend.h"
|
||||
|
||||
namespace esphome::rp2040 {
|
||||
namespace esphome::rp2 {
|
||||
|
||||
class RP2040Preferences final : public PreferencesMixin<RP2040Preferences> {
|
||||
class RP2Preferences final : public PreferencesMixin<RP2Preferences> {
|
||||
public:
|
||||
using PreferencesMixin<RP2040Preferences>::make_preference;
|
||||
RP2040Preferences();
|
||||
using PreferencesMixin<RP2Preferences>::make_preference;
|
||||
RP2Preferences();
|
||||
void setup();
|
||||
ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash) {
|
||||
return this->make_preference(length, type);
|
||||
@@ -26,8 +26,8 @@ class RP2040Preferences final : public PreferencesMixin<RP2040Preferences> {
|
||||
void setup_preferences();
|
||||
void preferences_prevent_write(bool prevent);
|
||||
|
||||
} // namespace esphome::rp2040
|
||||
} // namespace esphome::rp2
|
||||
|
||||
DECLARE_PREFERENCE_ALIASES(esphome::rp2040::RP2040Preferences)
|
||||
DECLARE_PREFERENCE_ALIASES(esphome::rp2::RP2Preferences)
|
||||
|
||||
#endif // USE_RP2040
|
||||
#endif // USE_RP2
|
||||
+3
-3
@@ -13,12 +13,12 @@
|
||||
* Saves ~8.9 KB of flash.
|
||||
*/
|
||||
|
||||
#if defined(USE_RP2040) && !defined(USE_FULL_PRINTF)
|
||||
#if defined(USE_RP2) && !defined(USE_FULL_PRINTF)
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace esphome::rp2040 {}
|
||||
namespace esphome::rp2 {}
|
||||
|
||||
static constexpr size_t PRINTF_BUFFER_SIZE = 512;
|
||||
|
||||
@@ -71,4 +71,4 @@ int __wrap_fprintf(FILE *stream, const char *fmt, ...) {
|
||||
} // extern "C"
|
||||
// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
|
||||
|
||||
#endif // USE_RP2040 && !USE_FULL_PRINTF
|
||||
#endif // USE_RP2 && !USE_FULL_PRINTF
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user