#ifndef __CONFIG_EXTRA_H__
#define __CONFIG_EXTRA_H__

/*****************************************************************************
 * Module    : SDK version configuration
 *****************************************************************************/
#ifndef SDK_VERSION
    #define SDK_VERSION             0x0100      //V010.0
#endif

/*****************************************************************************
 * Module    : System function configuration
 *****************************************************************************/

#ifndef SPIFLASH_SPEED_UP_EN
#define SPIFLASH_SPEED_UP_EN         1
#endif



#if !CHARGE_EN
#undef  CHARGE_TRICK_EN
#undef  CHARGE_DC_IN
#undef  CHARGE_DC_NOT_PWRON
#define CHARGE_TRICK_EN             0
#define CHARGE_DC_NOT_PWRON         0
#define CHARGE_DC_IN()              0
#endif

#ifndef PWROFF_PRESS_TIME
#define PWROFF_PRESS_TIME           3               //1: About 1 second 3: 1.5s, 6: 2s, 9: 2.5s, 12: 3s
#endif // PWROFF_PRESS_TIME

#ifndef PWRON_PRESS_TIME
#define PWRON_PRESS_TIME            1500           //1.5s
#endif // PWRON_PRESS_TIME

#ifndef RLED_LOWBAT_FOLLOW_EN
#define RLED_LOWBAT_FOLLOW_EN       0
#endif // RLED_LOWBAT_FOLLOW_EN

#ifndef PWRON_FRIST_BAT_EN
#define PWRON_FRIST_BAT_EN          1
#endif // PWRON_FRIST_BAT_EN

#if !LED_DISP_EN
#undef LED_LOWBAT_EN
#undef RLED_LOWBAT_FOLLOW_EN
#undef BLED_FFT_EN
#undef BLED_LOW2ON_EN
#undef BLED_CHARGE_FULL_EN
#undef BT_RECONN_LED_EN
#define LED_LOWBAT_EN              0
#define RLED_LOWBAT_FOLLOW_EN       0
#define BLED_FFT_EN                 0
#define BLED_LOW2ON_EN              0
#define BLED_CHARGE_FULL_EN         0
#define BT_RECONN_LED_EN            0
#endif

#if !LED_DISP_EN
#undef LED_INIT
#define LED_INIT()
#undef LED_SET_ON
#define LED_SET_ON()
#undef LED_SET_OFF
#define LED_SET_OFF()
#endif

#if !LED_PWR_EN
#undef LED_PWR_INIT
#define LED_PWR_INIT()
#undef LED_PWR_SET_ON
#define LED_PWR_SET_ON()
#undef LED_PWR_SET_OFF
#define LED_PWR_SET_OFF()
#endif

/*****************************************************************************
 * Module    : Music function configuration
 *****************************************************************************/
#if !0
#undef  MUSIC_UDISK_EN
#undef  MUSIC_SDCARD_EN
#undef  MUSIC_SDCARD1_EN

#undef  MUSIC_WAV_SUPPORT
#undef  MUSIC_WMA_SUPPORT
#undef  MUSIC_APE_SUPPORT
#undef  MUSIC_FLAC_SUPPORT
#undef  MUSIC_SBC_SUPPORT
#undef  MUSIC_AAC_SUPPORT
#undef  MUSIC_ID3_TAG_EN

#define MUSIC_UDISK_EN              0
#define MUSIC_SDCARD_EN             0
#define MUSIC_SDCARD1_EN             0
#define MUSIC_WAV_SUPPORT           0
#define MUSIC_WMA_SUPPORT           0
#define MUSIC_APE_SUPPORT           0
#define MUSIC_FLAC_SUPPORT          0
#define MUSIC_SBC_SUPPORT           0
#define MUSIC_ID3_TAG_EN            0
#define MUSIC_AAC_SUPPORT           0
#endif // FUNC_MUSIC_EN

#if !CHARGE_EN
#undef  CHARGE_TRICK_EN
#undef  CHARGE_DC_IN
#undef  CHARGE_DC_NOT_PWRON
#define CHARGE_TRICK_EN             0
#define CHARGE_DC_NOT_PWRON         0
#define CHARGE_DC_IN()              0
#endif
/*****************************************************************************
 * Module    : Bluetooth related configuration
 *****************************************************************************/
#if !LE_APP_EN
#undef LE_APP_FOT_EN
#define LE_APP_FOT_EN               0
#endif

#if LE_APP_EN
    #define LE_EN                   1
    #define BT_DUAL_MODE_EN         1
#else
    #define LE_EN                   0
    #define BT_DUAL_MODE_EN         0
#endif

#ifndef BT_A2DP_RECON_EN
#define BT_A2DP_RECON_EN            0
#endif

#ifndef BT_PAIR_SLEEP_EN
#define BT_PAIR_SLEEP_EN            0
#endif // BT_PAIR_SLEEP_EN

#if BT_BACKSTAGE_EN
#undef MUSIC_WMA_SUPPORT
#undef MUSIC_FLAC_SUPPORT
#undef FMRX_THRESHOLD_FZ

#define MUSIC_WMA_SUPPORT           0
#define MUSIC_FLAC_SUPPORT          0
#define FMRX_THRESHOLD_FZ           0
#endif

#ifndef BT_HFP_RINGS_BEFORE_NUMBER
#define BT_HFP_RINGS_BEFORE_NUMBER  0
#endif

#ifndef BT_A2DP_AAC_AUDIO_EN
#define BT_A2DP_AAC_AUDIO_EN        0
#endif // BT_A2DP_AAC_AUDIO_EN

#if !BT_A2DP_EN
#undef  BT_A2DP_AAC_AUDIO_EN
#define BT_A2DP_AAC_AUDIO_EN        0
#endif

#if BT_FCC_TEST_EN    //FCC default PB3 (USB_DP) baud rate 1500000 communication, close the program using PB3
#if (UART0_PRINTF_SEL == PRINTF_PB3)
#undef UART0_PRINTF_SEL
#define UART0_PRINTF_SEL  PRINTF_NONE
#endif
#endif

#if !BT_TWS_EN
#undef BT_TWS_SCO_EN
#define BT_TWS_SCO_EN               0
#undef BT_TWS_MS_SWITCH_EN
#define BT_TWS_MS_SWITCH_EN         0
//#undef FOT_SUPER_TWS
//#define FOT_SUPER_TWS               0
#undef BT_TWS_DBG_EN
#define BT_TWS_DBG_EN               0
#endif

#if BT_TWS_DBG_EN
#if !BT_SPP_EN
#error "TWS_DBG: please open BT_TWS_DBG_EN & BT_SPP_EN at the same time\n"
#endif
#endif // BT_TWS_DBG_EN

#if LE_APP_FOT_EN
#define LE_FOT_EN                   1
#endif

#if BT_SPP_FOT_EN || LE_FOT_EN
#undef FOT_EN
#define FOT_EN                      1  //Whether to enable FOTA upgrade function
#endif

#if BT_SPP_FOT_EN
#if !BT_SPP_EN
#error "FOTA: please open BT_SPP_FOT_EN & BT_SPP_EN at the same time\n"
#endif
#endif // BT_SPP_FOT_EN

#if BT_A2DP_VOL_HID_CTRL_EN
#undef  BT_HID_EN
#undef  BT_A2DP_VOL_CTRL_EN

#define BT_HID_EN                    1
#define BT_A2DP_VOL_CTRL_EN          1
#endif // BT_A2DP_VOL_HID_CTRL_EN

#if BT_AEC_EN && BT_NLMS_AEC_EN
#error "AEC_DBG: please choose only one selection in BT_AEC_EN or BT_NLMS_AEC_EN at the same time\n"
#endif // BT_AEC_EN

#if BT_NLMS_AEC_EN && (BT_SNDP_MODE || BT_SCO_AINS2_MODE)
#error "NLMS_AEC_DBG: please set BT_SNDP_MODE and BT_SCO_AINS2_EN to 0\n"
#endif

#if BT_SNDP_DMIC_EN && (BT_SNDP_EN || BT_SCO_AINS2_EN)
#error "NR_DBG: please select only one nr algorithm in BT_SNDP_DMIC_EN or BT_SNDP_EN or BT_SCO_AINS2_EN\n"
#endif

#if BT_SNDP_EN && BT_SCO_AINS2_EN
#error "NR_DBG: please select only one nr algorithm in BT_SNDP_DMIC_EN or BT_SNDP_EN or BT_SCO_AINS2_EN\n"
#endif

#if BT_AEC_DUMP_EN && (BT_SNDP_DUMP_EN || BT_SCO_FAR_DUMP_EN || BT_AINS2_DUMP_EN)
#error "DUMP_DBG: please select only one dump in BT_AEC_DUMP_EN, BT_SNDP_DUMP_EN, BT_SCO_FAR_DUMP_EN, BT_AINS2_DUMP_EN\n"
#endif

#if BT_SCO_FAR_DUMP_EN && (BT_SNDP_DUMP_EN || BT_AINS2_DUMP_EN)
#error "DUMP_DBG: please select only one dump in BT_AEC_DUMP_EN, BT_SNDP_DUMP_EN, BT_SCO_FAR_DUMP_EN, BT_AINS2_DUMP_EN\n"
#endif

#if BT_SNDP_DUMP_EN && BT_AINS2_DUMP_EN
#error "DUMP_DBG: please select only one dump in BT_AEC_DUMP_EN, BT_SNDP_DUMP_EN, BT_SCO_FAR_DUMP_EN, BT_AINS2_DUMP_EN\n"
#endif
/*****************************************************************************
 * Module    : ANC related configuration
 *****************************************************************************/
#if ANC_EN
#undef DAC_DNR_EN
#undef SYS_ADJ_DIGVOL_EN
#undef TINY_TRANSPARENCY_EN

#define DAC_DNR_EN                  0       //Turn off dynamic noise reduction
#define SYS_ADJ_DIGVOL_EN           1       //DAC fixed analog gain and digital gain
#define TINY_TRANSPARENCY_EN        0      //When ANC is turned on, it cannot be turned on
#endif

#if TINY_TRANSPARENCY_EN
#undef DAC_DNR_EN
#undef SYS_ADJ_DIGVOL_EN

#define DAC_DNR_EN                  0       //Turn off dynamic noise reduction
#define SYS_ADJ_DIGVOL_EN           1       //DAC fixed analog gain and digital gain
#endif

#if !ANC_EN
#undef EQ_TBL_RES2_EN
#define EQ_TBL_RES2_EN                 0        //If the ANC is closed, the priority resource 2 cannot be opened
#endif


/*****************************************************************************
 * Module    : uart0 printf Function automatic configuration (automatic shutdown of SD card, USB)
 *****************************************************************************/
#if (UART0_PRINTF_SEL == PRINTF_PB2)
    #if (SD0_MAPPING == SD0MAP_G2)
    #undef  MUSIC_SDCARD_EN
    #define MUSIC_SDCARD_EN         0
    #endif

    #if (SD1_MAPPING == SD0MAP_G2)
    #undef  MUSIC_SDCARD1_EN
    #define MUSIC_SDCARD1_EN        0
    #endif
#elif (UART0_PRINTF_SEL == PRINTF_PA7)
    #if (SD0_MAPPING == SD0MAP_G1)
    #undef  MUSIC_SDCARD_EN
    #define MUSIC_SDCARD_EN         0
    #endif

    #if (SD1_MAPPING == SD0MAP_G1)
    #undef  MUSIC_SDCARD1_EN
    #define MUSIC_SDCARD1_EN        0
    #endif
#elif (UART0_PRINTF_SEL == PRINTF_PB3)
    #if ((SD0_MAPPING == SD0MAP_G5) || (SD0_MAPPING == SD0MAP_G6))
    #undef  MUSIC_SDCARD_EN
    #define MUSIC_SDCARD_EN         0
    #endif

    #if ((SD1_MAPPING == SD0MAP_G5) || (SD1_MAPPING == SD0MAP_G6))
    #undef  MUSIC_SDCARD1_EN
    #define MUSIC_SDCARD1_EN        0
    #endif

    // USB function is prohibited when using PB3 for printf output
    #if FUNC_USBDEV_EN
    #error "Can't use PB3 for printer when enable USB macro."
    #endif

    #undef  FUNC_USBDEV_EN
    #undef  MUSIC_UDISK_EN
    #define FUNC_USBDEV_EN          0
    #define MUSIC_UDISK_EN          0
#elif (UART0_PRINTF_SEL == PRINTF_NONE)
    //Close so print information
    #undef printf
    #undef vprintf
    #undef print_r
    #undef print_r16
    #undef print_r32
    #undef printk
    #undef vprintk
    #undef print_kr
    #undef print_kr16
    #undef print_kr32

    #define printf(...)
    #define vprintf(...)
    #define print_r(...)
    #define print_r16(...)
    #define print_r32(...)
    #define printk(...)
    #define vprintk(...)
    #define print_kr(...)
    #define print_kr16(...)
    #define print_kr32(...)
#endif

#if !MUSIC_SDCARD_EN
#undef SDCLK_MUX_DETECT_SD
#undef SD_DETECT_INIT
#undef SD_IS_ONLINE
#undef IS_DET_SD_BUSY

#define SD_DETECT_INIT()
#define SDCLK_MUX_DETECT_SD         0
#define SD_IS_ONLINE()              0
#define IS_DET_SD_BUSY()            0
#endif

#if !MUSIC_SDCARD1_EN
#undef SD1_DETECT_INIT
#undef SD1_IS_ONLINE
#undef IS_DET_SD1_BUSY

#define SD1_DETECT_INIT()
#define SD1_IS_ONLINE()              0
#define IS_DET_SD1_BUSY()            0
#endif

/*****************************************************************************
 * Module    : usb device Function configuration
 *****************************************************************************/
#if !FUNC_USBDEV_EN
    #undef  UDE_PRINTER_EN

    #define UDE_PRINTER_EN              0
#else
    #define UDE_PRINTER_EN              (FUNC_USBDEV_EN*0x10)
#endif

/*****************************************************************************
 * Module    : iis Function configuration
 *****************************************************************************/
#if I2S_EN
#undef  I2S_EXT_EN
#undef  I2S_2_BT_SCO_EN

#define I2S_EXT_EN                      0
#define I2S_2_BT_SCO_EN                 0
#endif // I2S_EN

/*****************************************************************************
 * Module    : Prompt tone configuration
 *****************************************************************************/
#if (!WARNING_TONE_EN)
#undef WARNING_POWER_ON
#undef WARNING_POWER_OFF
#undef WARNING_FUNC_MUSIC
#undef WARNING_FUNC_BT
#undef WARNING_FUNC_CLOCK
#undef WARNING_FUNC_FMRX
#undef WARNING_FUNC_AUX
#undef WARNING_FUNC_USBDEV
#undef WARNING_FUNC_SPEAKER
#undef WARNING_LOW_BATTERY
#undef WARNING_BT_CONNECT
#undef WARNING_BT_DISCONNECT
#undef WARNING_BT_INCALL
#undef WARNING_USB_SD
#undef WARNING_BT_HID_MENU
#undef WARNING_BTHID_CONN
#undef WARNING_MAX_VOLUME
#undef WARNING_BT_PAIR

#define WARNING_POWER_ON               0
#define WARNING_POWER_OFF              0
#define WARNING_FUNC_MUSIC             0
#define WARNING_FUNC_BT                0
#define WARNING_FUNC_CLOCK             0
#define WARNING_FUNC_FMRX              0
#define WARNING_FUNC_AUX               0
#define WARNING_FUNC_USBDEV            0
#define WARNING_FUNC_SPEAKER           0
#define WARNING_LOW_BATTERY            0
#define WARNING_BT_CONNECT             0
#define WARNING_BT_DISCONNECT          0
#define WARNING_BT_INCALL              0
#define WARNING_USB_SD                 0
#define WARNING_BT_HID_MENU            0
#define WARNING_BTHID_CONN             0
#define WARNING_MAX_VOLUME             0
#define WARNING_BT_PAIR                0
#endif

#if ((!MUSIC_UDISK_EN) && (!MUSIC_SDCARD_EN) && (!MUSIC_SDCARD1_EN))
#undef  USB_SD_UPDATE_EN
#define USB_SD_UPDATE_EN               0
#endif

#if SD_USB_MUX_IO_EN == 1
	#undef FUNC_USBDEV_EN
	#define FUNC_USBDEV_EN 			   0
#endif

#ifndef UPD_FILENAME
#define UPD_FILENAME                   "fw5000.upd"
#endif

#if ((SD0_MAPPING == SD0MAP_G1) || (SD0_MAPPING == SD0MAP_G4) || (SD0_MAPPING == SD0MAP_G5) || (SD0_MAPPING == SD0MAP_G6))
#define SDCLK_AD_CH                    ADCCH_PA6
#elif (SD0_MAPPING == SD0MAP_G2)
#define SDCLK_AD_CH                    ADCCH_PB1
#else
#define SDCLK_AD_CH                    ADCCH_PE6
#endif
#define USB_SUPPORT_EN                 (MUSIC_UDISK_EN | FUNC_USBDEV_EN)
#define SD_SUPPORT_EN                  (MUSIC_SDCARD_EN | MUSIC_SDCARD1_EN)

#if MUSIC_SDCARD_EN
#define SDCMD_MUX_DETECT_EN            1
#define SDCLK_MUX_DETECT_EN            1
#else
#undef  USER_ADKEY_MUX_SDCLK
#undef  I2C_MUX_SD_EN

#define I2C_MUX_SD_EN                  0
#define SDCMD_MUX_DETECT_EN            0
#define SDCLK_MUX_DETECT_EN            0
#define USER_ADKEY_MUX_SDCLK           0
#endif // MUSIC_SDCARD_EN

#if !SD_SUPPORT_EN
#undef  UDE_STORAGE_EN
#define UDE_STORAGE_EN                 0
#undef  SD_SOFT_DETECT_EN
#define SD_SOFT_DETECT_EN              0
#endif

#if ((!USER_PWRKEY) && (!USER_IOKEY))
#undef IS_PWRKEY_PRESS
#define IS_PWRKEY_PRESS()               0
#endif

/*****************************************************************************
* Module    : There are conflicts or macros that cannot be opened at the same time functionally
*****************************************************************************/
#if (SYS_KARAOK_EN && BT_BACKSTAGE_EN)
#error "SYS_KARAOK_EN and BT_BACKSTAGE_EN (include BT_APP_EN) can't open at sametime"
#endif

/*****************************************************************************
* Module    : Calculate FunctionKey
*****************************************************************************/
#if BT_TWS_EN
    #define FUNCKEY_TWS                 0xe0938553
#else
    #define FUNCKEY_TWS                 0
#endif
#if ANC_EN
    #define FUNCKEY_ANC                 0x6a490f91
#else
    #define FUNCKEY_ANC                 0
#endif
#if ANC_HYBRID_EN
    #define FUNCKEY_ANC_HYBRID          0x2f244af0
#else
    #define FUNCKEY_ANC_HYBRID          0
#endif
#if BT_SNDP_EN
    #define FUNCKEY_SNDP_NS             0xf8789d28
#else
    #define FUNCKEY_SNDP_NS             0
#endif
#if BT_SNDP_DMIC_EN
    #define FUNCKEY_SNDP_DMIC           0xf3c19711
#else
    #define FUNCKEY_SNDP_DMIC           0
#endif
#if BT_LOW_LATENCY_EN
    #define FUNCKEY_LOW_LATENCY         0xa364c2b4
#else
    #define FUNCKEY_LOW_LATENCY         0
#endif

#endif // __CONFIG_EXTRA_H__

