# Kconfig settings for Atmel SAMD processors

if MACH_ATSAMD

config ATSAMD_SELECT
    bool
    default y
    select HAVE_GPIO
    select HAVE_GPIO_ADC
    select HAVE_GPIO_I2C
    select HAVE_GPIO_SPI if MACH_SAMD21
    select HAVE_GPIO_HARD_PWM if MACH_SAMD21
    select HAVE_GPIO_BITBANGING

config BOARD_DIRECTORY
    string
    default "atsamd"

choice
    prompt "Processor model"
    config MACH_SAMD21G18
        bool "SAMD21G18 (Arduino Zero)"
        select MACH_SAMD21
    config MACH_SAMD51G19
        bool "SAMD51G19 (Adafruit ItsyBitsy M4)"
        select MACH_SAMD51
    config MACH_SAMD51J19
        bool "SAMD51J19 (Adafruit Metro M4)"
        select MACH_SAMD51
    config MACH_SAMD51N19
        bool "SAMD51N19"
        select MACH_SAMD51
    config MACH_SAMD51P20
        bool "SAMD51P20 (Adafruit Grand Central)"
        select MACH_SAMD51
endchoice

config MACH_SAMD21
    bool
config MACH_SAMD51
    bool

config MCU
    string
    default "samd21g" if MACH_SAMD21G18
    default "samd51g19" if MACH_SAMD51G19
    default "samd51j19" if MACH_SAMD51J19
    default "samd51n19" if MACH_SAMD51N19
    default "samd51p20" if MACH_SAMD51P20

config CLOCK_FREQ
    int
    default 48000000 if MACH_SAMD21
    default 120000000 if MACH_SAMD51

choice
    depends on MACH_SAMD51
    prompt "Clock Reference"
    config CLOCK_REF_X32K
        bool "32.768Khz crystal"
    config CLOCK_REF_INTERNAL
        bool "Factory calibration"
endchoice

choice
    prompt "Bootloader offset"
    config FLASH_START_2000
        bool "8KiB bootloader (Arduino Zero)"
    config FLASH_START_4000
        bool "16KiB bootloader (Arduino M0)"
    config FLASH_START_0000
        bool "No bootloader"
endchoice

config FLASH_START
    hex
    default 0x4000 if FLASH_START_4000
    default 0x2000 if FLASH_START_2000
    default 0x0000

config USBSERIAL
    bool "Use USB for communication (instead of serial)" if MACH_SAMD21
    default y
config SERIAL
    depends on !USBSERIAL
    bool
    default y

endif
