From 73edcf313c1884bbb520d8c53d493224c20faff2 Mon Sep 17 00:00:00 2001 From: jflyper Date: Sun, 23 Sep 2018 02:48:50 +0900 Subject: [PATCH] Move bst related defs to bst.h plus some cleanup --- src/main/target/COLIBRI_RACE/bst.h | 28 +++++++++++ .../target/COLIBRI_RACE/bus_bst_stm32f30x.c | 5 +- src/main/target/COLIBRI_RACE/config.c | 49 +++++++++++++++++++ src/main/target/COLIBRI_RACE/target.c | 19 ------- src/main/target/COLIBRI_RACE/target.h | 7 +-- 5 files changed, 81 insertions(+), 27 deletions(-) create mode 100644 src/main/target/COLIBRI_RACE/bst.h create mode 100644 src/main/target/COLIBRI_RACE/config.c diff --git a/src/main/target/COLIBRI_RACE/bst.h b/src/main/target/COLIBRI_RACE/bst.h new file mode 100644 index 0000000000..c6b23af1db --- /dev/null +++ b/src/main/target/COLIBRI_RACE/bst.h @@ -0,0 +1,28 @@ +/* + * This file is part of Cleanflight and Betaflight. + * + * Cleanflight and Betaflight are free software. You can redistribute + * this software and/or modify this software under the terms of the + * GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Cleanflight and Betaflight are distributed in the hope that they + * will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software. + * + * If not, see . + */ + +#pragma once + +#define BST_DEVICE_NAME "COLIBRI RACE" +#define BST_DEVICE_NAME_LENGTH 12 +#define BST_DEVICE (BSTDEV_1) +/* Configure the CRC peripheral to use the polynomial x8 + x7 + x6 + x4 + x2 + 1 */ +#define BST_CRC_POLYNOM 0xD5 + diff --git a/src/main/target/COLIBRI_RACE/bus_bst_stm32f30x.c b/src/main/target/COLIBRI_RACE/bus_bst_stm32f30x.c index 17b99f7b1c..0a6e818d2f 100644 --- a/src/main/target/COLIBRI_RACE/bus_bst_stm32f30x.c +++ b/src/main/target/COLIBRI_RACE/bus_bst_stm32f30x.c @@ -10,6 +10,8 @@ #include "platform.h" +#ifdef USE_BST + #include "build/build_config.h" #include "drivers/nvic.h" @@ -17,10 +19,9 @@ #include "drivers/io_impl.h" #include "drivers/rcc.h" +#include "bst.h" #include "bus_bst.h" - -#ifdef USE_BST #define NVIC_PRIO_BST_READ_DATA NVIC_BUILD_PRIORITY(1, 1) #define BST_SHORT_TIMEOUT ((uint32_t)0x1000) diff --git a/src/main/target/COLIBRI_RACE/config.c b/src/main/target/COLIBRI_RACE/config.c new file mode 100644 index 0000000000..02f1203136 --- /dev/null +++ b/src/main/target/COLIBRI_RACE/config.c @@ -0,0 +1,49 @@ +/* + * This file is part of Cleanflight and Betaflight. + * + * Cleanflight and Betaflight are free software. You can redistribute + * this software and/or modify this software under the terms of the + * GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Cleanflight and Betaflight are distributed in the hope that they + * will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software. + * + * If not, see . + */ + +#include +#include + +#include "platform.h" + +#ifdef USE_BST + +#include "bst.h" +#include "bus_bst.h" +#include "pg/bus_i2c.h" +#include "pg/bus_spi.h" + +// XXX Requires some additional work here. +// XXX Can't do this now without proper semantics about I2C on this target. +void targetBusInit(void) +{ +#ifdef USE_SPI + spiPinConfigure(spiPinConfig(0)); +#ifdef USE_SPI_DEVICE_1 + spiInit(SPIDEV_1); +#endif +#endif + + i2cHardwareConfigure(i2cConfig(0)); + i2cInit(I2CDEV_2); + + bstInit(BST_DEVICE); +} +#endif diff --git a/src/main/target/COLIBRI_RACE/target.c b/src/main/target/COLIBRI_RACE/target.c index 814b315b0a..139f1619e4 100644 --- a/src/main/target/COLIBRI_RACE/target.c +++ b/src/main/target/COLIBRI_RACE/target.c @@ -52,22 +52,3 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { DEF_TIM(TIM16, CH1, PA6, TIM_USE_LED, 0), // PWM11 - PB15 }; - -// XXX Requires some additional work here. -// XXX Can't do this now without proper semantics about I2C on this target. -#ifdef USE_BST -void targetBusInit(void) -{ -#ifdef USE_SPI - spiPinConfigure(spiPinConfig(0)); -#ifdef USE_SPI_DEVICE_1 - spiInit(SPIDEV_1); -#endif -#endif - - i2cHardwareConfigure(i2cConfig(0)); - i2cInit(I2CDEV_2); - - bstInit(BST_DEVICE); -} -#endif diff --git a/src/main/target/COLIBRI_RACE/target.h b/src/main/target/COLIBRI_RACE/target.h index e2a5d7315c..3d916f0a68 100644 --- a/src/main/target/COLIBRI_RACE/target.h +++ b/src/main/target/COLIBRI_RACE/target.h @@ -25,10 +25,8 @@ #undef USE_RTC_TIME #define TARGET_BOARD_IDENTIFIER "CLBR" -#define BST_DEVICE_NAME "COLIBRI RACE" -#define BST_DEVICE_NAME_LENGTH 12 -#define TARGET_BUS_INIT +#define TARGET_BUS_INIT #define LED0_PIN PC15 #define LED1_PIN PC14 @@ -106,9 +104,6 @@ #define I2C2_SDA_PIN PA10 #define USE_BST -#define BST_DEVICE (BSTDEV_1) -/* Configure the CRC peripheral to use the polynomial x8 + x7 + x6 + x4 + x2 + 1 */ -#define BST_CRC_POLYNOM 0xD5 #define USE_ADC #define ADC_INSTANCE ADC1