/* Blink 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"
#include "driver/gpio.h"
#define LED_PIN GPIO_NUM_18
#define LED_PIN2 GPIO_NUM_2
#define LED_PIN3 GPIO_NUM_4
#define LED_PIN4 GPIO_NUM_5
#define LED_PIN5 GPIO_NUM_19
#define BLINK_TIME 1000
extern "C" void app_main()
{
int count=0;
uint8_t led_value = 0;
gpio_reset_pin(LED_PIN); //复位引脚
gpio_reset_pin(LED_PIN2);
gpio_reset_pin(LED_PIN3);
gpio_reset_pin(LED_PIN4);
gpio_reset_pin(LED_PIN5);
gpio_set_direction(LED_PIN ,GPIO_MODE_OUTPUT);//设置GPIO端口模式为输出
gpio_set_direction(LED_PIN2, GPIO_MODE_OUTPUT);
gpio_set_direction(LED_PIN3, GPIO_MODE_OUTPUT);
gpio_set_direction(LED_PIN4, GPIO_MODE_OUTPUT);
gpio_set_direction(LED_PIN5 ,GPIO_MODE_OUTPUT);
while (1) { //死循环要谨慎使用,一个进程里不能有超过一个以上死循环
gpio_set_level(LED_PIN,0==count);
gpio_set_level(LED_PIN2, 1==count);
gpio_set_level(LED_PIN3, 2==count);
gpio_set_level(LED_PIN4, 3==count);
gpio_set_level(LED_PIN5, 4==count);
led_value = !led_value; //将led_value的值取反,0->1,1->0
vTaskDelay(BLINK_TIME / portTICK_PERIOD_MS); //延时BLINK_TIME毫秒
count++;
if(count==5) {count=0;}
}
}