From a3b6e40fa2aecbb7c5025fc0d5c9601a8ee9dc85 Mon Sep 17 00:00:00 2001 From: EmanuelFeru Date: Tue, 7 Jan 2020 18:09:19 +0100 Subject: [PATCH] Minor updates - fixed all warnings for VARIANT_NUNCHUCK and VARIANT_PPM - changed the variant order: the basic Variants on top, more application specific in the bottom --- Inc/config.h | 4 +- Inc/defines.h | 6 ++- Src/main.c | 6 ++- Src/stm32f1xx_it.c | 1 + platformio.ini | 94 ++++++++++++++++++++++++++-------------------- 5 files changed, 65 insertions(+), 46 deletions(-) diff --git a/Inc/config.h b/Inc/config.h index fb9e198..20be07f 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -8,10 +8,10 @@ #if !defined(PLATFORMIO) //#define VARIANT_ADC // Variant for control via ADC input //#define VARIANT_USART3 // Variant for Serial control via USART3 input - //#define VARIANT_HOVERCAR // Variant for HOVERCAR build - //#define VARIANT_TRANSPOTTER // Variant for TRANSPOTTER build https://github.com/NiklasFauth/hoverboard-firmware-hack/wiki/Build-Instruction:-TranspOtter https://hackaday.io/project/161891-transpotter-ng //#define VARIANT_NUNCHUCK // Variant for Nunchuck controlled vehicle build //#define VARIANT_PPM // Variant for RC-Remote with PPM-Sum Signal + //#define VARIANT_HOVERCAR // Variant for HOVERCAR build + //#define VARIANT_TRANSPOTTER // Variant for TRANSPOTTER build https://github.com/NiklasFauth/hoverboard-firmware-hack/wiki/Build-Instruction:-TranspOtter https://hackaday.io/project/161891-transpotter-ng #endif // For any particular needs, feel free to change this file according to your needs. diff --git a/Inc/defines.h b/Inc/defines.h index 51462c6..ec5f6bc 100644 --- a/Inc/defines.h +++ b/Inc/defines.h @@ -174,8 +174,10 @@ void mixerFcn(int16_t rtu_speed, int16_t rtu_steer, int16_t *rty_speedR, int16_t void rateLimiter16(int16_t u, int16_t rate, int16_t *y); void multipleTapDet(int16_t u, uint32_t timeNow, MultipleTap *x); -// Define I2C and Nunchuck functions +// Define I2C, Nunchuck, PPM functions void I2C_Init(void); void Nunchuck_Init(void); void Nunchuck_Read(void); -uint8_t Nunchuck_Ping(void); \ No newline at end of file +uint8_t Nunchuck_Ping(void); +void PPM_Init(void); +void PPM_ISR_Callback(void); \ No newline at end of file diff --git a/Src/main.c b/Src/main.c index 60d09da..6d632b5 100644 --- a/Src/main.c +++ b/Src/main.c @@ -71,7 +71,8 @@ extern volatile adc_buf_t adc_buffer; LCD_PCF8574_HandleTypeDef lcd; #endif extern I2C_HandleTypeDef hi2c2; -#ifndef VARIANT_TRANSPOTTER +#if defined(CONTROL_SERIAL_USART2) || defined(FEEDBACK_SERIAL_USART2) || defined(DEBUG_SERIAL_USART2) \ + || defined(CONTROL_SERIAL_USART3) || defined(FEEDBACK_SERIAL_USART3) || defined(DEBUG_SERIAL_USART3) extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; static UART_HandleTypeDef huart; @@ -454,7 +455,8 @@ int main(void) { cmd1 = CLAMP((ppm_captured_value[0] - INPUT_MID) * 2, INPUT_MIN, INPUT_MAX); cmd2 = CLAMP((ppm_captured_value[1] - INPUT_MID) * 2, INPUT_MIN, INPUT_MAX); button1 = ppm_captured_value[5] > INPUT_MID; - float scale = ppm_captured_value[2] / 1000.0f; + button2 = 0; + // float scale = ppm_captured_value[2] / 1000.0f; // not used for now, uncomment if needed #endif #ifdef CONTROL_ADC diff --git a/Src/stm32f1xx_it.c b/Src/stm32f1xx_it.c index 8ca24ee..9de1ee7 100644 --- a/Src/stm32f1xx_it.c +++ b/Src/stm32f1xx_it.c @@ -34,6 +34,7 @@ #include "stm32f1xx_hal.h" #include "stm32f1xx.h" #include "stm32f1xx_it.h" +#include "defines.h" #include "config.h" extern DMA_HandleTypeDef hdma_i2c2_rx; diff --git a/platformio.ini b/platformio.ini index fd04d77..7e2efea 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,10 +11,12 @@ src_dir = Src ; ;default_envs = VARIANT_ADC ; Variant for control via ADC input ;default_envs = VARIANT_USART3 ; Variant for Serial control via USART3 input -;default_envs = VARIANT_HOVERCAR ; Variant for HOVERCAR build -;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_NUNCHUCK ; Variant for Nunchuck controlled vehicle build ;default_envs = VARIANT_PPM ; Variant for RC-Remotes with PPM-Sum signal +;default_envs = VARIANT_HOVERCAR ; Variant for HOVERCAR build +;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 +;================================================================ + ;================================================================ [env:VARIANT_ADC] @@ -40,6 +42,8 @@ build_flags = -D VARIANT_ADC -D PALTFORMIO +;================================================================ + [env:VARIANT_USART3] platform = ststm32 framework = stm32cube @@ -63,6 +67,50 @@ build_flags = -D VARIANT_USART3 -D PALTFORMIO +;================================================================ + +[env:VARIANT_NUNCHUCK] +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 VARIANT_NUNCHUCK + -D PALTFORMIO + +;================================================================ + +[env:VARIANT_PPM] +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 VARIANT_PPM + -D PALTFORMIO + +;================================================================ + [env:VARIANT_HOVERCAR] platform = ststm32 framework = stm32cube @@ -86,6 +134,8 @@ build_flags = -D VARIANT_HOVERCAR -D PALTFORMIO +;================================================================ + [env:VARIANT_TRANSPOTTER] platform = ststm32 framework = stm32cube @@ -104,41 +154,5 @@ build_flags = # -Wl,-lnosys -D VARIANT_TRANSPOTTER -D PALTFORMIO - -[env:VARIANT_NUNCHUCK] -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 VARIANT_NUNCHUCK - -D PALTFORMIO - -[env:VARIANT_PPM] -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 VARIANT_PPM - -D PALTFORMIO \ No newline at end of file + +;================================================================ \ No newline at end of file