zoukankan      html  css  js  c++  java
  • esp32-智能语音-led驱动

    代码如下:

     1 /* Blink 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 "driver/gpio.h"
    13 #include "sdkconfig.h"
    14 
    15 /* Can run 'make menuconfig' to choose the GPIO to blink,
    16    or you can edit the following line and set a number here.
    17 */
    18 #define LED_GPIO CONFIG_LED_GPIO
    19 
    20 void blink_task(void *pvParameter)
    21 {
    22     /* Configure the IOMUX register for pad LED_GPIO (some pads are
    23        muxed to GPIO on reset already, but some default to other
    24        functions and need to be switched to GPIO. Consult the
    25        Technical Reference for a list of pads and their default
    26        functions.)
    27     */
    28     gpio_pad_select_gpio(LED_GPIO);
    29     /* Set the GPIO as a push/pull output */
    30     gpio_set_direction(LED_GPIO, GPIO_MODE_OUTPUT);
    31     while(1) {
    32         /* Blink off (output low) */
    33         gpio_set_level(LED_GPIO, 0);
    34         vTaskDelay(1000 / portTICK_PERIOD_MS);
    35         /* Blink on (output high) */
    36         gpio_set_level(LED_GPIO, 1);
    37         vTaskDelay(1000 / portTICK_PERIOD_MS);
    38     }
    39 }
    40 
    41 void app_main()
    42 {
    43     xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
    44 }

    案例使用了make menuconfig菜单来进行led IO口定义。

  • 相关阅读:
    Nginx的启动、停止与重启
    用Java实现链表结构对象:单向无环链表
    java匿名内部类详解
    如何统计博客园的个人博客访问量
    Java 读写Properties配置文件
    java的枚举类型Enum解释
    接口测试框架1
    python几道简单的算法题
    很全的 Python 面试题
    有有面试
  • 原文地址:https://www.cnblogs.com/llw2017/p/9608676.html
Copyright © 2011-2022 走看看