Files
celrs/celrs/crsf_param.h
T
portersky df3d399610 feat: adopt ELRS USB CRSF frame format, add skeleton modules
Switch CRC from CCITT (0x07) to DVB-S2 (0xD5) to match ELRS.
Adopt ELRS USB frame format: [addr][length][type][payload][crc].
Update frame type constants to match current ELRS protocol values.

New skeleton modules (stub implementations with TODO comments):
  - crsf_telemetry.h/.c: telemetry decoders (GPS, battery, link..)
  - crsf_stream.h/.c: incremental streaming frame reader
  - crsf_param.h/.c: parameter protocol (read/write/set_power)

Retained old frame format as *_legacy functions for backward
compatibility with existing telemetry tool and tests.

Add cel_serial_find_elrs_port() and cel_serial_open_probe()
stubs to serial module for port auto-detection and baud probing.
2026-06-14 20:47:56 +02:00

55 lines
1.8 KiB
C

#pragma once
#include <stdint.h>
#include <stddef.h>
#include "celrs/crsf.h"
#include "celrs/serial.h"
/* TX power levels (mW) */
#define CEL_POWER_10_MW 10
#define CEL_POWER_25_MW 25
#define CEL_POWER_50_MW 50
#define CEL_POWER_100_MW 100
#define CEL_POWER_250_MW 250
#define CEL_POWER_500_MW 500
#define CEL_POWER_1000_MW 1000
#define CEL_POWER_2000_MW 2000
/* Parsed parameter entry */
typedef struct {
uint8_t index;
uint8_t type; /* CEL_PARAM_* */
uint8_t hidden;
char name[64];
/* TEXT_SELECT specific */
char options[256]; /* semicolon-separated option strings */
uint8_t value;
uint8_t min_val;
uint8_t max_val;
uint8_t default_val;
} cel_crsf_param;
/* Send a device ping and wait for DEVICE_INFO response.
* Returns 0 on success, -1 on timeout/error. */
int cel_crsf_param_ping(cel_serial_port* port, float timeout_sec);
/* Read a single parameter by index.
* Returns 0 on success (out filled), -1 on timeout/error. */
int cel_crsf_param_read(cel_serial_port* port, uint8_t index,
cel_crsf_param* out, float timeout_sec);
/* Write a parameter value.
* Returns 0 on success, -1 on error. */
int cel_crsf_param_write(cel_serial_port* port, uint8_t index,
uint8_t value);
/* Set TX output power by enumerating parameters.
* mw: transmit power in mW (one of CEL_POWER_* constants).
* Returns 0 on success, -1 on error. */
int cel_crsf_param_set_power(cel_serial_port* port, int mw,
float timeout_sec);
/* Parse a PARAM_ENTRY payload into a cel_crsf_param struct.
* Returns 0 on success, -1 on bad payload. */
int cel_crsf_param_parse(cel_crsf_param* out, uint8_t const* payload,
size_t len);