uint32_t io_num; for(;;) { if(xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) { //接受gpio队列,并在读取完后删除队列 printf("GPIO[%d] intr, val: %d\n", io_num, gpio_get_level(io_num)); //将GPIO的信息打印输出 } } } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 1...
ledc_channel_config_t ledc_channel = {0}; ledc_channel.gpio_num = PWM::_pin; ledc_channel.channel = (ledc_channel_t)PWM::_channel; ledc_channel.speed_mode = LEDC_LOW_SPEED_MODE; ledc_channel.timer_sel = (ledc_timer_t)(timer_id % LEDC_TIMER_MAX); ledc_channel.duty = 0; ledc_...
intuart_write_bytes(uart_port_t uart_num,constchar*src,size_t size); 3、代码实现 3.1、参数定义 代码语言:javascript 复制 #defineEX_UART_NUMUART_NUM_1//串口1#defineTXD_PIN(GPIO_NUM_17)//txd使用gpio17#defineRXD_PIN(GPIO_NUM_16)//rxd使用gpio16#defineBUF_SIZE(128)//缓冲区定义staticQueue...
{ESP_LOGE(TAG,"timer cfg fail! freq:%d, err:0x%x", freq, ret);return; } _tim_freq[timer_id] = freq;ledc_channel_config_tledc_channel = {0}; ledc_channel.gpio_num = PWM::_pin; ledc_channel.channel = (ledc_channel_t)PWM::_channel; ledc_channel.speed_mode = LEDC_LOW_SPEED_M...
esp_err_t gpio_reset_pin(gpio_num_t gpio_num)设置为上拉、禁用输入、禁用输出参数: gpio口号返回: ESP_OK 3. 设置 gpio 方向 gpio_set_direction(gpio_num_tgpio_num, gpio_mode_tmode)gpio_mode_tmode值:GPIO_MODE_DISABLEGPIO_MODE_INPUTGPIO_MODE_OUTPUTGPIO_MODE_OUTPUT_ODGPIO_MODE_INPUT_...
static void IRAM_ATTR gpio_isr_handler(void* arg) { uint32_t gpio_num = (uint32_t) arg; xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL); //freertos中断中发送消息队列} static void gpio_task_example(void* arg) { uint32_t io_num; ...
可以看出LED对应的GPIO编号是GPIO1。 2、使用idf中的例程改造 对idf里面的demo进行改造,在examples\get-started\blink里面更改GPIO口: 代码语言:javascript 复制 #defineBLINK_GPIO1 3、GPIO操作相关API 代码语言:javascript 复制 voidgpio_pad_select_gpio(uint8_t gpio_num); ...
esp_err_t gpio_set_level(gpio_num_t gpio_num, uint32_t level);intgpio_get_level(gpio_num_t gpio_num); set_level和get_Level用来设置io的的高低电平和读取io的电平。 gpio_install_isr_service(ESP_INTR_FLAG_LEVEL1); gpio_isr_handler_add(LED_PIN,gpio_isr_handler,(void*)LED_PIN); ...
int SCCB_Init(void){ESP_LOGI(TAG, "pin_sda %d pin_scl %d", pin_sda, pin_scl);i2c_config_t conf;memset(&conf, 0, sizeof(i2c_config_t));conf.mode = I2C_MODE_MASTER;conf.sda_io_num = GPIO_NUM_26;conf.sda_pullup_en = GPIO_PULLUP_ENABLE;conf.scl_io_num = GPIO_NUM_27;co...