NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Configuration
Collaboration diagram for Configuration:

Modules

 Accelerometer
 
 Altitudehold
 
 Anglerate
 

Files

file  config.c
 

Data Structures

struct  eeprom_delta
 
struct  config_profile
 
struct  config
 
struct  config_store
 structure used for storing config in the eeprom More...
 

Macros

#define CONFIG_EEPROM_START   0
 this is the starting address of the config eeprom area More...
 
#define CONFIG_EEPROM_SIZE   4096
 this is the size of the eeporm area used by the config More...
 
#define DEFAULT_BLACKBOX_DEVICE   BLACKBOX_DEVICE_SERIAL
 
#define BRUSHED_MOTORS_PWM_RATE   16000
 
#define BRUSHLESS_MOTORS_PWM_RATE   400
 
#define DEFAULT_PWM_RATE   BRUSHLESS_MOTORS_PWM_RATE
 
#define DEFAULT_TELEMETRY_INVERSION   0
 
#define MAX_PROFILE_COUNT   1
 
#define ONESHOT_FEATURE_CHANGED_DELAY_ON_BOOT_MS   1500
 

Functions

struct eeprom_delta __attribute__ ((packed))
 
void config_reset (struct config *self)
 
const struct config_profile const * config_get_profile (const struct config *const self)
 
struct config_profileconfig_get_profile_rw (struct config *self)
 
struct rate_profile const * config_get_rate_profile (const struct config *const self)
 
struct rate_profileconfig_get_rate_profile_rw (struct config *self)
 
int config_save (const struct config *self, const struct system_calls *system)
 
bool config_fixup (struct config *config)
 
int config_load (struct config *self, const struct system_calls *system)
 
struct config __attribute__ ((packed, aligned(2)))
 
struct config_store __attribute__ ((aligned(4)))
 

Variables

const serialPortIdentifier_e serialPortIdentifiers [SERIAL_PORT_COUNT]
 

Detailed Description

The purpose of this module is to provide a systemwide configuration structure where all settings can be stored. It uses system calls to save the configuration to an eeprom (or equivalent) storage. This module decouples configuration variables from implementation of the subsystems and organizes them into a single packed structure called struct config. Many other systems depend on this module for their settings. It also provides reasonable default values and perhaps later will also provide validation of values for each config. It should be seen as an equivalent of a database where each configuration submodule does contain some module specifics but always only uses basic types to represent the data. You should never ever make any data structures in this module depend on any driver/hardware/implementation specific data structures. It should be kept very simple and completely implementation-agnostic.

Loading of config

Config module typically only stores deltas in the eeprom. Before loading a config, the data area is filled with available defaults. Then deltas are loaded from the eeprom which overwrite some values that have been modified by the user from defaults. Finally the new checksum is loaded from the eeprom as well. If checksum of the loaded data matches the checksum loaded from the eeprom then all config data is copied to the config struct supplied to config_load. If data can not be loaded then config_load will return an error.

Macro Definition Documentation

#define BRUSHED_MOTORS_PWM_RATE   16000
#define BRUSHLESS_MOTORS_PWM_RATE   400
#define CONFIG_EEPROM_SIZE   4096

this is the size of the eeporm area used by the config

#define CONFIG_EEPROM_START   0

this is the starting address of the config eeprom area

#define DEFAULT_BLACKBOX_DEVICE   BLACKBOX_DEVICE_SERIAL
#define DEFAULT_PWM_RATE   BRUSHLESS_MOTORS_PWM_RATE
#define DEFAULT_TELEMETRY_INVERSION   0
#define MAX_PROFILE_COUNT   1
#define ONESHOT_FEATURE_CHANGED_DELAY_ON_BOOT_MS   1500

Function Documentation

struct eeprom_delta __attribute__ ( (packed)  )
struct config __attribute__ ( (packed, aligned(2))  )
struct config_store __attribute__ ( (aligned(4))  )
bool config_fixup ( struct config config)
struct config_profile const * config_get_profile ( const struct config *const  self)
struct config_profile * config_get_profile_rw ( struct config self)
struct rate_profile const * config_get_rate_profile ( const struct config *const  self)

Here is the call graph for this function:

struct rate_profile * config_get_rate_profile_rw ( struct config self)

Here is the call graph for this function:

int config_load ( struct config self,
const struct system_calls system 
)

Here is the call graph for this function:

void config_reset ( struct config self)

Here is the call graph for this function:

int config_save ( const struct config self,
const struct system_calls system 
)

NOTE: this function makes heavy use of the stack to store 2 * sizeof(config) which can be up to 4k. It may therefore cause stack overflow if ram if almost used up when it is called

Parameters
selfconfig which is to be saved to eeprom

Here is the call graph for this function:

Variable Documentation

const serialPortIdentifier_e serialPortIdentifiers[SERIAL_PORT_COUNT]
Initial value:
= {
}