diff --git a/.travis.yml b/.travis.yml index 608f099b8e..b244fe100a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,3 +31,6 @@ script: # Build cf2 with TDOA3 and all config options - docker run --rm -v ${PWD}:/module bitcraze/builder ./tools/build/make clean - docker run --rm -v ${PWD}:/module bitcraze/builder ./tools/build/build PLATFORM=cf2 DEBUG=1 LPS_TDOA3_ENABLE=1 "EXTRA_CFLAGS=-DLPS_2D_POSITION_HEIGHT=1.2 -DLPS_LONGER_RANGE" + + # Build the tag platform + - docker run --rm -v ${PWD}:/module bitcraze/builder ./tools/build/build PLATFORM=tag diff --git a/Makefile b/Makefile index f488a91622..a6ac9cd7eb 100644 --- a/Makefile +++ b/Makefile @@ -338,7 +338,7 @@ ifeq ($(SHELL),/bin/sh) endif print_version: - @echo "$(PLATFORM_NAME_$(PLATFORM)) build!" + @echo "BUild for the $(PLATFORM_NAME_$(PLATFORM))!" @$(PYTHON2) tools/make/versionTemplate.py --print-version ifeq ($(CLOAD), 1) @echo "Crazyloader build!" diff --git a/src/hal/src/sensors.c b/src/hal/src/sensors.c index dae368db70..57339c2ba8 100644 --- a/src/hal/src/sensors.c +++ b/src/hal/src/sensors.c @@ -68,8 +68,10 @@ typedef struct { void (*dataAvailableCallback)(void); } sensorsImplementation_t; - +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" static void nullFunction(void) {} +#pragma GCC diagnostic pop static const sensorsImplementation_t sensorImplementations[SensorImplementation_COUNT] = { #ifdef SENSOR_INCLUDED_BMI088_BMP388 diff --git a/src/modules/src/system.c b/src/modules/src/system.c index 8327b3e694..05ed525e69 100644 --- a/src/modules/src/system.c +++ b/src/modules/src/system.c @@ -158,7 +158,7 @@ void systemTask(void *arg) deckInit(); estimator = deckGetRequiredEstimator(); stabilizerInit(estimator); - if (deckGetRequiredLowInterferenceRadioMode()) + if (deckGetRequiredLowInterferenceRadioMode() && platformConfigPhysicalLayoutAntennasAreClose()) { platformSetLowInterferenceRadioMode(); } diff --git a/src/platform/platform.c b/src/platform/platform.c index b75749664f..d8008ec398 100644 --- a/src/platform/platform.c +++ b/src/platform/platform.c @@ -25,11 +25,35 @@ * */ +#define DEBUG_MODULE "PLATFORM" + #include #include "platform.h" +#include "radiolink.h" +#include "debug.h" + +// Define to decrease the nRF51 Tx power to reduce interference +#ifndef PLATFORM_NRF51_LOW_INTERFERENCE_TX_POWER_DBM +#define PLATFORM_NRF51_LOW_INTERFERENCE_TX_POWER_DBM (-12) +#endif static const platformConfig_t* active_config = 0; +static int platformInitConfiguration(const platformConfig_t* configs, const int nrOfConfigs); +int platformInit(void) { + int nrOfConfigs = 0; + const platformConfig_t* configs = platformGetListOfConfigurations(&nrOfConfigs); + + int err = platformInitConfiguration(configs, nrOfConfigs); + if (err != 0) + { + // This firmware is not compatible, abort init + return 1; + } + + platformInitHardware(); + return 0; +} int platformParseDeviceTypeString(const char* deviceTypeString, char* deviceType) { if (deviceTypeString[0] != '0' || deviceTypeString[1] != ';') { @@ -55,12 +79,19 @@ int platformParseDeviceTypeString(const char* deviceTypeString, char* deviceType return 0; } -int platformInitConfiguration(const platformConfig_t* configs, const int nrOfConfigs) { +static int platformInitConfiguration(const platformConfig_t* configs, const int nrOfConfigs) { +#ifndef DEVICE_TYPE_STRING_FORCE char deviceTypeString[PLATFORM_DEVICE_TYPE_STRING_MAX_LEN]; char deviceType[PLATFORM_DEVICE_TYPE_MAX_LEN]; platformGetDeviceTypeString(deviceTypeString); platformParseDeviceTypeString(deviceTypeString, deviceType); +#else + #define xstr(s) str(s) + #define str(s) #s + + char* deviceType = xstr(DEVICE_TYPE_STRING_FORCE); +#endif for (int i = 0; i < nrOfConfigs; i++) { const platformConfig_t* config = &configs[i]; @@ -81,3 +112,13 @@ SensorImplementation_t platformConfigGetSensorImplementation() { return active_config->sensorImplementation; } +bool platformConfigPhysicalLayoutAntennasAreClose() { + return active_config->physicalLayoutAntennasAreClose; +} + + +void platformSetLowInterferenceRadioMode(void) { + // Decrease the nRF51 Tx power to reduce interference + radiolinkSetPowerDbm(PLATFORM_NRF51_LOW_INTERFERENCE_TX_POWER_DBM); + DEBUG_PRINT("Low interference mode. NRF51 TX power offset by %ddb.\r\n", PLATFORM_NRF51_LOW_INTERFERENCE_TX_POWER_DBM); +} diff --git a/src/platform/platform.h b/src/platform/platform.h index a5bbc2d3a2..b466449449 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -55,6 +55,7 @@ typedef struct { char deviceType[PLATFORM_DEVICE_TYPE_MAX_LEN]; char deviceTypeName[14]; SensorImplementation_t sensorImplementation; + bool physicalLayoutAntennasAreClose; } platformConfig_t; /** @@ -64,14 +65,18 @@ int platformInit(void); void platformGetDeviceTypeString(char* deviceTypeString); int platformParseDeviceTypeString(const char* deviceTypeString, char* deviceType); -int platformInitConfiguration(const platformConfig_t* configs, const int nrOfConfigs); -void platformSetLowInterferenceRadioMode(void); +// Implemented in platform specific files +const platformConfig_t* platformGetListOfConfigurations(int* nrOfConfigs); +void platformInitHardware(); + +void platformSetLowInterferenceRadioMode(void); // Functions to read configuration const char* platformConfigGetPlatformName(); const char* platformConfigGetDeviceTypeName(); SensorImplementation_t platformConfigGetSensorImplementation(); +bool platformConfigPhysicalLayoutAntennasAreClose(); #endif /* PLATFORM_H_ */ diff --git a/src/platform/platform_cf2.c b/src/platform/platform_cf2.c index 1b34f73bfb..db19014207 100644 --- a/src/platform/platform_cf2.c +++ b/src/platform/platform_cf2.c @@ -7,7 +7,7 @@ * * Crazyflie control firmware * - * Copyright (C) 2011-2012 Bitcraze AB + * Copyright (C) 2011-2018 Bitcraze AB * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,51 +32,28 @@ #include "exti.h" #include "nvic.h" #include "debug.h" -#include "radiolink.h" - -// Define to decrease the nRF51 Tx power to reduce interference -#ifndef PLATFORM_NRF51_LOW_INTERFERENCE_TX_POWER_DBM -#define PLATFORM_NRF51_LOW_INTERFERENCE_TX_POWER_DBM (-12) -#endif - -static void initHardware(); static platformConfig_t configs[] = { { .deviceType = "CF20", .deviceTypeName = "Crazyflie 2.0", .sensorImplementation = SensorImplementation_mpu9250_lps25h, + .physicalLayoutAntennasAreClose = true, }, { .deviceType = "CF21", .deviceTypeName = "Crazyflie 2.1", .sensorImplementation = SensorImplementation_bmi088_bmp388, + .physicalLayoutAntennasAreClose = true, } }; - - -int platformInit(void) { - int err = platformInitConfiguration(configs, sizeof(configs) / sizeof(platformConfig_t)); - if (err != 0) - { - // This firmware is not compatible, abort init - return 1; - } - - initHardware(); - return 0; +const platformConfig_t* platformGetListOfConfigurations(int* nrOfConfigs) { + *nrOfConfigs = sizeof(configs) / sizeof(platformConfig_t); + return configs; } - -void platformSetLowInterferenceRadioMode(void) { - // Decrease the nRF51 Tx power to reduce interference - radiolinkSetPowerDbm(PLATFORM_NRF51_LOW_INTERFERENCE_TX_POWER_DBM); - DEBUG_PRINT("Low interference mode. NRF51 TX power offset by %ddb.\r\n", PLATFORM_NRF51_LOW_INTERFERENCE_TX_POWER_DBM); -} - - -static void initHardware() { +void platformInitHardware() { //Low level init: Clock and Interrupt controller nvicInit(); diff --git a/tools/make/config.mk.example b/tools/make/config.mk.example index 136a6a54e2..d251a2c587 100644 --- a/tools/make/config.mk.example +++ b/tools/make/config.mk.example @@ -1,5 +1,11 @@ ## Copy this file to config.mk and modify to get you personal build configuration +## Force device type string +# CFLAGS += -DDEVICE_TYPE_STRING_FORCE="CF20" + +## Force a sensor implementation to be used +# SENSORS=bosch + ## Set CRTP link to E-SKY receiver # CFLAGS += -DUSE_ESKYLINK @@ -63,10 +69,6 @@ ## TDaA 3 - experimental ------------------------------------------- - -## Set the positioning system in TDoA3 mode on startup -# LPS_TDOA3_ENABLE=1 - # Enable 2D positioning. The value (1.2) is the height that the tag will move at # Only use in TDoA 3 # CFLAGS += -DLPS_2D_POSITION_HEIGHT=1.2 diff --git a/tools/make/platforms/cf2.mk b/tools/make/platforms/cf2.mk index 0630450bea..7880744c1d 100644 --- a/tools/make/platforms/cf2.mk +++ b/tools/make/platforms/cf2.mk @@ -1,7 +1,7 @@ -# Make configuration for Crazyflie 2 family of platform +# Make configuration for the Crazyflie 2 platform -PLATFORM_HELP_cf2 = Crazyflie2 family, includes Crazyflie 2.0 and Crazyflie 2.1 -PLATFORM_NAME_cf2 = CF2 family +PLATFORM_HELP_cf2 = Crazyflie2 platform, includes Crazyflie 2.0 and Crazyflie 2.1 +PLATFORM_NAME_cf2 = CF2 platform CPU=stm32f4 diff --git a/tools/make/platforms/tag.mk b/tools/make/platforms/tag.mk new file mode 100644 index 0000000000..2f5cd0b7e3 --- /dev/null +++ b/tools/make/platforms/tag.mk @@ -0,0 +1,19 @@ +# Make configuration for the Tag platform + +PLATFORM_HELP_tag = Tag platform, includes Roadrunner +PLATFORM_NAME_tag = Tag platform + +CPU=stm32f4 + +######### Sensors configuration ########## +CFLAGS += -DSENSOR_INCLUDED_BMI088_BMP388 +PROJ_OBJ += sensors_bmi088_bmp388.o + +######### Stabilizer configuration ########## +ESTIMATOR ?= any +CONTROLLER ?= Any # one of Any, PID, Mellinger +POWER_DISTRIBUTION ?= stock + +######### COMPILE FLAGS ########## +CFLAGS += -DDECK_FORCE=bcDWM1000 +CFLAGS += -DSENSORS_IGNORE_BAROMETER_FAIL