-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1311 from bitcraze/krichardsson/stm-gap8-cpx
Example app for CPX communication with the GAP8
- Loading branch information
Showing
8 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin/* | ||
cf2.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
obj-y += src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# The firmware uses the Kbuild build system. There are 'Kbuild' files in this | ||
# example that outlays what needs to be built. (check src/Kbuild). | ||
# | ||
# The firmware is configured using options in Kconfig files, the | ||
# values of these end up in the .config file in the firmware directory. | ||
# | ||
# By setting the OOT_CONFIG (it is '$(PWD)/oot-config' by default) environment | ||
# variable you can provide a custom configuration. It is important that you | ||
# enable the app-layer. See app-config in this directory for example. | ||
|
||
# | ||
# We want to execute the main Makefile for the firmware project, | ||
# it will handle the build for us. | ||
# | ||
CRAZYFLIE_BASE := ../.. | ||
|
||
# | ||
# We override the default OOT_CONFIG here, we could also name our config | ||
# to oot-config and that would be the default. | ||
# | ||
OOT_CONFIG := $(PWD)/app-config | ||
|
||
include $(CRAZYFLIE_BASE)/tools/make/oot.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# STM-GAP8 CPX communication example | ||
|
||
This folder contains the app layer application for an example app that communicates with the GAP8 on the AI-deck. | ||
The intention is to show how CPX can be used to feed data from the STM to the GAP8 or the other way around. | ||
One possible use case for this type of communication could be to control the Crzyflie from a neural network for instance. | ||
|
||
This application is intended to be used with an AI-deck, together with the "stm_gap8_cpx" example in the | ||
[aideck-gap8-examples](https://github.com/bitcraze/aideck-gap8-examples) repository. | ||
|
||
CPX packets are sent from the STM (this app) to the GAP8, containing a counter that is increased for each packet. The | ||
same number is sent back to the STM in a new CPX packet and the number is printed on the console, that is when a | ||
number is printed on the console, the counter value has done a round trip STM-GAP8-STM. | ||
|
||
|
||
See the [CPX documentation](https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/functional-areas/cpx/). | ||
|
||
See App layer API guide and build instructions [here](https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/userguides/app_layer/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_APP_ENABLE=y | ||
CONFIG_APP_PRIORITY=1 | ||
CONFIG_APP_STACKSIZE=350 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
obj-y += stm_gap8_cpx.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* ,---------, ____ _ __ | ||
* | ,-^-, | / __ )(_) /_______________ _____ ___ | ||
* | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \ | ||
* | / ,--´ | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ | ||
* +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/ | ||
* | ||
* Crazyflie control firmware | ||
* | ||
* Copyright (C) 2023 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 layer application that communicates with the GAP8 on an AI deck. | ||
*/ | ||
|
||
|
||
#include <string.h> | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
#include "app.h" | ||
|
||
#include "cpx.h" | ||
#include "cpx_internal_router.h" | ||
|
||
#include "FreeRTOS.h" | ||
#include "task.h" | ||
|
||
#define DEBUG_MODULE "APP" | ||
#include "debug.h" | ||
|
||
// Callback that is called when a CPX packet arrives | ||
static void cpxPacketCallback(const CPXPacket_t* cpxRx); | ||
|
||
static CPXPacket_t txPacket; | ||
|
||
void appMain() { | ||
DEBUG_PRINT("Hello! I am the stm_gap8_cpx app\n"); | ||
|
||
// Register a callback for CPX packets. | ||
// Packets sent to destination=CPX_T_STM32 and function=CPX_F_APP will arrive here | ||
cpxRegisterAppMessageHandler(cpxPacketCallback); | ||
|
||
uint8_t counter = 0; | ||
while(1) { | ||
vTaskDelay(M2T(2000)); | ||
|
||
cpxInitRoute(CPX_T_STM32, CPX_T_GAP8, CPX_F_APP, &txPacket.route); | ||
txPacket.data[0] = counter; | ||
txPacket.dataLength = 1; | ||
|
||
cpxSendPacketBlocking(&txPacket); | ||
DEBUG_PRINT("Sent packet to GAP8 (%u)\n", counter); | ||
counter++; | ||
} | ||
} | ||
|
||
static void cpxPacketCallback(const CPXPacket_t* cpxRx) { | ||
DEBUG_PRINT("Got packet from GAP8 (%u)\n", cpxRx->data[0]); | ||
} |