将~\esp-idf\examples\get-started\hello_world下面所有的文件 (三个吧)复制到你自己刚才建立的app目录下,选择 覆盖粘贴,然后 对左侧总目录右击,选择 Refresh 更新一下,现在你也可以编译了,不过是人家的,(编译时间太长了,如果你想试验自己的代码的话,还是先修改吧。)以后写程序的步骤基本就是这样。要是改名字的话可以去Makefile文件里改一下(其他地方可能也要改,自己摸索一下)。
它的代码如下:
1 /* Hello World Example
2
3 This example code is in the Public Domain (or CC0 licensed, at your option.)
4
5 Unless required by applicable law or agreed to in writing, this
6 software is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
7 CONDITIONS OF ANY KIND, either express or implied.
8 */
9 #include 《stdio.h》
10 #include “freertos/FreeRTOS.h”
11 #include “freertos/task.h”
12 #include “esp_system.h”
13 #include “esp_spi_flash.h”
14
15
16 void app_main()
17 {
18 printf(“Hello world!\n”);//串口打印
19
20 /* Print chip information */
21 esp_chip_info_t chip_info;
22 esp_chip_info(&chip_info);
23 printf(“This is ESP32 chip with %d CPU cores, WiFi%s%s, ”,
24 chip_info.cores,
25 (chip_info.features & CHIP_FEATURE_BT) ? “/BT” : “”,
26 (chip_info.features & CHIP_FEATURE_BLE) ? “/BLE” : “”);
27
28 printf(“silicon revision %d, ”, chip_info.revision);
29
30 printf(“%dMB %s flash\n”, spi_flash_get_chip_size() / (1024 * 1024),
31 (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? “embedded” : “external”);