#
# This file is part of AtomVM.
#
# Copyright 2022 Davide Bettio <davide@uninstall.it>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
#

menu "AtomVM Built-In Components"

config AVM_ENABLE_ADC_NIFS
    bool "Enable ADC NIFs"
    default y

    config AVM_ADC2_ENABLE
        depends on AVM_ENABLE_ADC_NIFS
        depends on SOC_ADC_PERIPH_NUM >= 2
        bool "Enable ADC Unit 2"
        default "y" if ADC_ONESHOT_FORCE_USE_ADC2_ON_C3 && IDF_TARGET_ESP32C3
        default "n" if IDF_TARGET_ESP32C3
        default "n" if IDF_TARGET_ESP32
        default "y"
        help
            This will allow using both ADC units.

            ADC2 is used by the Wi-Fi driver. The ESP32 classic can only use ADC2 when the
            wifi driver is not in use, all other models have an arbitrator peripheral that
            allows the simultaneous use of ADC unit 2 with WiFi. With the possibility of occasional
            timeout errors when taking a measurements during times of heavy network traffic.

            The results from ADC2 on the ESP32C3 are not at all accurate and should not be used.
            See: https://docs.espressif.com/projects/esp-chip-errata/en/latest/esp32c3/index.html

            For the ESP32C3 if you choose to ignore these warnings and enable unit 2 anyway,
            "ADC_ONESHOT_FORCE_USE_ADC2_ON_C3" must also be enabled in the "ADC and ADC Calibration"
            submenu.

config AVM_ENABLE_GPIO_NIFS
    bool "Enable GPIO NIFs"
    default y

config AVM_ENABLE_LEDC_NIFS
    bool "Enable LEDC NIFs"
    default y

config AVM_ENABLE_NVS_NIFS
    bool "Enable NVS NIFs"
    default y

config AVM_ENABLE_RTC_SLOW_NIFS
    bool "Enable RTC SLOW NIFs"
    default y

config AVM_RTC_SLOW_MAX_SIZE
    int "RTC SLOW maximum binary size (maximum varies by soc and idf versions)"
    # ESP32-H2 has no RTC SLOW, only RTC FAST and both are mapped at the same
    # space, and based on other usage of RTC FAST we can use up to 3.5kb
    # sdkconfig.defaults.esp32h2 sets value to 3KB
    # 8130 works on esp-idf 5.1 with other socs
    # 4KB is a reasonable default
    default 4096

config AVM_ENABLE_STORAGE_NIFS
    bool "Enable Storage NIFs"
    default y

config AVM_ENABLE_GPIO_PORT_DRIVER
    bool "Enable GPIO port driver"
    default y

config AVM_ENABLE_I2C_PORT_DRIVER
    bool "Enable I2C port driver"
    default y

config AVM_ENABLE_NETWORK_PORT_DRIVER
    bool "Enable network port driver"
	depends on ESP_WIFI_ENABLED || ESP_HOST_WIFI_ENABLED || ESP32_WIFI_ENABLED
    default y

config AVM_ENABLE_SOCKET_PORT_DRIVER
    bool "Enable socket port driver"
	depends on ESP_WIFI_ENABLED || ESP_HOST_WIFI_ENABLED || ESP32_WIFI_ENABLED || ETH_ENABLED
    default y

config AVM_ENABLE_SPI_PORT_DRIVER
    bool "Enable SPI port driver"
    default y

config AVM_ENABLE_UART_PORT_DRIVER
    bool "Enable UART port driver"
    default y

config AVM_ENABLE_OTP_CRYPTO_NIFS
    bool "Enable OTP Crypto NIFs"
    default y

config AVM_ENABLE_OTP_SOCKET_NIFS
    bool "Enable OTP Socket NIFs"
	depends on ESP_WIFI_ENABLED || ESP_HOST_WIFI_ENABLED || ESP32_WIFI_ENABLED || ETH_ENABLED
    default y

config AVM_ENABLE_OTP_NET_NIFS
    bool "Enable OTP Net NIFs"
	depends on ESP_WIFI_ENABLED || ESP_HOST_WIFI_ENABLED || ESP32_WIFI_ENABLED || ETH_ENABLED
    default y

config AVM_ENABLE_OTP_SSL_NIFS
    bool "Enable OTP SSL NIFs"
	depends on ESP_WIFI_ENABLED || ESP_HOST_WIFI_ENABLED || ESP32_WIFI_ENABLED || ETH_ENABLED
    default y

endmenu
