diff --git a/Makefile b/Makefile index a6ac9cd7eb..07e7a7d90e 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/src/platform/platform.c b/src/platform/platform.c index d8008ec398..85d57da839 100644 --- a/src/platform/platform.c +++ b/src/platform/platform.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 @@ -25,20 +25,10 @@ * */ -#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; @@ -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]; @@ -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); -} diff --git a/src/platform/platform.h b/src/platform/platform.h index b466449449..993266a35e 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -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); diff --git a/src/platform/platform_tag.c b/src/platform/platform_tag.c new file mode 100644 index 0000000000..c1be50c644 --- /dev/null +++ b/src/platform/platform_tag.c @@ -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 . + * + * Platform functionality for the TAG platform + */ + +#define DEBUG_MODULE "PLATFORM" + +#include + +#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"; +} + diff --git a/src/platform/platform_utils.c b/src/platform/platform_utils.c new file mode 100644 index 0000000000..3f136b00ea --- /dev/null +++ b/src/platform/platform_utils.c @@ -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 . + * + * 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); +} + diff --git a/test/platform/Test_platform.c b/test/platform/Test_platform.c index 2720a13102..a0cccc4de7 100644 --- a/test/platform/Test_platform.c +++ b/test/platform/Test_platform.c @@ -132,6 +132,15 @@ void testThatItIsNotSearchingOutsideListOfPlatformConfigs() { } + +// Dummy implementations ------------------- + +const platformConfig_t* platformGetListOfConfigurations(int* nrOfConfigs){ + return 0; +} + +void platformInitHardware(){} + // Fixtures -------------------------