mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Removed support for profile handling in parameter groups.
This commit is contained in:
parent
2e4184dc6d
commit
774cae215c
6 changed files with 35 additions and 169 deletions
|
@ -34,14 +34,9 @@ typedef enum {
|
|||
PGR_PGN_MASK = 0x0fff,
|
||||
PGR_PGN_VERSION_MASK = 0xf000,
|
||||
PGR_SIZE_MASK = 0x0fff,
|
||||
PGR_SIZE_SYSTEM_FLAG = 0x0000, // documentary
|
||||
PGR_SIZE_PROFILE_FLAG = 0x8000 // start using flags from the top bit down
|
||||
PGR_SIZE_SYSTEM_FLAG = 0x0000 // documentary
|
||||
} pgRegistryInternal_e;
|
||||
|
||||
enum {
|
||||
PG_PROFILE_COUNT = 3
|
||||
};
|
||||
|
||||
// function that resets a single parameter group instance
|
||||
typedef void (pgResetFunc)(void * /* base */, int /* size */);
|
||||
|
||||
|
@ -60,8 +55,6 @@ typedef struct pgRegistry_s {
|
|||
static inline uint16_t pgN(const pgRegistry_t* reg) {return reg->pgn & PGR_PGN_MASK;}
|
||||
static inline uint8_t pgVersion(const pgRegistry_t* reg) {return (uint8_t)(reg->pgn >> 12);}
|
||||
static inline uint16_t pgSize(const pgRegistry_t* reg) {return reg->size & PGR_SIZE_MASK;}
|
||||
static inline uint16_t pgIsSystem(const pgRegistry_t* reg) {return (reg->size & PGR_SIZE_PROFILE_FLAG) == 0;}
|
||||
static inline uint16_t pgIsProfile(const pgRegistry_t* reg) {return (reg->size & PGR_SIZE_PROFILE_FLAG) == PGR_SIZE_PROFILE_FLAG;}
|
||||
|
||||
#define PG_PACKED __attribute__((packed))
|
||||
|
||||
|
@ -89,19 +82,11 @@ extern const uint8_t __pg_resetdata_end[];
|
|||
#define PG_FOREACH(_name) \
|
||||
for (const pgRegistry_t *(_name) = __pg_registry_start; (_name) < __pg_registry_end; _name++)
|
||||
|
||||
#define PG_FOREACH_PROFILE(_name) \
|
||||
PG_FOREACH(_name) \
|
||||
if(pgIsSystem(_name)) \
|
||||
continue; \
|
||||
else \
|
||||
/**/
|
||||
|
||||
// Reset configuration to default (by name)
|
||||
// Only current profile is reset for profile based configs
|
||||
#define PG_RESET_CURRENT(_name) \
|
||||
#define PG_RESET(_name) \
|
||||
do { \
|
||||
extern const pgRegistry_t _name ##_Registry; \
|
||||
pgResetCurrent(&_name ## _Registry); \
|
||||
pgReset(&_name ## _Registry); \
|
||||
} while(0) \
|
||||
/**/
|
||||
|
||||
|
@ -124,15 +109,6 @@ extern const uint8_t __pg_resetdata_end[];
|
|||
struct _dummy \
|
||||
/**/
|
||||
|
||||
// Declare profile config
|
||||
#define PG_DECLARE_PROFILE(_type, _name) \
|
||||
extern _type *_name ## _ProfileCurrent; \
|
||||
static inline const _type* _name(void) { return _name ## _ProfileCurrent; } \
|
||||
static inline _type* _name ## Mutable(void) { return _name ## _ProfileCurrent; } \
|
||||
struct _dummy \
|
||||
/**/
|
||||
|
||||
|
||||
// Register system config
|
||||
#define PG_REGISTER_I(_type, _name, _pgn, _version, _reset) \
|
||||
_type _name ## _System; \
|
||||
|
@ -195,43 +171,6 @@ extern const uint8_t __pg_resetdata_end[];
|
|||
/**/
|
||||
#endif
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
# define _PG_PROFILE_CURRENT_DECL(_type, _name) \
|
||||
_type *_name ## _ProfileCurrent = &_name ## _Storage[0];
|
||||
#else
|
||||
# define _PG_PROFILE_CURRENT_DECL(_type, _name) \
|
||||
_type *_name ## _ProfileCurrent;
|
||||
#endif
|
||||
|
||||
// register profile config
|
||||
#define PG_REGISTER_PROFILE_I(_type, _name, _pgn, _version, _reset) \
|
||||
STATIC_UNIT_TESTED _type _name ## _Storage[PG_PROFILE_COUNT]; \
|
||||
_PG_PROFILE_CURRENT_DECL(_type, _name) \
|
||||
extern const pgRegistry_t _name ## _Registry; \
|
||||
const pgRegistry_t _name ## _Registry PG_REGISTER_ATTRIBUTES = { \
|
||||
.pgn = _pgn | (_version << 12), \
|
||||
.size = sizeof(_type) | PGR_SIZE_PROFILE_FLAG, \
|
||||
.address = (uint8_t*)&_name ## _Storage, \
|
||||
.ptr = (uint8_t **)&_name ## _ProfileCurrent, \
|
||||
_reset, \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#define PG_REGISTER_PROFILE(_type, _name, _pgn, _version) \
|
||||
PG_REGISTER_PROFILE_I(_type, _name, _pgn, _version, .reset = {.ptr = 0}) \
|
||||
/**/
|
||||
|
||||
#define PG_REGISTER_PROFILE_WITH_RESET_FN(_type, _name, _pgn, _version) \
|
||||
extern void pgResetFn_ ## _name(_type *); \
|
||||
PG_REGISTER_PROFILE_I(_type, _name, _pgn, _version, .reset = {.fn = (pgResetFunc*)&pgResetFn_ ## _name}) \
|
||||
/**/
|
||||
|
||||
#define PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(_type, _name, _pgn, _version) \
|
||||
extern const _type pgResetTemplate_ ## _name; \
|
||||
PG_REGISTER_PROFILE_I(_type, _name, _pgn, _version, .reset = {.ptr = (void*)&pgResetTemplate_ ## _name}) \
|
||||
/**/
|
||||
|
||||
|
||||
// Emit reset defaults for config.
|
||||
// Config must be registered with PG_REGISTER_<xxx>_WITH_RESET_TEMPLATE macro
|
||||
#define PG_RESET_TEMPLATE(_type, _name, ...) \
|
||||
|
@ -245,10 +184,8 @@ extern const uint8_t __pg_resetdata_end[];
|
|||
|
||||
const pgRegistry_t* pgFind(pgn_t pgn);
|
||||
|
||||
void pgLoad(const pgRegistry_t* reg, int profileIndex, const void *from, int size, int version);
|
||||
int pgStore(const pgRegistry_t* reg, void *to, int size, uint8_t profileIndex);
|
||||
void pgResetAll(int profileCount);
|
||||
void pgResetCurrent(const pgRegistry_t *reg);
|
||||
void pgLoad(const pgRegistry_t* reg, const void *from, int size, int version);
|
||||
int pgStore(const pgRegistry_t* reg, void *to, int size);
|
||||
void pgResetAll();
|
||||
bool pgResetCopy(void *copy, pgn_t pgn);
|
||||
void pgReset(const pgRegistry_t* reg, int profileIndex);
|
||||
void pgActivateProfile(int profileIndex);
|
||||
void pgReset(const pgRegistry_t* reg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue