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

if ARCH_CHIP_ESP32C3

comment "ESP32-C3 Configuration Options"

choice
	prompt "ESP32-C3 Chip Selection"
	default ARCH_CHIP_ESP32C3WROOM02

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

config ARCH_CHIP_ESP32C3FX4
	bool "ESP32-C3Fx4"
	select ESP32C3_ESP32C3XXX
	select ESP32C3_FLASH_4M
	---help---
		ESP32-C3 chip with a single RISC-V IMC core, 4 MB of in-package Flash memory

config ARCH_CHIP_ESP32C3MINI1
	bool "ESP32-C3-MINI-1"
	select ESP32C3_ESP32C3XXX
	select ESP32C3_FLASH_4M
	---help---
		Generic module with an embedded ESP32-C3Fx4 chip

config ARCH_CHIP_ESP32C3WROOM02
	bool "ESP32-C3-WROOM-02"
	select ESP32C3_ESP32C3XXX
	select ESP32C3_FLASH_4M
	---help---
		Generic module with an embedded ESP32-C3 chip, 4 MB of Flash memory

endchoice # ESP32-C3 Chip Selection

config ESP32C3_SINGLE_CPU
	bool
	default n

config ESP32C3_DUAL_CPU
	bool
	default n

config ESP32C3_ESP32C3XXX
	bool
	default n
	select ESP32C3_SINGLE_CPU
	select ARCH_HAVE_I2CRESET

config ESP32C3_FLASH_2M
	bool
	default n

config ESP32C3_FLASH_4M
	bool
	default n

config ESP32C3_FLASH_8M
	bool
	default n

config ESP32C3_FLASH_16M
	bool
	default n

config ESP32C3_FLASH_DETECT
	bool "Auto-detect FLASH size (to be used with master esptool)"
	default n
	---help---
		Auto detect flash size when flashing.
		Current released version of esptool doesn't support auto-detecting flash size.
		Use latest master from https://github.com/espressif/esptool.

choice ESP32C3_FLASH_MODE
	prompt "SPI FLASH mode"
	default ESP32C3_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 ESP32C3_FLASH_MODE_DIO
	bool "Dual IO (DIO)"

config ESP32C3_FLASH_MODE_DOUT
	bool "Dual Output (DOUT)"

config ESP32C3_FLASH_MODE_QIO
	bool "Quad IO (QIO)"

config ESP32C3_FLASH_MODE_QOUT
	bool "Quad Output (QOUT)"

endchoice # ESP32C3_FLASH_MODE

choice ESP32C3_FLASH_FREQ
	prompt "SPI FLASH frequency"
	default ESP32C3_FLASH_FREQ_40M
	---help---
		SPI FLASH frequency
		
config ESP32C3_FLASH_FREQ_80M
	bool "80 MHz"

config ESP32C3_FLASH_FREQ_40M
	bool "40 MHz"

config ESP32C3_FLASH_FREQ_26M
	bool "26 MHz"

config ESP32C3_FLASH_FREQ_20M
	bool "20 MHz"

endchoice # ESP32C3_FLASH_FREQ

choice ESP32C3_CPU_FREQ
	prompt "CPU frequency"
	default ESP32C3_CPU_FREQ_160
	---help---
		CPU frequency to be set on application startup.

config ESP32C3_CPU_FREQ_40
	bool "40 MHz"
	---help---
		Set the CPU to 40 MHz. This frequency is obtained from the XTAL.

config ESP32C3_CPU_FREQ_80
	bool "80 MHz"
	---help---
		Set the CPU to 80 MHz. This frequency is obtained from the 480 MHz PLL.

config ESP32C3_CPU_FREQ_160
	bool "160 MHz"
	---help---
		Set the CPU to 160 MHz. This frequency is obtained from the 480 MHz PLL.

endchoice # ESP32C3_CPU_FREQ

config ESP32C3_CPU_FREQ_MHZ
	int
	default 40 if ESP32C3_CPU_FREQ_40
	default 80 if ESP32C3_CPU_FREQ_80
	default 160 if ESP32C3_CPU_FREQ_160

config ESP32C3_RT_TIMER
	bool "Real-time Timer"
	default n

config ESP32C3_DISABLE_STDC_ATOMIC
	bool "Disable standard C atomic"
	default n

menu "ESP32-C3 Peripheral Support"

config ESP32C3_ADC
	bool
	default n
	select ANALOG
	select ADC

config ESP32C3_UART
	bool
	default n

config ESP32C3_I2C
	bool
	default n

config ESP32C3_TIMER
	bool
	default n

config ESP32C3_WDT
	bool
	default n

config ESP32C3_SPI
	bool
	default n

config ESP32C3_LEDC
	bool "LEDC (PWM)"
	default n
	select PWM

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

config ESP32C3_UART0
	bool "UART0"
	default y
	select ESP32C3_UART
	select UART0_SERIALDRIVER
	select ARCH_HAVE_SERIAL_TERMIOS

config ESP32C3_UART1
	bool "UART1"
	default n
	select ESP32C3_UART
	select UART1_SERIALDRIVER
	select ARCH_HAVE_SERIAL_TERMIOS

config ESP32C3_I2C0
	bool "I2C 0"
	default n
	select ESP32C3_I2C

config ESP32C3_RNG
	bool "Random Number Generator (RNG)"
	default n
	select ARCH_HAVE_RNG
	---help---
		ESP32-C3 supports an RNG that passed on Dieharder test suite.

config ESP32C3_TIMER0
	bool "54-bit Timer 0 (Group 0 Timer 0)"
	default n
	select ESP32C3_TIMER
	---help---
		Enables Timer 0

config ESP32C3_TIMER1
	bool "54-bit Timer 0 (Group 1 Timer 0)"
	default n
	select ESP32C3_TIMER
	---help---
		Enables Timer 1

config ESP32C3_SPIFLASH
	bool "SPI Flash"
	default n
	select MTD
	select MTD_BYTE_WRITE
	select MTD_PARTITION

config ESP32C3_SPI2
	bool "SPI 2"
	default n
	select ESP32C3_SPI
	select SPI

config ESP32C3_DMA
	bool "General DMA (GDMA)"
	default n
	select ARCH_DMA

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

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

config ESP32C3_RWDT
	bool "RTC Watchdog Timer"
	default n
	select ESP32C3_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 ESP32C3_ADC1
	bool "ADC1"
	default n
	select ESP32C3_ADC

config ESP32C3_WIRELESS
	bool "Wireless"
	default n
	select NET
	select ARCH_PHY_INTERRUPT
	select ESP32C3_RT_TIMER
	select ESP32C3_TIMER0
	---help---
		Enable Wireless support

endmenu # ESP32-C3 Peripheral Support

menu "I2C Configuration"
	depends on ESP32C3_I2C

if ESP32C3_I2C0

config ESP32C3_I2C0_SCLPIN
	int "I2C0 SCL Pin"
	default 6
	range 0 21

config ESP32C3_I2C0_SDAPIN
	int "I2C0 SDA Pin"
	default 5
	range 0 21

endif # ESP32C3_I2C0

endmenu # I2C configuration

menu "SPI configuration"
	depends on ESP32C3_SPI

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

config ESP32C3_SPI_UDCS
	bool "User defined CS"
	default n
	depends on ESP32C3_SPI_SWCS
	---help---
		Use user-defined CS.

if ESP32C3_SPI2

config ESP32C3_SPI2_DMA
	bool "SPI2 use GDMA"
	default n
	depends on ESP32C3_DMA
	---help---
		Enable support for transfers using the GDMA engine.

config ESP32C3_SPI2_DMADESC_NUM
	int "SPI2 Master GDMA maximum number of descriptors"
	default 2
	depends on ESP32C3_SPI2_DMA
	---help---
		Configure the maximum number of out-link/in-link descriptors to
		be chained for a GDMA transfer.

config ESP32C3_SPI2_DMATHRESHOLD
	int "SPI2 GDMA threshold"
	default 64
	depends on ESP32C3_SPI2_DMA
	---help---
		When SPI GDMA is enabled, GDMA transfers whose size are below the
		defined threshold will be performed by polling logic.

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

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

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

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

endif # ESP32C3_SPI2

endmenu # SPI configuration

menu "UART configuration"
	depends on ESP32C3_UART

if ESP32C3_UART0

config ESP32C3_UART0_TXPIN
	int "UART0 TX Pin"
	default 21

config ESP32C3_UART0_RXPIN
	int "UART0 RX Pin"
	default 20

endif # ESP32C3_UART0

if ESP32C3_UART1

config ESP32C3_UART1_TXPIN
	int "UART1 TX Pin"
	default 6

config ESP32C3_UART1_RXPIN
	int "UART1 RX Pin"
	default 7

endif # ESP32C3_UART1

config ESP32C3_PARTITION
	bool "ESP32-C3 Partition"
	default n
	select ESP32C3_SPIFLASH
	---help---
		Decode partition file and initialize partition as MTD.

endmenu

menu "Real-Time Timer"
	depends on ESP32C3_RT_TIMER

config ESP32C3_RT_TIMER_TASK_NAME
	string "Timer task name"
	default "rt_timer"

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

config ESP32C3_RT_TIMER_TASK_STACK_SIZE
	int "Timer task stack size"
	default 2048

endmenu # Real-Time Timer

if ESP32C3_TIMER
menu "Timer/counter Configuration"

config ESP32C3_ONESHOT
	bool "One-shot wrapper"
	default n
	---help---
		Enable a wrapper around the low level timer/counter functions to
		support one-shot timer.

config ESP32C3_FREERUN
	bool "TIM free-running wrapper"
	default n
	---help---
		Enable a wrapper around the low level timer/counter functions to
		support a free-running timer.

endmenu # Timer/counter Configuration
endif # ESP32C3_TIMER

menu "LEDC configuration"
	depends on ESP32C3_LEDC

menuconfig ESP32C3_LEDC_TIM0
	bool "Timer 0"
	default n

if ESP32C3_LEDC_TIM0

config ESP32C3_LEDC_TIM0_CHANNELS
	int "Number of Timer 0 channels"
	default 2

endif # ESP32C3_LEDC_TIM0

menuconfig ESP32C3_LEDC_TIM1
	bool "Timer 1"
	default n

if ESP32C3_LEDC_TIM1

config ESP32C3_LEDC_TIM1_CHANNELS
	int "Number of Timer 1 channels"
	default 2

endif # ESP32C3_LEDC_TIM1

menuconfig ESP32C3_LEDC_TIM2
	bool "Timer 2"
	default n

if ESP32C3_LEDC_TIM2

config ESP32C3_LEDC_TIM2_CHANNELS
	int "Number of Timer 2 channels"
	default 2

endif # ESP32C3_LEDC_TIM2

config ESP32C3_LEDC_CHANNEL0_PIN
	int "Channel 0 pin"
	default 2

config ESP32C3_LEDC_CHANNEL1_PIN
	int "Channel 1 pin"
	default 3

config ESP32C3_LEDC_CHANNEL2_PIN
	int "Channel 2 pin"
	default 4

config ESP32C3_LEDC_CHANNEL3_PIN
	int "Channel 3 pin"
	default 5

config ESP32C3_LEDC_CHANNEL4_PIN
	int "Channel 4 pin"
	default 6

config ESP32C3_LEDC_CHANNEL5_PIN
	int "Channel 5 pin"
	default 7

endmenu # LEDC configuration

menu "ADC Configuration"
	depends on ESP32C3_ADC

if ESP32C3_ADC1

choice ESP32C3_ADC_VOL_RANGES
	prompt "ADC1 voltage ranges"
	default ESP32C3_ADC_VOL_750

config ESP32C3_ADC_VOL_750
	bool "0~750mV"

config ESP32C3_ADC_VOL_1050
	bool "0~1050mV"

config ESP32C3_ADC_VOL_1300
	bool "0~1300mV"

config ESP32C3_ADC_VOL_2500
	bool "0~2500mV"

endchoice

config ESP32C3_ADC1_CHANNEL0
	bool "ADC1 channel 0"
	default n

config ESP32C3_ADC1_CHANNEL1
	bool "ADC1 channel 1"
	default n

config ESP32C3_ADC1_CHANNEL2
	bool "ADC1 channel 2"
	default n

config ESP32C3_ADC1_CHANNEL3
	bool "ADC1 channel 3"
	default n

config ESP32C3_ADC1_CHANNEL4
	bool "ADC1 channel 4"
	default n

endif # ESP32C3_ADC1
endmenu # ADC Configuration

menu "Wi-Fi configuration"
	depends on ESP32C3_WIRELESS

choice
	prompt "ESP32-C3 Wi-Fi mode"
	default ESP32C3_WIFI_STATION

config ESP32C3_WIFI_STATION
	bool "Station mode"

config ESP32C3_WIFI_SOFTAP
	bool "SoftAP mode"

config ESP32C3_WIFI_STATION_SOFTAP_COEXISTENCE
	bool "Station + SoftAP coexistence"

endchoice # ESP32-C3 Wi-Fi mode

config ESP32C3_WIFI_STATIC_RXBUF_NUM
	int "Wi-Fi static RX buffer number"
	default 10

config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
	int "Wi-Fi dynamic RX buffer number"
	default 32

config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
	int "Wi-Fi dynamic TX buffer number"
	default 32

config ESP32C3_WIFI_TX_AMPDU
	bool "Wi-Fi TX AMPDU"
	default y

config ESP32C3_WIFI_RX_AMPDU
	bool "Wi-Fi RX AMPDU"
	default y

config ESP32C3_WIFI_RXBA_AMPDU_WZ
	int "Wi-Fi RX BA AMPDU windown size"
	default 6

config ESP32C3_WLAN_PKTBUF_NUM
	int "WLAN netcard packet buffer number per netcard"
	default 16

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

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

config ESP32C3_WIFI_SAVE_PARAM
	bool "Save Wi-Fi Parameters"
	default n
	depends on !DISABLE_MOUNTPOINT
	---help---
		If you enable this option, Wi-Fi adapter parameters will be saved
		into the file system instead of computing them each time.

		These parameters mainly contains:
		  - SSID
		  - Password
		  - BSSID
		  - PMK(compute when connecting)
		  - Author mode
		  - MAC address
		  - Wi-Fi hardware configuration parameters

config ESP32C3_WIFI_FS_MOUNTPT
	string "Save Wi-Fi Parameters"
	default "/mnt/esp/wifi"
	depends on ESP32C3_WIFI_SAVE_PARAM
	---help---
		Mount point of Wi-Fi storage file system.

config ESP32C3_WIFI_STA_DISCONNECT_PM
	bool "Power Management for station when disconnected"
	default n
	---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.

endmenu # ESP32C3_WIRELESS

menu "SPI Flash configuration"
	depends on ESP32C3_SPIFLASH

config ESP32C3_MTD_OFFSET
	hex "MTD base address in SPI Flash"
	default 0x180000
	---help---
		MTD base address in SPI Flash.

config ESP32C3_MTD_SIZE
	hex "MTD size in SPI Flash"
	default 0x100000
	---help---
		MTD size in SPI Flash.

config ESP32C3_SPIFLASH_DEBUG
	bool "Debug SPI Flash"
	default n
	depends on DEBUG_FS_INFO
	---help---
		If this option is enabled, SPI Flash driver read and write functions
		will output input parameters and return values (if applicable).

endmenu # ESP32C3_SPIFLASH

menu "Partition Configuration"
	depends on ESP32C3_PARTITION

config ESP32C3_PARTITION_OFFSET
	hex "Partition offset"
	default "0x8000"

config ESP32C3_PARTITION_MOUNT
	string "Partition mount point"
	default "/dev/esp/partition/"

endmenu # ESP32C3_PARTITION

menu "GDMA Configuration"
	depends on ESP32C3_DMA

config ESP32C3_DMA_M2M_TEST
	bool "Test GDMA M2M"
	default n

config ESP32C3_DMA_M2M_TEST_LOOPS
	int "Test GDMA M2M loops"
	default 256
	depends on ESP32C3_DMA_M2M_TEST

config ESP32C3_DMA_M2M_TEST_BUFSIZE
	int "Test GDMA M2M buffer size"
	default 16000
	depends on ESP32C3_DMA_M2M_TEST

endmenu # GDMA Configuration

endif # ARCH_CHIP_ESP32C3
