menu "ESP8266-specific"

choice ESP8266_DEFAULT_CPU_FREQ_MHZ
    prompt "CPU frequency"
    default ESP8266_DEFAULT_CPU_FREQ_80
    help
        CPU frequency to be set on application startup.

    config ESP8266_DEFAULT_CPU_FREQ_80
        bool "80 MHz"
    config ESP8266_DEFAULT_CPU_FREQ_160
        bool "160 MHz"
endchoice

config ESP8266_DEFAULT_CPU_FREQ_MHZ
    int
    default 80 if ESP8266_DEFAULT_CPU_FREQ_80
    default 160 if ESP8266_DEFAULT_CPU_FREQ_160

choice NEWLIB_STDOUT_LINE_ENDING
    prompt "Line ending for UART output"
    default NEWLIB_STDOUT_LINE_ENDING_CRLF
    help
        This option allows configuring the desired line endings sent to UART
        when a newline ('\n', LF) appears on stdout.
        Three options are possible:

        CRLF: whenever LF is encountered, prepend it with CR

        LF: no modification is applied, stdout is sent as is

        CR: each occurence of LF is replaced with CR

        This option doesn't affect behavior of the UART driver (drivers/uart.h).

config NEWLIB_STDOUT_LINE_ENDING_CRLF
    bool "CRLF"
config NEWLIB_STDOUT_LINE_ENDING_LF
    bool "LF"
config NEWLIB_STDOUT_LINE_ENDING_CR
    bool "CR"
endchoice

choice ESP_FILENAME_MACRO
    prompt "File name macro text"
    default ESP_FILENAME_MACRO_NO_PATH
    help
        This option allows configuring the macro __ESP_FILE__ text.
        Three options are possible:

        no PATH: strip the path of macro __FILE__, for example: __FILE__="a/b/c/d.h", then __ESP_FILE__="d.h"

        raw: same as macro __FILE__

        null: text is string "null"

config ESP_FILENAME_MACRO_NO_PATH
    bool "no PATH"
config ESP_FILENAME_MACRO_RAW
    bool "raw"
config ESP_FILENAME_MACRO_NULL
    bool "null"
endchoice

config USING_NEW_ETS_VPRINTF
    bool "Using new ets_vprintf instead of rom code"
    default y
    help
        Enable this option, SDK will use new "ets_vprintf" function instead of old code "ets_vprintf" which is depend on ROM
        code "ets_io_vprintf".

        Note: Bootloader can't use this function.

config LINK_ETS_PRINTF_TO_IRAM
    bool "Link ets_printf to IRAM"
    default n
    help
        Enable this option, SDK will link the old/new "ets_printf" and "ets_vprintf" to IRAM instead of flash.
        So although flash can't be access for SoC when reading to writing, the "ets_printf" and "ets_vprintf" also can be used by user.

        Using new "ets_vprintf" should cost more 1.6KB IRAM.

        Note: Bootloader can't use this function.

config SOC_FULL_ICACHE
    bool "Enable full cache mode"
    default n
    help
        Enable this option, full 32 KB iram instead of 16 KB iram will be used as icache, so the heap use can use
        may reduce a lot.

config SOC_IRAM_SIZE
    hex
    default 0x8000 if SOC_FULL_ICACHE
    default 0xC000 if !SOC_FULL_ICACHE

config DISABLE_ROM_UART_PRINT
    bool "Disable ROM UART print"
    default n
    help
        "Disable main part of ROM UART print when rom bootloader process."

choice ESP_PANIC
    prompt "Panic handler behaviour"
    default ESP_PANIC_PRINT_REBOOT
    help
        If an unhandled exception, the panic handler is invoked.
        Configure the panic handlers action here.

config ESP_PANIC_PRINT_HALT
    bool "Print registers and halt"
    help
        Outputs the relevant registers over the serial port and halt the
        processor. Needs a manual reset to restart.

config ESP_PANIC_PRINT_REBOOT
    bool "Print registers and reboot"
    help
        Outputs the relevant registers over the serial port and immediately
        reset the processor.

config ESP_PANIC_SILENT_REBOOT
    bool "Silent reboot"
    help
        Just resets the processor without outputting anything

config ESP_PANIC_GDBSTUB
    bool "Invoke GDBStub"
    select ESP_GDBSTUB_ENABLED
    help
        Invoke gdbstub on the serial port, allowing for gdb to attach to it to do a postmortem
        of the crash.

        The UART's baudrate should be 115200 or others which can be recognized by xtensa GDB.
endchoice

config RESET_REASON
    bool "Enable reset reason"
    default y
    help
        Enable this option, the reset reason function can be used, or compiler will show function linking error.

config WIFI_PPT_TASKSTACK_SIZE
    int "ppT task stack size"
    default 2048
    range 2048 8192
    help
        Configure the "ppT task" stack size. This is the stack of the task
        which calls promiscuous callback function. So if user's function is
        complex, the stack must be set larger.

config ESP8266_CORE_GLOBAL_DATA_LINK_IRAM
    bool "Link libcore.a internal global data to IRAM"
    default y
    depends on !LWIP_HIGH_THROUGHPUT
    depends on !SOC_FULL_ICACHE
    help
        Link libcore.a internal global data(.bss .data COMMON) from DRAM to IRAM.

config INIT_OS_BEFORE_START
    bool "Init OS before starting it"
    default n
    depends on DISABLE_FREERTOS
    help
        Some OSes should initialize their global data structure before starting them. rt-thread is like this one.

        FreeRTOS need not do this.

config ESP8266_OTA_FROM_OLD
    bool "ESP8266 update from old SDK by OTA"
    default n
    depends on IDF_TARGET_ESP8266
    select ESP8266_BOOT_COPY_APP if ESPTOOLPY_FLASHSIZE_1MB
    help
        The function is not released.

        Enable this option, script will generate the complete firmware for both old RTOS SDK(before V3.0)
        and NonOS SDK to update to v3 by OTA.

        The old RTOS SDK(before V3.0) or NonOS SDK can download the firmware to its partition and run it as it self's application.

config LOAD_OLD_RF_PARAMETER
    bool "Load old RF Parameters"
    default n
    depends on ESP8266_OTA_FROM_OLD
    select ESP_PHY_INIT_DATA_IN_PARTITION
    help
        The function is not released.

        Enable this option, after updating from old SDK to new SDK, bootloader will copy RF
        parameters from old SDK partition to new SDK partition.

        Then application can read the RF parameters from new partition directly.

config ESP8266_BOOT_COPY_APP
    bool "Boot copy app"
    default n
    help
        The function is not released.

        Enable this option, when it is that "OTA1" application is to run after update by OTA,
        bootloader will copy "OTA1" application to "OTA0" partition and run "OTA0".

    choice ESP8266_TIME_SYSCALL
        prompt "Timers used for gettimeofday function"
        default ESP8266_TIME_SYSCALL_USE_FRC1
        help
            This setting defines which hardware timers are used to
            implement 'gettimeofday' and 'time' functions in C library.

            - If high-resolution timer is used, gettimeofday will
              provide time at microsecond resolution.
              Time will not be preserved when going into deep sleep mode.
            - If no timers are used, gettimeofday and time functions
              return -1 and set errno to ENOSYS.

        config ESP8266_TIME_SYSCALL_USE_FRC1
            bool "High-resolution timer"
        config ESP8266_TIME_SYSCALL_USE_NONE
            bool "None"
    endchoice
endmenu

menu "Power Management"
    config PM_ENABLE
        bool "Support for power management"
        default n
        help
            If enabled, application is compiled with support for power management.
            This option has run-time overhead (increased interrupt latency,
            longer time to enter idle state), and it also reduces accuracy of
            RTOS ticks and timers used for timekeeping.
            Enable this option if application uses power management APIs.
endmenu

menu Wi-Fi

config SCAN_AP_MAX
    int "Max scan AP number"
    range 1 100
    default 99
    help
        Function "esp_wifi_scan_get_ap_num" return value will be less than this. It is said that user cannot
        scan more than this.

        User can use own function "esp_wifi_scan_get_ap_num_max" to determin how many AP to scan , too.

config WIFI_TX_RATE_SEQUENCE_FROM_HIGH
    bool "Set WiFi TX rate from 54M to 1M"
    default y
    help
        If this option is enabled, WiFi will try to send packets first from high rate(54M). If it fails, it will
        try at low rate until the transmission is successful.

config ESP8266_WIFI_QOS_ENABLED
    bool "WiFi QoS"
    default n
    help
        Select this option to enable QoS feature

config ESP8266_WIFI_AMPDU_RX_ENABLED
    bool "WiFi AMPDU RX"
    default n
    help
        Select this option to enable AMPDU RX feature

config ESP8266_WIFI_RX_BA_WIN_SIZE
    int "WiFi AMPDU RX BA window size"
    depends on ESP8266_WIFI_AMPDU_RX_ENABLED
    range 0 16
    default 6
    help
        Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better
        compatibility but more memory.

config ESP8266_WIFI_AMSDU_ENABLED
    bool "WiFi AMSDU RX"
    default n
    help
        Select this option to enable AMSDU feature

config ESP8266_WIFI_RX_BUFFER_NUM
    int "Max number of WiFi RX buffers"
    range 14 28
    default 16
    help
        Set the number of WiFi RX buffers. Each buffer takes approximately ESP8266_WIFI_RX_BUFFER_LEN bytes of RAM.

        WiFi hardware use these buffers to receive all 802.11 frames.
        A higher number may allow higher throughput but increases memory use. If ESP8266_WIFI_AMPDU_RX_ENABLED
        is enabled, this value is recommended to set equal or bigger than 8*1024/ESP8266_WIFI_RX_BUFFER_LEN in order
        to achieve better throughput and compatibility with both stations and APs.
        Most of time we should NOT change the default value unless special reason, e.g. test the maximum UDP RX
        throughput with iperf etc. For iperf test in shieldbox, the recommended value is 26.

config ESP8266_WIFI_LEFT_CONTINUOUS_RX_BUFFER_NUM
    int "The min number of WiFi continuous RX buffer"
    range 0 16
    default 8
    help
        Set the number of WiFi continuous RX buffer num.
        The smaller the value, the easier RX hang will appear. Most of time we should NOT change the default
        value unless special reason.

config ESP8266_WIFI_RX_PKT_NUM
    int "Max number of WiFi RX packets"
    range 4 16
    default 7
    help
        Set the max number of signle WiFi packet. 

config ESP8266_WIFI_TX_PKT_NUM
    int "Max number of WiFi TX packets"
    range 4 16
    default 6
    help
        Set the number of WiFi TX packets. Each buffer takes approximately 1.6KB of RAM.
        For some applications especially UDP applications, the upper layer can deliver frames faster than WiFi
        layer can transmit. In these cases, we may run out of TX packets.

config ESP8266_WIFI_NVS_ENABLED
    bool "WiFi NVS flash"
    default y
    help
        Select this option to enable WiFi NVS flash

config ESP8266_WIFI_CONNECT_OPEN_ROUTER_WHEN_PWD_IS_SET
    bool "Connect open router when wifi password is set"
    default y
    help
        When this option is enabled, ESP8266 will connect to open router even if wifi password is set, otherwise 
        ESP8266 will not connect to open router when wifi password is set.

config ESP8266_WIFI_DEBUG_LOG_ENABLE
    bool "Enable WiFi debug log"
    default n
    help
        Select this option to enable WiFi debug log

choice ESP8266_WIFI_DEBUG_LOG_LEVEL
    depends on ESP8266_WIFI_DEBUG_LOG_ENABLE
    prompt "The DEBUG level is enabled"
    default ESP8266_WIFI_DEBUG_LOG_ERROR
    help
        The WiFi log is divided into the following levels: ERROR,WARNING,INFO,DEBUG,VERBOSE.
        The ERROR level is enabled by default, and the WARNING,INFO,DEBUG,VERBOSE levels can be enabled here.

    config ESP8266_WIFI_DEBUG_LOG_ERROR
        bool "Error"
    config ESP8266_WIFI_DEBUG_LOG_WARNING
        bool "Warning"
    config ESP8266_WIFI_DEBUG_LOG_INFO
        bool "Info"
    config ESP8266_WIFI_DEBUG_LOG_DEBUG
        bool "Debug"
    config ESP8266_WIFI_DEBUG_LOG_VERBOSE
        bool "Verbose"
endchoice

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    depends on ESP8266_WIFI_DEBUG_LOG_ENABLE
    bool "WiFi debug log submodule"
    default n
    help
        Enable this option to set the WiFi debug log submodule.
        Currently the log submodule contains the following parts: INIT,IOCTL,CONN,SCAN.
        The INIT submodule indicates the initialization process.The IOCTL submodule indicates the API calling
        process.
        The CONN submodule indicates the connecting process.The SCAN submodule indicates the scaning process.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_CORE
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "core"
    default n
    help
        When this option is enabled, log for core module will be enabled..

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_SCAN
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "scan"
    default n
    help
        When this option is enabled, log for scan module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_PM
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "power management"
    default n
    help
        When this option is enabled, log for power management module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_NVS
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "NVS"
    default n
    help
        When this option is enabled, log for NVS module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_TRC
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "TRC"
    default n
    help
        When this option is enabled, log for TRC module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_EBUF
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "EBUF"
    default n
    help
        When this option is enabled, log for EBUF module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_NET80211
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "NET80211"
    default n
    help
        When this option is enabled, log for net80211 module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_TIMER
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "TIMER"
    default n
    help
        When this option is enabled, log for timer module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_ESPNOW
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "ESPNOW"
    default n
    help
        When this option is enabled, log for espnow module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_MAC
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "MAC layer"
    default n
    help
        When this option is enabled, log for mac layer module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_WPA
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "wpa"
    default n
    help
        When this option is enabled, log for wpa module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_WPS
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "wps"
    default n
    help
        When this option is enabled, log for wps module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_AMPDU
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "ampdu"
    default n
    help
        When this option is enabled, log for ampdu module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_AMSDU
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "amsdu"
    default n
    help
        When this option is enabled, log for amsdu module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_FRAG
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "fragment"
    default n
    help
        When this option is enabled, log for frag module will be enabled.

config ESP8266_WIFI_DEBUG_LOG_SUBMODULE_WPA2
    depends on ESP8266_WIFI_DEBUG_LOG_SUBMODULE
    bool "wpa2_enterprise"
    default n
    help
        When this option is enabled, log for wpa2_enterprise module will be enabled.

endmenu

menu PHY

config ESP_PHY_CALIBRATION_AND_DATA_STORAGE
    bool "Store phy calibration data in NVS"
    default y
    help
        If this option is enabled, NVS will be initialized and calibration data will be loaded from there.
        If calibration data is not found, full calibration will be performed and stored in NVS. Normally,
        only partial calibration will be performed. If this option is disabled, full calibration will be performed.

        Full calibration needs 170 - 180ms.
        Partial calibration needs 35 - 40ms.
        No calibration needs 3.260 - 3.264ms.

        If it's easy that your board calibrate bad data, choose 'n'.
        Two cases for example, you should choose 'n':
        1.If your board is easy to be booted up with antenna disconnected.
        2.Because of your board design, each time when you do calibration, the result are too unstable.
        If unsure, choose 'y'.

config ESP_PHY_INIT_DATA_IN_PARTITION
    bool "Use a partition to store PHY init data"
    default n
    help
        If enabled, PHY init data will be loaded from a partition.
        When using a custom partition table, make sure that PHY data
        partition is included (type: 'data', subtype: 'phy').
        With default partition tables, this is done automatically.
        If PHY init data is stored in a partition, it has to be flashed there,
        otherwise runtime error will occur.

        If this option is not enabled, PHY init data will be embedded
        into the application binary.

        If unsure, choose 'n'.

config ESP_PHY_INIT_DATA_VDD33_CONST
    int "vdd33_const value"
    range 0 255
    default 33
    help
        vdd33_const provides ADC mode settings, i.e. selecting system voltage or external voltage measurements. 
        When measuring system voltage, it must be set to 255. 
        To read the external voltage on TOUT(ADC) pin, vdd33_const need less than 255
        When the ADC reference voltage is set to the actual VDD33 power supply voltage, the value range of vdd33_const is [18,36], the unit is 0.1V.
        When the ADC reference voltage is set to the default value of 3.3V as the supply voltage, the range of vdd33_const is [0, 18] or (36, 255).

config ESP8266_PHY_MAX_WIFI_TX_POWER
    int "Max WiFi TX power (dBm)"
    range 0 21
    default 20
    help
        Set maximum transmit power for WiFi radio. Actual transmit power for high
        data rates may be lower than this setting.

endmenu  # PHY

menu HSPI
config ESP8266_HSPI_HIGH_THROUGHPUT
    bool "Do some optimization to improve throughput"
    default n
    help
        If enable this configuration, some spi api will be placed into iram.
        And it will reduce iram memory.
endmenu  # Driver