board/main/hw-ms03.c

27 lines
683 B
C

#pragma once
#include "driver/gpio.h"
#include "freeRTOS/FreeRTOS.h"
#define HW_MS03_INT_GPIO 6
#define BEEP_GPIO 7
void hw_ms03_int_handler(void *arg) {
gpio_set_level(BEEP_GPIO, gpio_get_level(HW_MS03_INT_GPIO));
}
void hw_ms03_init() {
gpio_config_t io_conf = {};
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = 0;
io_conf.pull_down_en = 1;
io_conf.intr_type = GPIO_INTR_ANYEDGE;
io_conf.pin_bit_mask = 1ULL << HW_MS03_INT_GPIO;
gpio_config(&io_conf);
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = 1ULL << BEEP_GPIO;
io_conf.pull_down_en = 0;
gpio_config(&io_conf);
gpio_isr_handler_add(HW_MS03_INT_GPIO, hw_ms03_int_handler, NULL);
}