Merge branch 'feature/support_esp32c3_aligenie_demo' into 'master'

ble_mesh: aligenie_demo: Add sdkconfig.defaults for esp32c3

See merge request espressif/esp-idf!12260
pull/6718/head
Island 2021-02-24 12:08:08 +00:00
commit f283b7087d
5 zmienionych plików z 93 dodań i 1 usunięć

Wyświetl plik

@ -26,10 +26,10 @@
#include "esp_ble_mesh_provisioning_api.h"
#include "esp_ble_mesh_local_data_operation_api.h"
#include "genie_mesh.h"
#include "genie_util.h"
#include "genie_model_srv.h"
#include "genie_event.h"
#include "genie_mesh.h"
#include "genie_reset.h"
#include "genie_timer.h"
#include "ble_mesh_example_nvs.h"

Wyświetl plik

@ -16,6 +16,8 @@
#ifndef _GENIE_MESH_H_
#define _GENIE_MESH_H_
#include "esp_timer.h"
#include "esp_ble_mesh_defs.h"
#include "esp_ble_mesh_common_api.h"

Wyświetl plik

@ -0,0 +1,45 @@
#
# Partition Table
#
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
#
# Serial flasher config
#
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
# Override some defaults so BT stack is enabled
# by default in this example
CONFIG_BT_ENABLED=y
CONFIG_BT_CTRL_ESP32C3=y
CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE=y
CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN=y
CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
CONFIG_BT_BTU_TASK_STACK_SIZE=4512
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# Override some defaults of ESP BLE Mesh
CONFIG_BLE_MESH=y
CONFIG_BLE_MESH_NODE=y
CONFIG_BLE_MESH_PB_GATT=y
CONFIG_BLE_MESH_TX_SEG_MSG_COUNT=10
CONFIG_BLE_MESH_RX_SEG_MSG_COUNT=10
CONFIG_BLE_MESH_SETTINGS=y
CONFIG_BLE_MESH_SUBNET_COUNT=5
CONFIG_BLE_MESH_APP_KEY_COUNT=5
CONFIG_BLE_MESH_MODEL_KEY_COUNT=5
CONFIG_BLE_MESH_MODEL_GROUP_COUNT=5
CONFIG_BLE_MESH_MSG_CACHE_SIZE=20
CONFIG_BLE_MESH_ADV_BUF_COUNT=256
#
# light driver config
#
CONFIG_LIGHT_GPIO_RED=4
CONFIG_LIGHT_GPIO_GREEN=5
CONFIG_LIGHT_GPIO_BLUE=6
CONFIG_LIGHT_GPIO_COLD=7
CONFIG_LIGHT_GPIO_WARM=10
# end of light driver config

Wyświetl plik

@ -107,17 +107,28 @@ static IRAM_ATTR esp_err_t iot_ledc_duty_config(ledc_mode_t speed_mode, ledc_cha
uint32_t duty_direction, uint32_t duty_num, uint32_t duty_cycle, uint32_t duty_scale)
{
if (hpoint_val >= 0) {
#if CONFIG_IDF_TARGET_ESP32C3
LEDC.channel_group[speed_mode].channel[channel].hpoint.hpoint = hpoint_val & LEDC_HPOINT_LSCH1_V;
#elif CONFIG_IDF_TARGET_ESP32
LEDC.channel_group[speed_mode].channel[channel].hpoint.hpoint = hpoint_val & LEDC_HPOINT_HSCH1_V;
#endif
}
if (duty_val >= 0) {
LEDC.channel_group[speed_mode].channel[channel].duty.duty = duty_val;
}
#if CONFIG_IDF_TARGET_ESP32C3
LEDC.channel_group[speed_mode].channel[channel].conf1.val = ((duty_direction & LEDC_DUTY_INC_LSCH0_V) << LEDC_DUTY_INC_LSCH0_S) |
((duty_num & LEDC_DUTY_NUM_LSCH0_V) << LEDC_DUTY_NUM_LSCH0_S) |
((duty_cycle & LEDC_DUTY_CYCLE_LSCH0_V) << LEDC_DUTY_CYCLE_LSCH0_S) |
((duty_scale & LEDC_DUTY_SCALE_LSCH0_V) << LEDC_DUTY_SCALE_LSCH0_S);
#elif CONFIG_IDF_TARGET_ESP32
LEDC.channel_group[speed_mode].channel[channel].conf1.val = ((duty_direction & LEDC_DUTY_INC_HSCH0_V) << LEDC_DUTY_INC_HSCH0_S) |
((duty_num & LEDC_DUTY_NUM_HSCH0_V) << LEDC_DUTY_NUM_HSCH0_S) |
((duty_cycle & LEDC_DUTY_CYCLE_HSCH0_V) << LEDC_DUTY_CYCLE_HSCH0_S) |
((duty_scale & LEDC_DUTY_SCALE_HSCH0_V) << LEDC_DUTY_SCALE_HSCH0_S);
#endif
LEDC.channel_group[speed_mode].channel[channel].conf0.sig_out_en = 1;
LEDC.channel_group[speed_mode].channel[channel].conf1.duty_start = 1;
@ -190,16 +201,28 @@ static IRAM_ATTR esp_err_t _iot_set_fade_with_time(ledc_mode_t speed_mode, ledc_
scale = 1;
cycle_num = total_cycles / duty_delta;
#if CONFIG_IDF_TARGET_ESP32C3
if (cycle_num > LEDC_DUTY_NUM_LSCH0_V) {
cycle_num = LEDC_DUTY_NUM_LSCH0_V;
}
#elif CONFIG_IDF_TARGET_ESP32
if (cycle_num > LEDC_DUTY_NUM_HSCH0_V) {
cycle_num = LEDC_DUTY_NUM_HSCH0_V;
}
#endif
} else {
cycle_num = 1;
scale = duty_delta / total_cycles;
#if CONFIG_IDF_TARGET_ESP32C3
if (scale > LEDC_DUTY_SCALE_LSCH0_V) {
scale = LEDC_DUTY_SCALE_LSCH0_V;
}
#elif CONFIG_IDF_TARGET_ESP32
if (scale > LEDC_DUTY_SCALE_HSCH0_V) {
scale = LEDC_DUTY_SCALE_HSCH0_V;
}
#endif
}
return _iot_set_fade_with_step(speed_mode, channel, target_duty, scale, cycle_num);
@ -263,27 +286,45 @@ static IRAM_ATTR void fade_timercb(void *para)
if (HW_TIMER_GROUP == TIMER_GROUP_0) {
/* Retrieve the interrupt status */
#if CONFIG_IDF_TARGET_ESP32C3
uint32_t intr_status = TIMERG0.int_st.val;
TIMERG0.hw_timer[timer_idx].update.val = 1;
#elif CONFIG_IDF_TARGET_ESP32
uint32_t intr_status = TIMERG0.int_st_timers.val;
TIMERG0.hw_timer[timer_idx].update = 1;
#endif
/* Clear the interrupt */
if ((intr_status & BIT(timer_idx)) && timer_idx == TIMER_0) {
#if CONFIG_IDF_TARGET_ESP32C3
TIMERG0.int_clr.t0 = 1;
#elif CONFIG_IDF_TARGET_ESP32
TIMERG0.int_clr_timers.t0 = 1;
} else if ((intr_status & BIT(timer_idx)) && timer_idx == TIMER_1) {
TIMERG0.int_clr_timers.t1 = 1;
#endif
}
/* After the alarm has been triggered
we need enable it again, so it is triggered the next time */
TIMERG0.hw_timer[timer_idx].config.alarm_en = TIMER_ALARM_EN;
} else if (HW_TIMER_GROUP == TIMER_GROUP_1) {
#if CONFIG_IDF_TARGET_ESP32C3
uint32_t intr_status = TIMERG1.int_st.val;
TIMERG1.hw_timer[timer_idx].update.val = 1;
#elif CONFIG_IDF_TARGET_ESP32
uint32_t intr_status = TIMERG1.int_st_timers.val;
TIMERG1.hw_timer[timer_idx].update = 1;
#endif
if ((intr_status & BIT(timer_idx)) && timer_idx == TIMER_0) {
#if CONFIG_IDF_TARGET_ESP32C3
TIMERG1.int_clr.t0 = 1;
#elif CONFIG_IDF_TARGET_ESP32
TIMERG1.int_clr_timers.t0 = 1;
} else if ((intr_status & BIT(timer_idx)) && timer_idx == TIMER_1) {
TIMERG1.int_clr_timers.t1 = 1;
#endif
}
TIMERG1.hw_timer[timer_idx].config.alarm_en = TIMER_ALARM_EN;

Wyświetl plik

@ -95,7 +95,11 @@ esp_err_t light_driver_init(light_driver_config_t *config)
g_light_status.brightness = 30;
}
#if CONFIG_IDF_TARGET_ESP32C3
iot_led_init(LEDC_TIMER_0, LEDC_LOW_SPEED_MODE, 1000);
#elif CONFIG_IDF_TARGET_ESP32
iot_led_init(LEDC_TIMER_0, LEDC_HIGH_SPEED_MODE, 1000);
#endif
g_light_status.fade_period_ms = config->fade_period_ms;
g_light_status.blink_period_ms = config->blink_period_ms;