ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
params.h File Reference

Drone parameters of protocol v2 (HANDOVER_FW.md §8, ids.ts PARAMS). More...

#include <stdint.h>
Include dependency graph for params.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  param_def_t
 

Macros

#define PARAM(i)   param_get(i)
 

Enumerations

enum  {
  P_TAKEOFF_ALT = 0 , P_LAND_SPEED , P_AUTO_DISARM , P_MAX_TILT ,
  P_MAX_YAW_RATE , P_MAX_CLIMB , P_MAX_HSPEED , P_BEGINNER ,
  P_FS_APP_SHORT , P_FS_APP_LONG , P_FS_RADIO , P_FS_GPS_LOST ,
  P_FS_FLOW_LOST , P_BATT_WARN , P_BATT_CRIT , P_BATT_EMERG ,
  P_GF_MAX_ALT , P_GF_CEILING , P_GF_MAX_DIST , P_GF_ACTION ,
  P_RTH_ALT , P_RTH_STICK_CANCEL , P_ARM_REQUIRE_CHECKS , P_COMPASS_PRIMARY ,
  P_BATT_CAPACITY , P_BATT_CELLS , P_LOG_MODE , PARAM_COUNT
}
 indices in the table (fast access from the flight core) More...
 
enum  { PARAM_LOG_OFF = 0 , PARAM_LOG_ARMED = 1 , PARAM_LOG_ALWAYS = 2 }
 log modes (P_LOG_MODE) More...
 

Functions

void params_defaults (void)
 RAM <- defaults (dirty until saved)
 
int params_index (uint16_t id)
 -1 if unknown
 
float param_get (int idx)
 lock-free read, any thread
 
uint8_t params_set (uint16_t id, float v, uint8_t *reason)
 PARAM_SET rules: returns an ACK result (PV2_ACK_*) and sets *reason.
 
void params_load (const float *values, uint16_t n)
 flash image
 
void params_get_all (float *values)
 PARAM_COUNT values.
 
void params_mark_saved (void)
 saved <- RAM
 
uint8_t params_dirty (int idx)
 RAM != flash.
 
uint8_t params_visible (int idx, uint16_t sensors)
 listing: parameters whose sensor is missing are omitted
 
uint16_t params_visible_count (uint16_t sensors)
 
int params_visible_pos (int idx, uint16_t sensors)
 index in PARAM_LIST, -1 if hidden
 

Variables

const param_def_t g_param_def [PARAM_COUNT]
 

Detailed Description

Drone parameters of protocol v2 (HANDOVER_FW.md §8, ids.ts PARAMS).

Ids are stable forever: add new ids, never reuse one. Values are float32 on the wire and here. RAM values are written only by the AppTask (one 32-bit store each, atomic on Cortex-M); the flight core reads them at any time with param_get() without locks.

Host-testable: no HAL, no RTOS.

Definition in file params.h.

Macro Definition Documentation

◆ PARAM

#define PARAM (   i)    param_get(i)

Definition at line 43 of file params.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

indices in the table (fast access from the flight core)

Enumerator
P_TAKEOFF_ALT 
P_LAND_SPEED 
P_AUTO_DISARM 
P_MAX_TILT 
P_MAX_YAW_RATE 
P_MAX_CLIMB 
P_MAX_HSPEED 
P_BEGINNER 
P_FS_APP_SHORT 
P_FS_APP_LONG 
P_FS_RADIO 
P_FS_GPS_LOST 
P_FS_FLOW_LOST 
P_BATT_WARN 
P_BATT_CRIT 
P_BATT_EMERG 
P_GF_MAX_ALT 
P_GF_CEILING 
P_GF_MAX_DIST 
P_GF_ACTION 
P_RTH_ALT 
P_RTH_STICK_CANCEL 
P_ARM_REQUIRE_CHECKS 
P_COMPASS_PRIMARY 
P_BATT_CAPACITY 
P_BATT_CELLS 
P_LOG_MODE 
PARAM_COUNT 

Definition at line 18 of file params.h.

◆ anonymous enum

anonymous enum

log modes (P_LOG_MODE)

Enumerator
PARAM_LOG_OFF 
PARAM_LOG_ARMED 
PARAM_LOG_ALWAYS 

Definition at line 49 of file params.h.

Function Documentation

◆ params_defaults()

void params_defaults ( void  )

RAM <- defaults (dirty until saved)

Definition at line 45 of file params.c.

References g_param_def, PARAM_COUNT, and s_val.

Referenced by app_task_boot(), local_cmd(), and params_load().

Here is the caller graph for this function:

◆ params_index()

int params_index ( uint16_t  id)

-1 if unknown

Definition at line 50 of file params.c.

References g_param_def, and PARAM_COUNT.

Referenced by cfg_params_get(), local_cmd(), and params_set().

Here is the caller graph for this function:

◆ param_get()

float param_get ( int  idx)

lock-free read, any thread

Definition at line 56 of file params.c.

References PARAM_COUNT, and s_val.

Referenced by send_param().

Here is the caller graph for this function:

◆ params_set()

uint8_t params_set ( uint16_t  id,
float  v,
uint8_t *  reason 
)

PARAM_SET rules: returns an ACK result (PV2_ACK_*) and sets *reason.

Definition at line 68 of file params.c.

References in_range(), P_BATT_CRIT, P_BATT_EMERG, P_BATT_WARN, params_index(), PV2_ACK_INVALID, PV2_ACK_OK, PV2_R_NONE, PV2_R_OUT_OF_RANGE, PV2_R_UNKNOWN_PARAM, and s_val.

Referenced by local_cmd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ params_load()

void params_load ( const float *  values,
uint16_t  n 
)

flash image

out-of-range values -> default

Definition at line 84 of file params.c.

References param_def_t::def, g_param_def, in_range(), n, P_BATT_CRIT, P_BATT_EMERG, P_BATT_WARN, PARAM_COUNT, params_defaults(), and s_val.

Referenced by app_task_boot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ params_get_all()

void params_get_all ( float *  values)

PARAM_COUNT values.

Definition at line 96 of file params.c.

References PARAM_COUNT, and s_val.

Referenced by save_image().

Here is the caller graph for this function:

◆ params_mark_saved()

void params_mark_saved ( void  )

saved <- RAM

Definition at line 101 of file params.c.

References PARAM_COUNT, s_saved, and s_val.

Referenced by app_task_boot(), and local_cmd().

Here is the caller graph for this function:

◆ params_dirty()

uint8_t params_dirty ( int  idx)

RAM != flash.

Definition at line 106 of file params.c.

References PARAM_COUNT, s_saved, and s_val.

Referenced by send_param().

Here is the caller graph for this function:

◆ params_visible()

uint8_t params_visible ( int  idx,
uint16_t  sensors 
)

listing: parameters whose sensor is missing are omitted

Definition at line 112 of file params.c.

References g_param_def, param_def_t::needs, and PARAM_COUNT.

Referenced by list_pace(), local_cmd(), params_visible_count(), and params_visible_pos().

Here is the caller graph for this function:

◆ params_visible_count()

uint16_t params_visible_count ( uint16_t  sensors)

Definition at line 119 of file params.c.

References n, PARAM_COUNT, and params_visible().

Referenced by send_param().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ params_visible_pos()

int params_visible_pos ( int  idx,
uint16_t  sensors 
)

index in PARAM_LIST, -1 if hidden

Definition at line 126 of file params.c.

References params_visible(), and pos.

Referenced by send_param().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_param_def