es32c2: Support for esp32c2

This includes some memory optimisations.
Also corresponding changes required for idf 5.0.
This commit is contained in:
Chirag Atal
2022-09-14 12:24:49 +05:30
committed by Shubham Patil
parent 30edd36b52
commit 4b7c107b0e
12 changed files with 124 additions and 30 deletions
+24
View File
@@ -36,4 +36,28 @@ menu "ESP Matter"
endchoice
config ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT
int "Maximum dynamic endpoints"
default 16
help
The maximum dynamic endpoints supported.
config ESP_MATTER_SCENES_TABLE_SIZE
int "Scenes table size"
default 3
help
Size of the scenes table.
config ESP_MATTER_BINDING_TABLE_SIZE
int "Binding table size"
default 10
help
Size of the binding table.
config ESP_MATTER_UNICAST_MESSAGE_COUNT
int "Unicast message count"
default 10
help
APS unicast message count.
endmenu
+1 -1
View File
@@ -756,7 +756,7 @@ esp_err_t chip_stack_unlock()
static void esp_matter_chip_init_task(intptr_t context)
{
xTaskHandle task_to_notify = reinterpret_cast<xTaskHandle>(context);
TaskHandle_t task_to_notify = reinterpret_cast<TaskHandle_t>(context);
static chip::CommonCaseDeviceServerInitParams initParams;
initParams.InitializeStaticResourcesBeforeServerInit();
@@ -20,13 +20,15 @@
// Prevent multiple inclusion
#pragma once
#include <sdkconfig.h>
// User options for plugin Binding Table Library
#define EMBER_BINDING_TABLE_SIZE 10
#define EMBER_BINDING_TABLE_SIZE CONFIG_ESP_MATTER_BINDING_TABLE_SIZE
/**** Network Section ****/
#define EMBER_SUPPORTED_NETWORKS (1)
#define EMBER_APS_UNICAST_MESSAGE_COUNT 10
#define EMBER_APS_UNICAST_MESSAGE_COUNT CONFIG_ESP_MATTER_UNICAST_MESSAGE_COUNT
/* Cluster macros for all */
#define ZCL_USING_ACCESS_CONTROL_CLUSTER_SERVER
@@ -167,25 +169,26 @@
/* Other cluster specific macros which are made generic */
#define EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in account login
#define EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in application basic
#define EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in application launcher
#define EMBER_AF_AUDIO_OUTPUT_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in audio output
#define EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in channel
#define EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in color control
#define EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in content launch
#define EMBER_AF_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in identify
#define EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in keypad input
#define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in level control
#define EMBER_AF_LOW_POWER_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in low power
#define EMBER_AF_MEDIA_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in media input
#define EMBER_AF_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in media playback
#define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in on off
#define EMBER_AF_OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in ota software update provider
#define EMBER_AF_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in target navigator
#define EMBER_AF_WAKE_ON_LAN_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in wake on lan
#define EMBER_AF_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in window covering
#define EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT (16) // used in door lock
#define DYNAMIC_ENDPOINTS CONFIG_ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT
#define EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in account login
#define EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in application basic
#define EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in application launcher
#define EMBER_AF_AUDIO_OUTPUT_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in audio output
#define EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in channel
#define EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in color control
#define EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in content launch
#define EMBER_AF_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in identify
#define EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in keypad input
#define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in level control
#define EMBER_AF_LOW_POWER_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in low power
#define EMBER_AF_MEDIA_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in media input
#define EMBER_AF_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in media playback
#define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in on off
#define EMBER_AF_OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in ota software update provider
#define EMBER_AF_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in target navigator
#define EMBER_AF_WAKE_ON_LAN_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in wake on lan
#define EMBER_AF_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in window covering
#define EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT DYNAMIC_ENDPOINTS // used in door lock
#define MATTER_SCENES_TABLE_SIZE 3 // used in scenes // TODO: check this again
#define MATTER_SCENES_TABLE_SIZE CONFIG_ESP_MATTER_SCENES_TABLE_SIZE // used in scenes // TODO: check this again
@@ -3,6 +3,10 @@ include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake)
set(src_dirs )
set(requires driver)
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
list(APPEND requires esp_adc)
endif()
if ("${button_type}" STREQUAL "hollow_button")
list(APPEND src_dirs hollow_button)
endif()
@@ -15,7 +15,12 @@
#define _IOT_BUTTON_ADC_H_
#include "driver/gpio.h"
#include <esp_idf_version.h>
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
#include "esp_adc/adc_continuous.h"
#else
#include "driver/adc.h"
#endif
#ifdef __cplusplus
extern "C" {
@@ -30,7 +35,7 @@ extern "C" {
*
*/
typedef struct {
adc1_channel_t adc_channel; /**< Channel of ADC */
adc_channel_t adc_channel; /**< Channel of ADC */
uint8_t button_index; /**< button index on the channel */
uint16_t min; /**< min voltage in mv corresponding to the button */
uint16_t max; /**< max voltage in mv corresponding to the button */
@@ -59,7 +64,7 @@ esp_err_t button_adc_init(const button_adc_config_t *config);
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG Arguments is invalid.
*/
esp_err_t button_adc_deinit(adc1_channel_t channel, int button_index);
esp_err_t button_adc_deinit(adc_channel_t channel, int button_index);
/**
* @brief Get the adc button level
@@ -0,0 +1,43 @@
// 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 <esp_log.h>
#include <iot_button.h>
#include <led_driver.h>
#define LED_GPIO_PIN GPIO_NUM_8
#define LED_CHANNEL 0 /* RMT_CHANNEL_0 */
#define BUTTON_GPIO_PIN GPIO_NUM_9
static const char *TAG = "device";
led_driver_config_t led_driver_get_config()
{
led_driver_config_t config = {
.gpio = LED_GPIO_PIN,
.channel = LED_CHANNEL,
};
return config;
}
button_config_t button_driver_get_config()
{
button_config_t config = {
.type = BUTTON_TYPE_GPIO,
.gpio_button_config = {
.gpio_num = BUTTON_GPIO_PIN,
.active_level = 0,
}
};
return config;
}
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.5)
if (NOT ("${IDF_TARGET}" STREQUAL "esp32c2" ))
message(FATAL_ERROR "please set esp32c2 as the IDF_TARGET using 'idf.py set-target esp32c2'")
endif()
SET(device_type esp32c2_devkit_m)
SET(led_type gpio)
SET(button_type hollow_button)
SET(extra_components_dirs_append "$ENV{ESP_MATTER_DEVICE_PATH}/../../led_driver"
"$ENV{ESP_MATTER_DEVICE_PATH}/../../button_driver/button")
@@ -59,7 +59,7 @@ esp_err_t led_driver_set_saturation(led_driver_handle_t handle, uint8_t saturati
esp_err_t led_driver_set_temperature(led_driver_handle_t handle, uint32_t temperature)
{
ESP_LOGI(TAG, "Setting temperature to: %d", temperature);
ESP_LOGI(TAG, "Setting temperature to: %lu", temperature);
/* Set the color temp here*/
return ESP_OK;
@@ -21,6 +21,7 @@
#pragma once
#include <lib/core/CHIPConfig.h>
#include <sdkconfig.h>
#define GENERATED_ATTRIBUTES \
{}
@@ -46,7 +47,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
#ifdef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
#undef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
#endif
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT (16)
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT CONFIG_ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT
// Array of endpoints that are supported, the data inside
// the array is the endpoint number.
@@ -21,6 +21,7 @@
#pragma once
#include <lib/core/CHIPConfig.h>
#include <sdkconfig.h>
#define GENERATED_ATTRIBUTES \
{}
@@ -46,7 +47,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
#ifdef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
#undef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
#endif
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT (16)
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT CONFIG_ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT
// Array of endpoints that are supported, the data inside
// the array is the endpoint number.
@@ -21,6 +21,7 @@
#pragma once
#include <lib/core/CHIPConfig.h>
#include <sdkconfig.h>
#define GENERATED_ATTRIBUTES \
{}
@@ -46,7 +47,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
#ifdef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
#undef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
#endif
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT (16)
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT CONFIG_ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT
// Array of endpoints that are supported, the data inside
// the array is the endpoint number.
@@ -21,6 +21,7 @@
#pragma once
#include <lib/core/CHIPConfig.h>
#include <sdkconfig.h>
#define GENERATED_ATTRIBUTES \
{}
@@ -46,7 +47,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
#ifdef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
#undef CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
#endif
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT (16)
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT CONFIG_ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT
// Array of endpoints that are supported, the data inside
// the array is the endpoint number.