diff --git a/Makefile b/Makefile index 3730842a9f..d05bac78a7 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ MISC=sw/ground_segment/misc LOGALIZER=sw/logalizer SIMULATOR=sw/simulator EXT=sw/ext -MAKE:=$(MAKE) PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) +MAKE=make PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) CONF=$(PAPARAZZI_SRC)/conf STATICINCLUDE =$(PAPARAZZI_HOME)/var/include MESSAGES_H=$(STATICINCLUDE)/messages.h @@ -252,7 +252,7 @@ cleanspaces: distclean : dist_clean dist_clean : - @echo "Warning: This removes all non-repository files. This means you will loose your aircraft list, your maps, your logfiles, ... if you want this, then run: $(MAKE) dist_clean_irreversible" + @echo "Warning: This removes all non-repository files. This means you will loose your aircraft list, your maps, your logfiles, ... if you want this, then run: make dist_clean_irreversible" dist_clean_irreversible: clean rm -rf conf/srtm_data @@ -270,7 +270,7 @@ test_all_example_airframes: $(MAKE) AIRCRAFT=EasyStar_ETS clean_ac ap sim test_all_example_airframes2: - for ap in `grep name conf/conf.xml.example | sed -e 's/.*name=\"//' | sed -e 's/"//'`; do echo "Making $$ap"; $(MAKE) -C ./ AIRCRAFT=$$ap clean_ac ap.compile || exit 1; done + for ap in `grep name conf/conf.xml.example | sed -e 's/.*name=\"//' | sed -e 's/"//'`; do echo "Making $$ap"; make -C ./ AIRCRAFT=$$ap clean_ac ap.compile || exit 1; done commands: paparazzi sw/simulator/launchsitl diff --git a/Makefile.ac b/Makefile.ac index d738526d7f..3d04b1aa22 100644 --- a/Makefile.ac +++ b/Makefile.ac @@ -51,7 +51,7 @@ SETTINGS_FILE=$(SETTINGS:settings%=%) #TUNING_FILE=$(subst ,_,$(SETTINGS:settings/%.xml=%)).h TUNING_H=$(AC_GENERATED)/tuning.h SUPERVISION=./paparazzi -MAKE:=$(MAKE) PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) +MAKE=make PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) MODULES_H=$(AC_GENERATED)/modules.h AIRCRAFT_MD5=$(AIRCRAFT_CONF_DIR)/aircraft.md5 @@ -138,7 +138,7 @@ $(MODULES_H) : $(CONF)/$(AIRFRAME_XML) $(TOOLS)/gen_modules.out $(CONF)/modules/ $(SETTINGS_MODULES) : $(MODULES_H) %.ac_h : $(TOOLS)/gen_aircraft.out - $(Q)if (expr "$(AIRCRAFT)"); then : ; else echo "AIRCRAFT undefined: type '$(MAKE) AIRCRAFT=AircraftName ...'"; exit 1; fi + $(Q)if (expr "$(AIRCRAFT)"); then : ; else echo "AIRCRAFT undefined: type 'make AIRCRAFT=AircraftName ...'"; exit 1; fi @echo BUILD $(AIRCRAFT), TARGET $* +$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) TARGET=$* Q=$(Q) $(TOOLS)/gen_aircraft.out $(AIRCRAFT) @@ -187,5 +187,5 @@ check_fuses_fbw: fbw.check_fuses hard_ac ac: ac_h fbw ap clean_ac : - $(Q)if (expr "$(AIRCRAFT)"); then : ; else echo "AIRCRAFT undefined: type '$(MAKE) AIRCRAFT=AircraftName ...'"; exit 1; fi + $(Q)if (expr "$(AIRCRAFT)"); then : ; else echo "AIRCRAFT undefined: type 'make AIRCRAFT=AircraftName ...'"; exit 1; fi rm -fr $(PAPARAZZI_HOME)/var/$(AIRCRAFT) diff --git a/conf/Makefile.sim b/conf/Makefile.sim index 34db63a13d..8097438bdf 100644 --- a/conf/Makefile.sim +++ b/conf/Makefile.sim @@ -56,15 +56,10 @@ CFLAGS += $(INCLUDES) CFLAGS += $($(TARGET).CFLAGS) CFLAGS += $(LOCAL_CFLAGS) CFLAGS += -O2 -CFLAGS += -std=gnu99 -# meschach prototypes trigger numerous warnings -ifneq ($(SIM_TYPE),BOOZ) ifneq ($(SIM_TYPE),JSBSIM) -CFLAGS += -Wstrict-prototypes +CFLAGS += -std=gnu99 endif -endif - LDFLAGS = -lm diff --git a/conf/autopilot/rotorcraft.makefile b/conf/autopilot/rotorcraft.makefile index 967a538355..97901aa1d7 100644 --- a/conf/autopilot/rotorcraft.makefile +++ b/conf/autopilot/rotorcraft.makefile @@ -50,7 +50,7 @@ ap.srcs += $(SRC_ARCH)/mcu_arch.c # # Math functions # -$(TARGET).srcs += math/pprz_geodetic_int.c math/pprz_geodetic_float.c math/pprz_geodetic_double.c math/pprz_trig_int.c +ap.srcs += math/pprz_geodetic_int.c math/pprz_geodetic_float.c math/pprz_geodetic_double.c math/pprz_trig_int.c ifeq ($(ARCH), stm32) ap.srcs += lisa/plug_sys.c @@ -74,7 +74,7 @@ endif ifndef PERIODIC_FREQUENCY PERIODIC_FREQUENCY = 512 endif -$(TARGET).CFLAGS += -DPERIODIC_FREQUENCY=$(PERIODIC_FREQUENCY) +ap.CFLAGS += -DPERIODIC_FREQUENCY=$(PERIODIC_FREQUENCY) # # Systime # diff --git a/conf/autopilot/subsystems/fixedwing/autopilot.makefile b/conf/autopilot/subsystems/fixedwing/autopilot.makefile index 4d4b89a45c..cec39b5688 100644 --- a/conf/autopilot/subsystems/fixedwing/autopilot.makefile +++ b/conf/autopilot/subsystems/fixedwing/autopilot.makefile @@ -56,8 +56,9 @@ $(TARGET).CFLAGS += -DTRAFFIC_INFO # # LEDs # - -$(TARGET).CFLAGS += -DUSE_LED +ifneq ($(ARCH), jsbsim) + $(TARGET).CFLAGS += -DUSE_LED +endif ifneq ($(ARCH), lpc21) ifneq ($(ARCH), jsbsim) $(TARGET).srcs += $(SRC_ARCH)/led_hw.c @@ -71,7 +72,8 @@ ifndef PERIODIC_FREQUENCY PERIODIC_FREQUENCY = 60 endif $(TARGET).CFLAGS += -DPERIODIC_FREQUENCY=$(PERIODIC_FREQUENCY) -$(TARGET).srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c +$(TARGET).srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c +$(TARGET).CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_RESOLUTION='(1./$(PERIODIC_FREQUENCY).)' # # InterMCU & Commands @@ -119,11 +121,6 @@ ifneq ($(SYS_TIME_LED),none) ns_CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED) endif -# -# Sys-time -# -ns_CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_RESOLUTION='(1./$(PERIODIC_FREQUENCY).)' - # # UARTS diff --git a/conf/autopilot/subsystems/rotorcraft/fdm_nps.makefile b/conf/autopilot/subsystems/rotorcraft/fdm_nps.makefile index a40b082b65..4ae5663642 100644 --- a/conf/autopilot/subsystems/rotorcraft/fdm_nps.makefile +++ b/conf/autopilot/subsystems/rotorcraft/fdm_nps.makefile @@ -51,7 +51,7 @@ sim.srcs += $(NPSDIR)/nps_main.c \ $(NPSDIR)/nps_radio_control.c \ $(NPSDIR)/nps_radio_control_joystick.c \ $(NPSDIR)/nps_radio_control_spektrum.c \ - $(NPSDIR)/nps_autopilot_booz.c \ + $(NPSDIR)/nps_autopilot_rotorcraft.c \ $(NPSDIR)/nps_ivy.c \ $(NPSDIR)/nps_flightgear.c \ @@ -68,7 +68,7 @@ ifeq ($(TARGET), sim) endif -sim.CFLAGS += -DPERIODIC_FREQUENCY='512.' +sim.CFLAGS += -DPERIODIC_FREQUENCY=512 #sim.CFLAGS += -DUSE_LED sim.srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c @@ -85,9 +85,9 @@ sim.srcs += $(SRC_FIRMWARE)/commands.c sim.srcs += $(SRC_FIRMWARE)/datalink.c # +# Math functions # -# - +sim.srcs += math/pprz_geodetic_int.c math/pprz_geodetic_float.c math/pprz_geodetic_double.c math/pprz_trig_int.c sim.CFLAGS += -DROTORCRAFT_BARO_LED=2 sim.srcs += $(SRC_BOARD)/baro_board.c diff --git a/conf/autopilot/subsystems/shared/imu_aspirin_common.makefile b/conf/autopilot/subsystems/shared/imu_aspirin_common.makefile index 913a57cf12..b017d4e366 100644 --- a/conf/autopilot/subsystems/shared/imu_aspirin_common.makefile +++ b/conf/autopilot/subsystems/shared/imu_aspirin_common.makefile @@ -36,7 +36,11 @@ # imu aspirin -IMU_ASPIRIN_CFLAGS = -DUSE_IMU +# for fixedwing firmware and ap only +ifeq ($(TARGET), ap) + IMU_ASPIRIN_CFLAGS = -DUSE_IMU +endif + IMU_ASPIRIN_CFLAGS += -DIMU_TYPE_H=\"imu/imu_aspirin.h\" IMU_ASPIRIN_SRCS = $(SRC_SUBSYSTEMS)/imu.c \ $(SRC_SUBSYSTEMS)/imu/imu_aspirin.c \ diff --git a/conf/conf.xml.example b/conf/conf.xml.example index 69d70d82b6..8998d5adba 100644 --- a/conf/conf.xml.example +++ b/conf/conf.xml.example @@ -37,16 +37,6 @@ settings="settings/settings_booz2.xml" gui_color="white" /> - - + diff --git a/sw/airborne/arch/lpc21/subsystems/radio_control/ppm_arch.h b/sw/airborne/arch/lpc21/subsystems/radio_control/ppm_arch.h index b06954aa48..b42eefcd95 100644 --- a/sw/airborne/arch/lpc21/subsystems/radio_control/ppm_arch.h +++ b/sw/airborne/arch/lpc21/subsystems/radio_control/ppm_arch.h @@ -28,6 +28,8 @@ #include "LPC21xx.h" #include BOARD_CONFIG +#include "mcu_periph/sys_time.h" + /** * On tiny (and booz) the ppm counter is running at the same speed as * the systic counter. There is no reason for this to be true. diff --git a/sw/airborne/arch/sim/mcu_periph/sys_time_arch.c b/sw/airborne/arch/sim/mcu_periph/sys_time_arch.c index d516657fed..83ccbdfe27 100644 --- a/sw/airborne/arch/sim/mcu_periph/sys_time_arch.c +++ b/sw/airborne/arch/sim/mcu_periph/sys_time_arch.c @@ -26,3 +26,21 @@ void sys_time_arch_init( void ) { } + +void sys_tick_handler( void ) { + + sys_time.nb_tick++; + sys_time.nb_sec_rem += SYS_TIME_RESOLUTION_CPU_TICKS; + if (sys_time.nb_sec_rem >= CPU_TICKS_PER_SEC) { + sys_time.nb_sec_rem -= CPU_TICKS_PER_SEC; + sys_time.nb_sec++; + } + for (unsigned int i=0; i= sys_time.timer[i].end_time) { + sys_time.timer[i].end_time += sys_time.timer[i].duration; + sys_time.timer[i].elapsed = TRUE; + if (sys_time.timer[i].cb) sys_time.timer[i].cb(i); + } + } +} diff --git a/sw/airborne/arch/sim/mcu_periph/sys_time_arch.h b/sw/airborne/arch/sim/mcu_periph/sys_time_arch.h index a47b23f9da..da431f45bb 100644 --- a/sw/airborne/arch/sim/mcu_periph/sys_time_arch.h +++ b/sw/airborne/arch/sim/mcu_periph/sys_time_arch.h @@ -21,22 +21,24 @@ * */ -/* - *\brief simulator dummy timing functions - * +/** @file arch/sim/mcu_periph/sys_time_arch.h + * Simulator timing functions */ #ifndef SYS_TIME_ARCH_H #define SYS_TIME_ARCH_H -#include +#include "std.h" -#define CPU_TICKS_OF_SEC(x) (x) -#define SIGNED_CPU_TICKS_OF_SEC(x) (x) +extern void sys_tick_handler(void); -#define SEC_OF_CPU_TICKS(st) (st) -#define MSEC_OF_CPU_TICKS(st) (st) -#define USEC_OF_CPU_TICKS(st) (st) +// simulate 1us cpu ticks +#define CPU_TICKS_OF_SEC(s) (uint32_t)((s) * 1e6 + 0.5) +#define SIGNED_CPU_TICKS_OF_SEC(s) (int32_t)((s) * 1e6 + 0.5) + +#define SEC_OF_CPU_TICKS(t) ((t) / 1e6) +#define MSEC_OF_CPU_TICKS(t) ((t) / 1e3) +#define USEC_OF_CPU_TICKS(t) (t) #define SysTimeTimerStart(_t) { } #define SysTimeTimer(_t) (_t) diff --git a/sw/airborne/arch/stm32/subsystems/radio_control/ppm_arch.h b/sw/airborne/arch/stm32/subsystems/radio_control/ppm_arch.h index f1be912ecd..c3eebdec23 100644 --- a/sw/airborne/arch/stm32/subsystems/radio_control/ppm_arch.h +++ b/sw/airborne/arch/stm32/subsystems/radio_control/ppm_arch.h @@ -29,6 +29,8 @@ #ifndef PPM_ARCH_H #define PPM_ARCH_H +#include "mcu_periph/sys_time.h" + /** * On tiny (and booz) the ppm counter is running at the same speed as * the systic counter. There is no reason for this to be true. diff --git a/sw/airborne/boards/booz_1.0.h b/sw/airborne/boards/booz_1.0.h index 2d6d2a5b8a..95048428e7 100644 --- a/sw/airborne/boards/booz_1.0.h +++ b/sw/airborne/boards/booz_1.0.h @@ -142,7 +142,7 @@ #define PWM1_PINSEL_BIT 14 -#define BOARD_HAS_BARO +#define BOARD_HAS_BARO 1 /* * Modem diff --git a/sw/airborne/boards/lisa_l_1.0.h b/sw/airborne/boards/lisa_l_1.0.h index e9652741ad..b7cb6171fd 100644 --- a/sw/airborne/boards/lisa_l_1.0.h +++ b/sw/airborne/boards/lisa_l_1.0.h @@ -34,6 +34,6 @@ #define BOARD_ADC_CHANNEL_3 ADC_Channel_0 #define BOARD_ADC_CHANNEL_4 ADC_Channel_15 -#define BOARD_HAS_BARO +#define BOARD_HAS_BARO 1 #endif /* CONFIG_LISA_L_1_0_H */ diff --git a/sw/airborne/boards/lisa_m_1.0.h b/sw/airborne/boards/lisa_m_1.0.h index 5d56e7bb6b..5d4549aa6e 100644 --- a/sw/airborne/boards/lisa_m_1.0.h +++ b/sw/airborne/boards/lisa_m_1.0.h @@ -56,7 +56,7 @@ #define BOARD_ADC_CHANNEL_3 ADC_Channel_14 #define BOARD_ADC_CHANNEL_4 ADC_Channel_11 -#define BOARD_HAS_BARO +#define BOARD_HAS_BARO 1 #define USE_OPENCM3 1 diff --git a/sw/airborne/boards/navgo_1.0.h b/sw/airborne/boards/navgo_1.0.h index 17a6fbf118..0f23fa9ee0 100644 --- a/sw/airborne/boards/navgo_1.0.h +++ b/sw/airborne/boards/navgo_1.0.h @@ -76,6 +76,6 @@ #define PWM1_PINSEL_VAL 0x02 #define PWM1_PINSEL_BIT 14 -#define BOARD_HAS_BARO +#define BOARD_HAS_BARO 1 #endif /* CONFIG_NAVGO_V1_0_H */ diff --git a/sw/airborne/boards/umarim_1.0.h b/sw/airborne/boards/umarim_1.0.h index eb47a0545c..6c0b01187c 100644 --- a/sw/airborne/boards/umarim_1.0.h +++ b/sw/airborne/boards/umarim_1.0.h @@ -99,6 +99,6 @@ #define SPI1_DRDY_EINT 0 #define SPI1_DRDY_VIC_IT VIC_EINT0 -#define BOARD_HAS_BARO +#define BOARD_HAS_BARO 1 #endif /* CONFIG_UMARIM_V1_0_H */ diff --git a/sw/airborne/firmwares/fixedwing/ap_downlink.h b/sw/airborne/firmwares/fixedwing/ap_downlink.h index 30dee8aec7..08e80ea45f 100644 --- a/sw/airborne/firmwares/fixedwing/ap_downlink.h +++ b/sw/airborne/firmwares/fixedwing/ap_downlink.h @@ -245,7 +245,9 @@ extern uint8_t telemetry_mode_Ap_DefaultChannel; #define PERIODIC_SEND_SCP_STATUS(_trans, _dev) {} #endif -#ifdef BOARD_HAS_BARO +//FIXME: we need a better switch here... +#if BOARD_HAS_BARO && USE_BARO_AS_ALTIMETER +#include "subsystems/sensors/baro.h" #define PERIODIC_SEND_BARO_RAW(_trans, _dev) { \ DOWNLINK_SEND_BARO_RAW(_trans, _dev, \ &baro.absolute, \ diff --git a/sw/airborne/firmwares/fixedwing/main_ap.c b/sw/airborne/firmwares/fixedwing/main_ap.c index f5d76ff2a5..787d6c59e0 100644 --- a/sw/airborne/firmwares/fixedwing/main_ap.c +++ b/sw/airborne/firmwares/fixedwing/main_ap.c @@ -69,7 +69,7 @@ #include "subsystems/datalink/datalink.h" #include "subsystems/settings.h" #include "subsystems/datalink/xbee.h" -#include "ap_downlink.h" +#include "firmwares/fixedwing/ap_downlink.h" // modules & settings #include "generated/modules.h" diff --git a/sw/airborne/firmwares/rotorcraft/main.c b/sw/airborne/firmwares/rotorcraft/main.c index a65562effb..f3278c871c 100644 --- a/sw/airborne/firmwares/rotorcraft/main.c +++ b/sw/airborne/firmwares/rotorcraft/main.c @@ -58,7 +58,7 @@ #include "firmwares/rotorcraft/main.h" #ifdef SITL -#include "nps_autopilot_booz.h" +#include "nps_autopilot_rotorcraft.h" #endif #include "generated/modules.h" @@ -70,7 +70,6 @@ static inline void on_baro_dif_event( void ); static inline void on_gps_event( void ); static inline void on_mag_event( void ); -#ifndef SITL tid_t main_periodic_tid; ///< id for main_periodic() timer tid_t failsafe_tid; ///< id for failsafe_check() timer @@ -79,22 +78,12 @@ tid_t electrical_tid; ///< id for electrical_periodic() timer tid_t baro_tid; ///< id for baro_periodic() timer tid_t telemetry_tid; ///< id for telemetry_periodic() timer +#ifndef SITL int main( void ) { main_init(); while(1) { - if (sys_time_check_and_ack_timer(main_periodic_tid)) - main_periodic(); - if (sys_time_check_and_ack_timer(radio_control_tid)) - radio_control_periodic_task(); - if (sys_time_check_and_ack_timer(failsafe_tid)) - failsafe_check(); - if (sys_time_check_and_ack_timer(electrical_tid)) - electrical_periodic(); - if (sys_time_check_and_ack_timer(baro_tid)) - baro_periodic(); - if (sys_time_check_and_ack_timer(telemetry_tid)) - telemetry_periodic(); + handle_periodic_tasks(); main_event(); } return 0; @@ -146,6 +135,20 @@ STATIC_INLINE void main_init( void ) { telemetry_tid = sys_time_register_timer((1./60.), NULL); } +STATIC_INLINE void handle_periodic_tasks( void ) { + if (sys_time_check_and_ack_timer(main_periodic_tid)) + main_periodic(); + if (sys_time_check_and_ack_timer(radio_control_tid)) + radio_control_periodic_task(); + if (sys_time_check_and_ack_timer(failsafe_tid)) + failsafe_check(); + if (sys_time_check_and_ack_timer(electrical_tid)) + electrical_periodic(); + if (sys_time_check_and_ack_timer(baro_tid)) + baro_periodic(); + if (sys_time_check_and_ack_timer(telemetry_tid)) + telemetry_periodic(); +} STATIC_INLINE void main_periodic( void ) { diff --git a/sw/airborne/firmwares/rotorcraft/main.h b/sw/airborne/firmwares/rotorcraft/main.h index 63f5e068e1..c548af8a58 100644 --- a/sw/airborne/firmwares/rotorcraft/main.h +++ b/sw/airborne/firmwares/rotorcraft/main.h @@ -31,9 +31,10 @@ #endif STATIC_INLINE void main_init( void ); -STATIC_INLINE void main_periodic( void ); STATIC_INLINE void main_event( void ); +STATIC_INLINE void handle_periodic_tasks( void ); +STATIC_INLINE void main_periodic( void ); STATIC_INLINE void telemetry_periodic(void); STATIC_INLINE void failsafe_check( void ); diff --git a/sw/airborne/subsystems/imu/imu_b2.h b/sw/airborne/subsystems/imu/imu_b2.h index 1860501be9..02b7e69c59 100644 --- a/sw/airborne/subsystems/imu/imu_b2.h +++ b/sw/airborne/subsystems/imu/imu_b2.h @@ -169,7 +169,7 @@ } \ } #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC5843 -include "peripherals/hmc5843.h" +#include "peripherals/hmc5843.h" #define foo_handler() {} #define ImuMagEvent(_mag_handler) { \ MagEvent(foo_handler); \ diff --git a/sw/ground_segment/multimon/Makefile b/sw/ground_segment/multimon/Makefile index 45e235386e..d7c9d2988b 100644 --- a/sw/ground_segment/multimon/Makefile +++ b/sw/ground_segment/multimon/Makefile @@ -32,7 +32,7 @@ LD =ld LDFLAGS =-lm HOSTCC =gcc CC =gcc -MAKE :=$(MAKE) +MAKE =make CPP =$(CC) -E AR =ar STRIP =strip diff --git a/sw/simulator/nps/nps_autopilot.h b/sw/simulator/nps/nps_autopilot.h index 9e6c5b8438..730c46cce0 100644 --- a/sw/simulator/nps/nps_autopilot.h +++ b/sw/simulator/nps/nps_autopilot.h @@ -13,6 +13,7 @@ extern struct NpsAutopilot autopilot; extern void nps_autopilot_init(enum NpsRadioControlType type, int num_script, char* js_dev); extern void nps_autopilot_run_step(double time); +extern void nps_autopilot_run_systime_step(void); #endif /* NPS_AUTOPILOT_H */ diff --git a/sw/simulator/nps/nps_autopilot_booz.c b/sw/simulator/nps/nps_autopilot_rotorcraft.c similarity index 92% rename from sw/simulator/nps/nps_autopilot_booz.c rename to sw/simulator/nps/nps_autopilot_rotorcraft.c index 0d085d547a..240e50d75b 100644 --- a/sw/simulator/nps/nps_autopilot_booz.c +++ b/sw/simulator/nps/nps_autopilot_rotorcraft.c @@ -1,4 +1,4 @@ -#include "nps_autopilot_booz.h" +#include "nps_autopilot_rotorcraft.h" #include "firmwares/rotorcraft/main.h" #include "nps_sensors.h" @@ -8,6 +8,7 @@ #include "subsystems/sensors/baro.h" #include "baro_board.h" #include "subsystems/electrical.h" +#include "mcu_periph/sys_time.h" #include "actuators/supervision.h" @@ -32,6 +33,10 @@ void nps_autopilot_init(enum NpsRadioControlType type_rc, int num_rc_script, cha } +void nps_autopilot_run_systime_step( void ) { + sys_tick_handler(); +} + #include #include "subsystems/gps.h" @@ -66,7 +71,7 @@ void nps_autopilot_run_step(double time __attribute__ ((unused))) { sim_overwrite_ahrs(); } - main_periodic(); + handle_periodic_tasks(); if (time < 8) { /* start with a little bit of hovering */ int32_t init_cmd[4]; diff --git a/sw/simulator/nps/nps_autopilot_booz.h b/sw/simulator/nps/nps_autopilot_rotorcraft.h similarity index 100% rename from sw/simulator/nps/nps_autopilot_booz.h rename to sw/simulator/nps/nps_autopilot_rotorcraft.h diff --git a/sw/simulator/nps/nps_main.c b/sw/simulator/nps/nps_main.c index ab04e02f34..900d7ad2d8 100644 --- a/sw/simulator/nps/nps_main.c +++ b/sw/simulator/nps/nps_main.c @@ -54,7 +54,7 @@ void cont_hdl (int n __attribute__ ((unused))) { printf("Press to continue.\n"); } -double time_to_double(timeval *t) { +double time_to_double(struct timeval *t) { return ((double)t->tv_sec + (double)(t->tv_usec * 1e-6)); } @@ -80,7 +80,7 @@ static void nps_main_init(void) { nps_main.sim_time = 0.; nps_main.display_time = 0.; - timeval t; + struct timeval t; gettimeofday (&t, NULL); nps_main.scaled_initial_time = time_to_double(&t); nps_main.host_time_factor = HOST_TIME_FACTOR; @@ -114,6 +114,8 @@ static void nps_main_init(void) { static void nps_main_run_sim_step(void) { // printf("sim at %f\n", nps_main.sim_time); + nps_autopilot_run_systime_step(); + nps_fdm_run_step(autopilot.commands); nps_sensors_run_step(nps_main.sim_time); diff --git a/sw/simulator/sim_ac_fw.c b/sw/simulator/sim_ac_fw.c index 8892722e75..6b3a5bda51 100644 --- a/sw/simulator/sim_ac_fw.c +++ b/sw/simulator/sim_ac_fw.c @@ -78,8 +78,8 @@ void autopilot_init(void) { } void autopilot_periodic_task(void) { - periodic_task_ap(); - periodic_task_fbw(); + handle_periodic_tasks_ap(); + handle_periodic_tasks_fbw(); } void autopilot_event_task(void) { diff --git a/sw/simulator/sim_ac_jsbsim.c b/sw/simulator/sim_ac_jsbsim.c index ee0a565943..57db201604 100644 --- a/sw/simulator/sim_ac_jsbsim.c +++ b/sw/simulator/sim_ac_jsbsim.c @@ -80,6 +80,9 @@ static void sim_init(void) { // main AP init (feed the sensors once before ?) autopilot_init(); + printf("sys_time resolution: %f\n", SYS_TIME_RESOLUTION); + printf("sys_time period in msec: %d\n", SYSTIME_PERIOD); + } static gboolean sim_periodic(gpointer data __attribute__ ((unused))) { @@ -116,6 +119,11 @@ static gboolean sim_periodic(gpointer data __attribute__ ((unused))) { return result; } +static gboolean systime_periodic(gpointer data __attribute__ ((unused))) { + sys_tick_handler(); + return true; +} + int main ( int argc, char** argv) { @@ -129,6 +137,7 @@ int main ( int argc, char** argv) { GMainLoop *ml = g_main_loop_new(NULL, FALSE); g_timeout_add(JSBSIM_PERIOD, sim_periodic, NULL); + g_timeout_add(SYSTIME_PERIOD, systime_periodic, NULL); g_main_loop_run(ml); diff --git a/sw/simulator/sim_ac_jsbsim.h b/sw/simulator/sim_ac_jsbsim.h index 44f3a8c7f5..05baa3087d 100644 --- a/sw/simulator/sim_ac_jsbsim.h +++ b/sw/simulator/sim_ac_jsbsim.h @@ -32,6 +32,7 @@ #include "std.h" #include "generated/airframe.h" #include "generated/flight_plan.h" +#include "mcu_periph/sys_time.h" #include @@ -43,6 +44,8 @@ #endif #define DT (JSBSIM_PERIOD*1e-3) ///< JSBSim timestep in seconds +#define SYSTIME_PERIOD ((uint32_t)(SYS_TIME_RESOLUTION * 1000)) ///< in msec + #define RAD2DEG 57.29578 #define FT2M 0.3048 diff --git a/sw/supervision/paparazzicenter.ml b/sw/supervision/paparazzicenter.ml index 72ca0860a7..308adcf55c 100644 --- a/sw/supervision/paparazzicenter.ml +++ b/sw/supervision/paparazzicenter.ml @@ -207,7 +207,7 @@ let () = let errors = "red", ["error"; "no such file"; "undefined reference"; "failure"] and warnings = "orange", ["warning"] - and info = "green", ["message"; "info"] in + and info = "green", ["pragma message"] in let color_regexps = List.map (fun (color, strings) ->