mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
CF/BF - Extract cli settings so they can be re-used.
CF/BF - Save 1280 bytes of flash and delete over 300 lines of code by removing giant switch statement and static variables in the CLI. fix CF/BF - Remove some conditional code because there is a copy of every PG so it will always be found*. * unless a developer makes an error in the value table by specifying an invalid PG. CF/BF - Remove final usages of getCurrentAndDefaultConfigs to save more flash space. CF/BF - Change CLI command 'dump showdefaults' to simply 'dump defaults'. * This will save a few bytes of flash space due to string re-use of the 'defaults' string. CF/BF - Save a few more bytes by re-using the 'defaults' string again. CF/BF - Fix CLI not being size optimized. * The file had moved but the makefile was not updated to reflect that. CF/BF - Add 'fc_init.c' and 'settings.c' to the size optimizations list. CF/BF - Add some config source files to the size-optimized list. CF/BF - De-duplicate CR/LF code by using appropriate methods. Promote additional string re-use. * This saves quite a lot of space when the file is size optimized, but grows it otherwise. CF/BF - Further flash savings by removing more CR/LF on the cliDump/cliDefaultPrintf format strings. * It turns out that all the format strings ended in CR+LF so they could all be removed. CF/BF - Fix LF+CR being used instead of CR+LF for further flash savings.
This commit is contained in:
parent
63552348c0
commit
970f193dd7
5 changed files with 1104 additions and 1300 deletions
|
@ -49,6 +49,7 @@ typedef struct pgRegistry_s {
|
|||
pgn_t pgn; // The parameter group number, the top 4 bits are reserved for version
|
||||
uint16_t size; // Size of the group in RAM, the top 4 bits are reserved for flags
|
||||
uint8_t *address; // Address of the group in RAM.
|
||||
uint8_t *copy; // Address of the copy in RAM.
|
||||
uint8_t **ptr; // The pointer to update after loading the record into ram.
|
||||
union {
|
||||
void *ptr; // Pointer to init template
|
||||
|
@ -107,14 +108,16 @@ extern const uint8_t __pg_resetdata_end[];
|
|||
// Declare system config
|
||||
#define PG_DECLARE(_type, _name) \
|
||||
extern _type _name ## _System; \
|
||||
extern _type _name ## _Copy; \
|
||||
static inline const _type* _name(void) { return &_name ## _System; }\
|
||||
static inline _type* _name ## Mutable(void) { return &_name ## _System; }\
|
||||
struct _dummy \
|
||||
/**/
|
||||
|
||||
// Declare system config array
|
||||
#define PG_DECLARE_ARRAY(_type, _size, _name) \
|
||||
#define PG_DECLARE_ARRAY(_type, _size, _name) \
|
||||
extern _type _name ## _SystemArray[_size]; \
|
||||
extern _type _name ## _CopyArray[_size]; \
|
||||
static inline const _type* _name(int _index) { return &_name ## _SystemArray[_index]; } \
|
||||
static inline _type* _name ## Mutable(int _index) { return &_name ## _SystemArray[_index]; } \
|
||||
static inline _type (* _name ## _array(void))[_size] { return &_name ## _SystemArray; } \
|
||||
|
@ -133,12 +136,14 @@ extern const uint8_t __pg_resetdata_end[];
|
|||
// Register system config
|
||||
#define PG_REGISTER_I(_type, _name, _pgn, _version, _reset) \
|
||||
_type _name ## _System; \
|
||||
_type _name ## _Copy; \
|
||||
/* Force external linkage for g++. Catch multi registration */ \
|
||||
extern const pgRegistry_t _name ## _Registry; \
|
||||
const pgRegistry_t _name ##_Registry PG_REGISTER_ATTRIBUTES = { \
|
||||
.pgn = _pgn | (_version << 12), \
|
||||
.size = sizeof(_type) | PGR_SIZE_SYSTEM_FLAG, \
|
||||
.address = (uint8_t*)&_name ## _System, \
|
||||
.copy = (uint8_t*)&_name ## _Copy, \
|
||||
.ptr = 0, \
|
||||
_reset, \
|
||||
} \
|
||||
|
@ -161,11 +166,13 @@ extern const uint8_t __pg_resetdata_end[];
|
|||
// Register system config array
|
||||
#define PG_REGISTER_ARRAY_I(_type, _size, _name, _pgn, _version, _reset) \
|
||||
_type _name ## _SystemArray[_size]; \
|
||||
_type _name ## _CopyArray[_size]; \
|
||||
extern const pgRegistry_t _name ##_Registry; \
|
||||
const pgRegistry_t _name ## _Registry PG_REGISTER_ATTRIBUTES = { \
|
||||
.pgn = _pgn | (_version << 12), \
|
||||
.size = (sizeof(_type) * _size) | PGR_SIZE_SYSTEM_FLAG, \
|
||||
.address = (uint8_t*)&_name ## _SystemArray, \
|
||||
.copy = (uint8_t*)&_name ## _CopyArray, \
|
||||
.ptr = 0, \
|
||||
_reset, \
|
||||
} \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue