mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
HWSettings: Allow late Initialization and Start of Modules as defined in Makefile(available modules) and UAVObject(actually started modules)
This commit is contained in:
parent
b75890fcd4
commit
dfd301571a
@ -64,8 +64,10 @@ endif
|
||||
|
||||
FLASH_TOOL = OPENOCD
|
||||
|
||||
OPTMODULES = CameraStab GPS
|
||||
# List of modules to include
|
||||
MODULES = Attitude Stabilization Actuator ManualControl FirmwareIAP CameraStab
|
||||
MODULES = ${OPTMODULES}
|
||||
MODULES += Attitude Stabilization Actuator ManualControl FirmwareIAP
|
||||
# Telemetry must be last to grab the optional modules
|
||||
MODULES += Telemetry
|
||||
|
||||
@ -166,6 +168,7 @@ SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c
|
||||
SRC += $(OPUAVSYNTHDIR)/attitudesettings.c
|
||||
SRC += $(OPUAVSYNTHDIR)/camerastabsettings.c
|
||||
SRC += $(OPUAVSYNTHDIR)/cameradesired.c
|
||||
SRC += $(OPUAVSYNTHDIR)/gpsposition.c
|
||||
SRC += $(OPUAVSYNTHDIR)/hwsettings.c
|
||||
|
||||
SRC += $(OPUAVSYNTHDIR)/taskinfo.c
|
||||
@ -511,6 +514,19 @@ endif
|
||||
endif
|
||||
endif
|
||||
|
||||
gencode: ${OUTDIR}/InitOptMods.h
|
||||
|
||||
# this is supposed to be standard function, but apparently it is not
|
||||
uc = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
|
||||
|
||||
${OUTDIR}/InitOptMods.h:
|
||||
@echo ${quote}${foreach MOD, ${OPTMODULES}, int32_t ${MOD}Initialize(); }${quote} > ${OUTDIR}/InitOptMods.h
|
||||
@echo ${quote}${foreach MOD, ${OPTMODULES}, int32_t ${MOD}Start(); }${quote} >> ${OUTDIR}/InitOptMods.h
|
||||
@echo ${quote}#define MODULE_INITIALISE_OPTIONAL(list) \${quote} >> ${OUTDIR}/InitOptMods.h
|
||||
@echo ${quote}${foreach MOD, ${OPTMODULES}, OPTMODULE_INIT(list, $(call uc, ${MOD}), ${MOD});}${quote} >> ${OUTDIR}/InitOptMods.h
|
||||
@echo ${quote}#define MODULE_TASKCREATE_OPTIONAL(list) \${quote} >> ${OUTDIR}/InitOptMods.h
|
||||
@echo ${quote}${foreach MOD, ${OPTMODULES}, OPTMODULE_START(list, $(call uc, ${MOD}), ${MOD});}${quote} >> ${OUTDIR}/InitOptMods.h
|
||||
|
||||
# Generate code for PyMite
|
||||
#$(OUTDIR)/pmlib_img.c $(OUTDIR)/pmlib_nat.c $(OUTDIR)/pmlibusr_img.c $(OUTDIR)/pmlibusr_nat.c $(OUTDIR)/pmfeatures.h: $(wildcard $(PYMITELIB)/*.py) $(wildcard $(PYMITEPLAT)/*.py) $(wildcard $(FLIGHTPLANLIB)/*.py) $(wildcard $(FLIGHTPLANS)/*.py)
|
||||
# @echo $(MSG_PYMITEINIT) $(call toprel, $@)
|
||||
@ -553,13 +569,13 @@ $(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISI
|
||||
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE)))
|
||||
|
||||
.PHONY: elf lss sym hex bin bino opfw
|
||||
elf: $(OUTDIR)/$(TARGET).elf
|
||||
lss: $(OUTDIR)/$(TARGET).lss
|
||||
sym: $(OUTDIR)/$(TARGET).sym
|
||||
hex: $(OUTDIR)/$(TARGET).hex
|
||||
bin: $(OUTDIR)/$(TARGET).bin
|
||||
bino: $(OUTDIR)/$(TARGET).bin.o
|
||||
opfw: $(OUTDIR)/$(TARGET).opfw
|
||||
elf: gencode $(OUTDIR)/$(TARGET).elf
|
||||
lss: gencode $(OUTDIR)/$(TARGET).lss
|
||||
sym: gencode $(OUTDIR)/$(TARGET).sym
|
||||
hex: gencode $(OUTDIR)/$(TARGET).hex
|
||||
bin: gencode $(OUTDIR)/$(TARGET).bin
|
||||
bino: gencode $(OUTDIR)/$(TARGET).bin.o
|
||||
opfw: gencode $(OUTDIR)/$(TARGET).opfw
|
||||
|
||||
# Display sizes of sections.
|
||||
$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf))
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "openpilot.h"
|
||||
#include "uavobjectsinit.h"
|
||||
#include "hwsettings.h"
|
||||
#include "camerastab.h"
|
||||
#include "systemmod.h"
|
||||
|
||||
/* Task Priorities */
|
||||
@ -78,9 +77,7 @@ int main()
|
||||
* it grows */
|
||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||
HwSettingsOptionalModulesGet(optionalModules);
|
||||
if(optionalModules[HWSETTINGS_OPTIONALMODULES_CAMERASTABILIZATION] == HWSETTINGS_OPTIONALMODULES_ENABLED) {
|
||||
CameraStabInitialize();
|
||||
}
|
||||
MODULE_INITIALISE_OPTIONAL(optionalModules)
|
||||
|
||||
/* swap the stack to use the IRQ stack */
|
||||
Stack_Change();
|
||||
|
@ -84,6 +84,12 @@ int32_t CameraStabInitialize(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* stub: module has no module thread */
|
||||
int32_t CameraStabStart(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void attitudeUpdated(UAVObjEvent* ev)
|
||||
{
|
||||
if (ev->obj != AttitudeActualHandle())
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "systemsettings.h"
|
||||
#include "i2cstats.h"
|
||||
#include "taskinfo.h"
|
||||
#include "hwsettings.h"
|
||||
#include "watchdogstatus.h"
|
||||
#include "taskmonitor.h"
|
||||
#include "pios_config.h"
|
||||
@ -135,6 +136,11 @@ static void systemTask(void *parameters)
|
||||
/* create all modules thread */
|
||||
MODULE_TASKCREATE_ALL
|
||||
|
||||
/* create optional module threads */
|
||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||
HwSettingsOptionalModulesGet(optionalModules);
|
||||
MODULE_TASKCREATE_OPTIONAL(optionalModules)
|
||||
|
||||
// Initialize vars
|
||||
idleCounter = 0;
|
||||
idleCounterClear = 0;
|
||||
|
35
flight/OpenPilot/System/inc/InitOptMods.h
Normal file
35
flight/OpenPilot/System/inc/InitOptMods.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup OpenPilotSystem OpenPilot System
|
||||
* @{
|
||||
* @addtogroup OpenPilotCore OpenPilot Core
|
||||
* @{
|
||||
* @file InitOptMods.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @brief Main OpenPilot header.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file is a stub since no such file is autogenerated yet.
|
||||
* This architecture does not use optional modules yet.
|
||||
*/
|
||||
|
||||
#define MODULE_INITIALISE_OPTIONAL(list)
|
||||
#define MODULE_TASKCREATE_OPTIONAL(list)
|
@ -31,6 +31,8 @@
|
||||
#ifndef PIOS_INITCALL_H
|
||||
#define PIOS_INITCALL_H
|
||||
|
||||
#include "InitOptMods.h"
|
||||
|
||||
/**
|
||||
* Just a stub define to make things compile.
|
||||
* Automatically link based initialization currently doesn't work
|
||||
@ -64,6 +66,16 @@ extern void StartModules();
|
||||
/* Initialize the system thread */ \
|
||||
SystemModInitialize();}
|
||||
|
||||
#define OPTMODULE_INIT(list,mod) \
|
||||
if(list[HWSETTINGS_OPTIONALMODULES_##mod##] == HWSETTINGS_OPTIONALMODULES_ENABLED) { \
|
||||
mod##Initialize(); \
|
||||
}
|
||||
|
||||
#define OPTMODULE_START(list,mod) \
|
||||
if(list[HWSETTINGS_OPTIONALMODULES_##mod##] == HWSETTINGS_OPTIONALMODULES_ENABLED) { \
|
||||
mod##Start(); \
|
||||
}
|
||||
|
||||
#endif /* PIOS_INITCALL_H */
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,8 @@
|
||||
#ifndef PIOS_INITCALL_H
|
||||
#define PIOS_INITCALL_H
|
||||
|
||||
#include "InitOptMods.h"
|
||||
|
||||
/*
|
||||
* This implementation is heavily based on the Linux Kernel initcall
|
||||
* infrastructure:
|
||||
@ -77,6 +79,16 @@ extern initmodule_t __module_initcall_start[], __module_initcall_end[];
|
||||
if (fn->fn_tinit) \
|
||||
(fn->fn_tinit)(); }
|
||||
|
||||
#define OPTMODULE_INIT(list,moduc,mod) \
|
||||
if(list[ HWSETTINGS_OPTIONALMODULES_##moduc ] == HWSETTINGS_OPTIONALMODULES_ENABLED) { \
|
||||
mod##Initialize(); \
|
||||
}
|
||||
|
||||
#define OPTMODULE_START(list,moduc,mod) \
|
||||
if(list[ HWSETTINGS_OPTIONALMODULES_##moduc ] == HWSETTINGS_OPTIONALMODULES_ENABLED) { \
|
||||
mod##Start(); \
|
||||
}
|
||||
|
||||
#endif /* PIOS_INITCALL_H */
|
||||
|
||||
/**
|
||||
|
@ -87,7 +87,7 @@ void ConfigCameraStabilizationWidget::applySettings()
|
||||
// Enable or disable the settings
|
||||
HwSettings * hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTABILIZATION] =
|
||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] =
|
||||
m_camerastabilization->enableCameraStabilization->isChecked() ?
|
||||
HwSettings::OPTIONALMODULES_ENABLED :
|
||||
HwSettings::OPTIONALMODULES_DISABLED;
|
||||
@ -177,7 +177,7 @@ void ConfigCameraStabilizationWidget::refreshValues()
|
||||
HwSettings * hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||
m_camerastabilization->enableCameraStabilization->setChecked(
|
||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTABILIZATION] ==
|
||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] ==
|
||||
HwSettings::OPTIONALMODULES_ENABLED);
|
||||
|
||||
CameraStabSettings * cameraStabSettings = CameraStabSettings::GetInstance(getObjectManager());
|
||||
|
@ -3,7 +3,7 @@
|
||||
<description>Selection of optional hardware configurations.</description>
|
||||
<field name="CC_FlexiPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,GPS,Spektrum,ComAux,I2C" defaultvalue="Disabled"/>
|
||||
<field name="CC_MainPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,S.Bus,GPS,Spektrum,ComAux" defaultvalue="Telemetry"/>
|
||||
<field name="OptionalModules" units="" type="enum" elementnames="CameraStabilization,GPS" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
||||
<field name="OptionalModules" units="" type="enum" elementnames="CameraStab,GPS" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user