#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

if ARCH_CHIP_ESPRESSIF || ARCH_CHIP_ESP32C6 || ARCH_CHIP_ESP32H2 || ARCH_CHIP_ESP32C3_GENERIC

choice ESPRESSIF_CHIP_SERIES
	prompt "Chip Series"
	default ESPRESSIF_ESP32C3

config ESPRESSIF_ESP32C3
	bool "ESP32-C3"
	---help---
		ESP32-C3 chip with a single RISC-V IMC core, no embedded Flash memory

config ESPRESSIF_ESP32C6
	bool "ESP32-C6"
	---help---
		Espressif ESP32-C6 (RV32IMAC).

config ESPRESSIF_ESP32H2
	bool "ESP32-H2"
	---help---
		Espressif ESP32-H2 (RV32IMC).

endchoice # ESPRESSIF_CHIP_SERIES

config ESPRESSIF_CHIP_SERIES
	string
	default "esp32c3" if ESPRESSIF_ESP32C3
	default "esp32c6" if ESPRESSIF_ESP32C6
	default "esp32h2" if ESPRESSIF_ESP32H2
	default "unknown"

choice ESPRESSIF_FLASH
	prompt "Flash Size"
	default ESPRESSIF_FLASH_4M if ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2

config ESPRESSIF_FLASH_2M
	bool "2 MB"

config ESPRESSIF_FLASH_4M
	bool "4 MB"

config ESPRESSIF_FLASH_8M
	bool "8 MB"

config ESPRESSIF_FLASH_16M
	bool "16 MB"

endchoice # ESPRESSIF_FLASH

config ESPRESSIF_FLASH_DETECT
	bool "Auto-detect FLASH size"
	default n
	---help---
		Auto detect flash size when flashing.

config ESPRESSIF_NUM_CPUS
	int
	default 1 if ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2

choice ESPRESSIF_CPU_FREQ
	prompt "CPU frequency"
	default ESPRESSIF_CPU_FREQ_160 if ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6
	default ESPRESSIF_CPU_FREQ_96 if ESPRESSIF_ESP32H2
	---help---
		CPU frequency to be set on application startup.

config ESPRESSIF_CPU_FREQ_40
	bool "40 MHz"
	depends on ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6
	---help---
		Set the CPU frequency to 40 MHz.

config ESPRESSIF_CPU_FREQ_48
	bool "48 MHz"
	depends on ESPRESSIF_ESP32H2
	---help---
		Set the CPU frequency to 48 MHz.

config ESPRESSIF_CPU_FREQ_64
	bool "64 MHz"
	depends on ESPRESSIF_ESP32H2
	---help---
		Set the CPU frequency to 64 MHz.

config ESPRESSIF_CPU_FREQ_80
	bool "80 MHz"
	depends on ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6
	---help---
		Set the CPU frequency to 80 MHz.

config ESPRESSIF_CPU_FREQ_96
	bool "96 MHz"
	depends on ESPRESSIF_ESP32H2
	---help---
		Set the CPU frequency to 96 MHz.

config ESPRESSIF_CPU_FREQ_160
	bool "160 MHz"
	depends on ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6
	---help---
		Set the CPU frequency to 160 MHz.

endchoice # ESPRESSIF_CPU_FREQ

config ESPRESSIF_CPU_FREQ_MHZ
	int
	default 40 if ESPRESSIF_CPU_FREQ_40
	default 48 if ESPRESSIF_CPU_FREQ_48
	default 64 if ESPRESSIF_CPU_FREQ_64
	default 80 if ESPRESSIF_CPU_FREQ_80
	default 96 if ESPRESSIF_CPU_FREQ_96
	default 160 if ESPRESSIF_CPU_FREQ_160

config ESPRESSIF_REGION_PROTECTION
	bool "Enable region protection"
	default y
	select ARCH_USE_MPU
	---help---
		Configure the MPU to disable access to invalid memory regions.

config ESPRESSIF_RUN_IRAM
	bool "Run from IRAM"
	default n
	---help---
		This loads all of NuttX inside IRAM. Used to test somewhat small
		images that can fit entirely in IRAM.

config ESPRESSIF_ESPTOOLPY_NO_STUB
	bool "Disable download stub"
	default n
	---help---
		The flasher tool sends a precompiled download stub first by default.
		That stub allows things like compressed downloads and more.
		Usually you should not need to disable that feature.
		It is only required to be disabled in certain scenarios when either
		Secure Boot V2 or Flash Encryption is enabled.

config ESPRESSIF_HAL_ASSERTIONS
	bool "Enable HAL assertions"
	depends on DEBUG_ASSERTIONS
	default y
	---help---
		Enable the assertions implemented in the HAL. Otherwise, the assertions
		are replaced by empty macros.

config ESPRESSIF_SOC_RTC_MEM_SUPPORTED
	bool
	default n

menu "Bootloader and Image Configuration"

config ESPRESSIF_SIMPLE_BOOT
	bool
	depends on !ESPRESSIF_BOOTLOADER_MCUBOOT
	default y

config ESPRESSIF_BOOTLOADER_MCUBOOT
	bool "Enable MCUboot-bootable format"
	select ESPRESSIF_HAVE_OTA_PARTITION
	depends on ESPRESSIF_ESP32C3
	---help---
		Enables the Espressif port of MCUboot to be used as 2nd stage bootloader.

config ESPRESSIF_MCUBOOT_VERSION
	string "MCUboot version"
	depends on ESPRESSIF_BOOTLOADER_MCUBOOT
	default "aa7e2b1faae623dbe01bbc6094e71ab44ec9d80a"

choice ESPRESSIF_ESPTOOL_TARGET_SLOT
	prompt "Target slot for image flashing"
	default ESPRESSIF_ESPTOOL_TARGET_PRIMARY
	depends on ESPRESSIF_HAVE_OTA_PARTITION
	---help---
		Slot to which ESPTOOL will flash the generated binary image.

config ESPRESSIF_ESPTOOL_TARGET_PRIMARY
	bool "Application image primary slot"
	---help---
		This assumes that the generated image is already pre-validated.
		This is the recommended option for the initial stages of the
		application firmware image development.

config ESPRESSIF_ESPTOOL_TARGET_SECONDARY
	bool "Application image secondary slot"
	---help---
		The application needs to confirm the generated image as valid,
		otherwise the bootloader may consider it invalid and perform the
		rollback of the update after a reset.
		This is the choice most suitable for the development and verification
		of a secure firmware update workflow.

endchoice

config ESPRESSIF_APP_MCUBOOT_HEADER_SIZE
	int "Application image header size (in bytes)"
	default 32
	depends on ESPRESSIF_BOOTLOADER_MCUBOOT

config ESPRESSIF_HAVE_OTA_PARTITION
	bool
	default n

if ESPRESSIF_HAVE_OTA_PARTITION

comment "Application Image OTA Update support"

config ESPRESSIF_OTA_PRIMARY_SLOT_OFFSET
	hex "Application image primary slot offset"
	default 0x10000

config ESPRESSIF_OTA_PRIMARY_SLOT_DEVPATH
	string "Application image primary slot device path"
	default "/dev/ota0"

config ESPRESSIF_OTA_SECONDARY_SLOT_OFFSET
	hex "Application image secondary slot offset"
	default 0x110000

config ESPRESSIF_OTA_SECONDARY_SLOT_DEVPATH
	string "Application image secondary slot device path"
	default "/dev/ota1"

config ESPRESSIF_OTA_SLOT_SIZE
	hex "Application image slot size (in bytes)"
	default 0x100000

config ESPRESSIF_OTA_SCRATCH_OFFSET
	hex "Scratch partition offset"
	default 0x210000

config ESPRESSIF_OTA_SCRATCH_SIZE
	hex "Scratch partition size"
	default 0x40000

config ESPRESSIF_OTA_SCRATCH_DEVPATH
	string "Scratch partition device path"
	default "/dev/otascratch"

endif # ESPRESSIF_HAVE_OTA_PARTITION

endmenu # Bootloader and Image Configuration

menu "Peripheral Support"

config ESPRESSIF_RTC
	bool "Real Time Clock (RTC)"
	default y

config ESPRESSIF_UART
	bool
	default n

config ESPRESSIF_UART0
	bool "UART0"
	default y
	select ESPRESSIF_UART
	select UART0_SERIALDRIVER
	select ARCH_HAVE_SERIAL_TERMIOS

config ESPRESSIF_UART1
	bool "UART1"
	default n
	select ESPRESSIF_UART
	select UART1_SERIALDRIVER
	select ARCH_HAVE_SERIAL_TERMIOS

config ESPRESSIF_TWAI
	bool "TWAI (CAN)"
	default n
	select ARCH_HAVE_CAN_ERRORS
	select CAN

config ESPRESSIF_TWAI0
	bool "TWAI0 (CAN)"
	default n
	select ESPRESSIF_TWAI
	select ARCH_HAVE_CAN_ERRORS
	select CAN

config ESPRESSIF_TWAI1
	bool "TWAI1 (CAN)"
	default n
	depends on ESPRESSIF_ESP32C6
	select ESPRESSIF_TWAI
	select ARCH_HAVE_CAN_ERRORS
	select CAN

config ESPRESSIF_USBSERIAL
	bool "USB-Serial-JTAG Driver"
	default n
	select OTHER_UART_SERIALDRIVER
	select ARCH_HAVE_SERIAL_TERMIOS

config ESPRESSIF_GPIO_IRQ
	bool "GPIO pin interrupts"
	default n
	---help---
		Enable support for interrupting GPIO pins

config ESPRESSIF_RTCIO_IRQ
	bool "RTC IO interrupts"
	default n
	depends on !ARCH_CHIP_ESP32H2 && !ARCH_CHIP_ESP32C6
	---help---
		Enable support for RTC peripherals interrupts.

config ESPRESSIF_LEDC
	bool "LEDC (PWM)"
	default n
	select PWM
	select ARCH_HAVE_PWM_MULTICHAN

config ESPRESSIF_SPI
	bool
	default n

config ESPRESSIF_SPI2
	bool "SPI 2"
	default n
	select ESPRESSIF_SPI
	select SPI

config ESPRESSIF_SPIFLASH
	bool "SPI Flash"
	default n

config ESPRESSIF_HR_TIMER
	bool
	default RTC_DRIVER
	---help---
		A high-resolution hardware timer for supporting the management of
		kernel events.
		The HR Timer is built on top of the System Timer (SYSTIMER) peripheral.
		Timer callbacks are dispatched from a high-priority kernel task.

config ESPRESSIF_WDT
	bool
	default n
	select WATCHDOG

config ESPRESSIF_MWDT0
	bool "Main System Watchdog Timer (Group 0)"
	default n
	select ESPRESSIF_WDT
	---help---
		Includes MWDT0. This watchdog timer is part of the Group 0
		timer submodule.

config ESPRESSIF_MWDT1
	bool "Main System Watchdog Timer (Group 1)"
	default n
	select ESPRESSIF_WDT
	---help---
		Includes MWDT1. This watchdog timer is part of the Group 1
		timer submodule.

config ESPRESSIF_RWDT
	bool "RTC Watchdog Timer"
	default n
	select ESPRESSIF_WDT
	---help---
		Includes RWDT. This watchdog timer is from the RTC module.
		When it is selected, if the developer sets it to reset on expiration
		it will reset Main System and the RTC module. If you don't want
		to have the RTC module reset, please, use the Timers' Module WDTs.
		They will only reset Main System.

config ESPRESSIF_XTWDT
	bool "XTAL32K Watchdog Timer"
	depends on ARCH_CHIP_ESP32C3_GENERIC
	depends on ESPRESSIF_RTCIO_IRQ
	depends on ESPRESSIF_RTC_CLK_EXT_OSC || ESPRESSIF_RTC_CLK_EXT_XTAL
	default n
	select ESPRESSIF_WDT
	---help---
		Includes XTWDT. This watchdog timer monitors the status of the
		external 32 kHz crystal oscillator (XTAL32K). When XTAL32K_CLK works
		as the clock source of RTC_SLOW_CLK and it stops oscillating, the
		XTAL32K watchdog timer first switches to BACKUP32K_CLK derived from
		RC_SLOW_CLK (if ESP32S2_XTWDT_BACKUP_CLK_ENABLE) and, then, generates
		an interrupt that could be captured by WDIOC_CAPTURE.

config ESPRESSIF_XTWDT_TIMEOUT
	int "XTAL32K watchdog timeout period"
	depends on ESPRESSIF_XTWDT
	range 1 255
	default 200
	help
		Timeout period configuration for the XTAL32K watchdog timer based on RTC_CLK.

config ESPRESSIF_XTWDT_BACKUP_CLK_ENABLE
	bool "Automatically switch to BACKUP32K_CLK when timer expires"
	depends on ESPRESSIF_XTWDT
	default y
	---help---
		Enable this to automatically switch to BACKUP32K_CLK as the source of
		RTC_SLOW_CLK when the watchdog timer expires.

config ESPRESSIF_BROWNOUT_DET
	bool "Brownout Detector"
	default y
	---help---
		A built-in brownout detector which can detect if the voltage is lower
		than a specific value. If this happens, it will reset the chip in
		order to prevent unintended behaviour.

config ESP_RMT
	bool "Remote Control Module (RMT)"
	default n
	depends on RMT
	---help---
		The RMT (Remote Control Transceiver) peripheral was designed to act as
		an infrared transceiver. However, due to the flexibility of its data
		format, RMT can be extended to a versatile and general-purpose
		transceiver, transmitting or receiving many other types of signals.

config ESP_WIRELESS
	bool
	default n
	select NET
	select ARCH_PHY_INTERRUPT
	select RTC
	select RTC_DRIVER
	select ESPRESSIF_HR_TIMER

config ESPRESSIF_WIFI
	bool "Wi-Fi"
	depends on ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6
	default n
	select ESP_WIRELESS
	---help---
		Enable Wi-Fi support

config ESP_COEX_SW_COEXIST_ENABLE
	bool "Software WiFi/Bluetooth/IEEE 802.15.4 coexistence"
	depends on (ESPRESSIF_WIFI && ESPRESSIF_BLE) || \
               (ESPRESSIF_WIFI && ESP_IEEE802154)   || \
               (ESP_IEEE802154 && ESPRESSIF_BLE)
	default y
	---help---
		If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware.
		Recommended for heavy traffic scenarios. Both coexistence configuration options are
		automatically managed, no user intervention is required.
		If only Bluetooth is used, it is recommended to disable this option to reduce binary file
		size.

endmenu # Peripheral Support

menu "Wi-Fi Configuration"
	depends on ESPRESSIF_WIFI

menu "ESP WPA-Supplicant"

config WPA_WAPI_PSK
	bool "Enable WAPI PSK support"
	default n
	---help---
		Select this option to enable WAPI-PSK
		which is a Chinese National Standard Encryption for Wireless LANs (GB 15629.11-2003).

config WPA_SUITE_B_192
	bool "Enable NSA suite B support with 192-bit key"
	default n
	select ESPRESSIF_WIFI_GCMP_SUPPORT
	select ESPRESSIF_WIFI_GMAC_SUPPORT
	---help---
		Select this option to enable 192-bit NSA suite-B.
		This is necessary to support WPA3 192-bit security.

config ESP_WPA_DEBUG_PRINT
	bool "Print debug messages from Espressif's WPA Supplicant"
	default n
	---help---
		Select this option to print logging information from WPA supplicant,
		this includes handshake information and key hex dumps depending
		on the project logging level.

		Enabling this could increase the build size ~60kb
		depending on the project logging level.

endmenu # ESP WPA-Supplicant

choice ESPRESSIF_WIFI_MODE
	prompt "ESP Wi-Fi mode"
	default ESPRESSIF_WIFI_STATION

config ESPRESSIF_WIFI_STATION
	bool "Station mode"

config ESPRESSIF_WIFI_SOFTAP
	bool "SoftAP mode"

config ESPRESSIF_WIFI_STATION_SOFTAP
	bool "Station + SoftAP"

endchoice # ESPRESSIF_WIFI_MODE

config ESPRESSIF_WIFI_ENABLE_WPA3_SAE
	bool "Enable WPA3-Personal"
	default y
	---help---
		Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's.
		PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be
		explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details.

config ESPRESSIF_WIFI_ENABLE_SAE_PK
	bool "Enable SAE-PK"
	depends on ESPRESSIF_WIFI_ENABLE_WPA3_SAE
	default y
	---help---
		Select this option to enable SAE-PK

config ESPRESSIF_WIFI_SOFTAP_SAE_SUPPORT
	bool "Enable WPA3 Personal(SAE) SoftAP"
	default y
	depends on ESPRESSIF_WIFI_ENABLE_WPA3_SAE
	depends on ESPRESSIF_WIFI_SOFTAP || ESPRESSIF_WIFI_STATION_SOFTAP
	---help---
		Select this option to enable SAE support in softAP mode.

config ESPRESSIF_WIFI_ENABLE_WPA3_OWE_STA
	bool "Enable OWE STA"
	default y
	---help---
		Select this option to allow the device to establish OWE connection with eligible AP's.
		PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be
		explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details.

config ESPRESSIF_WIFI_STATIC_RX_BUFFER_NUM
	int "Max number of WiFi static RX buffers"
	range 2 25 if !ESPRESSIF_ESP32C6
	range 2 128 if ESPRESSIF_ESP32C6
	default 10
	---help---
		Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM.
		The static rx buffers are allocated when esp_wifi_init is called, they are not freed
		until esp_wifi_deinit is called.

		WiFi hardware use these buffers to receive all 802.11 frames.
		A higher number may allow higher throughput but increases memory use. If ESPRESSIF_WIFI_AMPDU_RX_ENABLED
		is enabled, this value is recommended to set equal or bigger than ESPRESSIF_WIFI_RX_BA_WIN in order to
		achieve better throughput and compatibility with both stations and APs.

config ESPRESSIF_WIFI_DYNAMIC_RX_BUFFER_NUM
	int "Max number of WiFi dynamic RX buffers"
	default 32
	---help---
		Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers will be allocated
		(provided sufficient free RAM). The size of each dynamic RX buffer depends on the size of
		the received data frame.

		For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers
		it to the high layer TCP/IP stack. The dynamic RX buffer is freed after the higher layer has
		successfully received the data frame.

		For some applications, WiFi data frames may be received faster than the application can
		process them. In these cases we may run out of memory if RX buffer number is unlimited (0).

		If a dynamic RX buffer limit is set, it should be at least the number of static RX buffers.

config ESPRESSIF_WIFI_DYNAMIC_TX_BUFFER_NUM
	int "Max number of WiFi dynamic TX buffers"
	range 1 128
	default 32
	---help---
		Set the number of WiFi dynamic TX buffers. The size of each dynamic TX buffer is not fixed,
		it depends on the size of each transmitted data frame.

		For each transmitted frame from the higher layer TCP/IP stack, the WiFi driver makes a copy
		of it in a TX buffer. 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
		buffers.

config ESPRESSIF_WIFI_AMPDU_TX_ENABLED
	bool "Wi-Fi TX AMPDU"
	default y
	---help---
		Select this option to enable AMPDU TX feature

config ESPRESSIF_WIFI_TX_BA_WIN
	int "WiFi AMPDU TX BA window size"
	depends on ESPRESSIF_WIFI_AMPDU_TX_ENABLED
	range 2 32 if !ESPRESSIF_ESP32C6
	range 2 64 if ESPRESSIF_ESP32C6
	default 6

config ESPRESSIF_WIFI_AMPDU_RX_ENABLED
	bool "WiFi AMPDU RX"
	default y
	---help---
		Select this option to enable AMPDU RX feature

config ESPRESSIF_WIFI_RX_BA_WIN
	int "WiFi AMPDU RX BA window size"
	depends on ESPRESSIF_WIFI_AMPDU_RX_ENABLED
	range 2 32 if !ESPRESSIF_ESP32C6
	range 2 64 if ESPRESSIF_ESP32C6
	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. 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 9~12. If PSRAM is used and WiFi memory is prefered to allocat in PSRAM first,
		the default and minimum value should be 16 to achieve better throughput and compatibility with both
		stations and APs.

config ESPRESSIF_WIFI_GCMP_SUPPORT
	bool "WiFi GCMP Support(GCMP128 and GCMP256)"
	default n
	---help---
		Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support.

config ESPRESSIF_WIFI_GMAC_SUPPORT
	bool "WiFi GMAC Support(GMAC128 and GMAC256)"
	default n
	---help---
		Select this option to enable GMAC support. GMAC support is compulsory for WiFi 192-bit certification.

config ESPRESSIF_WIFI_CONNECT_TIMEOUT
	int "Connect timeout in second"
	default 10
	---help---
		Max waiting time of connecting to AP.

config ESPRESSIF_WIFI_SCAN_RESULT_SIZE
	int "Scan result buffer"
	default 4096
	---help---
		Maximum scan result buffer size.

config ESPRESSIF_WIFI_STA_DISCONNECT_PM
	bool "Power Management for station when disconnected"
	default y
	---help---
		Select this option to enable power management for station when disconnected.
		Chip will do modem-sleep when RF module is not in use anymore.

choice ESP_POWER_SAVE_MODE
	prompt "Wi-Fi Power save mode"
	default ESP_POWER_SAVE_MIN_MODEM if ESPRESSIF_WIFI_BT_COEXIST
	default ESP_POWER_SAVE_NONE
	---help---
		Wi-Fi supports the Modem-sleep mode which refers to the legacy power-saving mode in the IEEE 802.11 protocol.
		Modem-sleep mode works in station-only mode and the station must connect to the AP first. If the Modem-sleep
		mode is enabled, station will switch between active and sleep state periodically. In sleep state, RF, PHY and
		BB are turned off in order to reduce power consumption. Station can keep connection with AP in modem-sleep mode.

		Modem-sleep mode includes minimum and maximum power-saving modes.

		In minimum power-saving mode, station wakes
		up every DTIM to receive beacon. Broadcast data will not be lost because it is transmitted after DTIM.
		However, it cannot save much more power if DTIM is short for DTIM is determined by AP.

		In maximum power-saving mode, station wakes up in every listen interval to receive beacon. This listen interval
		can be set to be longer than the AP DTIM period. Broadcast data may be lost because station may be in sleep
		state at DTIM time. If listen interval is longer, more power is saved, but broadcast data is more easy to lose.
		Listen interval can be configured by setting ESPRESSIF_WIFI_LISTEN_INTERVAL.

		ESP_POWER_SAVE_NONE disables Modem-sleep mode entirely. Disabling it increases power consumption, but
		minimizes the delay in receiving Wi-Fi data in real time. When Modem-sleep mode is enabled, the delay in
		receiving Wi-Fi data may be the same as the DTIM cycle (minimum power-saving mode) or the listening interval
		(maximum power-saving mode). Setting ESP_POWER_SAVE_NONE is suitable when high throughput is required.

config ESP_POWER_SAVE_NONE
	bool "No power save"

config ESP_POWER_SAVE_MIN_MODEM
	bool "Minimum modem power saving."

config ESP_POWER_SAVE_MAX_MODEM
	bool "Maximum modem power saving"

endchoice # ESP_POWER_SAVE_MODE

endmenu # ESPRESSIF_WIFI

menu "UART Configuration"
	depends on ESPRESSIF_UART

if ESPRESSIF_UART0

config ESPRESSIF_UART0_TXPIN
	int "UART0 TX Pin"
	default 21 if ESPRESSIF_ESP32C3
	default 16 if ESPRESSIF_ESP32C6
	default 24 if ESPRESSIF_ESP32H2
	range 0 21 if ESPRESSIF_ESP32C3
	range 0 30 if ESPRESSIF_ESP32C6
	range 0 27 if ESPRESSIF_ESP32H2

config ESPRESSIF_UART0_RXPIN
	int "UART0 RX Pin"
	default 20 if ESPRESSIF_ESP32C3
	default 17 if ESPRESSIF_ESP32C6
	default 23 if ESPRESSIF_ESP32H2
	range 0 21 if ESPRESSIF_ESP32C3
	range 0 30 if ESPRESSIF_ESP32C6
	range 0 27 if ESPRESSIF_ESP32H2

config ESPRESSIF_UART0_RTSPIN
	int "UART0 RTS Pin"
	depends on SERIAL_IFLOWCONTROL
	default 16 if ESPRESSIF_ESP32C3
	default 15 if ESPRESSIF_ESP32C6
	default 22 if ESPRESSIF_ESP32H2
	range 0 21 if ESPRESSIF_ESP32C3
	range 0 30 if ESPRESSIF_ESP32C6
	range 0 27 if ESPRESSIF_ESP32H2

config ESPRESSIF_UART0_CTSPIN
	int "UART0 CTS Pin"
	depends on SERIAL_OFLOWCONTROL
	default 15 if ESPRESSIF_ESP32C3
	default 14 if ESPRESSIF_ESP32C6
	default 21 if ESPRESSIF_ESP32H2
	range 0 21 if ESPRESSIF_ESP32C3
	range 0 30 if ESPRESSIF_ESP32C6
	range 0 27 if ESPRESSIF_ESP32H2

endif # ESPRESSIF_UART0

if ESPRESSIF_UART1

config ESPRESSIF_UART1_TXPIN
	int "UART1 TX Pin"
	default 8 if ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2

config ESPRESSIF_UART1_RXPIN
	int "UART1 RX Pin"
	default 9 if ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2

config ESPRESSIF_UART1_RTSPIN
	int "UART1 RTS Pin"
	depends on SERIAL_IFLOWCONTROL
	default 1 if ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2
	range 0 21 if ESPRESSIF_ESP32C3
	range 0 30 if ESPRESSIF_ESP32C6
	range 0 27 if ESPRESSIF_ESP32H2

config ESPRESSIF_UART1_CTSPIN
	int "UART1 CTS Pin"
	depends on SERIAL_OFLOWCONTROL
	default 2 if ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2
	range 0 21 if ESPRESSIF_ESP32C3
	range 0 30 if ESPRESSIF_ESP32C6
	range 0 27 if ESPRESSIF_ESP32H2

endif # ESPRESSIF_UART1

endmenu # UART Configuration

menu "TWAI driver options"
	depends on ESPRESSIF_TWAI

if ESPRESSIF_TWAI0

config ESPRESSIF_TWAI0_TXPIN
	int "TWAI0 TX Pin"
	default 2

config ESPRESSIF_TWAI0_RXPIN
	int "TWAI0 RX Pin"
	default 3

choice ESPRESSIF_TWAI0_TIMING
	prompt "TWAI0 Timing config"
	default TWAI0_TIMING_100KBITS
	---help---
		These options control timing of TWAI0.

config TWAI0_TIMING_100KBITS
	bool "100 KBits"

config TWAI0_TIMING_125KBITS
	bool "125 KBits"

config TWAI0_TIMING_250KBITS
	bool "250 KBits"

config TWAI0_TIMING_500KBITS
	bool "500 KBits"

config TWAI0_TIMING_800KBITS
	bool "800 KBits"

endchoice # ESPRESSIF_TWAI0_TIMING

config ESPRESSIF_TWAI0_SAM
	bool "TWAI0 sampling"
	default n
	---help---
		The bus is sampled 3 times (recommended for low to medium speed buses
		to spikes on the bus-line).

endif # ESPRESSIF_TWAI0

if ESPRESSIF_TWAI1

config ESPRESSIF_TWAI1_TXPIN
	int "TWAI1 TX Pin"
	default 4

config ESPRESSIF_TWAI1_RXPIN
	int "TWAI1 RX Pin"
	default 5

choice ESPRESSIF_TWAI1_TIMING
	prompt "TWAI1 Timing config"
	default TWAI1_TIMING_100KBITS
	---help---
		These options control timing of TWAI1.

config TWAI1_TIMING_100KBITS
	bool "100 KBits"

config TWAI1_TIMING_125KBITS
	bool "125 KBits"

config TWAI1_TIMING_250KBITS
	bool "250 KBits"

config TWAI1_TIMING_500KBITS
	bool "500 KBits"

config TWAI1_TIMING_800KBITS
	bool "800 KBits"

endchoice # ESPRESSIF_TWAI1_TIMING

config ESPRESSIF_TWAI1_SAM
	bool "TWAI1 sampling"
	default n
	---help---
		The bus is sampled 3 times (recommended for low to medium speed buses
		to spikes on the bus-line).

endif # ESPRESSIF_TWAI1

config ESPRESSIF_TWAI_TEST_MODE
	bool "TWAI character driver loopback test mode (for testing only)"
	default n
	depends on CAN_LOOPBACK
	---help---
		This enables a loopback test mode that attaches the transmitter
		to the receiver internally, being able to test the TWAI
		peripheral without any external connection.

endmenu #ESPRESSIF_TWAI

menu "SPI configuration"
	depends on ESPRESSIF_SPI

config ESPRESSIF_SPI_SWCS
	bool "SPI software CS"
	default n
	---help---
		Use SPI software CS.

config ESPRESSIF_SPI_UDCS
	bool "User defined CS"
	default n
	depends on ESPRESSIF_SPI_SWCS
	---help---
		Use user-defined CS.

if ESPRESSIF_SPI2

config ESPRESSIF_SPI2_SLAVE
	bool "SPI2 Slave mode"
	default n
	depends on SPI_SLAVE
	select ESPRESSIF_GPIO_IRQ
	---help---
		Configure SPI2 to operate in Slave mode.

config ESPRESSIF_SPI2_SLAVE_BUFSIZE
	int "SPI2 Slave buffer size"
	default 2048
	depends on ESPRESSIF_SPI2_SLAVE
	---help---
		Configure the size of SPI2 Slave controller's internal buffers.

config ESPRESSIF_SPI2_CSPIN
	int "SPI2 CS Pin"
	default 10
	range 0 21

config ESPRESSIF_SPI2_CLKPIN
	int "SPI2 CLK Pin"
	default 6
	range 0 21

config ESPRESSIF_SPI2_MOSIPIN
	int "SPI2 MOSI Pin"
	default 7
	range 0 21

config ESPRESSIF_SPI2_MISOPIN
	int "SPI2 MISO Pin"
	default 2
	range 0 21

endif # ESPRESSIF_SPI2

config ESPRESSIF_SPI_TEST_MODE
	bool "SPI driver loopback test mode (for testing only)"
	default n
	depends on SYSTEM_SPITOOL
	---help---
		This enables a loopback test mode that attaches the transmitter
		to the receiver internally, being able to test the SPI
		peripheral without any external connection.

endmenu # SPI configuration

menu "SPI Flash Configuration"

choice ESPRESSIF_FLASH_MODE
	prompt "SPI Flash mode"
	default ESPRESSIF_FLASH_MODE_DIO
	---help---
		These options control how many I/O pins are used for communication with the attached SPI Flash chip.
		The option selected here is then used by esptool when flashing.

config ESPRESSIF_FLASH_MODE_DIO
	bool "Dual IO (DIO)"

config ESPRESSIF_FLASH_MODE_DOUT
	bool "Dual Output (DOUT)"

config ESPRESSIF_FLASH_MODE_QIO
	bool "Quad IO (QIO)"

config ESPRESSIF_FLASH_MODE_QOUT
	bool "Quad Output (QOUT)"

endchoice # ESPRESSIF_FLASH_MODE

if ESPRESSIF_SPIFLASH
comment "General storage MTD configuration"

config ESPRESSIF_MTD
	bool "MTD driver"
	default y
	select MTD
	select MTD_BYTE_WRITE
	select MTD_PARTITION
	---help---
		Initialize an MTD driver for the SPI Flash, which will
		add an entry at /dev for application access from userspace.

config ESPRESSIF_SPIFLASH_MTD_BLKSIZE
	int "Storage MTD block size"
	default 64
	depends on ESPRESSIF_MTD
	---help---
		Block size for MTD driver in kB. This size must be divisible by 2

config ESPRESSIF_STORAGE_MTD_DEBUG
	bool "Storage MTD Debug"
	default n
	depends on ESPRESSIF_MTD && DEBUG_FS_INFO
	---help---
		If this option is enabled, Storage MTD driver read and write functions
		will output input parameters and return values (if applicable).
endif # ESPRESSIF_SPIFLASH

choice ESPRESSIF_FLASH_FREQ
	prompt "SPI Flash frequency"
	default ESPRESSIF_FLASH_FREQ_80M if ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6
	default ESPRESSIF_FLASH_FREQ_48M if ESPRESSIF_ESP32H2
	---help---
		SPI Flash frequency.

config ESPRESSIF_FLASH_FREQ_80M
	bool "80 MHz"
	depends on ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6

config ESPRESSIF_FLASH_FREQ_48M
	bool "48 MHz"
	depends on ESPRESSIF_ESP32H2

config ESPRESSIF_FLASH_FREQ_40M
	bool "40 MHz"
	depends on ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6

config ESPRESSIF_FLASH_FREQ_26M
	bool "26 MHz"
	depends on ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6

config ESPRESSIF_FLASH_FREQ_20M
	bool "20 MHz"
	depends on ESPRESSIF_ESP32C3 || ESPRESSIF_ESP32C6

endchoice # ESPRESSIF_FLASH_FREQ

config ESPRESSIF_SPI_FLASH_USE_ROM_CODE
	bool "Use SPI flash driver in ROM"
	default n
	depends on ESPRESSIF_ESP32C3
	---help---
		Use functions in ROM for SPI flash driver instead of
		source code.

config ESPRESSIF_SPI_FLASH_USE_32BIT_ADDRESS
	bool "SPI flash uses 32-bit address"
	default n
	---help---
		SPI flash driver in ROM only support 24-bit address access,
		if select the option, it will force to use source code instead
		of functions in ROM, so that SPI flash driver can access full
		32-bit address.

config ESPRESSIF_STORAGE_MTD_OFFSET
	hex "Storage MTD base address in SPI Flash"
	default 0x180000
	depends on ESPRESSIF_MTD
	---help---
		MTD base address in SPI Flash.

config ESPRESSIF_STORAGE_MTD_SIZE
	hex "Storage MTD size in SPI Flash"
	default 0x100000
	depends on ESPRESSIF_MTD
	---help---
		MTD size in SPI Flash.

endmenu # SPI Flash Configuration

menu "RTC Configuration"
	depends on ESPRESSIF_RTC

choice ESPRESSIF_RTC_CLK_SRC
	prompt "RTC clock source"
	default ESPRESSIF_RTC_CLK_INT_RC
	---help---
		Choose which clock is used as RTC clock source.

		- "Internal 90KHz oscillator" option provides lowest deep sleep current
			consumption, and does not require extra external components. However
			frequency stability with respect to temperature is poor, so time may
			drift in deep/light sleep modes.
		- "External 32KHz crystal" provides better frequency stability, at the
			expense of slightly higher (1uA) deep sleep current consumption.
		- "External 32KHz oscillator" allows using 32KHz clock generated by an
			external circuit. In this case, external clock signal must be connected
			to 32K_XN pin. Amplitude should be <1.2V in case of sine wave signal,
			and <1V in case of square wave signal. Common mode voltage should be
			0.1 < Vcm < 0.5Vamp, where Vamp is the signal amplitude.
			Additionally, 1nF capacitor must be connected between 32K_XP pin and
			ground. 32K_XP pin can not be used as a GPIO in this case.
		- "Internal 8.5MHz oscillator divided by 256" option results in higher
			deep sleep current (by 5uA) but has better frequency stability than
			the internal 90KHz oscillator. It does not require external components.

config ESPRESSIF_RTC_CLK_INT_RC
	bool "Internal 90KHz RC oscillator"

config ESPRESSIF_RTC_CLK_EXT_XTAL
	bool "External 32KHz crystal"
	select ESP_SYSTEM_RTC_EXT_XTAL

config ESPRESSIF_RTC_CLK_EXT_OSC
	bool "External 32KHz oscillator at 32K_XN pin"
	select ESP_SYSTEM_RTC_EXT_XTAL

config ESPRESSIF_RTC_CLK_INT_8MD256
	bool "Internal 8.5MHz oscillator, divided by 256 (~33kHz)"

endchoice
endmenu # "RTC Configuration"

menu "LEDC configuration"
	depends on ESPRESSIF_LEDC

config ESPRESSIF_LEDC_HPOINT
	hex "LEDC hpoint value"
	default 0x0000
	range 0x0 0xfffff

menuconfig ESPRESSIF_LEDC_TIMER0
	bool "Timer 0"
	default n

if ESPRESSIF_LEDC_TIMER0

config ESPRESSIF_LEDC_TIMER0_CHANNELS
	int "Number of Timer 0 channels"
	default 2 if PWM_MULTICHAN && PWM_NCHANNELS > 1
	default 1 if !PWM_MULTICHAN || PWM_NCHANNELS = 1
	range 0 6

config ESPRESSIF_LEDC_TIMER0_RESOLUTION
	int "Timer 0 resolution"
	default 13
	range 1 14 if ESPRESSIF_ESP32C3 && !(ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2)
	range 1 20 if !ESPRESSIF_ESP32C3 && (ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2)
	---help---
		Timer resolution in bits. The resolution is the number of bits used to by the timer
		counter to generate the PWM signal. The duty cycle provided by the upper layers
		will be scaled to fit the resolution.

endif # ESPRESSIF_LEDC_TIMER0

menuconfig ESPRESSIF_LEDC_TIMER1
	bool "Timer 1"
	default n

if ESPRESSIF_LEDC_TIMER1

config ESPRESSIF_LEDC_TIMER1_CHANNELS
	int "Number of Timer 1 channels"
	default 2 if PWM_MULTICHAN && PWM_NCHANNELS > 1
	default 1 if !PWM_MULTICHAN || PWM_NCHANNELS = 1
	range 0 6

config ESPRESSIF_LEDC_TIMER1_RESOLUTION
	int "Timer 1 resolution"
	default 13
	range 1 14 if ESPRESSIF_ESP32C3 && !(ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2)
	range 1 20 if !ESPRESSIF_ESP32C3 && (ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2)
	---help---
		Timer resolution in bits. The resolution is the number of bits used to by the timer
		counter to generate the PWM signal. The duty cycle provided by the upper layers
		will be scaled to fit the resolution.

endif # ESPRESSIF_LEDC_TIMER1

menuconfig ESPRESSIF_LEDC_TIMER2
	bool "Timer 2"
	default n

if ESPRESSIF_LEDC_TIMER2

config ESPRESSIF_LEDC_TIMER2_CHANNELS
	int "Number of Timer 2 channels"
	default 2 if PWM_MULTICHAN && PWM_NCHANNELS > 1
	default 1 if !PWM_MULTICHAN || PWM_NCHANNELS = 1
	range 0 6

config ESPRESSIF_LEDC_TIMER2_RESOLUTION
	int "Timer 2 resolution"
	default 13
	range 1 14 if ESPRESSIF_ESP32C3 && !(ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2)
	range 1 20 if !ESPRESSIF_ESP32C3 && (ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2)
	---help---
		Timer resolution in bits. The resolution is the number of bits used to by the timer
		counter to generate the PWM signal. The duty cycle provided by the upper layers
		will be scaled to fit the resolution.

endif # ESPRESSIF_LEDC_TIMER2

menuconfig ESPRESSIF_LEDC_TIMER3
	bool "Timer 3"
	default n

if ESPRESSIF_LEDC_TIMER3

config ESPRESSIF_LEDC_TIMER3_CHANNELS
	int "Number of Timer 3 channels"
	default 2 if PWM_MULTICHAN && PWM_NCHANNELS > 1
	default 1 if !PWM_MULTICHAN || PWM_NCHANNELS = 1
	range 0 6

config ESPRESSIF_LEDC_TIMER3_RESOLUTION
	int "Timer 3 resolution"
	default 13
	range 1 14 if ESPRESSIF_ESP32C3 && !(ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2)
	range 1 20 if !ESPRESSIF_ESP32C3 && (ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2)
	---help---
		Timer resolution in bits. The resolution is the number of bits used to by the timer
		counter to generate the PWM signal. The duty cycle provided by the upper layers
		will be scaled to fit the resolution.

endif # ESPRESSIF_LEDC_TIMER3

config ESPRESSIF_LEDC_CHANNEL0_PIN
	int "Channel 0 pin"
	default 2

config ESPRESSIF_LEDC_CHANNEL1_PIN
	int "Channel 1 pin"
	default 3

config ESPRESSIF_LEDC_CHANNEL2_PIN
	int "Channel 2 pin"
	default 4

config ESPRESSIF_LEDC_CHANNEL3_PIN
	int "Channel 3 pin"
	default 5

if PWM_MULTICHAN && PWM_NCHANNELS > 1

config ESPRESSIF_LEDC_CHANNEL4_PIN
	int "Channel 4 pin"
	default 6

config ESPRESSIF_LEDC_CHANNEL5_PIN
	int "Channel 5 pin"
	default 7

endif # PWM_MULTICHAN && PWM_NCHANNELS > 1

endmenu # LEDC configuration

menu "High Resolution Timer"
	depends on ESPRESSIF_HR_TIMER

config ESPRESSIF_HR_TIMER_TASK_NAME
	string "High Resolution Timer task name"
	default "hr_timer"

config ESPRESSIF_HR_TIMER_TASK_PRIORITY
	int "High Resolution Timer task priority"
	default 223
	---help---
		Priority level of the High Resolution Timer task.
		Must be lower than the SCHED_HPWORKPRIORITY.

config ESPRESSIF_HR_TIMER_TASK_STACK_SIZE
	int "High Resolution Timer task stack size"
	default 2048

endmenu # High Resolution Timer

menu "Brownout Detector Configuration"
	depends on ESPRESSIF_BROWNOUT_DET

choice ESPRESSIF_BROWNOUT_DET_LVL_SEL
	prompt "Brownout voltage level"
	default ESPRESSIF_BROWNOUT_DET_LVL_SEL_7
	---help---
		The brownout detector will reset the chip when the supply voltage is
		approximately below this level. Note that there may be some variation
		of brownout voltage level between each chip.

config ESPRESSIF_BROWNOUT_DET_LVL_SEL_7
	bool "2.51V"

config ESPRESSIF_BROWNOUT_DET_LVL_SEL_6
	bool "2.64V"

config ESPRESSIF_BROWNOUT_DET_LVL_SEL_5
	bool "2.76V"

config ESPRESSIF_BROWNOUT_DET_LVL_SEL_4
	bool "2.92V"

config ESPRESSIF_BROWNOUT_DET_LVL_SEL_3
	bool "3.10V"

config ESPRESSIF_BROWNOUT_DET_LVL_SEL_2
	bool "3.27V"

endchoice # ESPRESSIF_BROWNOUT_DET_LVL_SEL

config ESPRESSIF_BROWNOUT_DET_LVL
	int
	default 2 if ESPRESSIF_BROWNOUT_DET_LVL_SEL_2
	default 3 if ESPRESSIF_BROWNOUT_DET_LVL_SEL_3
	default 4 if ESPRESSIF_BROWNOUT_DET_LVL_SEL_4
	default 5 if ESPRESSIF_BROWNOUT_DET_LVL_SEL_5
	default 6 if ESPRESSIF_BROWNOUT_DET_LVL_SEL_6
	default 7 if ESPRESSIF_BROWNOUT_DET_LVL_SEL_7

endmenu # ESPRESSIF_BROWNOUT_DET

endif # ARCH_CHIP_ESPRESSIF
