Skip to content

Commit

Permalink
#379 Added missing file and updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krichardsson committed Nov 23, 2018
1 parent 3d23111 commit 59b6b85
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ VPATH += src/init src/hal/src src/modules/src src/utils/src src/drivers/bosch/sr

# Init
PROJ_OBJ += main.o
PROJ_OBJ += platform.o platform_$(PLATFORM).o platform_$(CPU).o
PROJ_OBJ += platform.o platform_utils.o platform_$(PLATFORM).o platform_$(CPU).o

# Drivers
PROJ_OBJ += exti.o nvic.o motors.o
Expand Down
21 changes: 2 additions & 19 deletions src/platform/platform.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 @@ -25,20 +25,10 @@
*
*/

#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;
Expand Down Expand Up @@ -79,7 +69,7 @@ int platformParseDeviceTypeString(const char* deviceTypeString, char* deviceType
return 0;
}

static int platformInitConfiguration(const platformConfig_t* configs, const int nrOfConfigs) {
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];
Expand Down Expand Up @@ -115,10 +105,3 @@ SensorImplementation_t platformConfigGetSensorImplementation() {
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);
}
1 change: 1 addition & 0 deletions src/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int platformInit(void);

void platformGetDeviceTypeString(char* deviceTypeString);
int platformParseDeviceTypeString(const char* deviceTypeString, char* deviceType);
int platformInitConfiguration(const platformConfig_t* configs, const int nrOfConfigs);

// Implemented in platform specific files
const platformConfig_t* platformGetListOfConfigurations(int* nrOfConfigs);
Expand Down
64 changes: 64 additions & 0 deletions src/platform/platform_tag.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
*
* Crazyflie control firmware
*
* Copyright (C) 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
* the Free Software Foundation, in version 3.
*
* This program is distributed in the hope that it 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 program. If not, see <http://www.gnu.org/licenses/>.
*
* Platform functionality for the TAG platform
*/

#define DEBUG_MODULE "PLATFORM"

#include <string.h>

#include "platform.h"
#include "exti.h"
#include "nvic.h"
#include "debug.h"

static platformConfig_t configs[] = {
{
.deviceType = "RR10",
.deviceTypeName = "Roadrunner 1.0",
.sensorImplementation = SensorImplementation_bmi088_bmp388,
.physicalLayoutAntennasAreClose = false,
},
};

const platformConfig_t* platformGetListOfConfigurations(int* nrOfConfigs) {
*nrOfConfigs = sizeof(configs) / sizeof(platformConfig_t);
return configs;
}

void platformInitHardware() {
//Low level init: Clock and Interrupt controller
nvicInit();

//EXTI interrupts
extiInit();
}


// Config functions ------------------------

const char* platformConfigGetPlatformName() {
return "tag";
}

45 changes: 45 additions & 0 deletions src/platform/platform_utils.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
*
* Crazyflie control firmware
*
* Copyright (C) 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
* the Free Software Foundation, in version 3.
*
* This program is distributed in the hope that it 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 program. If not, see <http://www.gnu.org/licenses/>.
*
* Platform utilities
*
*/

#define DEBUG_MODULE "PLATFORM"

#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


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: 9 additions & 0 deletions test/platform/Test_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ void testThatItIsNotSearchingOutsideListOfPlatformConfigs() {
}



// Dummy implementations -------------------

const platformConfig_t* platformGetListOfConfigurations(int* nrOfConfigs){
return 0;
}

void platformInitHardware(){}

// Fixtures -------------------------


Expand Down

0 comments on commit 59b6b85

Please sign in to comment.