mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
modules: Allow optional modules to be used as built-in
Some modules are written such that they can be included or excluded at runtime. These are added to the OPTMODULES list in the makefile for a given board. This change provides a mechanism to allow a build to force a given module to be built-in (ie. always initialized) regardless of the configuration in hwsettings. The main use case for this is to handle a module being optional on one platform but essential on another. All modules added to the MODULES list in the Makefile will automatically result in a matching #define in the form MODULE_TheModuleName_BUILTIN being defined in the CFLAGS for all compiled source. Note that the capitalization of TheModuleName must match exactly the capitalization used in the MODULES list.
This commit is contained in:
parent
53e9ef06b4
commit
27ceb7ea92
@ -412,6 +412,9 @@ ifeq ($(USE_I2C), YES)
|
||||
CDEFS += -DUSE_I2C
|
||||
endif
|
||||
|
||||
# Declare all non-optional modules as built-in to force inclusion
|
||||
CDEFS += ${foreach MOD, ${MODULES}, -DMODULE_$(MOD)_BUILTIN }
|
||||
|
||||
# Place project-specific -D and/or -U options for
|
||||
# Assembler with preprocessor here.
|
||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||
|
@ -92,7 +92,9 @@ int32_t AltitudeStart()
|
||||
*/
|
||||
int32_t AltitudeInitialize()
|
||||
{
|
||||
|
||||
#ifdef MODULE_Altitude_BUILTIN
|
||||
altitudeEnabled = 1;
|
||||
#else
|
||||
HwSettingsInitialize();
|
||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||
HwSettingsOptionalModulesGet(optionalModules);
|
||||
@ -101,6 +103,7 @@ int32_t AltitudeInitialize()
|
||||
} else {
|
||||
altitudeEnabled = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// init down-sampling data
|
||||
alt_ds_temp = 0;
|
||||
|
@ -75,6 +75,10 @@ int32_t CameraStabInitialize(void)
|
||||
static UAVObjEvent ev;
|
||||
|
||||
bool cameraStabEnabled;
|
||||
|
||||
#ifdef MODULE_CameraStab_BUILTIN
|
||||
cameraStabEnabled = true;
|
||||
#else
|
||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||
|
||||
HwSettingsInitialize();
|
||||
@ -84,6 +88,7 @@ int32_t CameraStabInitialize(void)
|
||||
cameraStabEnabled = true;
|
||||
else
|
||||
cameraStabEnabled = false;
|
||||
#endif
|
||||
|
||||
if (cameraStabEnabled) {
|
||||
|
||||
|
@ -94,6 +94,9 @@ static int32_t comUsbBridgeInitialize(void)
|
||||
usart_port = PIOS_COM_BRIDGE;
|
||||
vcp_port = PIOS_COM_VCP;
|
||||
|
||||
#ifdef MODULE_ComUsbBridge_BUILTIN
|
||||
bridge_enabled = true;
|
||||
#else
|
||||
HwSettingsInitialize();
|
||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||
|
||||
@ -104,6 +107,7 @@ static int32_t comUsbBridgeInitialize(void)
|
||||
bridge_enabled = true;
|
||||
else
|
||||
bridge_enabled = false;
|
||||
#endif
|
||||
|
||||
if (bridge_enabled) {
|
||||
com2usb_buf = pvPortMalloc(BRIDGE_BUF_LEN);
|
||||
|
@ -40,6 +40,9 @@ static uint8_t active_fault;
|
||||
|
||||
static int32_t fault_initialize(void)
|
||||
{
|
||||
#ifdef MODULE_Fault_BUILTIN
|
||||
module_enabled = true;
|
||||
#else
|
||||
HwSettingsInitialize();
|
||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||
|
||||
@ -50,6 +53,7 @@ static int32_t fault_initialize(void)
|
||||
} else {
|
||||
module_enabled = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Do this outside the module_enabled test so that it
|
||||
* can be changed even when the module has been disabled.
|
||||
|
@ -121,6 +121,9 @@ int32_t GPSInitialize(void)
|
||||
{
|
||||
gpsPort = PIOS_COM_GPS;
|
||||
|
||||
#ifdef MODULE_GPS_BUILTIN
|
||||
gpsEnabled = true;
|
||||
#else
|
||||
HwSettingsInitialize();
|
||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||
|
||||
@ -130,6 +133,7 @@ int32_t GPSInitialize(void)
|
||||
gpsEnabled = true;
|
||||
else
|
||||
gpsEnabled = false;
|
||||
#endif
|
||||
|
||||
if (gpsPort && gpsEnabled) {
|
||||
GPSPositionInitialize();
|
||||
|
@ -369,6 +369,9 @@ ifeq ($(ENABLE_AUX_UART), YES)
|
||||
CDEFS += -DPIOS_ENABLE_AUX_UART
|
||||
endif
|
||||
|
||||
# Declare all non-optional modules as built-in to force inclusion
|
||||
CDEFS += ${foreach MOD, ${MODULES}, -DMODULE_$(MOD)_BUILTIN }
|
||||
|
||||
# Place project-specific -D and/or -U options for
|
||||
# Assembler with preprocessor here.
|
||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||
|
Loading…
x
Reference in New Issue
Block a user