完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我开始按照 PCBreflux 的教程在 esp32 上与 FreeRTOS 进行任务间通信,但我无法在 VS Code 中使用 esp-idf 构建示例,因为其中两个头文件引发了 No such file or directory 错误 :
Code: Select all #include "esp_heap_alloc_caps.h" #include "freertos/heap_regions.h" 经过一些研究,我发现“esp_heap_caps.h”可以替换“esp_heap_alloc_caps.h”(有人可以证实吗?)这确实消除了部分编译错误。 但是“freertos/heap_regions.h”仍然给我带来问题。 即使我手动添加此头文件,我也会收到对 xPortGetFreeHeapSizeTagged 的未定义引用编译错误。 我该如何解决这个问题? 这是我的 c_cpp_properties.json 文件: Code: Select all { "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "intelliSenseMode": "windows-msvc-x64", "compileCommands": "${workspaceFolder}/build/compile_commands.json" }, { "name": "ESP-IDF", "compilerPath": "c:\Users\arthu\.espressif\tools\xtensa-esp32-elf\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe", "cStandard": "c11", "cppStandard": "c++17", "includePath": [ "${config:idf.espIdfPath}/components/**", "${config:idf.espIdfPathWin}/components/**", "${config:idf.espAdfPath}/components/**", "${config:idf.espAdfPathWin}/components/**", "${workspaceFolder}/**" ], "browse": { "path": [ "${config:idf.espIdfPath}/components", "${config:idf.espIdfPathWin}/components", "${config:idf.espAdfPath}/components/**", "${config:idf.espAdfPathWin}/components/**", "${workspaceFolder}" ], "limitSymbolsToIncludedHeaders": false }, "configurationProvider": "ms-vscode.makefile-tools" } ], "version": 4 } 我main文件夹下面的 CMakeLists.txt : Code: Select all idf_component_register(SRCS "queue_main.c" INCLUDE_DIRS ".") 我项目文件夹下面的 CMakeLists.txt : Code: Select all cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(main) queue_main的代码: Code: Select all #include #include #include #include "sdkconfig.h" #include "esp_system.h" #include "esp_heap_caps.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/queue.h" #include "freertos/heap_regions.h" #define COLOR_PRINT_BLACK "30" #define COLOR_PRINT_RED "31" #define COLOR_PRINT_GREEN "32" #define COLOR_PRINT_BROWN "33" #define COLOR_PRINT_BLUE "34" #define COLOR_PRINT_PURPLE "35" #define COLOR_PRINT_CYAN "36" #define color_printf(COLOR, format, ...) { printf(" 33[0;" COLOR "m" format " 33[0mn", ##__VA_ARGS__); } xQueueHandle demo_queue; void tx_task1(void *arg) { uint32_t txpos = 0; color_printf(COLOR_PRINT_BLUE, "tx_task1"); while (1) { color_printf(COLOR_PRINT_BLUE, "free DRAM %u IRAM %u", esp_get_free_heap_size(), xPortGetFreeHeapSizeTagged(MALLOC_CAP_32BIT)); color_printf(COLOR_PRINT_BLUE, "tx_task1 notify %d", txpos); if (xQueueSendToBack(demo_queue, &txpos, 1000 / portTICK_RATE_MS) != pdTRUE) { color_printf(COLOR_PRINT_RED, "tx_task1 fail to queue value %d", txpos); } vTaskDelay(10000 / portTICK_RATE_MS); // delay 10s txpos++; } } void tx_task2(void *arg) { uint32_t txpos = 0; color_printf(COLOR_PRINT_CYAN, "ttx_task2"); while (1) { color_printf(COLOR_PRINT_CYAN, "tfree DRAM %u IRAM %u", esp_get_free_heap_size(), xPortGetFreeHeapSizeTagged(MALLOC_CAP_32BIT)); color_printf(COLOR_PRINT_CYAN, "ttx_task2 notify %d", txpos); if (xQueueSendToBack(demo_queue, &txpos, 1000 / portTICK_RATE_MS) != pdTRUE) { color_printf(COLOR_PRINT_RED, "ttx_task2 fail to queue value %d", txpos); } vTaskDelay(7000 / portTICK_RATE_MS); // delay 7s txpos++; } } void rx_task(void *arg) { uint32_t rxpos; color_printf(COLOR_PRINT_GREEN, "ttrx_task"); while (1) { color_printf(COLOR_PRINT_GREEN, "ttrx_task queue yield"); if (xQueueReceive(demo_queue, &rxpos, 60000 / portTICK_RATE_MS) != pdTRUE) { // max wait 60s color_printf(COLOR_PRINT_RED, "ttfail to receive queued value"); } else { color_printf(COLOR_PRINT_GREEN, "ttfree DRAM %u IRAM %u", esp_get_free_heap_size(), xPortGetFreeHeapSizeTagged(MALLOC_CAP_32BIT)); color_printf(COLOR_PRINT_GREEN, "ttrx_task get queued value %d", rxpos); } if (uxQueueMessagesWaiting(demo_queue) == 0) { // no message? take a break vTaskDelay(15000 / portTICK_RATE_MS); // delay 15s } } } void app_main() { color_printf(COLOR_PRINT_PURPLE, "start ESP32"); color_printf(COLOR_PRINT_PURPLE, "free DRAM %u IRAM %u", esp_get_free_heap_size(), xPortGetFreeHeapSizeTagged(MALLOC_CAP_32BIT)); demo_queue = xQueueCreate(10, sizeof(uint32_t)); color_printf(COLOR_PRINT_PURPLE, "free DRAM %u IRAM %u", esp_get_free_heap_size(), xPortGetFreeHeapSizeTagged(MALLOC_CAP_32BIT)); color_printf(COLOR_PRINT_PURPLE, "create three tasks"); xTaskCreate(tx_task1, "tx_task1", CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE, NULL, 5, NULL); xTaskCreate(tx_task2, "tx_task2", CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE, NULL, 5, NULL); xTaskCreate(rx_task, "rx_task", CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE, NULL, 5, NULL); color_printf(COLOR_PRINT_PURPLE, "end of main"); } 如果我应该提供更多详细信息,请告诉我。 |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
166个成员聚集在这个小组
加入小组1149 浏览 1 评论
582浏览 6评论
480浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
465浏览 5评论
466浏览 4评论
441浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 23:53 , Processed in 0.620164 second(s), Total 41, Slave 36 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号