; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[setup]
compiler = arm_none_eabi_gcc
spi = 1
i2c = 2

[platformio]
include_dir = inc
src_dir = src
default_envs = release_spi_m4f
build_dir = build/${setup.compiler}

[env]
custom_target_m4f = arm_cortex_m4f
custom_target_m4 = arm_cortex_m4
custom_api_dir = ./../../api
custom_common_dir = ./../_common
extra_scripts = pre:pre_script.py
                post:post_script.py
custom_prog_name = bmv080_example
platform = ststm32
board = adafruit_feather_f405
framework = stm32cube
platform_packages = toolchain-gccarmnoneeabi @ 1.120301.0
board_build.mcu = stm32f405rgt6
board_build.stm32cube.custom_config_header = yes
debug_tool = jlink
board_build.ldscript = STM32F405RGTX.ld
upload_protocol = jlink
build_flags =
    -mcpu=cortex-m4
    -std=gnu11
    -mthumb
    -DUSE_EXTERNAL_INTERRUPT
    -DUSE_HAL_DRIVER
    -DSTM32F405xx
    -Wall
    -fstack-usage
    -ffunction-sections
    -fdata-sections
    -MMD
    -MP
    -I ${this.custom_api_dir}/inc
    -I inc/usb_device
    -I ${this.custom_common_dir}/inc 
    -Wl,--gc-sections
    -Wl,-u_printf_float
    -Wl,--static
    -l lib_bmv080.a 
    -l lib_postProcessor.a
    -lc 
    -lm
    -Os
    -DSPI=${setup.spi}
    -DI2C=${setup.i2c}

[env:release_spi_m4]
build_type = release
; remove floating point flag, set by platformio environment
build_unflags = -mfloat-abi=hard
build_flags =
    -DHOST_INTERFACE=${setup.spi}
    -L ${env.custom_api_dir}/lib/${env.custom_target_m4}/${setup.compiler}/${this.build_type}
    -mfloat-abi=soft
    ${env.build_flags}

[env:release_i2c_m4]
build_type = release
; remove floating point flag, set by platformio environment
build_unflags = -mfloat-abi=hard
build_flags =
    -DHOST_INTERFACE=${setup.i2c}
    -L ${env.custom_api_dir}/lib/${env.custom_target_m4}/${setup.compiler}/${this.build_type}
    -mfloat-abi=soft
    ${env.build_flags}

[env:release_spi_m4f]
build_type = release
build_flags =
    -DHOST_INTERFACE=${setup.spi}
    -L ${env.custom_api_dir}/lib/${env.custom_target_m4f}/${setup.compiler}/${this.build_type}
    -mfpu=fpv4-sp-d16 
    -mfloat-abi=hard
    ${env.build_flags}

[env:release_i2c_m4f]
build_type = release
build_flags =
    -DHOST_INTERFACE=${setup.i2c}
    -mfpu=fpv4-sp-d16 
    -mfloat-abi=hard
    -L ${env.custom_api_dir}/lib/${env.custom_target_m4f}/${setup.compiler}/${this.build_type}
    ${env.build_flags}