1.参考文档
【立创·ESP32S3R8N8】IDF入门手册 - 飞书云文档 (feishu.cn)https://lceda001.feishu.cn/wiki/GOIlwwfbIi1SC3k8594cDeFVn8g
2.建立工程
3.运行效果
4.更改配置
5.插播
之前配置的环境是有问题的,就算有自动检测也要仔细检查,必须严格按照以下所示配置路径
6.代码编写
#include <stdio.h>
#include "driver/gpio.h"
#define LED_Pin 48
void app_main(void)
{
gpio_config_t pGPIOConfig;
pGPIOConfig.intr_type=GPIO_INTR_DISABLE;
pGPIOConfig.mode= GPIO_MODE_OUTPUT;
pGPIOConfig.pin_bit_mask=(1Ull<<LED_Pin);
pGPIOConfig.pull_down_en=GPIO_PULLDOWN_DISABLE;
pGPIOConfig.pull_up_en=GPIO_PULLUP_DISABLE;
gpio_config(&pGPIOConfig);
gpio_set_level(LED_Pin,0);
}
7.闪烁LED
#include <stdio.h>
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "unistd.h"
#define LED_Pin 48
void delay_ms(uint32_t ms);
void delay_us(uint32_t us);
void app_main(void)
{
gpio_config_t pGPIOConfig;
pGPIOConfig.intr_type=GPIO_INTR_DISABLE;
pGPIOConfig.mode= GPIO_MODE_OUTPUT;
pGPIOConfig.pin_bit_mask=(1Ull<<LED_Pin);
pGPIOConfig.pull_down_en=GPIO_PULLDOWN_DISABLE;
pGPIOConfig.pull_up_en=GPIO_PULLUP_DISABLE;
gpio_config(&pGPIOConfig);
gpio_set_level(LED_Pin,0);
while(1)
{
gpio_set_level(LED_Pin,0);
delay_ms(500);
gpio_set_level(LED_Pin,1);
delay_us(500000);
}
}
/*延时ms*/
void delay_ms(uint32_t ms)
{
vTaskDelay(ms/portTICK_PERIOD_MS);
}
/* 延时us*/
void delay_us(uint32_t us)
{
usleep(us);
}