Merge branch 'refactor/esp_driver_tsens' into 'master'

refactor(temperature_sensor): Make temperature sensor driver as a seperate component

See merge request espressif/esp-idf!27408
pull/12702/head
C.S.M 2023-11-28 10:39:14 +08:00
commit dbe08fbaae
23 zmienionych plików z 64 dodań i 46 usunięć

Wyświetl plik

@ -13,7 +13,6 @@ set(includes "deprecated"
"ledc/include"
"parlio/include"
"sigma_delta/include"
"temperature_sensor/include"
"touch_sensor/include"
"twai/include"
"uart/include"
@ -95,8 +94,7 @@ endif()
# Temperature Sensor related source files
if(CONFIG_SOC_TEMP_SENSOR_SUPPORTED)
list(APPEND srcs "temperature_sensor/temperature_sensor.c"
"deprecated/rtc_temperature_legacy.c")
list(APPEND srcs "deprecated/rtc_temperature_legacy.c")
endif()
# Touch Sensor related source files
@ -146,7 +144,7 @@ else()
# have a public dependency on other "esp_driver_foo" components
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
esp_driver_ana_cmpr esp_driver_i2s esp_driver_sdmmc esp_driver_sdspi esp_driver_sdio
esp_driver_dac esp_driver_rmt
esp_driver_dac esp_driver_rmt esp_driver_tsens
LDFRAGMENTS ${ldfragments}
)
endif()

Wyświetl plik

@ -64,34 +64,6 @@ menu "Driver Configurations"
orsource "./twai/Kconfig.twai"
menu "Temperature sensor Configuration"
depends on SOC_TEMP_SENSOR_SUPPORTED
config TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Wether to suppress the deprecation warnings when using legacy temperature sensor driver
(driver/temp_sensor.h). If you want to continue using the legacy driver,
and don't want to see related deprecation warnings, you can enable this option.
config TEMP_SENSOR_ENABLE_DEBUG_LOG
bool "Enable debug log"
default n
help
Wether to enable the debug log message for temperature sensor driver.
Note that, this option only controls the temperature sensor driver log, won't affect other drivers.
config TEMP_SENSOR_ISR_IRAM_SAFE
depends on SOC_TEMPERATURE_SENSOR_INTR_SUPPORT
bool "Temperature sensor ISR IRAM-Safe"
default n
help
Ensure the Temperature Sensor interrupt is IRAM-Safe by allowing the interrupt handler to be
executable when the cache is disabled (e.g. SPI Flash write).
endmenu # TEMP_SENSOR Configuration
orsource "./uart/Kconfig.uart"
menu "Sigma Delta Modulator Configuration"

Wyświetl plik

@ -96,10 +96,6 @@ components/driver/test_apps/sigma_delta:
depends_components:
- esp_driver_gpio
components/driver/test_apps/temperature_sensor:
disable:
- if: SOC_TEMP_SENSOR_SUPPORTED != 1
components/driver/test_apps/touch_sensor_v1:
disable:
- if: SOC_TOUCH_SENSOR_VERSION != 1

Wyświetl plik

@ -0,0 +1,11 @@
set(srcs)
set(priv_req efuse)
set(public_include "include")
if(CONFIG_SOC_TEMP_SENSOR_SUPPORTED)
list(APPEND srcs "src/temperature_sensor.c")
endif()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${public_include}
PRIV_REQUIRES ${priv_req}
)

Wyświetl plik

@ -0,0 +1,27 @@
menu "ESP-Driver:Temperature Sensor Configurations"
depends on SOC_TEMP_SENSOR_SUPPORTED
config TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Wether to suppress the deprecation warnings when using legacy temperature sensor driver
(driver/temp_sensor.h). If you want to continue using the legacy driver,
and don't want to see related deprecation warnings, you can enable this option.
config TEMP_SENSOR_ENABLE_DEBUG_LOG
bool "Enable debug log"
default n
help
Wether to enable the debug log message for temperature sensor driver.
Note that, this option only controls the temperature sensor driver log, won't affect other drivers.
config TEMP_SENSOR_ISR_IRAM_SAFE
depends on SOC_TEMPERATURE_SENSOR_INTR_SUPPORT
bool "Temperature sensor ISR IRAM-Safe"
default n
help
Ensure the Temperature Sensor interrupt is IRAM-Safe by allowing the interrupt handler to be
executable when the cache is disabled (e.g. SPI Flash write).
endmenu # TEMP_SENSOR Configuration

Wyświetl plik

@ -76,7 +76,7 @@ static void IRAM_ATTR temperature_sensor_isr(void *arg)
temperature_sensor_ll_clear_intr();
bool cbs_yield = false;
temperature_sensor_handle_t tsens = (temperature_sensor_handle_t) arg;
temperature_val_intr_condition_t intr_condition = (temperature_sensor_ll_get_wakeup_reason() == 1 ? TEMPERATURE_VAL_HIGHER_THAN_HIGH_THRESHOLD: TEMPERATURE_VAL_LOWER_THAN_LOW_THRESHOLD);
temperature_val_intr_condition_t intr_condition = (temperature_sensor_ll_get_wakeup_reason() == 1 ? TEMPERATURE_VAL_HIGHER_THAN_HIGH_THRESHOLD : TEMPERATURE_VAL_LOWER_THAN_LOW_THRESHOLD);
temperature_sensor_threshold_event_data_t data = {
.celsius_value = s_temperature_regval_2_celsius(tsens, temperature_sensor_ll_get_raw_value()),
.intr_condition = intr_condition,
@ -243,7 +243,7 @@ esp_err_t temperature_sensor_get_celsius(temperature_sensor_handle_t tsens, floa
static uint8_t s_temperature_celsius_2_regval(temperature_sensor_handle_t tsens, int8_t celsius)
{
return (uint8_t)((celsius + TEMPERATURE_SENSOR_LL_OFFSET_FACTOR + TEMPERATURE_SENSOR_LL_DAC_FACTOR * tsens->tsens_attribute->offset)/TEMPERATURE_SENSOR_LL_ADC_FACTOR);
return (uint8_t)((celsius + TEMPERATURE_SENSOR_LL_OFFSET_FACTOR + TEMPERATURE_SENSOR_LL_DAC_FACTOR * tsens->tsens_attribute->offset) / TEMPERATURE_SENSOR_LL_ADC_FACTOR);
}
IRAM_ATTR static int8_t s_temperature_regval_2_celsius(temperature_sensor_handle_t tsens, uint8_t regval)
@ -305,8 +305,8 @@ esp_err_t temperature_sensor_register_callbacks(temperature_sensor_handle_t tsen
// lazy install interrupt service.
if (!tsens->temp_sensor_isr_handle) {
ret = esp_intr_alloc_intrstatus(ETS_APB_ADC_INTR_SOURCE, isr_flags,
(uint32_t)temperature_sensor_ll_get_intr_status(),
TEMPERATURE_SENSOR_LL_INTR_MASK, temperature_sensor_isr, tsens, &tsens->temp_sensor_isr_handle);
(uint32_t)temperature_sensor_ll_get_intr_status(),
TEMPERATURE_SENSOR_LL_INTR_MASK, temperature_sensor_isr, tsens, &tsens->temp_sensor_isr_handle);
}
if (cbs->on_threshold != NULL) {

Wyświetl plik

@ -43,7 +43,6 @@ struct temperature_sensor_obj_t {
#endif // SOC_TEMPERATURE_SENSOR_INTR_SUPPORT
};
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -0,0 +1,8 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
components/esp_driver_tsens/test_apps/temperature_sensor:
disable:
- if: SOC_TEMP_SENSOR_SUPPORTED != 1
depends_components:
- esp_driver_tsens
- esp_phy

Wyświetl plik

@ -5,5 +5,5 @@ set(srcs "test_app_main.c"
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity driver esp_wifi test_utils nvs_flash
PRIV_REQUIRES unity esp_wifi test_utils nvs_flash esp_driver_tsens
WHOLE_ARCHIVE)

Wyświetl plik

@ -40,10 +40,11 @@ struct temperature_sensor_obj_t {
static void start_wifi_as_softap(void)
{
uint8_t ssid_len = strlen(TEST_DEFAULT_SSID);
wifi_config_t w_config = {
.ap.ssid = TEST_DEFAULT_SSID,
.ap.password = TEST_DEFAULT_PWD,
.ap.ssid_len = strlen(TEST_DEFAULT_SSID),
.ap.ssid_len = ssid_len,
.ap.channel = TEST_DEFAULT_CHANNEL,
.ap.authmode = WIFI_AUTH_WPA2_PSK,
.ap.ssid_hidden = false,
@ -66,7 +67,7 @@ static void start_wifi_as_sta(void)
static void stop_wifi(void)
{
TEST_ESP_OK(esp_wifi_stop());
vTaskDelay(500/portTICK_PERIOD_MS);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
static void wifi_connect(void)
@ -91,7 +92,7 @@ static void test_wifi_establish_sta(void)
unity_wait_for_signal("AP start");
// make sure softap has started
vTaskDelay(1000/portTICK_PERIOD_MS);
vTaskDelay(1000 / portTICK_PERIOD_MS);
wifi_connect();
unity_send_signal("connect");
unity_wait_for_signal("tsens test done");

Wyświetl plik

@ -80,7 +80,6 @@ INPUT = \
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_tx.h \
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_types.h \
$(PROJECT_PATH)/components/driver/sigma_delta/include/driver/sdm.h \
$(PROJECT_PATH)/components/driver/temperature_sensor/include/driver/temperature_sensor.h \
$(PROJECT_PATH)/components/driver/touch_sensor/include/driver/touch_sensor_common.h \
$(PROJECT_PATH)/components/driver/twai/include/driver/twai.h \
$(PROJECT_PATH)/components/driver/uart/include/driver/uart.h \
@ -143,6 +142,7 @@ INPUT = \
$(PROJECT_PATH)/components/esp_driver_spi/include/driver/spi_master.h \
$(PROJECT_PATH)/components/esp_driver_spi/include/driver/spi_slave_hd.h \
$(PROJECT_PATH)/components/esp_driver_spi/include/driver/spi_slave.h \
$(PROJECT_PATH)/components/esp_driver_tsens/include/driver/temperature_sensor.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_com.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_mac.h \

Wyświetl plik

@ -17,6 +17,7 @@ In order to control the dependence of other components on drivers at a smaller g
- `esp_driver_i2s` - Driver for I2S
- `esp_driver_dac` - Driver for DAC
- `esp_driver_rmt` - Driver for RMT
- `esp_driver_tsens` - Driver for Temperature Sensor
For compatibility, the original `driver`` component is still treated as an all-in-one component by registering these `esp_driver_xyz`` components as its public dependencies. In other words, you do not need to modify the CMake file of an existing project, but you now have a way to specify the specific peripheral driver that your project depends on.

Wyświetl plik

@ -17,6 +17,7 @@
- `esp_driver_i2s` - I2S 驱动
- `esp_driver_dac` - DAC 驱动
- `esp_driver_rmt` - RMT 驱动
- `esp_driver_tsens` - 温度传感器驱动
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。

Wyświetl plik

@ -322,10 +322,14 @@ examples/peripherals/spi_slave_hd/segment_mode/seg_slave:
examples/peripherals/temperature_sensor/temp_sensor:
disable:
- if: SOC_TEMP_SENSOR_SUPPORTED != 1
depends_components:
- esp_driver_tsens
examples/peripherals/temperature_sensor/temp_sensor_monitor:
disable:
- if: SOC_TEMPERATURE_SENSOR_INTR_SUPPORT != 1
depends_components:
- esp_driver_tsens
examples/peripherals/timer_group/gptimer:
disable: