Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
knmcguire committed Nov 18, 2020
2 parents 0d1e1ab + 1f405b1 commit f4e7b3e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/app_api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 41 additions & 0 deletions examples/app_api/src/app_loco.c
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*
* 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);
}
30 changes: 30 additions & 0 deletions examples/app_api/src/app_loco.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*
* app_loco.h - LPS example calls
*/

#pragma once

void appLocoExampleCalls();
2 changes: 2 additions & 0 deletions examples/app_api/src/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -52,6 +53,7 @@ void appMain() {
appEnableHighLevelCommander();
appInitLighthouse();
appRegisterMemory();
appLocoExampleCalls();

while(1) {
vTaskDelay(M2T(3000));
Expand Down
4 changes: 4 additions & 0 deletions src/deck/drivers/interface/locodeck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions src/deck/drivers/src/locodeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit f4e7b3e

Please sign in to comment.