; PlatformIO Project Configuration File2
; http://docs.platformio.org/page/projectconf.html

[platformio]
include_dir = Inc
src_dir     = Src

;=================== VARIANT SELECTION ==========================
;
; Choose one or all variants get built
;
;default_envs = VARIANT_ADC         ; Variant for control via ADC input
;default_envs = VARIANT_USART       ; Variant for Serial control via USART3 input
;default_envs = VARIANT_NUNCHUK     ; Variant for Nunchuk controlled vehicle build
;default_envs = VARIANT_PPM         ; Variant for RC-Remotes with PPM-Sum signal
;default_envs = VARIANT_PWM         ; Variant for RC-Remotes with PWM signal
;default_envs = VARIANT_IBUS        ; Variant for RC-Remotes with FLYSKY IBUS
;default_envs = VARIANT_HOVERCAR    ; Variant for HOVERCAR build
;default_envs = VARIANT_HOVERBOARD  ; Variant for HOVERBOARD
;default_envs = VARIANT_TRANSPOTTER ; Variant for TRANSPOTTER build https://github.com/NiklasFauth/hoverboard-firmware-hack/wiki/Build-Instruction:-TranspOtter https://hackaday.io/project/161891-transpotter-ng
;default_envs = VARIANT_SKATEBOARD  ; Variant for SKATEBOARD build controlled via RC-Remotes with PWM signal
default_envs = VARIANT_BBCAR       ; Variant for for small Toy-Car with steering wheel with 4 drive modes https://larsm.org/allrad-e-bobby-car/
;================================================================

;================================================================

[env:VARIANT_ADC]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

; Serial Port settings (make sure the COM port is correct)
monitor_port    = COM5
monitor_speed   = 115200

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_ADC

;================================================================

[env:VARIANT_USART]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

; Serial Port settings (make sure the COM port is correct)
monitor_port    = COM5
monitor_speed   = 115200

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_USART

;================================================================

[env:VARIANT_NUNCHUK]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_NUNCHUK

;================================================================

[env:VARIANT_PPM]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_PPM

;================================================================

[env:VARIANT_PWM]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_PWM

;================================================================

[env:VARIANT_IBUS]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_IBUS

;================================================================

[env:VARIANT_HOVERCAR]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_HOVERCAR

;================================================================

[env:VARIANT_HOVERBOARD]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_HOVERBOARD

;================================================================

[env:VARIANT_TRANSPOTTER]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_TRANSPOTTER
    
;================================================================


[env:VARIANT_SKATEBOARD]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
debug_tool      = stlink
upload_protocol = stlink

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE
    -T./STM32F103RCTx_FLASH.ld
    -lc
    -lm
    -g -ggdb        ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization
    -D VARIANT_SKATEBOARD
    
;================================================================

[env:VARIANT_BBCAR]
platform        = ststm32
framework       = stm32cube
board           = genericSTM32F103RC
; debug_tool      = jlink
; upload_protocol = jlink
debug_tool      = stlink
upload_protocol = stlink

; Optional: use latest version of toolchain-gccarmnoneeabi: search for "toolchain-gccarmnoneeabi" on https://bintray.com/platformio/tool-packages and look at files-tab to get latest version number. If you are having problems disable it, older version should also work fine. https://launchpad.net/gcc-arm-embedded/+milestones
platform_packages = 
    toolchain-gccarmnoneeabi @ >=1.90301.200702

; Serial Port settings (make sure the COM port is correct)
monitor_port    = COM3
monitor_speed   = 115200

board_build.ldscript=./STM32F103RCTx_FLASH.ld

build_flags =
    -DUSE_HAL_DRIVER
    -DSTM32F103xE  ; set correct cpu
    -Wl,-u,_printf_float  ; enable float for printf
    ; -Wl,-lnosys  ; needed for some functions of libc
    -Wno-comment  ; surpress warnings for multi-line-comments
    -Wno-parentheses  ; surpress warnings for parentheses
    -fsingle-precision-constant  ; do not use double precision (64 bit) by default
    -g -ggdb  ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization and gdb debugger
    -D VARIANT_BBCAR
    ; -Og  ; optimized for debugging, https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
    -O2  ; optimized for speed
    ; Tests for automatically adding git version to compiled binary:
    ; -DGIT_BRANCH=´git rev-parse --abbrev-ref HEAD´
    ; -DDATE=´date´
    ; https://docs.platformio.org/en/latest/projectconf/section_env_build.html#projectconf-dynamic-build-flags
    ; !echo "-DGIT_HASH="$(git describe --always --dirty)
