This page has deprecated and moved to the new documentation framework of the main Bitcraze website. Please go to https://www.bitcraze.io/documentation/system/
The Deck API allows to easily communicates with decks installed on the Crazyflie. The deck API is still in development, it will:
If you want to get started you can follow the howto to get your code running.
Decks are enumerated automatically using a One Wire (OW) memory soldered on the deck PCB. The Deck driver API is using a declarative syntax to register deck drivers and initialize them when the proper deck is installed.
This is a minimal deck driver, myled.c:
#include "deck.h" void myledInit(DeckInfo *info) { pinMode(DECK_GPIO_IO1, OUTPUT); // Set my Led pin to output digitalWrite(DECK_GPIO_IO1, HIGH); // Light it up } bool myledTest() { return true; } const DeckDriver myled_driver = { .vid = 0, .pid = 0, .name = "meMyled", .usedGpio = DECK_USING_IO_1, .init = myledInit, .test = myledTest, }; DECK_DRIVER(myled_driver);
To compile the driver, place it in deck/drivers/src/ and add it to the Makefile:
PROJ_OBJ += myled.o
The deck driver will be initialized only if a deck is connected with the right OW memory content. During development it is possible to force the initialisation of a deck by adding a define in ```tools/make/config.mk```:
CFLAGS += -DDECK_FORCE=meMyled
DECK_DRIVER(const struct DeckDriver)
To register a deck driver the DECK_DRIVER() macro should be called with a deck structure as argument.
typedef struct deck_driver { /* Identification of the deck (written in the board) */ uint8_t vid; uint8_t pid; char *name; /* Periphreal and Gpio used _dirrectly_ by the driver */ uint32_t usedPeriph; uint32_t usedGpio; /* Init and test functions */ void (*init)(struct deckInfo_s *); bool (*test)(void); } DeckDriver;