mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-26 16:30:07 +08:00
test_baro_board: optionally enable IMU for barometers connected as IMU I2C slaves
- add new configuration option (IMU_INIT) to test_progs Makefile. Example use:
<target name="test_baro_board" board="apogee_1.0">
<subsystem name="imu" type="apogee"/>
<configure name="IMU_INIT" value="1"/>
</target>
- add overridable functions -
test_baro_board_imu_{init,periodic_task,event_task} to the main
test_baro_board program.
- add a new C module with implementation that enables and manages
IMU so that the baro board works as slave
This commit is contained in:
@@ -378,6 +378,9 @@ include $(CFG_SHARED)/baro_board.makefile
|
||||
endif
|
||||
test_baro_board.CFLAGS += $(BARO_BOARD_CFLAGS)
|
||||
test_baro_board.srcs += $(BARO_BOARD_SRCS)
|
||||
ifeq ($(IMU_INIT),1)
|
||||
test_baro_board.srcs += test/test_baro_board_imu.c
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -39,10 +39,32 @@
|
||||
#define ABI_C
|
||||
#include "subsystems/abi.h"
|
||||
|
||||
#include "test_baro_board_imu.h"
|
||||
|
||||
static inline void main_init(void);
|
||||
static inline void main_periodic_task(void);
|
||||
static inline void main_event_task(void);
|
||||
|
||||
|
||||
|
||||
__attribute__((weak)) void test_baro_board_imu_init(void)
|
||||
{
|
||||
/* Optionally, to be overriden by board specific code */
|
||||
}
|
||||
|
||||
|
||||
__attribute__((weak)) void test_baro_board_imu_periodic_task(void)
|
||||
{
|
||||
/* Optionally, to be overriden by board specific code */
|
||||
}
|
||||
|
||||
|
||||
__attribute__((weak)) void test_baro_board_imu_event_task(void)
|
||||
{
|
||||
/* Optionally, to be overriden by board specific code */
|
||||
}
|
||||
|
||||
|
||||
#ifndef BARO_PERIODIC_FREQUENCY
|
||||
#define BARO_PERIODIC_FREQUENCY 50
|
||||
#endif
|
||||
@@ -90,6 +112,7 @@ static inline void main_init(void)
|
||||
mcu_init();
|
||||
sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
|
||||
downlink_init();
|
||||
test_baro_board_imu_init();
|
||||
baro_init();
|
||||
|
||||
baro_tid = sys_time_register_timer(1. / BARO_PERIODIC_FREQUENCY, NULL);
|
||||
@@ -101,10 +124,12 @@ static inline void main_periodic_task(void)
|
||||
{
|
||||
LED_PERIODIC();
|
||||
RunOnceEvery(256, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);});
|
||||
test_baro_board_imu_periodic_task();
|
||||
}
|
||||
|
||||
static inline void main_event_task(void)
|
||||
{
|
||||
mcu_event();
|
||||
test_baro_board_imu_event_task();
|
||||
BaroEvent();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Braiins Systems <jan.capek@braiins.cz>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi 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 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi 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 paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* IMU initialization functions for boards where barometer is an I2C
|
||||
* slave of IMU chip.
|
||||
*
|
||||
*/
|
||||
|
||||
#include BOARD_CONFIG
|
||||
|
||||
#include "mcu_periph/sys_time.h"
|
||||
|
||||
#include "subsystems/imu.h"
|
||||
#include "test_baro_board_imu.h"
|
||||
|
||||
void test_baro_board_imu_init(void)
|
||||
{
|
||||
imu_init();
|
||||
}
|
||||
|
||||
|
||||
void test_baro_board_imu_periodic_task(void)
|
||||
{
|
||||
if (sys_time.nb_sec > 1) {
|
||||
imu_periodic();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_baro_board_imu_event_task(void)
|
||||
{
|
||||
ImuEvent();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Braiins Systems <jan.capek@braiins.cz>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi 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 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi 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 paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the IMU when baro board is IMU slave
|
||||
*/
|
||||
void test_baro_board_imu_init(void);
|
||||
|
||||
/**
|
||||
* Periodic task for IMU subsystem
|
||||
*/
|
||||
void test_baro_board_imu_periodic_task(void);
|
||||
|
||||
/**
|
||||
* Event task for IMU subsystem
|
||||
*/
|
||||
void test_baro_board_imu_event_task(void);
|
||||
Reference in New Issue
Block a user