diff --git a/components/esp_driver_dac/dac_common.c b/components/esp_driver_dac/dac_common.c index 18b7c716ae5..afcb15c7345 100644 --- a/components/esp_driver_dac/dac_common.c +++ b/components/esp_driver_dac/dac_common.c @@ -28,8 +28,6 @@ static dac_channel_info_t s_dac_chan[SOC_DAC_CHAN_NUM] = { .mode = NULL, } }; -/* Global dac spin lock for the whole DAC driver */ -portMUX_TYPE dac_spinlock = portMUX_INITIALIZER_UNLOCKED; static const char *TAG = "dac_common"; diff --git a/examples/peripherals/gpio/matrix_keyboard/components/matrix_keyboard/src/matrix_keyboard.c b/examples/peripherals/gpio/matrix_keyboard/components/matrix_keyboard/src/matrix_keyboard.c index 48b7a23506e..156f0512124 100644 --- a/examples/peripherals/gpio/matrix_keyboard/components/matrix_keyboard/src/matrix_keyboard.c +++ b/examples/peripherals/gpio/matrix_keyboard/components/matrix_keyboard/src/matrix_keyboard.c @@ -11,7 +11,6 @@ #include "esp_check.h" #include "driver/dedic_gpio.h" #include "driver/gpio.h" -#include "esp_private/gpio.h" #include "matrix_keyboard.h" static const char *TAG = "mkbd"; diff --git a/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/idf_component.yml b/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/idf_component.yml index aaa5f704b6a..9400a25447c 100644 --- a/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/idf_component.yml +++ b/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/idf_component.yml @@ -1,3 +1,3 @@ dependencies: - pid_ctrl: "^0.1.1" + pid_ctrl: "^0.3.0" bdc_motor: "^0.2.0" diff --git a/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/mcpwm_bdc_control_example_main.c b/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/mcpwm_bdc_control_example_main.c index 228f03fd154..6e256c3e37a 100644 --- a/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/mcpwm_bdc_control_example_main.c +++ b/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/mcpwm_bdc_control_example_main.c @@ -17,7 +17,7 @@ static const char *TAG = "example"; -// Enable this config, we will print debug formated string, which in return can be captured and parsed by Serial-Studio +// Enable this config, we will print debug formatted string, which in return can be captured and parsed by Serial-Studio #define SERIAL_STUDIO_DEBUG CONFIG_SERIAL_STUDIO_DEBUG #define BDC_MCPWM_TIMER_RESOLUTION_HZ 10000000 // 10MHz, 1 tick = 0.1us @@ -37,7 +37,7 @@ static const char *TAG = "example"; typedef struct { bdc_motor_handle_t motor; pcnt_unit_handle_t pcnt_encoder; - pid_ctrl_block_handle_t pid_ctrl; + pid_ctrl_block_handle_f_t pid_ctrl; int report_pulses; } motor_control_context_t; @@ -46,7 +46,7 @@ static void pid_loop_cb(void *args) static int last_pulse_count = 0; motor_control_context_t *ctx = (motor_control_context_t *)args; pcnt_unit_handle_t pcnt_unit = ctx->pcnt_encoder; - pid_ctrl_block_handle_t pid_ctrl = ctx->pid_ctrl; + pid_ctrl_block_handle_f_t pid_ctrl = ctx->pid_ctrl; bdc_motor_handle_t motor = ctx->motor; // get the result from rotary encoder @@ -121,7 +121,7 @@ void app_main(void) motor_ctrl_ctx.pcnt_encoder = pcnt_unit; ESP_LOGI(TAG, "Create PID control block"); - pid_ctrl_parameter_t pid_runtime_param = { + pid_ctrl_parameter_f_t pid_runtime_param = { .kp = 0.6, .ki = 0.4, .kd = 0.2, @@ -131,8 +131,8 @@ void app_main(void) .max_integral = 1000, .min_integral = -1000, }; - pid_ctrl_block_handle_t pid_ctrl = NULL; - pid_ctrl_config_t pid_config = { + pid_ctrl_block_handle_f_t pid_ctrl = NULL; + pid_ctrl_config_f_t pid_config = { .init_param = pid_runtime_param, }; ESP_ERROR_CHECK(pid_new_control_block(&pid_config, &pid_ctrl)); diff --git a/examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c b/examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c index 6e635af2ca5..1be04a7254d 100644 --- a/examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c +++ b/examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c @@ -7,7 +7,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_log.h" -#include "esp_private/esp_clk.h" #include "driver/mcpwm_cap.h" #include "driver/gpio.h" @@ -99,13 +98,16 @@ void app_main(void) ESP_ERROR_CHECK(mcpwm_capture_timer_enable(cap_timer)); ESP_ERROR_CHECK(mcpwm_capture_timer_start(cap_timer)); + uint32_t cap_timer_resolution; + ESP_ERROR_CHECK(mcpwm_capture_timer_get_resolution(cap_timer, &cap_timer_resolution)); + uint32_t tof_ticks; while (1) { // trigger the sensor to start a new sample gen_trig_output(); // wait for echo done signal if (xTaskNotifyWait(0x00, ULONG_MAX, &tof_ticks, pdMS_TO_TICKS(1000)) == pdTRUE) { - float pulse_width_us = tof_ticks * (1000000.0 / esp_clk_apb_freq()); + float pulse_width_us = tof_ticks * (1000000.0 / cap_timer_resolution); if (pulse_width_us > 35000) { // out of range continue; diff --git a/tools/ci/sg_rules/no_esp_private_header_in_examples.yml b/tools/ci/sg_rules/no_esp_private_header_in_examples.yml new file mode 100644 index 00000000000..eb0f461b650 --- /dev/null +++ b/tools/ci/sg_rules/no_esp_private_header_in_examples.yml @@ -0,0 +1,40 @@ +# Refer to https://ast-grep.github.io/guide/rule-config.html for Rule Essentials +id: no-esp-private-header-in-c-examples +message: Don't include esp_private headers in the examples +severity: error # error, warning, info, hint +note: esp_private headers are internal to ESP-IDF and are not guaranteed to be stable across versions. +language: C +files: + - "examples/**/*" +ignores: + - "examples/network/eth2ap/main/ethernet_example_main.c" + - "examples/network/sta2eth/main/sta2eth_main.c" + - "examples/openthread/ot_sleepy_device/light_sleep/main/esp_ot_sleepy_device.c" + - "examples/peripherals/usb/device/tusb_ncm/main/tusb_ncm_main.c" + - "examples/wifi/itwt/main/wifi_stats_cmd.c" + - "examples/wifi/wifi_aware/nan_console/main/nan_main.c" + - "examples/peripherals/usb/device/tusb_cdc_acm_wakeup/main/tusb_cdc_acm_wakeup_main.c" +rule: + kind: preproc_include + has: + field: path + regex: "esp_private/.*h" + pattern: $N +fix: '' + +--- + +id: no-esp-private-header-in-cpp-examples +message: Don't include esp_private headers in the examples +severity: error # error, warning, info, hint +note: esp_private headers are internal to ESP-IDF and are not guaranteed to be stable across versions. +language: Cpp +files: + - "examples/**/*" +rule: + kind: preproc_include + has: + field: path + regex: "esp_private/.*h" + pattern: $N +fix: ''