mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +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
|
FLASH_TOOL = OPENOCD
|
||||||
|
|
||||||
|
OPTMODULES = CameraStab GPS
|
||||||
# List of modules to include
|
# 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
|
# Telemetry must be last to grab the optional modules
|
||||||
MODULES += Telemetry
|
MODULES += Telemetry
|
||||||
|
|
||||||
@ -166,6 +168,7 @@ SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c
|
|||||||
SRC += $(OPUAVSYNTHDIR)/attitudesettings.c
|
SRC += $(OPUAVSYNTHDIR)/attitudesettings.c
|
||||||
SRC += $(OPUAVSYNTHDIR)/camerastabsettings.c
|
SRC += $(OPUAVSYNTHDIR)/camerastabsettings.c
|
||||||
SRC += $(OPUAVSYNTHDIR)/cameradesired.c
|
SRC += $(OPUAVSYNTHDIR)/cameradesired.c
|
||||||
|
SRC += $(OPUAVSYNTHDIR)/gpsposition.c
|
||||||
SRC += $(OPUAVSYNTHDIR)/hwsettings.c
|
SRC += $(OPUAVSYNTHDIR)/hwsettings.c
|
||||||
|
|
||||||
SRC += $(OPUAVSYNTHDIR)/taskinfo.c
|
SRC += $(OPUAVSYNTHDIR)/taskinfo.c
|
||||||
@ -511,6 +514,19 @@ endif
|
|||||||
endif
|
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
|
# 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)
|
#$(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, $@)
|
# @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)))
|
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE)))
|
||||||
|
|
||||||
.PHONY: elf lss sym hex bin bino opfw
|
.PHONY: elf lss sym hex bin bino opfw
|
||||||
elf: $(OUTDIR)/$(TARGET).elf
|
elf: gencode $(OUTDIR)/$(TARGET).elf
|
||||||
lss: $(OUTDIR)/$(TARGET).lss
|
lss: gencode $(OUTDIR)/$(TARGET).lss
|
||||||
sym: $(OUTDIR)/$(TARGET).sym
|
sym: gencode $(OUTDIR)/$(TARGET).sym
|
||||||
hex: $(OUTDIR)/$(TARGET).hex
|
hex: gencode $(OUTDIR)/$(TARGET).hex
|
||||||
bin: $(OUTDIR)/$(TARGET).bin
|
bin: gencode $(OUTDIR)/$(TARGET).bin
|
||||||
bino: $(OUTDIR)/$(TARGET).bin.o
|
bino: gencode $(OUTDIR)/$(TARGET).bin.o
|
||||||
opfw: $(OUTDIR)/$(TARGET).opfw
|
opfw: gencode $(OUTDIR)/$(TARGET).opfw
|
||||||
|
|
||||||
# Display sizes of sections.
|
# Display sizes of sections.
|
||||||
$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf))
|
$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf))
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
#include "uavobjectsinit.h"
|
#include "uavobjectsinit.h"
|
||||||
#include "hwsettings.h"
|
#include "hwsettings.h"
|
||||||
#include "camerastab.h"
|
|
||||||
#include "systemmod.h"
|
#include "systemmod.h"
|
||||||
|
|
||||||
/* Task Priorities */
|
/* Task Priorities */
|
||||||
@ -78,9 +77,7 @@ int main()
|
|||||||
* it grows */
|
* it grows */
|
||||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||||
HwSettingsOptionalModulesGet(optionalModules);
|
HwSettingsOptionalModulesGet(optionalModules);
|
||||||
if(optionalModules[HWSETTINGS_OPTIONALMODULES_CAMERASTABILIZATION] == HWSETTINGS_OPTIONALMODULES_ENABLED) {
|
MODULE_INITIALISE_OPTIONAL(optionalModules)
|
||||||
CameraStabInitialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* swap the stack to use the IRQ stack */
|
/* swap the stack to use the IRQ stack */
|
||||||
Stack_Change();
|
Stack_Change();
|
||||||
|
@ -84,6 +84,12 @@ int32_t CameraStabInitialize(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* stub: module has no module thread */
|
||||||
|
int32_t CameraStabStart(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void attitudeUpdated(UAVObjEvent* ev)
|
static void attitudeUpdated(UAVObjEvent* ev)
|
||||||
{
|
{
|
||||||
if (ev->obj != AttitudeActualHandle())
|
if (ev->obj != AttitudeActualHandle())
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "systemsettings.h"
|
#include "systemsettings.h"
|
||||||
#include "i2cstats.h"
|
#include "i2cstats.h"
|
||||||
#include "taskinfo.h"
|
#include "taskinfo.h"
|
||||||
|
#include "hwsettings.h"
|
||||||
#include "watchdogstatus.h"
|
#include "watchdogstatus.h"
|
||||||
#include "taskmonitor.h"
|
#include "taskmonitor.h"
|
||||||
#include "pios_config.h"
|
#include "pios_config.h"
|
||||||
@ -135,6 +136,11 @@ static void systemTask(void *parameters)
|
|||||||
/* create all modules thread */
|
/* create all modules thread */
|
||||||
MODULE_TASKCREATE_ALL
|
MODULE_TASKCREATE_ALL
|
||||||
|
|
||||||
|
/* create optional module threads */
|
||||||
|
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||||
|
HwSettingsOptionalModulesGet(optionalModules);
|
||||||
|
MODULE_TASKCREATE_OPTIONAL(optionalModules)
|
||||||
|
|
||||||
// Initialize vars
|
// Initialize vars
|
||||||
idleCounter = 0;
|
idleCounter = 0;
|
||||||
idleCounterClear = 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
|
#ifndef PIOS_INITCALL_H
|
||||||
#define PIOS_INITCALL_H
|
#define PIOS_INITCALL_H
|
||||||
|
|
||||||
|
#include "InitOptMods.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just a stub define to make things compile.
|
* Just a stub define to make things compile.
|
||||||
* Automatically link based initialization currently doesn't work
|
* Automatically link based initialization currently doesn't work
|
||||||
@ -64,6 +66,16 @@ extern void StartModules();
|
|||||||
/* Initialize the system thread */ \
|
/* Initialize the system thread */ \
|
||||||
SystemModInitialize();}
|
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 */
|
#endif /* PIOS_INITCALL_H */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#ifndef PIOS_INITCALL_H
|
#ifndef PIOS_INITCALL_H
|
||||||
#define PIOS_INITCALL_H
|
#define PIOS_INITCALL_H
|
||||||
|
|
||||||
|
#include "InitOptMods.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This implementation is heavily based on the Linux Kernel initcall
|
* This implementation is heavily based on the Linux Kernel initcall
|
||||||
* infrastructure:
|
* infrastructure:
|
||||||
@ -77,6 +79,16 @@ extern initmodule_t __module_initcall_start[], __module_initcall_end[];
|
|||||||
if (fn->fn_tinit) \
|
if (fn->fn_tinit) \
|
||||||
(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 */
|
#endif /* PIOS_INITCALL_H */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,7 +87,7 @@ void ConfigCameraStabilizationWidget::applySettings()
|
|||||||
// Enable or disable the settings
|
// Enable or disable the settings
|
||||||
HwSettings * hwSettings = HwSettings::GetInstance(getObjectManager());
|
HwSettings * hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTABILIZATION] =
|
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] =
|
||||||
m_camerastabilization->enableCameraStabilization->isChecked() ?
|
m_camerastabilization->enableCameraStabilization->isChecked() ?
|
||||||
HwSettings::OPTIONALMODULES_ENABLED :
|
HwSettings::OPTIONALMODULES_ENABLED :
|
||||||
HwSettings::OPTIONALMODULES_DISABLED;
|
HwSettings::OPTIONALMODULES_DISABLED;
|
||||||
@ -177,7 +177,7 @@ void ConfigCameraStabilizationWidget::refreshValues()
|
|||||||
HwSettings * hwSettings = HwSettings::GetInstance(getObjectManager());
|
HwSettings * hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||||
m_camerastabilization->enableCameraStabilization->setChecked(
|
m_camerastabilization->enableCameraStabilization->setChecked(
|
||||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTABILIZATION] ==
|
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] ==
|
||||||
HwSettings::OPTIONALMODULES_ENABLED);
|
HwSettings::OPTIONALMODULES_ENABLED);
|
||||||
|
|
||||||
CameraStabSettings * cameraStabSettings = CameraStabSettings::GetInstance(getObjectManager());
|
CameraStabSettings * cameraStabSettings = CameraStabSettings::GetInstance(getObjectManager());
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<description>Selection of optional hardware configurations.</description>
|
<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_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="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"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user