#ifndef __BSP_H__
#define __BSP_H__

#include "base.h"
#include "deca_device_api.h"

#define DEFAULT_UWB_ANTENNA_ANT_RX_DELAY (16435)
#define DEFAULT_UWB_ANTENNA_ANT_TX_DELAY (16436)

extern EUI64 g_EUI64;
extern uint8_t current_mac[6];

void bsp_init(void);
void HardReset(void);
// void get_flash_unique_id(void);

void indicator_backlight_init(void);
void indicator_backlight_set_brightness(uint8_t brightness);

extern uint8_t cfg_button_pressed;
extern uint8_t cfg_button_long_pressed;
extern uint8_t cfg_button_long_pressed_from_boot;
void button_init(void);

void alive_led_init(void);
void alive_led_on(void);
void alive_led_off(void);
void set_system_status(uint8_t status);
void check_alive_led(void);

// for debug
void gpio_init_for_debug(void);

#define DBG_RX_GPIO (GPIO_NUM_7)
#define DBG_TX_GPIO (GPIO_NUM_4)
#define DBG_SLOT_GPIO (GPIO_NUM_15)


#include "hal/gpio_ll.h" // 引入底层寄存器头文件

// 针对 GPIO 0 ~ 31 的极速翻转宏（GPIO 4 为例）
#define DBG_RX_HI()  (GPIO.out_w1ts = (1ULL << DBG_RX_GPIO))
#define DBG_RX_LO()   (GPIO.out_w1tc = (1ULL << DBG_RX_GPIO))

#define DBG_TX_HI()  (GPIO.out_w1ts = (1ULL << DBG_TX_GPIO))
#define DBG_TX_LO()   (GPIO.out_w1tc = (1ULL << DBG_TX_GPIO))

#define DBG_SLOT_HI()  (GPIO.out_w1ts = (1ULL << DBG_SLOT_GPIO))
#define DBG_SLOT_LO()   (GPIO.out_w1tc = (1ULL << DBG_SLOT_GPIO))

// #define DBG_SLOT_HI()  (gpio_set_level(DBG_SLOT_GPIO, 1))
// #define DBG_SLOT_LO()   (gpio_set_level(DBG_SLOT_GPIO, 0))


#endif // __BSP_H__
