menu "Compiler options"
    config GDB_CFLAG
    bool "Keep debugging symbols"
    default y

    choice
    prompt "Compiler optimization"
        config OPTIMIZE_NONE
        bool "No optimization"

        config OPTIMIZE_SIZE
        bool "Optimize for size"

        config OPTIMIZE_PERF
        bool "Optimize for performance"
    endchoice


endmenu


menu "Platform Selection"

    choice ARCH
        prompt "Architecture"
        default ARCH_LM3S

        config ARCH_LM3S
        bool "LM3S"
        help
            Enable support for Stellaris LM3S systems

        config ARCH_LPC17XX
        bool "LPC17XX"
        help
            Enable support for NXP LPC17xx systems

        config ARCH_STM32F4
        bool "STM32F4"
        help
            Enable support for ST STM32F4 systems

        config ARCH_STM32F7
        bool "STM32F7"
        help
            Enable support for ST STM32F7 systems

        config ARCH_NRF51
        bool "NRF51"
        help
            Enable support for Nordic NRF51 systems

        config ARCH_NRF52
        bool "NRF52"
        help
            Enable support for Nordic NRF52 systems
    endchoice


    source "../kernel/stm32f7/Kconfig"
    source "../kernel/stm32f4/Kconfig"
    source "../kernel/lpc17xx/Kconfig"
    source "../kernel/lm3s/Kconfig"
    source "../kernel/nrf51/Kconfig"
    source "../kernel/nrf52/Kconfig"

    config FLASH_SIZE_2MB
            bool
    config FLASH_SIZE_1MB
            bool
    config FLASH_SIZE_512KB
            bool
    config FLASH_SIZE_384KB
            bool
    config FLASH_SIZE_256KB
            bool
    config FLASH_SIZE_192KB
            bool
    config FLASH_SIZE_128KB
            bool

    config RAM_SIZE_368KB
            bool
    config RAM_SIZE_320KB
            bool
    config RAM_SIZE_256KB
            bool
    config RAM_SIZE_192KB
            bool
    config RAM_SIZE_128KB
            bool
    config RAM_SIZE_96KB
            bool
    config RAM_SIZE_64KB
            bool
    config RAM_SIZE_32KB
            bool
    config RAM_SIZE_24KB
            bool
    config RAM_SIZE_16KB
            bool

    config ARCH_STM32F401
        bool
    config ARCH_STM32F405
        bool
    config ARCH_STM32F407
        bool
    config ARCH_STM32F411
        bool
    config ARCH_STM32F429
        bool
    config ARCH_STM32F446
        bool
    config ARCH_STM32F746
        bool
    config ARCH_STM32F769
        bool

    config DEVSTM32DMA
        bool

    #Temp hack to allow '407 & '411 clock setups to coexist
    choice
        prompt "Clock Speed"
        config CLK_16MHZ
            bool "16MHz"
            depends on (ARCH_NRF51)
        config CLK_48MHZ
            bool "48MHz"
            depends on (ARCH_STM32F401  || ARCH_STM32F411 || ARCH_STM32F429) || ARCH_STM32F407 || ARCH_STM32F405
        config CLK_84MHZ
            bool "84MHz"
            depends on (ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F429 || ARCH_NRF52) || ARCH_STM32F407 || ARCH_STM32F405
        config CLK_100MHZ
            bool "100MHz"
            depends on ARCH_LPC17XX || ARCH_STM32F411 || ARCH_STM32F407 || ARCH_STM32F405
        config CLK_120MHZ
            bool "120MHz"
            depends on (ARCH_STM32F407 || ARCH_STM32F405 || ARCH_LPC1769)
        config CLK_168MHZ
            bool "168MHz"
            depends on (ARCH_STM32F407 ||  ARCH_STM32F405 || ARCH_STM32F429)
        config CLK_180MHZ
            bool "180MHz"
            depends on (ARCH_STM32F446)
        config CLK_216MHZ
            bool "216MHZ"
            depends on (ARCH_STM32F746 || ARCH_STM32F769)
    endchoice

    choice
        prompt "Board"
        default MACH_STM32F407Discovery
    config MACH_STM32F746Discovery
        bool "STM32F746 Discovery"
        depends on (ARCH_STM32F746)
    config MACH_STM32F769Discovery
        bool "STM32F769 Discovery"
        depends on (ARCH_STM32F769)
    config MACH_STM32F746Nucleo144
        bool "STM32F746 Nucleo-144"
        depends on (ARCH_STM32F746)
    config MACH_STM32F407Discovery
        bool "STM32F407Discovery"
        depends on (ARCH_STM32F407)
    config MACH_STM32F405Pyboard10
        bool "STM32F405 PyBoard v1.0 (micropython)"
        depends on (ARCH_STM32F405)
    config MACH_STM32F405Pyboard11
        bool "STM32F405 PyBoard v1.1 (micropython)"
        depends on (ARCH_STM32F405)
    config MACH_STM32F411Pyboard11lite
        bool "STM32F411 PyBoard v1.1 lite (micropython)"
        depends on (ARCH_STM32F411)
    config MACH_STM32F4x1Discovery
        bool "STM32F4x1Discovery"
        depends on (   ARCH_STM32F401 ||ARCH_STM32F411)
    config MACH_STM32F429Discovery
        bool "STM32F429Discovery"
        depends on (ARCH_STM32F429)
    config MACH_STM32F446Nucleo
        bool "STM32F446 Nucleo"
        depends on (ARCH_STM32F446)
    config MACH_STM32F411Nucleo
        bool "STM32F411 Nucleo"
        depends on (ARCH_STM32F411)
    config MACH_STM32F407Diymore
        bool "STM32F407 based Diymore from dyimore.cc"
        depends on (ARCH_STM32F407)
    config MACH_LPC1768MBED
        bool "LPC1768MBED"
        depends on ARCH_LPC1768
    config MACH_SEEEDPRO
        bool "SEEEDPRO"
        depends on ARCH_LPC1768
    config MACH_LPC1679XPRESSO
        bool "LPC1679XPRESSO"
        depends on ARCH_LPC1769
    config MACH_LM3S6965EVB
        bool "lm3s6965evb"
        depends on ARCH_LM3S6965
    config MACH_LM3SVIRT
        bool "lm3s-qemu"
        depends on ARCH_LM3SVIRT
        default y
    config MACH_BLENANOV1_5
        bool "BLENanoV1.5"
        depends on ARCH_NRF51
        default y
    config MACH_BLENANOV2_0
        bool "BLENanoV2.0"
        depends on ARCH_NRF52
        default y

    endchoice

    config STM32F7_SDRAM
    depends on ARCH_STM32F7
    bool "Enable external SDRAM"
    default y

    config STM32F4_SDRAM
    depends on ARCH_STM32F4
    bool "Enable external SDRAM"
    default n

endmenu


menu "Kernel Configuration"

config KFLASHMEM_SIZE
    int "Kernel Flash size (KB)"
    default 64

config KRAMMEM_SIZE
    int "Kernel RAM size (KB)"
    default 64

choice
prompt "Tasks Stack Size"
default TASK_STACK_SIZE_2K

   config TASK_STACK_SIZE_1K
   bool "Tiny stack (1024 Bytes)"

   config TASK_STACK_SIZE_2K
   bool "Small stack (2048 Bytes)"

   config TASK_STACK_SIZE_4K
   bool "Big stack (4096 Bytes)"

   config TASK_STACK_SIZE_8K
   bool "Huge stack (8192 Bytes)"
endchoice

config MPU
bool "Run-time Memory Protection"
default y

config PTHREADS
bool "POSIX Threads (pthreads)"
default y

config SIGNALS
bool "Process Signals"
default y

config PIPE
bool "Pipe"
default y

config SOCK_UNIX
bool "UNIX Sockets for IPC"
default n

config PTY_UNIX
bool "UNIX98 scheme pseudo-tty devices (/dev/pts/X)"
default n

endmenu



menu "Debugging options"

config KLOG
    bool "Enable kernel logging"
    default y

config KLOG_SIZE
    depends on KLOG
    int "Kernel log buffer size"
    default 256

config MEMFAULT_DBG
    bool "Enable extended segfault debug"
    default y

config HARDFAULT_DBG
    bool "Enable extended hardfault debug"
    default n

config STRACE
    bool "Enable syscall tracer"
    default n

endmenu


menu "Filesystems"
       config SYSFS
       bool "SysFS (/sys)"
       default y

       config MEMFS
       bool "MemFS"
       default y

       config XIPFS
       bool "Xip FS"
       default y

       config FATFS
       bool "Fat FS"
       default n

       config FAT32
       depends on FATFS
       bool "Fat32 support"
       default n

endmenu

menu "Networking"
       config SOCK_INET
       bool "TCP/IP Socket support"
       default n
       config TCPIP_MEMPOOL_YN
       bool "Separate memory pool for TCP/IP stack"
       default n
       if TCPIP_MEMPOOL_YN
        config TCPIP_MEMPOOL
        string "TCP/IP pool base address"
        default "0x10000000"
       endif
       choice NET_STACK
        prompt "TCP/IP stack selection"
        default PICOTCP
        depends on SOCK_INET

        config PICOTCP
        bool "Built-in PicoTCP"
       endchoice
       source ../kernel/net/Kconfig

endmenu

menu "Device Drivers"
       config DEVNULL
       bool "Support for /dev/null and /dev/zero"
       default y

       menuconfig DEVUART
       bool "Generic UART driver"
       default y

       if DEVUART

            config USART_0
            bool "USART 0"
            depends on (ARCH_LM3S6965 || ARCH_LM3SVIRT)

            config USART_1
            bool "USART 1"
            depends on (ARCH_LM3S6965 || ARCH_LM3SVIRT || \
                        ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F405 || ARCH_STM32F407  || ARCH_STM32F429 || ARCH_STM32F446 || \
                        ARCH_STM32F746 || ARCH_STM32F769)

            config USART_2
            bool "USART 2"
            depends on (ARCH_LM3S6965 || ARCH_LM3SVIRT || \
                        ARCH_STM32F401 || ARCH_STM32F411 || ARCH_STM32F405 || ARCH_STM32F429  || ARCH_STM32F407 || ARCH_STM32F446 || \
                        ARCH_STM32F746 || ARCH_STM32F769 )

            config USART_3
            bool "USART 3"
            depends on (ARCH_STM32F407 || ARCH_STM32F405 || ARCH_STM32F746 || ARCH_STM32F769 )

            config USART_4
            bool "USART 4"
            depends on (ARCH_STM32F405)

            config USART_6
            bool "USART 6"
            depends on (ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F407 || ARCH_STM32F405 || ARCH_STM32F446 || \
                        ARCH_STM32F746 || ARCH_STM32F769 )

            config UART_0
            bool "UART 0"
            depends on (ARCH_LPC17XX || ARCH_NRF51 || ARCH_NRF52)

            config UART_1
            bool "UART 1"
            depends on ARCH_LPC17XX

            config UART_2
            bool "UART 2"
            depends on ARCH_LPC17XX

            config UART_3
            bool "UART 3"
            depends on ARCH_LPC17XX

       endif

       config DEVF4DSP
       bool "STM32F4 Sound driver"
       depends on (ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F407 || ARCH_STM32F405  || ARCH_STM32F429 || ARCH_STM32F446)
       select DEVSTM32DMA
       default n

       config DEVSTM32USB
       bool

       menuconfig DEVSTM32USBFS
       bool "Support for Full Speed USB OTG"
       depends on (!DEVSTM32USBHFS) && (ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F407 || ARCH_STM32F405  || ARCH_STM32F429 || ARCH_STM32F446 || \
                   ARCH_STM32F746)
       default n
       select DEVSTM32USB
       if DEVSTM32USBFS
          choice
            prompt "USB FS OTG mode"
            default USBFS_GUEST
            config USBFS_HOST
            bool "Host mode"

            config USBFS_GUEST
            bool "Device mode"

          endchoice
       endif

       menuconfig DEVSTM32USBHS
       bool "Support for High Speed USB OTG"
       depends on (ARCH_STM32F746 || ARCH_STM32F769)
       select DEVSTM32USB
       default n
       if DEVSTM32USBHS
          choice
            prompt "USB HS OTG mode"
            default USBHS_GUEST
            config USBHS_HOST
            bool "Host mode"

            config USBHS_GUEST
            bool "Device mode"

          endchoice

        endif

      config DEV_USB_ETH
      depends on PICOTCP && ( (DEVSTM32USBHS && USBHS_GUEST) || (DEVSTM32USBFS && USBFS_GUEST) )
      select DEVSTM32USB
      bool "Ethernet over USB (CDC-ECM)"
      default n

      config DEV_USBH_KBD
      depends on (USBHS_HOST || USBFS_HOST)
      bool "USB Keyboard support"
      default n

      if DEV_USB_ETH
      config USB_DEFAULT_IP
      string "Default (boot-up) address for usb0"
      default 192.168.6.150

      config USB_DEFAULT_NM
      string "Default (boot-up) netmask for usb0"
      default 255.255.255.0

      config USB_DEFAULT_GW
      string "Default (boot-up) gateway for usb0"
      default 192.168.6.1
      endif

       config DEVADC
       bool "Generic ADC driver"
       depends on (ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F407 || ARCH_STM32F405  || ARCH_STM32F429 || ARCH_STM32F446)
       select DEVSTM32DMA
       default n


       config DEVF4ETH
       bool "STM32F4 Ethernet driver"
       depends on ((ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F407 || ARCH_STM32F405  || ARCH_STM32F429 || ARCH_STM32F446) && PICOTCP)
       default n

       config DEVF7ETH
       bool "STM32F7 Ethernet driver"
       depends on ((ARCH_STM32F746 || ARCH_STM32F769) && PICOTCP)
       default n

       config DEVLM3SETH
       bool "LM3S Ethernet driver"
       depends on ((ARCH_LM3S) && PICOTCP)
       default n

       if DEVF4ETH || DEVF7ETH || DEVLM3SETH
               config ETH_DEFAULT_IP
               string "Default (boot-up) address for eth0"
               default 192.168.2.150

               config ETH_DEFAULT_NM
               string "Default (boot-up) netmask for eth0"
               default 255.255.255.0

               config ETH_DEFAULT_GW
               string "Default (boot-up) gateway for eth0"
               default 192.168.2.1

       endif

       config DEVSTM32SDIO
       bool "STM32F4/7 SD I/O driver"
       depends on (ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F407 || ARCH_STM32F405  || ARCH_STM32F429 || ARCH_STM32F7|| ARCH_STM32F446)
       default n

       menuconfig DEVSTM32I2C
       bool "STM32 I2C driver"
       depends on (ARCH_STM32F401 ||ARCH_STM32F411 || ARCH_STM32F407 || ARCH_STM32F405  || ARCH_STM32F429 || ARCH_STM32F446 || ARCH_STM32F746)
       select DEVSTM32DMA
       default n


           if DEVSTM32I2C
                config I2C1
                bool "I2C 1"
                default n
                config I2C2
                bool "I2C 2"
                default n
                config I2C3
                bool "I2C 3"
                default y
           endif

           config DEVCS43L22
           tristate "CS43L22 driver (Stereo DAC)"
           depends on (DEVSTM32I2C)
           default n


           config DEVLSM303DLHC
           tristate "LSM303DLHC driver (Accelerometer & Magnetometer)"
           depends on (DEVSTM32I2C)
           default n

           config DEVMCCOG21
           tristate "MCCOG21 driver (2-lines B/W display)"
           depends on (DEVSTM32I2C)
           default n

           config DEVXALED5X7
           tristate "Xadow LED Matrix 5X7 driver"
           depends on (DEVSTM32I2C)
           default n

           config DEVFT5336
           tristate "FT5336 driver (Touchscreen STM32F746)"
           depends on (DEVSTM32I2C)
           default n

           config DEVSTMPE811
           tristate "STMPE811 driver (Touchscreen)"
           depends on (DEVSTM32I2C)
           default n



       menuconfig DEVSPI
           bool "Generic SPI driver"
           depends on (ARCH_STM32F4 || ARCH_STM32F7)
           select DEVSTM32DMA
           default n

           if DEVSPI
                config SPI_1
                bool "SPI 1"

                config SPI_3
                bool "SPI 3"

                config SPI_5
                bool "SPI 5"

           endif

           config DEVLIS3DSH
           tristate "LIS3DSH driver (3-Axis Accelerometer)"
           depends on (DEVSPI)
           default n

           config DEVILI9341
           tristate "ILI9341 driver (LCD Controller)"
           depends on (DEVSPI)
           default n

           config DEVL3GD20
           tristate "L3GD20 driver (Gyro)"
           depends on (DEVSPI)
           default n

       config DEV_RANDOM
       depends on (ARCH_STM32F4 || ARCH_STM32F7)
       bool "STM32F2/F4/F7 Random devices"
       default n

       if DEV_RANDOM
          choice
            prompt "Random device selection"
            config DEVRNG
            bool "Hardware TRNG driver"

            config DEVFRAND
            bool "Fortuna PRNG device"
          endchoice
       endif

       menuconfig DEVFRAMEBUFFER
           depends on (ARCH_STM32F7 || ARCH_STM32F4)
           bool "STM32 Framebuffer driver"
           default y

       config DEVFBCON
           depends on DEVFRAMEBUFFER
           bool "Console on Framebuffer via /dev/fbcon"
           default y
        choice FONT_FACE
            prompt "Console font face"
            depends on DEVFBCON
            default FONT_CGA8X8

            config FONT_CGA_8X8
            bool "CGA 8x8"

            config FONT_PICCOLO_7X6
            bool "Piccolo 7x6"
        endchoice


       config DEVF7DISCOLTDC
           depends on DEVFRAMEBUFFER
           bool "F746 Discovery LTDC"
           default y

endmenu

menu "Power Management"
    config LOWPOWER
    bool "Enable suspend() and standby() syscalls"
    default n
    config LSE32K
    depends on LOWPOWER
    bool "Use external low-speed oscillator (LSE) at 32kHz to feed the RTC"
    default n
endmenu
