语言:

安信可科技

您的足迹: Hello World

Hello World

Hello World

本示例演示如何开启一个任务,并间隔打印 “Hello World”

首次使用项目时,必须先执行 make menuconfig 后方可编译

准备

硬件:

  • ESP32S 模组
  • USB转TTL

软件:

  • Cygwin + Eclipse 开发环境
  • 串口工具

代码

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "nvs_flash.h"
 
void helloworld_task(void *pvParameter)
{
    while(1)
    {
        printf("Hello world!\r\n");
        vTaskDelay(1000 / portTICK_RATE_MS);    //间隔 1000 ms
    }
}
 
void app_main()
{
    nvs_flash_init();   //nvs flash 初始化
    system_init();      //系统初始化
 
    printf("Creat Hello World task \r\n");
 
    xTaskCreate(&helloworld_task, "helloworld_task", 2048, NULL, 5, NULL);  //创建 hello world 任务
}

烧录

参考 如何为 ESP 系列模组烧录固件 进行下载

或者参考 如何使用安信可 ESP 系列一体化开发环境 进行 make flash 的配置,在项目中直接点击 Download taget 即可完成下载

运行

结束