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口定义。

  • 相关阅读:
    MySQL的四种事务隔离级别理解(new)
    深入分析ReentrantLock公平锁和非公平锁的区别 (转)
    Ubuntu 安装nginx
    Linux 文件的权限
    java Request 获得用户IP地址
    Maven profile 打包分环境加载不同的资源文件
    JQuery Ajax jsonp
    HttpClient 4.5.3 get和post请求https post
    Jenkins的安装配置
    javascript正则表达式
  • 原文地址:https://www.cnblogs.com/llw2017/p/9608676.html
Copyright © 2011-2022 走看看