Add Winbond 25Q128 flash driver
[betaflight.git] / src / main / target / CRAZYFLIE2 / crtp.h
blobb52c1a0e6b46ce8c65b4c3b9fa59bf11f5ae4f3c
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
24 * This file contains definitions for the CRTP protocol, the data transport
25 * protocol used for OTA communication to the crazyflie (via either Nordic ESB or
26 * Bluetooth LE) and transmitted from the NRF51 to the STM32 via the syslink protocol
28 * For more details, see https://wiki.bitcraze.io/projects:crazyflie:crtp
31 #define CRTP_MAX_DATA_SIZE 30
33 typedef enum {
34 CRTP_PORT_CONSOLE = 0x00,
35 CRTP_PORT_PARAM = 0x02,
36 CRTP_PORT_SETPOINT = 0x03,
37 CRTP_PORT_MEM = 0x04,
38 CRTP_PORT_LOG = 0x05,
39 CRTP_PORT_LOCALIZATION = 0x06,
40 CRTP_PORT_SETPOINT_GENERIC = 0x07,
41 CRTP_PORT_PLATFORM = 0x0D,
42 CRTP_PORT_LINK = 0x0F,
43 } crtpPort_e;
45 typedef struct crtpPacket_s
47 struct{
48 uint8_t chan : 2;
49 uint8_t link : 2;
50 uint8_t port : 4;
51 } header;
52 uint8_t data[CRTP_MAX_DATA_SIZE];
53 } __attribute__((packed)) crtpPacket_t;
55 typedef enum {
56 stopType = 0,
57 velocityWorldType = 1,
58 zDistanceType = 2,
59 cppmEmuType = 3,
60 } crtpCommanderPacketType_e;
62 // Legacy RPYT data type for supporting existing clients
63 // See https://wiki.bitcraze.io/projects:crazyflie:crtp:commander
64 typedef struct crtpCommanderRPYT_s
66 float roll; // deg
67 float pitch; // deg
68 float yaw; // deg
69 uint16_t thrust;
70 } __attribute__((packed)) crtpCommanderRPYT_t;
72 // Commander packet type for emulating CPPM-style setpoints
73 // Corresponds to crtpCommanderPacketType_e::cppmEmuType
74 #define CRTP_CPPM_EMU_MAX_AUX_CHANNELS 10
75 typedef struct crtpCommanderCPPMEmuPacket_s
77 struct {
78 uint8_t numAuxChannels : 4; // Set to 0 through CRTP_CPPM_EMU_MAX_AUX_CHANNELS
79 uint8_t reserved : 4;
80 } hdr;
81 uint16_t channelRoll;
82 uint16_t channelPitch;
83 uint16_t channelYaw;
84 uint16_t channelThrust;
85 uint16_t channelAux[CRTP_CPPM_EMU_MAX_AUX_CHANNELS];
86 } __attribute__((packed)) crtpCommanderCPPMEmuPacket_t;
88 //typedef struct crtpCommander_s
89 //{
90 // struct{
91 // uint8_t chan : 2;
92 // uint8_t link : 2;
93 // uint8_t port : 4;
94 // }hdr;
95 // uint8_t type;
96 // uint8_t numChannels;
97 // uint16_t channels[14];
99 //} __attribute__((packed)) crtpCommander_t;