/*****************************************************************************
 * Module    : Config
 * File      : config.h
 * Function  : SDK configuration file
 *****************************************************************************/

#ifndef USER_CONFIG_H
#define USER_CONFIG_H
#include "config_define.h"

/*****************************************************************************
 * Module    : Function Select relevant configuration
 *****************************************************************************/
#define FUNC_BT_EN                      1   //Whether to turn on Bluetooth function
#define FUNC_BT_DUT_EN                  0   //Whether to turn on the independent test mode of Bluetooth, CBT FCC
#define FUNC_USBDEV_EN                  0   //Whether to turn on the USB DEVICE function, pay attention to the print macro UART0_ PRINTF_ SEL should avoid selecting PB3 (PB3 ->DP PB4 ->DM)
#define FUNC_IDLE_EN                    0   //Whether to turn on IDLE function

/*****************************************************************************
 * Module    : System function selection configuration
 *****************************************************************************/
#define SYS_CLK_SEL                     SYS_24M                 //Select system clock
#define BUCK_MODE_EN                    xcfg_cb.buck_mode_en    //BUCK MODE or not
#define BUCK_CURR_LIMIT_DIS             xcfg_cb.buck_limit_dis  //Whether to turn off BUCK MODE current limiting
#define POWKEY_10S_RESET                xcfg_cb.powkey_10s_reset
#define SOFT_POWER_ON_OFF               1                       //Whether to use soft switch off function
#define PWRKEY_2_HW_PWRON               0                       //Simulate hard switch with PWRKEY
#define UART0_PRINTF_SEL                PRINTF_PB3              //Select UART print information output IO, or turn off print information output

/*****************************************************************************
 * Module    :FLASH configuration
 *****************************************************************************/
#define FLASH_SIZE                      FSIZE_1M              //LQFP48 chip has 1MB built-in, and other packaged chips have 512KB built-in (the actual exported prd file should be less than 492K)
#define FLASH_CODE_SIZE                 400K                    //Size of space used by the program
#define FLASH_ERASE_4K                  1                       //Whether 4K erasure is supported
#define FLASH_DUAL_READ                 1                       //Whether 2-wire mode is supported
#define FLASH_QUAD_READ                 0                       //Whether 4-wire mode is supported
#define SPIFLASH_SPEED_UP_EN            1                       //SPI FLASH speed up.

/*****************************************************************************
 * Module    : Bluetooth function configuration
 *****************************************************************************/
#define BT_BACKSTAGE_EN                 0   //Bluetooth background management (Bluetooth is used in full mode, and BLE background is not supported temporarily)
#define BT_BACKSTAGE_PLAY_DETECT_EN     0   //Switch to Bluetooth mode if it is detected that mobile phone Bluetooth plays music in non-Bluetooth mode
#define BT_NAME_DEFAULT                 "BT-GW3323"     //Default Bluetooth name (no more than 31 characters)
#define BT_NAME_WITH_ADDR_EN            0   //Whether the Bluetooth name is attached with address information (for example, btbox * * *)
#define BT_LINK_INFO_PAGE1_EN           1   //Whether to use PAGE1 callback information (you can save up to 8 callback information after opening)
#define BT_POWER_UP_RECONNECT_TIMES     3   //Number of power-on reconnection
#define BT_TIME_OUT_RECONNECT_TIMES     20  //Number of offline and reconnection
#define BT_SIMPLE_PAIR_EN               0   //O为输入PIN码   1为不需要输入PIN码 //Whether to turn on the Bluetooth simple pairing function (when turning off, you need to input the PIN code on the mobile phone)
#define BT_DISCOVER_CTRL_EN             0   //Whether to use the key to open can be found (you need to add a matching key to be connected and paired)
#define BT_PWRKEY_5S_DISCOVER_EN        0   //Whether to use the long press of 5S to turn on the phone can be found (long press of the headset to turn on the phone)
#define BT_DISCOVER_TIMEOUT             100 //Press the key to open it and it can be found how long it will take to automatically close without connection, 0 will not automatically close, unit: 100ms
#define BT_ANTI_LOST_EN                 0   //Whether Bluetooth anti-loss alarm is turned on
#define BT_DUT_MODE_EN                  0   //Normal connection mode, whether to enable DUT test
#define BT_BQB_RF_EN                    0   //BR/EDR DUT test mode, which is not automatically connected for convenience of test
#define BT_FCC_TEST_EN                  0   //Bluetooth FCC test enable//default PB3 baud rate 1500000 communication
#define BT_LOCAL_ADDR                   0   //Whether Bluetooth uses local address, 0 uses configuration tool address
#define BT_2ACL_EN                      1   //Whether it supports connecting two mobile phones (TWS does not support)
#define BT_LOW_LATENCY_EN               1   //Whether to turn on Bluetooth low-delay switching function

#define BT_SPP_EN                       1   //Whether to open Bluetooth serial port service
#define BT_SPP_FOT_EN                   1   //Whether to turn on the Bluetooth SPP FOTA dual backup upgrade function
#define BT_SPP_RX_FLOW_CTRL_EN          1   //Whether to turn on the flow control function of Bluetooth SPP RX

#define BT_HID_EN                       0   //Whether to open Bluetooth HID service
#define BT_HID_TYPE                     0   //Select HID service type: 0=self-timer (VOL+, some Android cannot take pictures), 1=self-timer (VOL+and ENTER, which affect the use of IOS keyboard), 2=game handle
#define BT_HID_MANU_EN                  0   //Does Bluetooth HID need to be connected/disconnected manually
#define BT_HID_DISCON_DEFAULT_EN        0   //Bluetooth HID service is not connected by default and needs to be connected manually

//BLE function configuration
#define LE_BQB_RF_EN                    0   //BLE DUT test mode, using serial communication
#define LE_PAIR_EN                      0   //Enable encryption pairing of BLE
#define LE_APP_EN                       1   //Whether to open AB-LINK APP control function
#define LE_APP_FOT_EN                   1   //Whether to turn on the Bluetooth BLE FOTA dual backup upgrade function

#define LE_ADV0_EN                      0   //Whether to turn on the connectionless broadcast function
#define LE_WIN10_POPUP                  0   //Whether to open win10 swift pair

/*****************************************************************************
 * Module    : User Key configuration
 *****************************************************************************/
#define USER_ADKEY                      0           //Use of ADKEY, 0 is not used
#define USER_ADKEY2                     0           //Use of ADKEY2, 0 is not used
#define USER_PWRKEY                     1           //Use of PWRKEY, 0 is not used
#define USER_IOKEY                      0           //Use of IOKEY, 0 is not used
#define ADKEY_PU10K_EN                  0           //Whether ADKEY uses internal 10K pull-up, see port for the number of keys and resistance value_ key.c

#define USER_MULTI_PRESS_EN             1           //Keystroke detection enable
#define USER_KEY_DOUBLE                 {KU_NEXT, KU_POWER, KU_PREV} //Support double click/three click/four click/five click buttons
#define ADKEY_CH                        xcfg_cb.adkey_ch    //ADCCH_PE7
#define ADKEY2_CH                       xcfg_cb.adkey2_ch   //ADCCH_PE6

#define POWER_KEY_USE_HIGHLEVEL			0

#define DOUBLE_KEY_TIME                 (xcfg_cb.double_key_time)                       //Double-click response time (unit: 50ms)
#define PWRON_PRESS_TIME                (500*xcfg_cb.pwron_press_time)                  //How long will PWRKEY be turned on?
#define PWROFF_PRESS_TIME               (3+3*xcfg_cb.pwroff_press_time)                 //How long will PWRKEY be shut down?

/*****************************************************************************
 * Module    : Detailed system configuration
 *****************************************************************************/
#define PWM_RGB_EN                      0           //PWM RGB three-color lamp function
#define SYS_PARAM_RTCRAM                0           //Whether the system parameters are saved to RTCRAM
#define VBAT_DETECT_EN                  0           //Battery power detection function
#define VBAT2_ADCCH                     ADCCH_VBAT  //ADCCH_ VBAT is an internal 1/2 voltage path, and external ADC path is required to detect 1/2 battery voltage for applications with boost
#define VBAT_FILTER_USE_PEAK            0           //Battery detection filter selection://0 Take the average value// 1 Take the peak value (applicable to the speaker scheme with large battery fluctuation when playing music)
#define LPWR_OFF_VBAT                   xcfg_cb.lpwr_off_vbat       //Low power off voltage

/*****************************************************************************
 * Module    : LED indicator configuration
 *****************************************************************************/
#define LED_DISP_EN                     0           //Whether to use LED indicator (blue light)
#define LED_PWR_EN                      0           //Charging and power indicator (red light)
#define LED_LOWBAT_EN                   0                           //Whether the red light flashes when the battery is low
#define BLED_CHARGE_FULL                xcfg_cb.charge_full_bled    //Whether the blue light is on when the battery is fully charged
#define BT_RECONN_LED_EN                0//xcfg_cb.bt_reconn_led_en    //Does the Bluetooth back-connection state have different flashing modes

#define LED_INIT()                      bled_func.port_init(&bled_gpio)
#define LED_SET_ON()                    bled_func.set_on(&bled_gpio)
#define LED_SET_OFF()                   bled_func.set_off(&bled_gpio)

#define LED_PWR_INIT()                  rled_func.port_init(&rled_gpio)
#define LED_PWR_SET_ON()                rled_func.set_on(&rled_gpio)
#define LED_PWR_SET_OFF()               rled_func.set_off(&rled_gpio)


#define SW_VERSION		"V0.0.1"		//Only digits 0-9 can be used. ota needs transcoding
#define HW_VERSION		"V0.0.1"		//Only digits 0-9 can be used. ota needs transcoding

#include "config_extra.h"

#endif // USER_FPGA_CONFIG_H
