zoukankan      html  css  js  c++  java
  • 野路子学习esp32(五) Hello World源码解析@a.宏万

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

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

    硬件:

    • ESP32 模组
    • USB转TTL

    软件:

    • Cygwin + Eclipse 开发环境
    • 串口工具
    /* Hello World Example
    
       This example code is in the Public Domain (or CC0 licensed, at your option.)
    
       Unless required by applicable law or agreed to in writing, this
       software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
       CONDITIONS OF ANY KIND, either express or implied.
    */
    #include <stdio.h>
    #include "freertos/FreeRTOS.h"    //可以看到idf是基于FreeRtos系统
    #include "freertos/task.h"
    #include "esp_system.h"
    #include "esp_spi_flash.h"
    
    
    void app_main()
    {
        printf("Hello world!
    ");      //打印内容
    
        /* Print chip information */
        esp_chip_info_t chip_info;
        esp_chip_info(&chip_info);      //系统初始化
        printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",   //打印系统信息
                chip_info.cores,
                (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
                (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
    
        printf("silicon revision %d, ", chip_info.revision);
    
        printf("%dMB %s flash
    ", spi_flash_get_chip_size() / (1024 * 1024),
                (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
    
        for (int i = 10; i >= 0; i--) {              
            printf("Restarting in %d seconds...
    ", i);
            vTaskDelay(1000 / portTICK_PERIOD_MS);        //延时函数  单位ms
        }
        printf("Restarting now.
    ");
        fflush(stdout);              //清除读写缓冲区,立即把输出缓冲区的数据进行物理写入
        esp_restart();               //系统重启
    }

    野路子学习esp32(四) 烧录固件 @a.宏万

  • 相关阅读:
    ExtAspNet新版本发布v2.0beta4
    自己实现Rich Text Editor
    ExtAspNet应用技巧(五) 动态创建工具栏菜单
    IronPython的Hello World
    关于“跨语言调用”和“CLS(公共语言规范)”的一点体会
    文档,又是文档
    对项目目标的一点想法
    推荐一个WMI的查询分析器
    几个很不错的.NET 相关的FAQ和例子代码的连接
    用IronPython写winform程序
  • 原文地址:https://www.cnblogs.com/hongwans/p/7773069.html
Copyright © 2011-2022 走看看