kopia lustrzana https://github.com/espressif/esp-idf
refactor(uart): make uart driver as component, and fix astyle
rodzic
62a0b52a91
commit
6ad80f0332
|
@ -63,8 +63,7 @@ endif()
|
|||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
PRIV_REQUIRES soc esp_driver_gptimer esp_driver_gpio
|
||||
driver # TODO: replace with esp_driver_uart (IDF-8384)
|
||||
PRIV_REQUIRES esp_driver_gptimer esp_driver_gpio esp_driver_uart
|
||||
REQUIRES esp_timer
|
||||
LDFRAGMENTS linker.lf)
|
||||
|
||||
|
|
|
@ -785,7 +785,7 @@ idf_component_register(SRCS "${srcs}"
|
|||
INCLUDE_DIRS "${include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
REQUIRES esp_timer esp_wifi
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls driver vfs
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls esp_driver_uart vfs esp_ringbuf
|
||||
LDFRAGMENTS "${ldfragments}")
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
|
|
|
@ -28,4 +28,6 @@ idf_component_register(SRCS "commands.c"
|
|||
${argtable_srcs}
|
||||
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
REQUIRES vfs
|
||||
PRIV_REQUIRES driver)
|
||||
PRIV_REQUIRES esp_driver_uart
|
||||
driver # to be replaced by esp_driver_usj
|
||||
)
|
||||
|
|
|
@ -14,7 +14,6 @@ set(includes "deprecated"
|
|||
"parlio/include"
|
||||
"touch_sensor/include"
|
||||
"twai/include"
|
||||
"uart/include"
|
||||
"usb_serial_jtag/include")
|
||||
|
||||
# Always included linker fragments
|
||||
|
@ -101,13 +100,6 @@ if(CONFIG_SOC_TWAI_SUPPORTED)
|
|||
list(APPEND ldfragments "twai/linker.lf")
|
||||
endif()
|
||||
|
||||
# UART related source files
|
||||
if(CONFIG_SOC_UART_SUPPORTED)
|
||||
list(APPEND srcs "uart/uart.c")
|
||||
|
||||
list(APPEND ldfragments "uart/linker.lf")
|
||||
endif()
|
||||
|
||||
# USB Serial JTAG related source files
|
||||
if(CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED)
|
||||
list(APPEND srcs "usb_serial_jtag/usb_serial_jtag.c"
|
||||
|
@ -135,6 +127,7 @@ else()
|
|||
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_tsens esp_driver_sdm esp_driver_i2c
|
||||
esp_driver_uart
|
||||
LDFRAGMENTS ${ldfragments}
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -64,8 +64,6 @@ menu "Driver Configurations"
|
|||
|
||||
orsource "./twai/Kconfig.twai"
|
||||
|
||||
orsource "./uart/Kconfig.uart"
|
||||
|
||||
menu "USB Serial/JTAG Configuration"
|
||||
depends on SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
config USJ_NO_AUTO_LS_ON_CONNECTION
|
||||
|
|
|
@ -78,14 +78,6 @@ components/driver/test_apps/parlio:
|
|||
temporary: true
|
||||
reason: lack of runner
|
||||
|
||||
components/driver/test_apps/rs485:
|
||||
disable:
|
||||
- if: SOC_UART_SUPPORTED != 1
|
||||
disable_test:
|
||||
- if: IDF_TARGET != "esp32"
|
||||
temporary: true
|
||||
reason: lack of runners
|
||||
|
||||
components/driver/test_apps/touch_sensor_v1:
|
||||
disable:
|
||||
- if: SOC_TOUCH_SENSOR_VERSION != 1
|
||||
|
@ -98,10 +90,6 @@ components/driver/test_apps/twai:
|
|||
disable:
|
||||
- if: SOC_TWAI_SUPPORTED != 1
|
||||
|
||||
components/driver/test_apps/uart:
|
||||
disable:
|
||||
- if: SOC_UART_SUPPORTED != 1
|
||||
|
||||
components/driver/test_apps/usb_serial_jtag:
|
||||
disable:
|
||||
- if: SOC_USB_SERIAL_JTAG_SUPPORTED != 1
|
||||
|
|
|
@ -8,3 +8,5 @@ components/esp_driver_gpio/test_apps/gpio_extensions:
|
|||
enable:
|
||||
- if: SOC_DEDICATED_GPIO_SUPPORTED == 1
|
||||
- if: SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER == 1 or SOC_GPIO_FLEX_GLITCH_FILTER_NUM > 0
|
||||
depends_components:
|
||||
- esp_driver_gpio
|
||||
|
|
|
@ -11,6 +11,6 @@ endif()
|
|||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
PRIV_REQUIRES "esp_pm"
|
||||
REQUIRES "esp_pm"
|
||||
LDFRAGMENTS "linker.lf"
|
||||
)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
set(srcs)
|
||||
set(public_include "include")
|
||||
if(CONFIG_SOC_UART_SUPPORTED)
|
||||
list(APPEND srcs "src/uart.c")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
PRIV_REQUIRES esp_pm esp_driver_gpio esp_ringbuf
|
||||
LDFRAGMENTS "linker.lf"
|
||||
)
|
|
@ -1,4 +1,4 @@
|
|||
menu "UART Configuration"
|
||||
menu "ESP-Driver:UART Configurations"
|
||||
|
||||
config UART_ISR_IN_IRAM
|
||||
bool "Place UART ISR function into IRAM"
|
||||
|
@ -9,4 +9,4 @@ menu "UART Configuration"
|
|||
If this option is not selected, UART interrupt will be disabled for a long time and
|
||||
may cause data lost when doing spi flash operation.
|
||||
|
||||
endmenu # UART Configuration
|
||||
endmenu
|
|
@ -14,10 +14,7 @@ extern "C" {
|
|||
#include "esp_intr_alloc.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
#include "hal/uart_types.h"
|
||||
|
||||
/* @brief When calling `uart_set_pin`, instead of GPIO number, `UART_PIN_NO_CHANGE`
|
|
@ -20,7 +20,6 @@
|
|||
#include "esp_private/critical_section.h"
|
||||
#include "hal/uart_hal.h"
|
||||
#include "hal/gpio_hal.h"
|
||||
#include "hal/clk_tree_ll.h"
|
||||
#include "soc/uart_periph.h"
|
||||
#include "driver/uart.h"
|
||||
#include "driver/gpio.h"
|
||||
|
@ -28,7 +27,6 @@
|
|||
#include "driver/uart_select.h"
|
||||
#include "driver/lp_io.h"
|
||||
#include "esp_private/uart_share_hw_ctrl.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_clk_tree.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_rom_gpio.h"
|
|
@ -0,0 +1,19 @@
|
|||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||
|
||||
components/esp_driver_uart/test_apps/rs485:
|
||||
disable:
|
||||
- if: SOC_UART_SUPPORTED != 1
|
||||
disable_test:
|
||||
- if: IDF_TARGET != "esp32"
|
||||
temporary: true
|
||||
reason: lack of runners
|
||||
depends_components:
|
||||
- esp_driver_uart
|
||||
- esp_driver_gpio
|
||||
|
||||
components/esp_driver_uart/test_apps/uart:
|
||||
disable:
|
||||
- if: SOC_UART_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_uart
|
||||
- esp_driver_gpio
|
|
@ -2,6 +2,6 @@
|
|||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(
|
||||
SRCS "test_app_main.c" "test_rs485.c"
|
||||
REQUIRES driver unity test_utils
|
||||
REQUIRES esp_driver_uart unity test_utils
|
||||
WHOLE_ARCHIVE
|
||||
)
|
|
@ -5,30 +5,21 @@
|
|||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_test_runner.h"
|
||||
#include "unity_test_utils.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#define TEST_MEMORY_LEAK_THRESHOLD (200)
|
||||
|
||||
static size_t before_free_8bit;
|
||||
static size_t before_free_32bit;
|
||||
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
unity_utils_record_free_mem();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
printf("\n");
|
||||
unity_utils_check_leak(before_free_8bit, after_free_8bit, "8BIT", TEST_MEMORY_LEAK_THRESHOLD);
|
||||
unity_utils_check_leak(before_free_32bit, after_free_32bit, "32BIT", TEST_MEMORY_LEAK_THRESHOLD);
|
||||
esp_reent_cleanup(); //clean up some of the newlib's lazy allocations
|
||||
unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD);
|
||||
}
|
||||
|
||||
void app_main(void)
|
|
@ -111,7 +111,6 @@ static const uint8_t crc_low[] = {
|
|||
0x40
|
||||
};
|
||||
|
||||
|
||||
// Calculate buffer checksum using tables
|
||||
// The checksum CRC16 algorithm is specific
|
||||
// for Modbus standard and uses polynomial value = 0xA001
|
||||
|
@ -123,8 +122,7 @@ static uint16_t get_buffer_crc16( uint8_t * frame_ptr, uint16_t length )
|
|||
uint8_t crc_low_byte = 0xFF;
|
||||
int index;
|
||||
|
||||
while ( length-- )
|
||||
{
|
||||
while (length--) {
|
||||
index = crc_low_byte ^ *(frame_ptr++);
|
||||
crc_low_byte = crc_hi_byte ^ crc_hi[index];
|
||||
crc_hi_byte = crc_low[index];
|
||||
|
@ -268,8 +266,7 @@ static void rs485_master(void)
|
|||
err_count++;
|
||||
printf("Errors: %d\r\n", err_count);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("Incorrect answer from slave, length = %d.\r\n", len);
|
||||
err_count++;
|
||||
}
|
|
@ -12,7 +12,7 @@ project(uart_test)
|
|||
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
||||
add_custom_target(check_test_app_sections ALL
|
||||
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
|
||||
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/
|
||||
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_uart/,${CMAKE_BINARY_DIR}/esp-idf/hal/
|
||||
--elf-file ${CMAKE_BINARY_DIR}/uart_test.elf
|
||||
find-refs
|
||||
--from-sections=.iram0.text
|
|
@ -2,6 +2,6 @@
|
|||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(
|
||||
SRCS "test_app_main.c" "test_uart.c"
|
||||
REQUIRES driver unity
|
||||
REQUIRES esp_driver_uart unity
|
||||
WHOLE_ARCHIVE
|
||||
)
|
|
@ -5,29 +5,21 @@
|
|||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_test_runner.h"
|
||||
#include "unity_test_utils.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#define TEST_MEMORY_LEAK_THRESHOLD (200)
|
||||
|
||||
static size_t before_free_8bit;
|
||||
static size_t before_free_32bit;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
unity_utils_record_free_mem();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
printf("\n");
|
||||
unity_utils_check_leak(before_free_8bit, after_free_8bit, "8BIT", TEST_MEMORY_LEAK_THRESHOLD);
|
||||
unity_utils_check_leak(before_free_32bit, after_free_32bit, "32BIT", TEST_MEMORY_LEAK_THRESHOLD);
|
||||
esp_reent_cleanup(); //clean up some of the newlib's lazy allocations
|
||||
unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD);
|
||||
}
|
||||
|
||||
void app_main(void)
|
|
@ -19,5 +19,5 @@ endif()
|
|||
# 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}
|
||||
REQUIRES unity driver test_utils efuse
|
||||
REQUIRES unity esp_driver_gpio esp_driver_gptimer esp_driver_uart test_utils efuse
|
||||
WHOLE_ARCHIVE)
|
||||
|
|
|
@ -4,5 +4,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
|
||||
PRIV_REQUIRES unity esp_driver_uart
|
||||
WHOLE_ARCHIVE)
|
||||
|
|
|
@ -4,5 +4,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}
|
||||
REQUIRES unity driver test_utils
|
||||
REQUIRES unity esp_driver_gpio test_utils
|
||||
WHOLE_ARCHIVE)
|
||||
|
|
|
@ -4,5 +4,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
|
||||
PRIV_REQUIRES unity esp_driver_uart driver
|
||||
WHOLE_ARCHIVE)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
set(requires "unity"
|
||||
"test_utils"
|
||||
"driver"
|
||||
"esp_driver_uart"
|
||||
"esp_driver_gpio"
|
||||
"esp_timer"
|
||||
"nvs_flash"
|
||||
"esp_psram")
|
||||
|
|
|
@ -196,7 +196,7 @@ idf_component_register(SRC_DIRS "${src_dirs}"
|
|||
EXCLUDE_SRCS "${exclude_srcs}"
|
||||
INCLUDE_DIRS "${public_include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${private_include_dirs}"
|
||||
REQUIRES esp_netif lwip driver
|
||||
REQUIRES esp_netif lwip esp_driver_uart driver
|
||||
LDFRAGMENTS linker.lf
|
||||
PRIV_REQUIRES console esp_event esp_partition esp_timer
|
||||
ieee802154 mbedtls nvs_flash)
|
||||
|
|
|
@ -11,6 +11,7 @@ list(APPEND sources "vfs.c"
|
|||
"vfs_console.c")
|
||||
|
||||
list(APPEND pr driver
|
||||
esp_driver_uart
|
||||
esp_timer)
|
||||
|
||||
idf_component_register(SRCS ${sources}
|
||||
|
|
|
@ -78,7 +78,6 @@ INPUT = \
|
|||
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_types.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 \
|
||||
$(PROJECT_PATH)/components/driver/test_apps/components/esp_serial_slave_link/include/esp_serial_slave_link/essl_sdio.h \
|
||||
$(PROJECT_PATH)/components/driver/test_apps/components/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h \
|
||||
$(PROJECT_PATH)/components/driver/test_apps/components/esp_serial_slave_link/include/esp_serial_slave_link/essl.h \
|
||||
|
@ -143,6 +142,7 @@ INPUT = \
|
|||
$(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_driver_uart/include/driver/uart.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 \
|
||||
|
|
|
@ -20,6 +20,7 @@ In order to control the dependence of other components on drivers at a smaller g
|
|||
- `esp_driver_tsens` - Driver for Temperature Sensor
|
||||
- `esp_driver_sdm` - Driver for Sigma-Delta Modulator
|
||||
- `esp_driver_i2c` - Driver for I2C
|
||||
- `esp_driver_uart` - Driver for UART
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
- `esp_driver_tsens` - 温度传感器驱动
|
||||
- `esp_driver_sdm` - Sigma-Delta 调制器驱动
|
||||
- `esp_driver_i2c` - I2C 驱动
|
||||
- `esp_driver_uart` - UART 驱动
|
||||
|
||||
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ examples/bluetooth/bluedroid/classic_bt:
|
|||
- vfs
|
||||
- esp_driver_gpio
|
||||
- esp_driver_i2s
|
||||
- esp_driver_uart
|
||||
depends_filepatterns:
|
||||
- components/driver/dac/**/*
|
||||
- components/driver/uart/**/*
|
||||
|
||||
examples/bluetooth/bluedroid/coex/a2dp_gatts_coex:
|
||||
<<: *bt_default_depends
|
||||
|
@ -134,15 +134,15 @@ examples/bluetooth/hci/controller_hci_uart_esp32:
|
|||
<<: *bt_default_depends
|
||||
enable:
|
||||
- if: IDF_TARGET == "esp32"
|
||||
depends_filepatterns:
|
||||
- components/driver/uart/**/*
|
||||
depends_components:
|
||||
- esp_driver_uart
|
||||
|
||||
examples/bluetooth/hci/controller_hci_uart_esp32c3_and_esp32s3:
|
||||
<<: *bt_default_depends
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32c3", "esp32s3"]
|
||||
depends_filepatterns:
|
||||
- components/driver/uart/**/*
|
||||
depends_components:
|
||||
- esp_driver_uart
|
||||
|
||||
|
||||
# config BT_NIMBLE_ENABLED does not depends on any soc cap
|
||||
|
@ -256,7 +256,7 @@ examples/bluetooth/nimble/throughput_app:
|
|||
- if: SOC_BLE_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_gpio
|
||||
- esp_driver_uart
|
||||
depends_filepatterns:
|
||||
- examples/bluetooth/nimble/common/**/*
|
||||
- examples/bluetooth/nimble/throughput_app/blecent_throughput/components/**/*
|
||||
- components/driver/uart/**/*
|
||||
|
|
|
@ -65,8 +65,8 @@ examples/wifi/power_save:
|
|||
<<: *wifi_depends_default
|
||||
disable:
|
||||
- if: SOC_WIFI_SUPPORTED != 1
|
||||
depends_filepatterns:
|
||||
- components/driver/uart/**/*
|
||||
depends_components:
|
||||
- esp_driver_uart
|
||||
|
||||
examples/wifi/wifi_aware:
|
||||
disable:
|
||||
|
|
Ładowanie…
Reference in New Issue