Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Crossfire (CRSF) Protocol Definitions and Helpers. More...

#include <zephyr/types.h>

Go to the source code of this file.

Data Structures

struct  crsf_payload_gps
 GPS telemetry payload (Type 0x02). More...
struct  crsf_payload_battery
 Battery telemetry payload (Type 0x08). More...
 Link statistics payload (Type 0x14). More...
struct  crsf_payload_attitude
 Attitude telemetry payload (Type 0x1E). More...

Macros

RC Channel Conversion Helpers

Conversion between CRSF ticks and microseconds.

#define CRSF_TICKS_TO_US(x)
 Convert CRSF channel ticks to microseconds.
#define CRSF_US_TO_TICKS(x)
 Convert microseconds to CRSF channel ticks.

Enumerations

enum  crsf_packet_type {
  CRSF_TYPE_GPS = 0x02 , CRSF_TYPE_BATTERY = 0x08 , CRSF_TYPE_LINK_TX_ID = 0x0A , CRSF_TYPE_LINK_STATS = 0x14 ,
  CRSF_TYPE_RC_CHANNELS = 0x16 , CRSF_TYPE_ATTITUDE = 0x1E , CRSF_TYPE_FLIGHT_MODE = 0x21 , CRSF_TYPE_PING_DEVICES = 0x28 ,
  CRSF_TYPE_DEVICE_INFO = 0x29 , CRSF_TYPE_PARAMETER_SETTINGS = 0x2B , CRSF_TYPE_COMMAND = 0x32 , CRSF_TYPE_RADIO_ID = 0x3A ,
  CRSF_TYPE_AP_CUSTOM_TELEM = 0x80
}
 CRSF packet (frame) types. More...

Functions

int input_crsf_send_telemetry (const struct device *dev, uint8_t type, uint8_t *payload, size_t payload_len)
 Send a generic CRSF telemetry frame.
struct crsf_link_stats input_crsf_get_link_stats (const struct device *dev)
 Retrieve the latest CRSF link statistics.

Detailed Description

Crossfire (CRSF) Protocol Definitions and Helpers.

This module provides constants, packet type definitions, telemetry payload structures, and helper APIs for working with the CRSF (Crossfire) protocol used by RC transmitters and receivers.

It covers frame layout, telemetry payload formats, RC channel conversions, and link statistics access.

Macro Definition Documentation

◆ CRSF_TICKS_TO_US

#define CRSF_TICKS_TO_US ( x)
Value:
(((x) - 992) * 5 / 8 + 1500)

Convert CRSF channel ticks to microseconds.

Parameters
xCRSF channel value in ticks
Returns
Pulse width in microseconds

◆ CRSF_US_TO_TICKS

#define CRSF_US_TO_TICKS ( x)
Value:
(((x) - 1500) * 8 / 5 + 992)

Convert microseconds to CRSF channel ticks.

Parameters
xPulse width in microseconds
Returns
CRSF channel value in ticks

Enumeration Type Documentation

◆ crsf_packet_type

CRSF packet (frame) types.

Enumerator
CRSF_TYPE_GPS 

GPS telemetry data.

CRSF_TYPE_BATTERY 

Battery telemetry data.

CRSF_TYPE_LINK_TX_ID 

Transmitter link identifier.

CRSF_TYPE_LINK_STATS 

Link statistics.

CRSF_TYPE_RC_CHANNELS 

RC channel data.

CRSF_TYPE_ATTITUDE 

Attitude telemetry.

CRSF_TYPE_FLIGHT_MODE 

Flight mode string.

CRSF_TYPE_PING_DEVICES 

Device discovery / ping.

CRSF_TYPE_DEVICE_INFO 

Device information.

CRSF_TYPE_PARAMETER_SETTINGS 

Parameter read/write.

CRSF_TYPE_COMMAND 

Command frame.

CRSF_TYPE_RADIO_ID 

Radio identifier.

CRSF_TYPE_AP_CUSTOM_TELEM 

ArduPilot custom telemetry.

Function Documentation

◆ input_crsf_get_link_stats()

struct crsf_link_stats input_crsf_get_link_stats ( const struct device * dev)

Retrieve the latest CRSF link statistics.

Parameters
devPointer to the CRSF input device
Returns
Current link statistics structure

◆ input_crsf_send_telemetry()

int input_crsf_send_telemetry ( const struct device * dev,
uint8_t type,
uint8_t * payload,
size_t payload_len )

Send a generic CRSF telemetry frame.

Parameters
devPointer to the CRSF input device
typePacket type (see crsf_packet_type)
payloadPointer to payload buffer
payload_lenPayload length in bytes
Returns
0 on success, negative errno on failure