
#include "bsp_Gpio.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "esp_log.h"
void bsp_syson_gpio_init(void)
{
    //     //zero-initialize the config structure.
    gpio_config_t io_conf = {};

    /* gpio input  */
    io_conf.intr_type = GPIO_INTR_DISABLE;
    io_conf.mode = GPIO_MODE_INPUT;
    io_conf.pin_bit_mask =
        ((1ULL << POWER_ACC1) | (1ULL << POWER_DC12));
    io_conf.pull_down_en = 0;
    io_conf.pull_up_en = 0;
    gpio_config(&io_conf);

    // io_conf.intr_type = GPIO_INTR_DISABLE;//GPIO_INTR_HIGH_LEVEL;
    // io_conf.mode = GPIO_MODE_INPUT;
    // io_conf.pin_bit_mask = 1ULL << N32G_INT ;
    // io_conf.pull_down_en = 0;
    // io_conf.pull_up_en = 0;
    // gpio_config(&io_conf);

    /* (1ULL << N32G_5V_EN) | */
    /* gpio output  */
    io_conf.intr_type = GPIO_INTR_DISABLE;
    io_conf.mode = GPIO_MODE_OUTPUT;
    io_conf.pin_bit_mask =
        ((1ULL << R485_EN) | (1ULL << N32G_5V_EN)  |(1ULL << IIC_SCL)  | (1ULL << IIC_SDA)
        );
    io_conf.pull_down_en = 0;
    io_conf.pull_up_en = 0;
    gpio_config(&io_conf);

    gpio_set_level(N32G_5V_EN, 1);
    // gpio_set_level(R485_EN, 0);
    // Set_LCD_EN(1);

    ESP_LOGI("GPIO", "GPIO initialization Successful ");
}

void bsp_GPIO_Wakeup_Init(void)
{

    // gpio_set_level(MCU_3_3V, 1);
    // Set_LCD_EN(1);
}
void bsp_GPIO_Sleep_Init(void)
{

    //     /* Initialize GPIO */
    //     gpio_config_t config = {
    //             .pin_bit_mask = BIT64(N32G_INT),
    //             .mode = GPIO_MODE_INPUT,
    //             .pull_down_en = false,
    //             .pull_up_en = false,
    //             .intr_type = GPIO_INTR_DISABLE
    //     };
    //     gpio_config(&config);

    //     /* Enable wake up from GPIO */
    //     gpio_wakeup_enable(N32G_INT, GPIO_INTR_HIGH_LEVEL);//GPIO_INTR_LOW_LEVEL  //GPIO_INTR_HIGH_LEVEL
    //     esp_sleep_enable_gpio_wakeup();

    //     /* Make sure the GPIO is inactive and it won't trigger wakeup immediately */
    //    // example_wait_gpio_inactive();

    //     gpio_set_level(MCU_3_3V, 0);
    //     Set_LCD_EN(0);
    //     ESP_LOGI("GPIO", "gpio wakeup source is ready");
}
