From 9c16cbf31823f506720cb3d021e8b7ff160393cc Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Thu, 27 Jan 2022 12:27:32 +0800 Subject: [PATCH] Add ESP32-S3 Target in device_hal --- device_hal/device/esp32s3_devkit_c/device.c | 48 +++++++++++++++++++ .../esp32s3_devkit_c/esp_matter_device.cmake | 15 ++++++ examples/light/CMakeLists.txt | 2 + examples/rainmaker_light/CMakeLists.txt | 2 + examples/zap_light/CMakeLists.txt | 2 + 5 files changed, 69 insertions(+) create mode 100644 device_hal/device/esp32s3_devkit_c/device.c create mode 100644 device_hal/device/esp32s3_devkit_c/esp_matter_device.cmake diff --git a/device_hal/device/esp32s3_devkit_c/device.c b/device_hal/device/esp32s3_devkit_c/device.c new file mode 100644 index 000000000..6f404d0e0 --- /dev/null +++ b/device_hal/device/esp32s3_devkit_c/device.c @@ -0,0 +1,48 @@ +// Copyright 2021 Espressif Systems (Shanghai) CO LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License + +#include + +#include +#include + +#define DEVICE_VERSION_1_0 + +#ifdef DEVICE_VERSION_1_0 +#define LED_GPIO_PIN 48 /* GPIO_NUM_48 */ +#define LED_CHANNEL 0 /* RMT_CHANNEL_0 */ +#endif + +static const char *TAG = "device"; + +static esp_err_t device_light_init() +{ + light_driver_config_t config = { + .gpio = LED_GPIO_PIN, + .channel = LED_CHANNEL, + }; + return light_driver_init(&config); +} + +static esp_err_t device_button_init() +{ + return button_driver_init(NULL); +} + +esp_err_t device_init() +{ + ESP_LOGI(TAG, "Initializing device"); + device_light_init(); + device_button_init(); + return ESP_OK; +} diff --git a/device_hal/device/esp32s3_devkit_c/esp_matter_device.cmake b/device_hal/device/esp32s3_devkit_c/esp_matter_device.cmake new file mode 100644 index 000000000..3df56055e --- /dev/null +++ b/device_hal/device/esp32s3_devkit_c/esp_matter_device.cmake @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.5) +if(NOT ("${IDF_TARGET}" STREQUAL "esp32s3" )) + message(FATAL_ERROR "please set esp32s3 as the IDF_TARGET using 'idf.py set-target esp32s3'") +endif() + +SET(device_hal_path $ENV{ESP_MATTER_DEVICE_PATH}/../../) +SET(device_name esp32s3_devkit_c) +SET(light_type ws2812) +SET(button_type hollow) +SET(used_driver light_driver button_driver) +SET(extra_components_dirs_append "${device_hal_path}/light_driver" + "${device_hal_path}/button_driver" + "$ENV{IDF_PATH}/examples/common_components/led_strip") + + diff --git a/examples/light/CMakeLists.txt b/examples/light/CMakeLists.txt index 0add5289e..610bb4242 100644 --- a/examples/light/CMakeLists.txt +++ b/examples/light/CMakeLists.txt @@ -15,6 +15,8 @@ if(NOT DEFINED ENV{ESP_MATTER_DEVICE_PATH}) set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32h2_devkit_c) elseif("${IDF_TARGET}" STREQUAL "esp32s2") set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32s2_devkit_c) + elseif("${IDF_TARGET}" STREQUAL "esp32s3") + set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32s3_devkit_c) else() message(FATAL_ERROR "Unsupported IDF_TARGET") endif() diff --git a/examples/rainmaker_light/CMakeLists.txt b/examples/rainmaker_light/CMakeLists.txt index 072bcb105..be65c14ef 100644 --- a/examples/rainmaker_light/CMakeLists.txt +++ b/examples/rainmaker_light/CMakeLists.txt @@ -13,6 +13,8 @@ if(NOT DEFINED ENV{ESP_MATTER_DEVICE_PATH}) set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32c3_devkit_m) elseif("${IDF_TARGET}" STREQUAL "esp32s2") set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32s2_devkit_c) + elseif("${IDF_TARGET}" STREQUAL "esp32s3") + set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32s3_devkit_c) else() message(FATAL_ERROR "Unsupported IDF_TARGET") endif() diff --git a/examples/zap_light/CMakeLists.txt b/examples/zap_light/CMakeLists.txt index 9669f4251..95221c08b 100644 --- a/examples/zap_light/CMakeLists.txt +++ b/examples/zap_light/CMakeLists.txt @@ -15,6 +15,8 @@ if(NOT DEFINED ENV{ESP_MATTER_DEVICE_PATH}) set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32h2_devkit_c) elseif("${IDF_TARGET}" STREQUAL "esp32s2") set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32s2_devkit_c) + elseif("${IDF_TARGET}" STREQUAL "esp32s3") + set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32s3_devkit_c) else() message(FATAL_ERROR "Unsupported IDF_TARGET") endif()