; PlatformIO Project Configuration File
;
; Platform, toolchain and boards
; "espressif32" -> https://registry.platformio.org/platforms/platformio/espressif32/versions
; "toolchain-xtensa-esp32" -> https://registry.platformio.org/tools/espressif/toolchain-xtensa-esp32/versions
; "toolchain-xtensa-esp32s2" -> https://registry.platformio.org/tools/espressif/toolchain-xtensa-esp32s2/versions
; "toolchain-xtensa-esp32s3" -> https://registry.platformio.org/tools/espressif/toolchain-xtensa-esp32s3/versions
; "toolchain-riscv32-esp" -> https://registry.platformio.org/tools/espressif/toolchain-riscv32-esp/versions
; "tool-esptoolpy" -> https://registry.platformio.org/tools/platformio/tool-esptoolpy/versions
; "board" -> https://github.com/platformio/platform-espressif32/tree/master/boards

[setup]
spi = 1
i2c = 2

[platformio]
include_dir = inc
src_dir = src
build_dir = build
default_envs = release_spi_esp32

[env]
custom_target_esp32 = xtensa_esp32
custom_compiler_esp32 = xtensa_esp32_elf_gcc
custom_target_esp32s2 = xtensa_esp32s2
custom_compiler_esp32s2 = xtensa_esp32s2_elf_gcc
custom_target_esp32s3 = xtensa_esp32s3
custom_compiler_esp32s3 = xtensa_esp32s3_elf_gcc
custom_target_esp32c6 = riscv_rv32imc
custom_compiler_esp32c6 = riscv_none_elf_gcc
custom_api_dir = ./../../api
platform = espressif32
framework = espidf
platform_packages =
    platformio/espressif32@^6.11.0
    platformio/tool-esptoolpy@^1.40801.0
    platformio/framework-espidf@^3.50401.0
    espressif/tool-xtensa-esp-elf-gdb@12.1.0+20221002
    platformio/tool-openocd-esp32@2.1200.20230419
custom_common_dir = ./../_common
extra_scripts = pre:pre_script.py
                post:post_script.py
custom_prog_name = bmv080_example
board_build.f_cpu = 240000000L
upload_protocol = esptool
monitor_speed = 115200
debug_tool = jlink
build_flags =
	-std=gnu11
    -Wall
	-mlongcalls
    -Wno-frame-address
    -Wl,--static
    -I ${this.custom_api_dir}/inc
    -I ${this.custom_common_dir}/inc
    -l lib_bmv080.a 
    -l lib_postProcessor.a
    -Os
    -DSPI=${setup.spi}
    -DI2C=${setup.i2c}

; ------------------------------------------------------------
; ESP32
; ------------------------------------------------------------
[env:release_spi_esp32]
build_type = release
board_build.mcu = esp32
board = adafruit_feather_esp32_v2
platform_packages =
    toolchain-xtensa-esp32@12.2.0+20230208
build_flags =
    -DUSE_EXTERNAL_INTERRUPT
    -DBOARD_ESP32_V2
    -DHOST_INTERFACE=${setup.spi}
    -L ${env.custom_api_dir}/lib/${env.custom_target_esp32}/${env.custom_compiler_esp32}/${this.build_type}
    ${env.build_flags}

[env:release_i2c_esp32]
build_type = release
board_build.mcu = esp32
board = adafruit_feather_esp32_v2
platform_packages =
    toolchain-xtensa-esp32@12.2.0+20230208
build_flags =
    -DUSE_EXTERNAL_INTERRUPT
    -DBOARD_ESP32_V2
    -DHOST_INTERFACE=${setup.i2c}
    -L ${env.custom_api_dir}/lib/${env.custom_target_esp32}/${env.custom_compiler_esp32}/${this.build_type}
    ${env.build_flags}

; ------------------------------------------------------------
; ESP32-S2
; ------------------------------------------------------------
[env:release_spi_esp32s2]
build_type = release
board_build.mcu = esp32s2
board = featheresp32-s2
platform_packages =
    toolchain-xtensa-esp32s2@12.2.0+20230208
build_flags =
    -DBOARD_ESP32_S2
    -DUSE_EXTERNAL_INTERRUPT
    -DHOST_INTERFACE=${setup.spi}
    -L ${env.custom_api_dir}/lib/${env.custom_target_esp32s2}/${env.custom_compiler_esp32s2}/${this.build_type}
    ${env.build_flags}

[env:release_i2c_esp32s2]
build_type = release
board_build.mcu = esp32s2
board = featheresp32-s2
platform_packages =
    toolchain-xtensa-esp32s2@12.2.0+20230208
build_flags =
    -DBOARD_ESP32_S2
    -DUSE_EXTERNAL_INTERRUPT
    -DHOST_INTERFACE=${setup.i2c}
    -L ${env.custom_api_dir}/lib/${env.custom_target_esp32s2}/${env.custom_compiler_esp32s2}/${this.build_type}
    ${env.build_flags}

; ------------------------------------------------------------
; ESP32-S3
; ------------------------------------------------------------
[env:release_spi_esp32s3]
build_type = release
board_build.mcu = esp32s3
board = adafruit_feather_esp32s3
platform_packages =
    toolchain-xtensa-esp32s3@12.2.0+20230208
build_flags =
    -DUSE_EXTERNAL_INTERRUPT
    -DBOARD_ESP32_S3
    -DHOST_INTERFACE=${setup.spi}
    -L ${env.custom_api_dir}/lib/${env.custom_target_esp32s3}/${env.custom_compiler_esp32s3}/${this.build_type}
    ${env.build_flags}

[env:release_i2c_esp32s3]
build_type = release
board_build.mcu = esp32s3
board = adafruit_feather_esp32s3
platform_packages = 
    toolchain-xtensa-esp32s3@12.2.0+20230208
build_flags =
    -DUSE_EXTERNAL_INTERRUPT
    -DBOARD_ESP32_S3
    -DHOST_INTERFACE=${setup.i2c}
    -L ${env.custom_api_dir}/lib/${env.custom_target_esp32s3}/${env.custom_compiler_esp32s3}/${this.build_type}
    ${env.build_flags}

; ------------------------------------------------------------
; ESP32-C6
; ------------------------------------------------------------
[env:release_spi_esp32c6]
build_type = release
board_build.mcu = esp32c6
board = esp32-c6-devkitc-1
platform_packages =
    toolchain-riscv32-esp@14.2.0+20241119
build_unflags = -mlongcalls
build_flags =
    -DUSE_EXTERNAL_INTERRUPT
    -DBOARD_ESP32_C6
    -DHOST_INTERFACE=${setup.spi}
    -L ${env.custom_api_dir}/lib/${env.custom_target_esp32c6}/${env.custom_compiler_esp32c6}/${this.build_type}
    ${env.build_flags}

[env:release_i2c_esp32c6]
build_type = release
board_build.mcu = esp32c6
board = esp32-c6-devkitc-1
platform_packages = 
    toolchain-riscv32-esp@14.2.0+20241119
build_unflags = -mlongcalls
build_flags =
    -DUSE_EXTERNAL_INTERRUPT
    -DBOARD_ESP32_C6
    -DHOST_INTERFACE=${setup.i2c}
    -L ${env.custom_api_dir}/lib/${env.custom_target_esp32c6}/${env.custom_compiler_esp32c6}/${this.build_type}
    ${env.build_flags}
