#ifndef CORE_CONFIG_H
#define CORE_CONFIG_H

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // DO NOT CHANGE THIS BLOCK!
    #define CONFIG_YES                          1
    #define CONFIG_NO                           0
    #define CONFIG_SYSCLOCK_HIGH                2
    #define CONFIG_SYSCLOCK_NORMAL              1
    #define CONFIG_SYSCLOCK_LOW                 0
    #define CONFIG_SYSTICK_NORMAL               1
    #define CONFIG_SYSTICK_LOW                  0
    #define CONFIG_MSI_FREQ_DEFAULT             0
    #define CONFIG_MSI_FREQ_4MHZ                4
    #define CONFIG_MSI_FREQ_2MHZ                2
    #define CONFIG_MSI_FREQ_1MHZ                1
    #define CONFIG_CRYSTAL_12MHZ                0
    #define CONFIG_CRYSTAL_16MHZ                1
    #define CONFIG_CRYSTAL_8MHZ                 2
    #define CONFIG_CRYSTAL_4MHZ                 3
    // DO NOT CHANGE THIS BLOCK!
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //----------------------------------------------------------------
    // CONFIG_CRYSTAL
    // Specifies the external crystal oscillator frequency
    // Default: CONFIG_CRYSTAL_12MHZ
    // WARNING: DO NOT FOFGET TO CHANGE "HSE_VALUE" macro in "stm32lxx_hal_conf.h"
    #define CONFIG_CRYSTAL                      CONFIG_CRYSTAL_16MHZ
    //----------------------------------------------------------------
    // CONFIG_SYSCLOCK
    // Default system clock source when USB is active
    // Possible values: CONFIG_SYSCLOCK_HIGH, CONFIG_SYSCLOCK_NORMAL, CONFIG_SYSCLOCK_LOW
    // Default: CONFIG_SYSCLOCK_NORMAL
    #define CONFIG_SYSCLOCK                     CONFIG_SYSCLOCK_HIGH   /// !!!!!!
    //----------------------------------------------------------------
    // CONFIG_SYSTICK
    // Default SysTick timer tick interval
    // Default: CONFIG_SYSTICK_NORMAL
    #define CONFIG_SYSTICK                      CONFIG_SYSTICK_NORMAL
    //----------------------------------------------------------------
    // CONFIG_SYSTICK_BOOST_MULTIPLIER
    // Requires: CONFIG_SYSTICK=CONFIG_SYSTICK_NORMAL
    // Default: 1 (No boost)
    #define CONFIG_SYSTICK_BOOST_MULTIPLIER     1
    //----------------------------------------------------------------
    // CONFIG_SLEEPMANAGER
    // Enable sleep/wakeup power-, clock- and usb- control
    // Default: CONFIG_NO
    #define CONFIG_SLEEPMANAGER                 CONFIG_NO

    #define CONFIG_SLEEPMANAGER_EXTRASLEEP      CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_EXTMEM
    // Use external memory
    // Default: CONFIG_YES
    #define CONFIG_EXTMEM                       CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_TSENSOR_INTERVAL
    // Temperature sensor measure interval, ms
    // Default: 1000
    #define CONFIG_TSENSOR_INTERVAL             1000
    #if I2CSTRESS
    #undef CONFIG_TSENSOR_INTERVAL
    #define CONFIG_TSENSOR_INTERVAL             50
    #warning I2C Stress test activated
    #endif
    //----------------------------------------------------------------
    // CONFIG_LEDS
    // Use LED-indication
    // Default: CONFIG_YES
    #define CONFIG_LEDS                         CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_ADC
    // Use ADC external power control
    // Default: CONFIG_YES
    #define CONFIG_ADC                          CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_POWER_MANAGEMENT
    // Use power management for control power on usb or external voltage source
    // Default: CONFIG_YES
    #define CONFIG_PM                           CONFIG_YES
    #define CONFIG_PM_INTERVAL                  300
    //----------------------------------------------------------------
    // CONFIG_TABLE_CONTROL_MANAGEMENT
    // Use table management for control device switching plan
    // Default: CONFIG_YES
    #define CONFIG_TABLE                        CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_LED_LOWBAT_FLASH_INTERVAL
    // Low Battery Voltage Indication interval, ms
    // Default: 5000
    #define CONFIG_LED_LOWBAT_FLASH_INTERVAL    2000
    //----------------------------------------------------------------
    // CONFIG_LED_LOWBAT_FLASH_TIME
    // Low Battery Voltage Indication time (LED ON), ms
    // Default: 10
    #define CONFIG_LED_LOWBAT_FLASH_TIME        40
    //----------------------------------------------------------------
    // CONFIG_LED_OKBAT_FLASH_INTERVAL
    // Normal Battery Voltage Indication interval, ms
    // Default: 5000
    // Depends on CONFIG_LED_OKBAT_FLASH_ENABLE
    #define CONFIG_LED_OKBAT_FLASH_INTERVAL     2000
    //----------------------------------------------------------------
    // CONFIG_LED_OKWBAT_FLASH_TIME
    // Normal Battery Voltage Indication time (LED ON), ms
    // Default: 1
    // Depends on CONFIG_LED_OKBAT_FLASH_ENABLE
    #define CONFIG_LED_OKBAT_FLASH_TIME         40
    //----------------------------------------------------------------
    // CONFIG_LED_SIGNALING_PERIOD
    // Period of changing the LED signals (RED -> GREED -> RED .. ) during
    //  LED-signaling state, ms
    // Default: 50
    #define CONFIG_LED_SIGNALING_PERIOD         50
    //----------------------------------------------------------------
    // CONFIG_LED_SIGNALING_TIME
    // Duration of LED-signaling phase on startup, ms
    // Default: 2000
    #define CONFIG_LED_SIGNALING_TIME           1500
    //----------------------------------------------------------------
    // CONFIG_LED_OKBAT_FLASH_ENABLE
    // Normal Battery Voltage Indication
    // Default: CONFIG_YES
    #define CONFIG_LED_OKBAT_FLASH_ENABLE       CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_BATTERY_LOW_VOLTAGE
    // Discharged battery voltage level
    // Default: 1000
    #define CONFIG_BATTERY_LOW_VOLTAGE          1000
    //----------------------------------------------------------------
    // CONFIG_LED_POLARITY_INVERTED
    // Invered LED-control polarity (Active Low)
    // Default: CONFIG_NO
    #define CONFIG_LED_POLARITY_INVERTED        CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_USB
    // Use USB interface
    // Default: CONFIG_YES
    #define CONFIG_USB                          CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_USB_DYNAMIC_CLOCK_ADOPT
    // Use dynamic system clock depending on if USB is connected or not
    // Depends on: CONFIG_SLEEPMANAGER
    // Default: CONFIG_NO
    #define CONFIG_USB_DYNAMIC_CLOCK_ADOPT      CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_USB_INTERNAL_WKUP_SUPPORT
    // Enables internal USB wakeup-event support
    // Default: CONFIG_NO
    #define CONFIG_USB_INTERNAL_WKUP_SUPPORT    CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_AUTOMAT_MODE
    // Enables "Automat Mode" - automatic switch control for remote measurement.
    // Requires: CONFIG_KEYSW
    // Default: CONFIG_NO
    #define CONFIG_AUTOMAT_MODE                 CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_MSI_FREQ
    // Set internal clock generator frequency (MSI)
    // Available values: CONFIG_MSI_FREQ_4MHZ, CONFIG_MSI_FREQ_2MHZ, CONFIG_MSI_FREQ_1MHZ
    // Default: CONFIG_MSI_FREQ_2MHZ
    #define CONFIG_MSI_FREQ                     CONFIG_MSI_FREQ_2MHZ   // !!!!!! , CONFIG_MSI_FREQ_2MHZ
    //----------------------------------------------------------------
    // CONFIG_FLASHMEM_CACHE_SIZE
    // File: acm_base_mem.c
    // Flash-memory cache RAM-size, in bytes
    // Default: 1024
    #define CONFIG_FLASHMEM_CACHE_SIZE          1024
    //----------------------------------------------------------------
    // CONFIG_ACMBASECLASS
    // File: acm_base.c
    // Initialize ACM-Base class in main()
    // Default: CONFIG_YES
    // Note: can not be used together with CONFIG_KEYSW
    #define CONFIG_NFMBASECLASS                 CONFIG_YES
    #define CONFIG_NFMBASECLASS_TEST            CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_ACMCLASS_AUTOPROTECT_MEMORY
    // File: acm_base.c
    // Enable memory write-protection automatically on AcmClass initialize
    // Default: CONFIG_YES (need to send disable-command to assign S/N)
    #define CONFIG_NFMCLASS_AUTOPROTECT_MEMORY  CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_AUTOMAT_MODE_USB_POWERBANK
    // File: usb_application_enumspy.c
    // Allows to enable ACM Automat mode while the device is connected
    // to the USB Power Bank.
    // Default: CONFIG_NO
    // Note: the config CONFIG_AUTOMAT_MODE must be enabled
    #define CONFIG_AUTOMAT_MODE_USB_POWERBANK   CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_AUTOMAT_MODE_USB_POWERBANK_ENUMTIMEOUT
    // File: usb_application_enumspy.c
    // Specifies the USB enumeration timeout before returting to AUTOMAT mode
    // after detecting USB VBUS in case the host does not enumerate the device.
    // Default: 3000
    // Note: the config CONFIG_AUTOMAT_MODE must be enabled
    // Note: the config CONFIG_AUTOMAT_MODE_USB_POWERBANK must be enabled
    #define CONFIG_AUTOMAT_MODE_USB_POWERBANK_ENUMTIMEOUT   3000
    //----------------------------------------------------------------
    // CONFIG_HARMUP_INTERVAL - the harming up duration since startup in seconds
    // To disable feature set 0.
    #define CONFIG_HARMUP_INTERVAL                          0
    //----------------------------------------------------------------
    #define CONFIG_USB_USBTMC_ENABLE            CONFIG_YES
    //----------------------------------------------------------------
    // DEBUG FEATURES:
    //----------------------------------------------------------------
    // CONFIG_USB_OVERRIDE_IFACE_USBTMC
    // Force enable USBTMC interface
    // Default: CONFIG_NO
    #define CONFIG_USB_OVERRIDE_IFACE_USBTMC    CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_USB_OVERRIDE_IFACE_VENDOR
    // Force enable VENDOR interface
    // Default: CONFIG_NO
    #define CONFIG_USB_OVERRIDE_IFACE_VENDOR    CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_EXTREME_LOWPOWTEST
    // Extreme low-power test for debug (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_EXTREME_LOWPOWTEST           CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_USBIRQ_TEST
    // USB IRQ test: disable USB IRQ for some time to test stability (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_USBIRQ_TEST                  CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_DEBUG_USB_SUPRESS_VBUS_WKUP
    // Debug: do not wakeup on VBUS line changing (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_DEBUG_USB_SUPRESS_VBUS_WKUP  CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_USB_VENDOR_DUMMYREAD
    // Debug: do not call user handler on USB Vendor IN request (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_USB_VENDOR_DUMMYREAD         CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_TSENSOR_EMULATE_FOR_USB
    // Emulate the thermosensor presence for USB requests  (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_TSENSOR_EMULATE_FOR_USB      CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_EXTMEM_EMULATEREAD
    // Emulate reading of external memory instead of real reading (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_EXTMEM_EMULATEREAD           CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_EXTMEM_EMULATEWRITE
    // Emulate writing of external memory instead of real writing (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_EXTMEM_EMULATEWRITE          CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_REBOOT_FEATURE
    // Enables automatic reboot by request
    // Default: CONFIG_YES
    #define CONFIG_REBOOT_FEATURE               CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_AMP_ENABLE
    // Enables amplifiers on device start
    // Default: CONFIG_YES
    #define CONFIG_AMP_ENABLE                   CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_REBOOT_FEATURE_DELAY
    // Set the delay before system restart after the request is received.
    // Valid only if CONFIG_REBOOT_FEATURE is enabled.
    // Default: 1000
    #define CONFIG_REBOOT_FEATURE_DELAY         1000
    //----------------------------------------------------------------
    // CONFIG_NOIRQ_SNPRINTF
    // Disables interrupts during @snprintf call to minimalize stack usage
    // Default: CONFIG_YES
    #define CONFIG_NOIRQ_SNPRINTF               CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_STACKOVERFLOW_CONTROL_SECTION
    // CSTACK overflow protection/notification section
    // Place specially prepared signature into the area before CSTACK block in RAM
    // to provide easy control of stack overflow.
    // It is required to modify your ICF (Linker Configuration) to support this feature.
    // Default: CONFIG_YES
    #define CONFIG_STACKOVERFLOW_CONTROLSECTION CONFIG_YES
    //----------------------------------------------------------------
    // CONFIG_SLEEPMANAGER_DEBUG_NOSLEEP
    // Do not sleep at all (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_SLEEPMANAGER_DEBUG_NOSLEEP   CONFIG_NO
    #if DEBUGMODE // see Project Options
    #undef  CONFIG_SLEEPMANAGER_DEBUG_NOSLEEP
    #define CONFIG_SLEEPMANAGER_DEBUG_NOSLEEP   CONFIG_YES
    #if CONFIG_SLEEPMANAGER
    #pragma message("In DEBUGMODE MCU does not sleep!")
    #endif
    #endif
    //----------------------------------------------------------------
    // CONFIG_SLEEPMANAGER_KEEPDEBUGCLK
    // Keep debugger clocking enabled during sleep modes (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_SLEEPMANAGER_KEEPDEBUGCLK    CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_MAINC_DEBUGPIN_1
    // Initialize DEBUG GPIO Pin #1 (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_MAINC_DEBUGPIN_1             CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_MAINC_DEBUGPIN_2
    // Initialize DEBUG GPIO Pin #2 (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_MAINC_DEBUGPIN_2             CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_MAINC_DEBUGPIN_3
    // Initialize DEBUG GPIO Pin #3 (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_MAINC_DEBUGPIN_3             CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_AUTOMAT_DEBUGPIN_1
    // CONFIG_AUTOMAT_DEBUGPIN_2
    // Use debug pin in "Automat" module (DEBUG)
    #define CONFIG_AUTOMAT_DEBUGPIN_1            CONFIG_NO
    #define CONFIG_AUTOMAT_DEBUGPIN_2            CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_CSECT_DEBUG
    // Use debug pin in "CSect" (critical sections) module (DEBUG)
    #define CONFIG_CSECT_DEBUG                  CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_SYSTICK_DEBUG
    // Use debug pin in "SysTick" module (SysTick IRQ) (DEBUG)
    #define CONFIG_SYSTICK_DEBUG                CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_HALTICK_DEBUG
    // Use debug pin in "HAL" module (Tick IRQ) (DEBUG)
    #define CONFIG_HALTICK_DEBUG                CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_USB_DEBUGPIN
    // Use debug pin in "USB" module (USB IRQ) (DEBUG)
    #define CONFIG_USB_DEBUGPIN                 CONFIG_NO
    //----------------------------------------------------------------
    // CONFIG_SLEEPMANAGER_DEBUGPIN
    // Use debug pin in sleep manager driver (DEBUG)
    // Default: CONFIG_NO
    #define CONFIG_SLEEPMANAGER_DEBUGPIN        CONFIG_NO
    //----------------------------------------------------------------
    // Debug Pin Routing
    #include "core/debugpinsapi.h" // debugpin_X_set / debugpin_X_clr
    // CONFIG_CSECT_DEBUG_SETPIN / CONFIG_CSECT_DEBUG_CLRPIN
    // Set and Clear macro for CSect debug pin, use debugpin_X_set / debugpin_X_clr functions
    #define CONFIG_CSECT_DEBUG_SETPIN           debugpin_2_set();
    #define CONFIG_CSECT_DEBUG_CLRPIN           debugpin_2_clr();

    // CONFIG_SYSTICK_DEBUG_SETPIN / CONFIG_SYSTICK_DEBUG_CLRPIN
    // Set and Clear macro for Systick debug pin, use debugpin_X_set / debugpin_X_clr functions
    #define CONFIG_SYSTICK_DEBUG_SETPIN         debugpin_2_set();
    #define CONFIG_SYSTICK_DEBUG_CLRPIN         debugpin_2_clr();

    // CONFIG_HALTICK_DEBUG_SETPIN / CONFIG_HALTICK_DEBUG_CLRPIN
    // Set and Clear macro for Systick debug pin, use debugpin_X_set / debugpin_X_clr functions
    #define CONFIG_HALTICK_DEBUG_SETPIN         debugpin_2_set();
    #define CONFIG_HALTICK_DEBUG_CLRPIN         debugpin_2_clr();

    // CONFIG_AUTOMAT_DEBUGPIN_SETPIN_1 / CONFIG_AUTOMAT_DEBUGPIN_CLRPIN_1
    // Set and Clear macro for Automat debug pin, use debugpin_X_set / debugpin_X_clr functions
    #define CONFIG_AUTOMAT_DEBUGPIN_SETPIN_1    debugpin_2_set();
    #define CONFIG_AUTOMAT_DEBUGPIN_CLRPIN_1    debugpin_2_clr();

    // CONFIG_AUTOMAT_DEBUGPIN_SETPIN_2 / CONFIG_AUTOMAT_DEBUGPIN_CLRPIN_2
    // Set and Clear macro for Automat debug pin, use debugpin_X_set / debugpin_X_clr functions
    #define CONFIG_AUTOMAT_DEBUGPIN_SETPIN_2    debugpin_1_set();
    #define CONFIG_AUTOMAT_DEBUGPIN_CLRPIN_2    debugpin_1_clr();

    // CONFIG_AUTOMAT_DEBUGPIN_SETPIN_3 / CONFIG_AUTOMAT_DEBUGPIN_CLRPIN_3
    // Set and Clear macro for Automat debug pin, use debugpin_X_set / debugpin_X_clr functions
    #define CONFIG_AUTOMAT_DEBUGPIN_SETPIN_3    debugpin_2_set();
    #define CONFIG_AUTOMAT_DEBUGPIN_CLRPIN_3    debugpin_2_clr();

    // CONFIG_USB_DEBUGPIN_SETPIN / CONFIG_USB_DEBUGPIN_CLRPIN
    // Set and Clear macro for USB debug pin, use debugpin_X_set / debugpin_X_clr functions
    #define CONFIG_USB_DEBUGPIN_SETPIN          debugpin_2_set();
    #define CONFIG_USB_DEBUGPIN_CLRPIN          debugpin_2_clr();

    // CONFIG_SLEEPMANAGER_DEBUGPIN_SETPIN / CONFIG_SLEEPMANAGER_DEBUGPIN_SETPIN
    #define CONFIG_SLEEPMANAGER_DEBUGPIN_SETPIN debugpin_1_set();
    #define CONFIG_SLEEPMANAGER_DEBUGPIN_CLRPIN debugpin_1_clr();
    //----------------------------------------------------------------
    #define CONFIG_SCPI_TEST                    CONFIG_NO
    //----------------------------------------------------------------
#endif