From aa4f047a7080ba25ee0dd12cb4948cab19210956 Mon Sep 17 00:00:00 2001 From: zwsd Date: Thu, 28 Jul 2022 11:41:03 +0800 Subject: [PATCH] =?UTF-8?q?LED=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=AE=BE=E7=BD=AE=E7=81=AF=E4=BA=AE=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main/main.c b/main/main.c index 228c54f..22d1026 100644 --- a/main/main.c +++ b/main/main.c @@ -1,3 +1,4 @@ +#include "driver/gpio.h" #include "esp_gatts_api.h" #include "esp_log.h" #include "esp_system.h" @@ -17,6 +18,12 @@ static char bluetooth_tx_buffer[profile_b_buffer_size] = {0}; static char bluetooth_rx_buffer[profile_b_buffer_size] = {0}; +#define GPIO_OUTPUT_IO_RED 3 +#define GPIO_OUTPUT_IO_GREEN 4 +#define GPIO_OUTPUT_IO_BLUE 5 + +#define GPIO_OUTPUT_PIN_SEL ((1ULL << GPIO_OUTPUT_IO_GREEN) | (1ULL << GPIO_OUTPUT_IO_BLUE) | (1ULL << GPIO_OUTPUT_IO_RED)) + bluetooth_processer_t s_bluetooth_processer = { .bluetooth_processer_rx_buf = bluetooth_rx_buffer, .bluetooth_processer_rx_buf_size = sizeof(bluetooth_rx_buffer), @@ -48,12 +55,26 @@ bluetooth_processer_t s_bluetooth_processer = { .motor_drive_turn_flag = false, }; +void gpio_rgb_init() { + gpio_config_t gpio_grb_led_structer; + + gpio_grb_led_structer.intr_type = GPIO_INTR_DISABLE; + gpio_grb_led_structer.mode = GPIO_MODE_OUTPUT; + gpio_grb_led_structer.pin_bit_mask = GPIO_OUTPUT_PIN_SEL; + gpio_grb_led_structer.pull_down_en = 0; + gpio_grb_led_structer.pull_up_en = 0; + + gpio_config(&gpio_grb_led_structer); +} + void app_main(void) { constructor_bluetooth_processer(&s_bluetooth_processer); ble_spp_server_demo_app_main(&s_bluetooth_processer); timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_group0_interval_num, timer_interval_ms); motor_drive_uart_init(); + gpio_rgb_init(); + gpio_set_level(GPIO_OUTPUT_IO_GREEN,1); while (true) { bluetooth_gatts_try_process_data(); // if (s_bluetooth_processer.auto_report_flag) {