# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

syscfg.defs:
    STM32_FLASH_SIZE_KB:
        description: 'Total flash size in KB.'
        value: 512

    STM32_FLASH_NUM_AREAS:
        description: 'Number of flash sectors for a non-linear STM32 MCU.'
        value: 8

    STM32_ETH_PHY_TYPE:
        description: >
            PHY type that can be found in enum in file stm32_eth_cfg.h.
        value: SMSC_8710_RMII
    STM32_ETH_PHY_ADDR:
        description: >
            PHY address.
        value: 0
    STM32_ETH_PHY_IRQ:
        description: >
            RMII interrupt pin.
        value: -1

syscfg.vals:
    REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG
    CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS
    NFFS_FLASH_AREA: FLASH_AREA_NFFS
    COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1
    LITTLEFS_FLASH_AREA: FLASH_AREA_LITTLEFS
    LITTLEFS_BLOCK_SIZE: 4096
    LITTLEFS_BLOCK_COUNT: 24
    HARDFLOAT: 1

    STM32_CLOCK_VOLTAGESCALING_CONFIG: 'PWR_REGULATOR_VOLTAGE_SCALE1'
    STM32_CLOCK_HSI: 0
    STM32_CLOCK_HSE: 1
    STM32_CLOCK_PLL_PLLM: 8
    STM32_CLOCK_PLL_PLLN: 336
    STM32_CLOCK_PLL_PLLP: 2
    STM32_CLOCK_PLL_PLLQ: 7
    STM32_CLOCK_AHB_DIVIDER: 'RCC_SYSCLK_DIV1'
    STM32_CLOCK_APB1_DIVIDER: 'RCC_HCLK_DIV4'
    STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV2'
    STM32_FLASH_LATENCY: 'FLASH_LATENCY_5'
    STM32_FLASH_PREFETCH_ENABLE: 1
    STM32_INSTRUCTION_CACHE_ENABLE: 1
    STM32_DATA_CACHE_ENABLE: 1

    SPI_0_MASTER: 1
    # On board SPIFLASH configuration for W25Q16VBS
    SPIFLASH: 1
    SPIFLASH_SPI_NUM: 0
    SPIFLASH_SPI_CS_PIN: 'MCU_GPIO_PORTB(0)'
    SPIFLASH_BAUDRATE: 42000
    SPIFLASH_MANUFACTURER: 0xEF
    SPIFLASH_MEMORY_TYPE: 0x40
    SPIFLASH_MEMORY_CAPACITY: 0x15
    SPIFLASH_SECTOR_COUNT: 512
    SPIFLASH_SECTOR_SIZE: 4096
    SPIFLASH_PAGE_SIZE: 256

    SPIFLASH_TBP1_TYPICAL: 20
    SPIFLASH_TBP1_MAXIMUM: 50
    SPIFLASH_TPP_TYPICAL: 700
    SPIFLASH_TPP_MAXIMUM: 3000
    SPIFLASH_TSE_TYPICAL: 30000
    SPIFLASH_TSE_MAXIMUM: 400000
    SPIFLASH_TBE1_TYPICAL: 120000
    SPIFLASH_TBE1_MAXIMUM: 800000
    SPIFLASH_TBE2_TYPICAL: 150000
    SPIFLASH_TBE2_MAXIMUM: 1000000
    SPIFLASH_TCE_TYPICAL: 3000000
    SPIFLASH_TCE_MAXIMUM: 10000000

    BSP_FLASH_SPI_BUS: '"spi0"'

    UART_0_PIN_TX: 'MCU_GPIO_PORTA(9)'
    UART_0_PIN_RX: 'MCU_GPIO_PORTA(10)'
    UART_1: 1
    UART_1_PIN_TX: 'MCU_GPIO_PORTD(5)'
    UART_1_PIN_RX: 'MCU_GPIO_PORTD(6)'
    UART_2: 1
    UART_2_PIN_TX: 'MCU_GPIO_PORTD(8)'
    UART_2_PIN_RX: 'MCU_GPIO_PORTD(9)'
    SPI_0_PIN_SS: 'MCU_GPIO_PORTA(4)'
    SPI_0_PIN_SCK: 'MCU_GPIO_PORTB(3)'
    SPI_0_PIN_MISO: 'MCU_GPIO_PORTB(4)'
    SPI_0_PIN_MOSI: 'MCU_GPIO_PORTB(5)'
    SPI_1_PIN_SCK: 'MCU_GPIO_PORTB(13)'
    SPI_1_PIN_MISO: 'MCU_GPIO_PORTB(14)'
    SPI_1_PIN_MOSI: 'MCU_GPIO_PORTB(15)'
    I2C_0_PIN_SCL: 'MCU_GPIO_PORTB(8)'
    I2C_0_PIN_SDA: 'MCU_GPIO_PORTB(9)'
    TIMER_0_TIM: 'TIM2'
    TIMER_1_TIM: 'TIM3'
    TIMER_2_TIM: 'TIM4'

    USB_DP_HAS_EXTERNAL_PULL_UP: 1

    # Flasher parameters
    MYNEWT_DOWNLOADER: stflash
    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
    JLINK_TARGET: STM32F407VE
