32

33 for (int i = 10; i 》= 0; i--) {

34 printf(“Restarting in %d seconds.。。\n”, i);

35 vTaskDelay(1000 / portTICK_PERIOD_MS);

36 }

37 printf(“Restarting now.\n”);

38 fflush(stdout);

39 esp_restart();//重启选项

40 }

参考example下的GPIO例子,简单修改如下:

复制代码

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 #include 《string.h》

17 #include 《stdlib.h》

18 #include “freertos/FreeRTOS.h”

19 #include “freertos/task.h”

20 #include “freertos/queue.h”

21 #include “driver/gpio.h”

22

23 #define GPIO_OUTPUT_IO_LED 2

24 #define GPIO_OUTPUT_PIN_SEL ((1《《GPIO_OUTPUT_IO_LED) )

25 int i=0;

26 void app_main()

27 {

28

29 //初始化GPIO引脚,直接复制自GPIO例子

30 gpio_config_t io_conf;

31 //disable interrupt

32 io_conf.intr_type = GPIO_PIN_INTR_DISABLE;

33 //set as output mode

34 io_conf.mode = GPIO_MODE_OUTPUT;

35 //bit mask of the pins that you want to set,e.g.GPIO2

36 io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;

37 //disable pull-down mode

  • UC3846控制芯片工作原理控制图 逆变焊机原理与用途
  • 数字万用表电阻档测试二极管正反向没有阻值(使用万用表测量二极管的正向电阻,为什么各档)
  • 学单片机需要学数电模电吗(学单片机要先学数电模电吗)
  • 电工怎么选择适合自己用的万用表(电工初学者买什么样的万用表好)
  • 单片机需要同时运行多个任务怎么办(单片机怎么同时执行多个任务)
  • 电机保护的方案取决于负载的机械特性
  • 绝缘电阻表正负搭接不复零位是怎么回事
  • 短路怎么用万用表查