# Main Kconfig settings

mainmenu "Klipper Firmware Configuration"

source "src/configs/Kconfig"

config LOW_LEVEL_OPTIONS
    bool "Enable extra low-level configuration options"
    default n
    help
        Enable low-level configuration options that (if modified) may
        result in a build that does not function correctly.

choice
    prompt "Micro-controller Architecture"
    config MACH_AVR
        bool "Atmega AVR"
    config MACH_ATSAM
        bool "SAM3/SAM4/SAM E70 (Due and Duet)"
    config MACH_ATSAMD
        bool "SAMD21/SAMD51/SAME5x"
    config MACH_LPC176X
        bool "LPC176x (Smoothieboard)"
    config MACH_STM32
        bool "STMicroelectronics STM32"
    config MACH_RP2040
        bool "Raspberry Pi RP2040"
    config MACH_GD32
		bool "Giga Device GD32"
    config MACH_PRU
        bool "Beaglebone PRU"
    config MACH_LINUX
        bool "Linux process"
    config MACH_SIMU
        bool "Host simulator"
endchoice

source "src/avr/Kconfig"
source "src/atsam/Kconfig"
source "src/atsamd/Kconfig"
source "src/lpc176x/Kconfig"
source "src/stm32/Kconfig"
source "src/rp2040/Kconfig"
source "src/gd32/Kconfig"
source "src/pru/Kconfig"
source "src/linux/Kconfig"
source "src/simulator/Kconfig"

config MCU_MENU
	string 
	default "S" if MACH_STM32
	default "G" if MACH_GD32

# Generic configuration options for serial ports
config SERIAL
    bool
config SERIAL_BOOTLOADER_SIDECHANNEL
    bool
config SERIAL_BAUD
    depends on SERIAL
    int "Baud rate for serial port" if LOW_LEVEL_OPTIONS
    default 250000
    help
        Specify the baud rate of the serial port. This should be set
        to 250000. Read the FAQ before changing this value.

# Generic configuration options for USB
config USBSERIAL
    bool
config USBCANBUS
    bool
config USB
    bool
    default y if USBSERIAL || USBCANBUS
config USB_VENDOR_ID
    default 0x1d50
config USB_DEVICE_ID
    default 0x614e
config USB_SERIAL_NUMBER_CHIPID
    depends on USB && HAVE_CHIPID
    default y
config USB_SERIAL_NUMBER
    default "12345"

menu "USB ids"
    depends on USB && LOW_LEVEL_OPTIONS
config USB_VENDOR_ID
    hex "USB vendor ID" if USBSERIAL
config USB_DEVICE_ID
    hex "USB device ID" if USBSERIAL
config USB_SERIAL_NUMBER_CHIPID
    bool "USB serial number from CHIPID" if HAVE_CHIPID
config USB_SERIAL_NUMBER
    string "USB serial number" if !USB_SERIAL_NUMBER_CHIPID
endmenu

# Generic configuration options for CANbus
config CANSERIAL
    bool
config CANBUS
    bool
    default y if CANSERIAL || USBCANBUS
config CANBUS_FREQUENCY
    int "CAN bus speed" if LOW_LEVEL_OPTIONS && CANBUS
    default 500000
config CANBUS_FILTER
    bool
    default y if CANSERIAL

# Support setting gpio state at startup

choice
    prompt "Creality machine type"
    config MACH_CREALITY_OTHERS
        bool "CRELITY others"
    config MACH_CREALITY_CR_10_SMART
        bool "CRELITY CR-10 SMART"
    config INITIAL_PINS
	    depends on MACH_CREALITY_CR_10_SMART
        string 
	    default "PA0"
endchoice

config INITIAL_PINS
    string "GPIO pins to set at micro-controller startup"
	depends on LOW_LEVEL_OPTIONS && !MACH_CREALITY_CR_10_SMART
	default "PA0" if MACH_CREALITY_CR_10_SMART
    help
        One may specify a comma separated list of gpio pins to set
        during the micro-controller startup sequence. By default the
        pins will be set to output high - preface a pin with a '!'
        character to set that pin to output low.
        "PA0" is default value for CREALITY CR-10 SMART, and MUST NOT
        MODIFIY! For the other machine types you should add pin name with
        your hardware configurations.

config BUILD_MACHINE_UID
	string "Custom your machine firmware name as unique ID"
	depends on LOW_LEVEL_OPTIONS
	help
		It is for klipper host making a distinction between each 
		printer when one host controls more than one machine. 

# The HAVE_x options allow boards to disable support for some commands
# if the hardware does not support the feature.
config HAVE_GPIO
    bool
    default n
config HAVE_GPIO_ADC
    bool
    default n
config HAVE_PRTOUCH
    bool
    default n
config HAVE_GPIO_SPI
    bool
    default n
config HAVE_GPIO_I2C
    bool
    default n
config HAVE_GPIO_HARD_PWM
    bool
    default n
config HAVE_GPIO_BITBANGING
    bool
    default n
config HAVE_STRICT_TIMING
    bool
    default n
config HAVE_CHIPID
    bool
    default n
config HAVE_STEPPER_BOTH_EDGE
    bool
    default n

config INLINE_STEPPER_HACK
    # Enables gcc to inline stepper_event() into the main timer irq handler
    bool
    depends on HAVE_GPIO
    default y
