From 72d2aae4d74ca0354a68ada1d25623c0f350943c Mon Sep 17 00:00:00 2001 From: EmanuelFeru Date: Mon, 23 Dec 2019 12:12:01 +0100 Subject: [PATCH] Made Variant selection easy via platformio.ini Now it is easy to select between different variant builds via platformio.ini. Currently, 3 variants can be selected: VARIANT_ADC VARIANT_USART3 TRANSPOTTER Note: For any particular needs, you can still change config.h according to your needs. --- .travis.yml | 4 ++-- Inc/config.h | 37 ++++++++++++++++++++++++++----------- platformio.ini | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 75 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index e7fe17f..de604c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,8 +43,8 @@ matrix: - export PATH=$HOME/arm-gcc-toolchain/bin:$PATH before_script: arm-none-eabi-gcc --version - - name: pio genericSTM32F103RC - script: platformio run -e genericSTM32F103RC + - name: platformio + script: platformio run -e VARIANT_ADC -e VARIANT_USART3 -e TRANSPOTTER language: python python: - "2.7" diff --git a/Inc/config.h b/Inc/config.h index 6b23307..8dafd56 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -2,7 +2,13 @@ #include "stm32f1xx_hal.h" // ############################### DEFINE FIRMWARE VARIANT ############################### -// #define TRANSPOTTER // Uncomment this line for TRANSPORTER configuration +// For variant selection, check platformio.ini +// For any particular needs, feel free to change this file according to your needs. + +// Select the VARIANT_ADC as default variant, in case NO variant is defined +#if !defined(VARIANT_ADC) && !defined(VARIANT_USART3) && !defined(TRANSPOTTER) + #define VARIANT_ADC +#endif // ############################### DO-NOT-TOUCH SETTINGS ############################### @@ -100,16 +106,25 @@ #define USART2_BAUD 38400 // UART2 baud rate (long wired cable) #define USART2_WORDLENGTH UART_WORDLENGTH_8B // UART_WORDLENGTH_8B or UART_WORDLENGTH_9B -// #define CONTROL_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! For Arduino control check the hoverSerial.ino -// #define FEEDBACK_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! -// #define DEBUG_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! +#define USART3_BAUD 38400 // UART3 baud rate (short wired cable) +#define USART3_WORDLENGTH UART_WORDLENGTH_8B // UART_WORDLENGTH_8B or UART_WORDLENGTH_9B -#ifndef TRANSPOTTER - #define USART3_BAUD 38400 // UART3 baud rate (short wired cable) - #define USART3_WORDLENGTH UART_WORDLENGTH_8B // UART_WORDLENGTH_8B or UART_WORDLENGTH_9B - // #define CONTROL_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! For Arduino control check the hoverSerial.ino - // #define FEEDBACK_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! - #define DEBUG_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! +#if defined(VARIANT_ADC) + // #define CONTROL_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! For Arduino control check the hoverSerial.ino + // #define FEEDBACK_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! + // #define DEBUG_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! + + // #define CONTROL_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! For Arduino control check the hoverSerial.ino + // #define FEEDBACK_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! + #define DEBUG_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! +#elif defined(VARIANT_USART3) + // #define CONTROL_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! For Arduino control check the hoverSerial.ino + // #define FEEDBACK_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! + // #define DEBUG_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used! + + #define CONTROL_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! For Arduino control check the hoverSerial.ino + #define FEEDBACK_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! + // #define DEBUG_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck or lcd) is used! #endif #if defined(FEEDBACK_SERIAL_USART2) || defined(DEBUG_SERIAL_USART2) @@ -133,7 +148,7 @@ * For middle resting potis: Let the potis in the middle resting position, write value 1 to ADC1_MID and value 2 to ADC2_MID * Make, flash and test it. */ -#ifndef TRANSPOTTER +#ifdef VARIANT_ADC #define CONTROL_ADC // use ADC as input. disable CONTROL_SERIAL_USART2, FEEDBACK_SERIAL_USART2, DEBUG_SERIAL_USART2! // #define ADC1_MID_POT // ADC1 middle resting poti: comment-out if NOT a middle resting poti #define ADC1_MIN 0 // min ADC1-value while poti at minimum-position (0 - 4095) diff --git a/platformio.ini b/platformio.ini index 790b6cd..0cefdec 100644 --- a/platformio.ini +++ b/platformio.ini @@ -5,7 +5,13 @@ include_dir = Inc src_dir = Src -[env:genericSTM32F103RC] +;=================== VARIANT SELECTION ========================== +default_envs = VARIANT_ADC ; Variant for control via ADC input +;default_envs = VARIANT_USART3 ; Variant for Serial control via USART3 input +;default_envs = TRANSPOTTER ; Variant for TRANSPOTTER build https://github.com/Jan--Henrik/transpOtterNG +;================================================================ + +[env:VARIANT_ADC] platform = ststm32 framework = stm32cube board = genericSTM32F103RC @@ -25,3 +31,43 @@ build_flags = -Wl,-lm -g -ggdb ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization # -Wl,-lnosys + +[env:VARIANT_USART3] +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 = 38400 + +build_flags = + -I${PROJECT_DIR}/inc/ + -DUSE_HAL_DRIVER + -DSTM32F103xE + -Wl,-T./STM32F103RCTx_FLASH.ld + -Wl,-lc + -Wl,-lm + -g -ggdb ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization +# -Wl,-lnosys + -D VARIANT_USART3 + +[env:TRANSPOTTER] +platform = ststm32 +framework = stm32cube +board = genericSTM32F103RC +debug_tool = stlink +upload_protocol = stlink + +build_flags = + -I${PROJECT_DIR}/inc/ + -DUSE_HAL_DRIVER + -DSTM32F103xE + -Wl,-T./STM32F103RCTx_FLASH.ld + -Wl,-lc + -Wl,-lm + -g -ggdb ; to generate correctly the 'firmware.elf' for STM STUDIO vizualization +# -Wl,-lnosys + -D TRANSPOTTER \ No newline at end of file