From 1f405b1fe373930a9ecee9b1e6aa3f688e2951e8 Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Wed, 18 Nov 2020 10:06:23 +0100 Subject: [PATCH] #636 Re-added loco functions to public API. --- examples/app_api/Makefile | 2 +- examples/app_api/src/app_loco.c | 41 +++++++++++++++++++++++++++ examples/app_api/src/app_loco.h | 30 ++++++++++++++++++++ examples/app_api/src/app_main.c | 2 ++ src/deck/drivers/interface/locodeck.h | 4 +++ src/deck/drivers/src/locodeck.c | 9 ++---- 6 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 examples/app_api/src/app_loco.c create mode 100644 examples/app_api/src/app_loco.h diff --git a/examples/app_api/Makefile b/examples/app_api/Makefile index 07032a80e1..66fc23208e 100644 --- a/examples/app_api/Makefile +++ b/examples/app_api/Makefile @@ -4,7 +4,7 @@ APP=1 APP_STACKSIZE=300 VPATH += src/ -PROJ_OBJ += app_main.o app_ledseq.o app_high_level_commander.o app_lighthouse.o app_memory_mapping.o +PROJ_OBJ += app_main.o app_ledseq.o app_high_level_commander.o app_lighthouse.o app_memory_mapping.o app_loco.o CRAZYFLIE_BASE=../.. include $(CRAZYFLIE_BASE)/Makefile diff --git a/examples/app_api/src/app_loco.c b/examples/app_api/src/app_loco.c new file mode 100644 index 0000000000..2c721f1869 --- /dev/null +++ b/examples/app_api/src/app_loco.c @@ -0,0 +1,41 @@ +/** + * ,---------, ____ _ __ + * | ,-^-, | / __ )(_) /_______________ _____ ___ + * | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \ + * | / ,--´ | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ + * +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/ + * + * Crazyflie control firmware + * + * Copyright (C) 2020 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 . + * + * + * app_loco.c - LPS example calls + * + * This code is mainly intended to make sure code is compiled in CI + */ + + +#include "locodeck.h" +#include "app_loco.h" + +void appLocoExampleCalls() { + point_t position; + locoDeckGetAnchorPosition(0, &position); + + uint8_t unorderedAnchorList[5]; + locoDeckGetAnchorIdList(unorderedAnchorList, 5); + locoDeckGetActiveAnchorIdList(unorderedAnchorList, 5); +} diff --git a/examples/app_api/src/app_loco.h b/examples/app_api/src/app_loco.h new file mode 100644 index 0000000000..858594dd87 --- /dev/null +++ b/examples/app_api/src/app_loco.h @@ -0,0 +1,30 @@ +/** + * ,---------, ____ _ __ + * | ,-^-, | / __ )(_) /_______________ _____ ___ + * | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \ + * | / ,--´ | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ + * +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/ + * + * Crazyflie control firmware + * + * Copyright (C) 2020 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 . + * + * + * app_loco.h - LPS example calls + */ + +#pragma once + +void appLocoExampleCalls(); diff --git a/examples/app_api/src/app_main.c b/examples/app_api/src/app_main.c index da0be4fe60..d460dce33c 100644 --- a/examples/app_api/src/app_main.c +++ b/examples/app_api/src/app_main.c @@ -44,6 +44,7 @@ #include "app_high_level_commander.h" #include "app_lighthouse.h" #include "app_memory_mapping.h" +#include "app_loco.h" #define DEBUG_MODULE "APPAPI" @@ -52,6 +53,7 @@ void appMain() { appEnableHighLevelCommander(); appInitLighthouse(); appRegisterMemory(); + appLocoExampleCalls(); while(1) { vTaskDelay(M2T(3000)); diff --git a/src/deck/drivers/interface/locodeck.h b/src/deck/drivers/interface/locodeck.h index fc8dc40d4e..2de85e77a4 100644 --- a/src/deck/drivers/interface/locodeck.h +++ b/src/deck/drivers/interface/locodeck.h @@ -81,6 +81,10 @@ typedef struct { uint32_t nextSwitchTick; } lpsAlgoOptions_t; +bool locoDeckGetAnchorPosition(const uint8_t anchorId, point_t* position); +uint8_t locoDeckGetAnchorIdList(uint8_t unorderedAnchorList[], const int maxListSize); +uint8_t locoDeckGetActiveAnchorIdList(uint8_t unorderedAnchorList[], const int maxListSize); + // Callbacks for uwb algorithms typedef struct uwbAlgorithm_s { void (*init)(dwDevice_t *dev); diff --git a/src/deck/drivers/src/locodeck.c b/src/deck/drivers/src/locodeck.c index e5558c2965..996b6a3d35 100644 --- a/src/deck/drivers/src/locodeck.c +++ b/src/deck/drivers/src/locodeck.c @@ -159,9 +159,6 @@ static const MemoryHandlerDef_t memDef = { .write = 0, // Write is not supported }; static void buildAnchorMemList(const uint32_t memAddr, const uint8_t readLen, uint8_t* dest, const uint32_t pageBase_address, const uint8_t anchorCount, const uint8_t unsortedAnchorList[]); -static bool locoDeckGetAnchorPosition(const uint8_t anchorId, point_t* position); -static uint8_t locoDeckGetAnchorIdList(uint8_t unorderedAnchorList[], const int maxListSize); -static uint8_t locoDeckGetActiveAnchorIdList(uint8_t unorderedAnchorList[], const int maxListSize); static void txCallback(dwDevice_t *dev) { @@ -237,7 +234,7 @@ static void buildAnchorMemList(const uint32_t memAddr, const uint8_t readLen, ui // This function is called from the memory sub system that runs in a different // task, protect it from concurrent calls from this task -static bool locoDeckGetAnchorPosition(const uint8_t anchorId, point_t* position) +bool locoDeckGetAnchorPosition(const uint8_t anchorId, point_t* position) { if (!isInit) { return false; @@ -251,7 +248,7 @@ static bool locoDeckGetAnchorPosition(const uint8_t anchorId, point_t* position) // This function is called from the memory sub system that runs in a different // task, protect it from concurrent calls from this task -static uint8_t locoDeckGetAnchorIdList(uint8_t unorderedAnchorList[], const int maxListSize) { +uint8_t locoDeckGetAnchorIdList(uint8_t unorderedAnchorList[], const int maxListSize) { if (!isInit) { return 0; } @@ -264,7 +261,7 @@ static uint8_t locoDeckGetAnchorIdList(uint8_t unorderedAnchorList[], const int // This function is called from the memory sub system that runs in a different // task, protect it from concurrent calls from this task -static uint8_t locoDeckGetActiveAnchorIdList(uint8_t unorderedAnchorList[], const int maxListSize) { +uint8_t locoDeckGetActiveAnchorIdList(uint8_t unorderedAnchorList[], const int maxListSize) { if (!isInit) { return 0; }