# Kconfig settings for RP2040 processor

if MACH_RP2040

config RP2040_SELECT
    bool
    default y
    select HAVE_GPIO
    select HAVE_CHIPID

config BOARD_DIRECTORY
    string
    default "rp2040"

config MCU
    string
    default "rp2040"

config CLOCK_FREQ
    int
    default 12000000

config FLASH_SIZE
    hex
    default 0x200000

config RAM_START
    hex
    default 0x20000000

config RAM_SIZE
    hex
    default 0x42000

config STACK_SIZE
    int
    default 512

config FLASH_START
    hex
    default 0x10000000

config LAUNCH_APP_ADDRESS
    default 0x10004000
    hex

config FLASH_BOOT_ADDRESS
    hex
    default 0x10000100

config BLOCK_SIZE
    int
    default 64

######################################################################
# Bootloader options
######################################################################

config RP2040_ADD_BOOT_SIGNATURE
    bool
    default y
    help
      Add boot signature (zero page at application start)
      into resulting uf2.
      This is used to force bootloader entry
      before application is updated.

choice
    prompt "Flash chip" if LOW_LEVEL_OPTIONS
    config RP2040_FLASH_W25Q080
        bool "W25Q080 with CLKDIV 2"
    config RP2040_FLASH_GENERIC_03
        bool "GENERIC_03H with CLKDIV 4"
endchoice

config RP2040_STAGE2_FILE
    string
    default "boot2_generic_03h.S" if RP2040_FLASH_GENERIC_03
    default "boot2_w25q080.S"

config RP2040_STAGE2_CLKDIV
    int
    default 4 if RP2040_FLASH_GENERIC_03
    default 2

######################################################################
# Deployer
######################################################################

choice
    prompt "Build Katapult deployment application"
    config RP2040_FLASH_START_0000
        bool "Do not build"
    config RP2040_FLASH_START_4000
        bool "16KiB bootloader"
endchoice
config FLASH_APPLICATION_ADDRESS
    hex
    default 0x10004000 if RP2040_FLASH_START_4000
    default 0x10000100

######################################################################
# Communication inteface
######################################################################

choice
    prompt "Communication interface"
    config RP2040_USB
        bool "USB"
        select USBSERIAL
    config RP2040_SERIAL_UART0
        bool "Serial (on UART0 GPIO1/GPIO0)"
        select SERIAL
    config RP2040_CANBUS
        bool "CAN bus"
        select CANSERIAL
endchoice

config RP2040_CANBUS_GPIO_RX
    int "CAN RX gpio number" if CANBUS
    default 4
    range 0 29

config RP2040_CANBUS_GPIO_TX
    int "CAN TX gpio number" if CANBUS
    default 5
    range 0 29

endif
