Skip to content

Commit

Permalink
#379 Added support for the Tag platform and the Roadrunner device. Re…
Browse files Browse the repository at this point in the history
…factoring of platform startup code.
  • Loading branch information
krichardsson committed Nov 23, 2018
1 parent 5cec953 commit 3d23111
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
4 changes: 3 additions & 1 deletion src/hal/src/sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/modules/src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void systemTask(void *arg)
deckInit();
estimator = deckGetRequiredEstimator();
stabilizerInit(estimator);
if (deckGetRequiredLowInterferenceRadioMode())
if (deckGetRequiredLowInterferenceRadioMode() && platformConfigPhysicalLayoutAntennasAreClose())
{
platformSetLowInterferenceRadioMode();
}
Expand Down
43 changes: 42 additions & 1 deletion src/platform/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,35 @@
*
*/

#define DEBUG_MODULE "PLATFORM"

#include <string.h>
#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] != ';') {
Expand All @@ -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];
Expand All @@ -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);
}
9 changes: 7 additions & 2 deletions src/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ typedef struct {
char deviceType[PLATFORM_DEVICE_TYPE_MAX_LEN];
char deviceTypeName[14];
SensorImplementation_t sensorImplementation;
bool physicalLayoutAntennasAreClose;
} platformConfig_t;

/**
Expand All @@ -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_ */
37 changes: 7 additions & 30 deletions src/platform/platform_cf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();

Expand Down
10 changes: 6 additions & 4 deletions tools/make/config.mk.example
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tools/make/platforms/cf2.mk
Original file line number Diff line number Diff line change
@@ -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

Expand Down
19 changes: 19 additions & 0 deletions tools/make/platforms/tag.mk
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3d23111

Please sign in to comment.