- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.3k
Esp32c3 app update #10780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Esp32c3 app update #10780
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -9,3 +9,53 @@ PKGS_DIR := packages | |
| source "$(RTT_DIR)/Kconfig" | ||
| osource "$PKGS_DIR/Kconfig" | ||
| rsource "drivers/Kconfig" | ||
| # In bsp/ESP32_C3/Kconfig | ||
|  | ||
| # Look for the section related to board peripherals or drivers | ||
|  | ||
| menu "Board Level Drivers" | ||
|  | ||
| # 1. Define the option that allows the user to input the pin number | ||
| config RT_BSP_LED_PIN | ||
| int "Onboard LED Pin (GPIO Number)" | ||
| default 21 # Set a common default (e.g., GPIO 21 is often used on ESP32 boards) | ||
| range 0 40 # Set a valid range for ESP32 GPIO pins (0-40) | ||
| help | ||
| This sets the GPIO number for the on-board LED. | ||
| Check your ESP32-C3 board schematic for the correct pin. | ||
|  | ||
| endmenu # Board Level Drivers | ||
|  | ||
| menu "ESP32-C3 On-Chip Drivers" | ||
|  | ||
| # BLE Dependency | ||
| config BSP_USING_BLE | ||
| bool "Enable Bluetooth Low Energy (BLE) Support" | ||
| default y | ||
| select ESP32C3_BLE_DRV # Link to the underlying chip driver config (name may vary) | ||
| help | ||
| Enable this to include the necessary BLE drivers and compile | ||
| the BLE-related code blocks in main.c (via #ifdef BSP_USING_BLE). | ||
|  | ||
| # WiFi Dependency | ||
| config RT_USING_WIFI | ||
| bool "Enable Wi-Fi Support" | ||
| default y | ||
| select RT_USING_WIFI_DRIVER_ESP32C3 # Link to the underlying driver config (name may vary) | ||
| 
     | ||
| help | ||
| Enable this to include the Wi-Fi framework and driver support | ||
| for network functionality. | ||
|  | ||
| endmenu # ESP32-C3 On-Chip Drivers | ||
|  | ||
| # -------------------------------------------------------------------------- | ||
| # Optional: Ensure core features are enabled when necessary | ||
| # -------------------------------------------------------------------------- | ||
|  | ||
| # If your custom feature requires msh, you can select it like this: | ||
| config BSP_USING_APP_COMMANDS | ||
| bool "Enable Custom Application Commands (app_data_cmd)" | ||
| default y | ||
| select FINSH_USING_MSH # This ensures the FinSH msh mode is enabled if this is selected | ||
| help | ||
| This enables the app_data_cmd function in main.c, which relies on the FinSH shell. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,46 @@ | ||||||
|  | ||||||
| #include <rtthread.h> | ||||||
| #include <stdlib.h> // For atoi() | ||||||
| #include <finsh.h> // For MSH_CMD_EXPORT | ||||||
|  | ||||||
| // The global variable you want to expose to FinSH | ||||||
| // NOTE: It must be a global or static global variable. | ||||||
| int app_data_value = 100; | ||||||
|  | ||||||
| // Function to handle reading and setting the variable | ||||||
| // All FinSH commands in msh mode must have this signature: (int argc, char **argv) | ||||||
| void app_data_cmd(int argc, char **argv) | ||||||
| { | ||||||
| // Check if the FinSH C-style interpreter is disabled | ||||||
| #ifndef FINSH_USING_MSH | ||||||
| rt_kprintf("Error: This command requires msh mode enabled.\n"); | ||||||
| return; | ||||||
| #endif | ||||||
|  | ||||||
| if (argc == 1) | ||||||
| { | ||||||
| // Case 1: No arguments (e.g., 'app_data_cmd') -> Read the current value | ||||||
| rt_kprintf("app_data_value (current): %d\n", app_data_value); | ||||||
| } | ||||||
| else if (argc == 2) | ||||||
| { | ||||||
| // Case 2: One argument (e.g., 'app_data_cmd 250') -> Set a new value | ||||||
| int new_value = atoi(argv[1]); | ||||||
| app_data_value = new_value; | ||||||
| rt_kprintf("app_data_value set to: %d\n", app_data_value); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| // Case 3: Invalid number of arguments | ||||||
| rt_kprintf("Usage:\n"); | ||||||
| rt_kprintf(" Read: app_data_cmd\n"); | ||||||
| rt_kprintf(" Write: app_data_cmd <value>\n"); | ||||||
| } | ||||||
| } | ||||||
|  | ||||||
| // Export the function as a FinSH command. | ||||||
| // Format: MSH_CMD_EXPORT(function_name, description) | ||||||
| MSH_CMD_EXPORT(app_data_cmd, Get or set the application data value); | ||||||
| /* | ||||||
| * Copyright (c) 2021-2022, RT-Thread Development Team | ||||||
| * | ||||||
|  | @@ -9,7 +52,7 @@ | |||||
| * 2022-06-02 supperthomas fix version | ||||||
| * 2023-10-20 WCX1024979076 add wifi application | ||||||
| */ | ||||||
|  | ||||||
| #define RT_BSP_LED_PIN 2 | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redefine 
     | ||||||
| #define RT_BSP_LED_PIN 2 | |
| #include <rtconfig.h> | 
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,13 @@ | ||||||
| #ifndef RT_CONFIG_H__ | ||||||
| #define RT_CONFIG_H__ | ||||||
|  | ||||||
| // Inside bsp/ESP32_C3/board.h | ||||||
| 
     | ||||||
| // Inside bsp/ESP32_C3/board.h | |
| // Board-related configuration options | 
    
      
    
      Copilot
AI
    
    
    
      Oct 11, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug/错误: The LED pin is defined as 'X' which is not a valid GPIO number and will cause compilation errors.
中文:LED引脚定义为'X',这不是有效的GPIO编号,会导致编译错误。
| #define RT_BSP_LED_PIN X | |
| #define RT_BSP_LED_PIN 12 | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2020", | ||
| "module": "commonjs", | ||
| "lib": ["ES2020"], | ||
| "outDir": "./dist", | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ?? what's this file used for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please delete the useless file | ||
| "rootDir": "./", | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "skipLibCheck": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "moduleResolution": "node", | ||
| "types": ["node"] | ||
| }, | ||
| "include": ["**/*.ts"], | ||
| "exclude": ["node_modules"] | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug/错误: The config option 'ESP32C3_BLE_DRV' may not exist in the RT-Thread configuration system, which could cause Kconfig errors.
中文:配置选项'ESP32C3_BLE_DRV'可能在RT-Thread配置系统中不存在,这可能导致Kconfig错误。