Skip to content

Commit

Permalink
[tests] mag ms2100 peripheral test prog
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Mar 3, 2013
1 parent 9cbc44d commit ece92c0
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 124 deletions.
1 change: 1 addition & 0 deletions conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml
Expand Up @@ -46,6 +46,7 @@
<target name="test_imu_b2_nomag" board="lisa_l_1.1"/>
<target name="test_imu_b2" board="lisa_l_1.1"/>
<target name="test_imu_b2_2" board="lisa_l_1.1"/>
<target name="test_ms2100" board="lisa_l_1.1"/>
<target name="test_rc_spektrum" board="lisa_l_1.1"/>
<target name="test_rc_ppm" board="lisa_l_1.1"/>
<target name="test_adc" board="lisa_l_1.1"/>
Expand Down
16 changes: 14 additions & 2 deletions conf/firmwares/lisa_test_progs.makefile
Expand Up @@ -480,9 +480,21 @@ endif



#
# test ms2100 mag
#
test_ms2100.ARCHDIR = $(ARCH)
test_ms2100.CFLAGS = $(COMMON_TEST_CFLAGS)
test_ms2100.srcs = $(COMMON_TEST_SRCS)
test_ms2100.CFLAGS += $(COMMON_TELEMETRY_CFLAGS)
test_ms2100.srcs += $(COMMON_TELEMETRY_SRCS)



test_ms2100.CFLAGS += -I$(SRC_LISA)
test_ms2100.srcs += test/peripherals/test_ms2100.c
test_ms2100.srcs += peripherals/ms2100.c $(SRC_ARCH)/peripherals/ms2100_arch.c
test_ms2100.CFLAGS += -DUSE_SPI_SLAVE4 -DMS2100_SLAVE_IDX=4 -DMS2100_SPI_DEV=spi2
test_ms2100.CFLAGS += -DUSE_SPI -DSPI_MASTER -DUSE_SPI2
test_ms2100.srcs += mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_arch.c

#
# test hmc5843
Expand Down
122 changes: 0 additions & 122 deletions sw/airborne/lisa/test/lisa_test_ms2100.c

This file was deleted.

81 changes: 81 additions & 0 deletions sw/airborne/test/peripherals/test_ms2100.c
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2010 Antoine Drouin <poinix@gmail.com>
*
* 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.
*/


#include BOARD_CONFIG
#include "mcu.h"
#include "mcu_periph/sys_time.h"
#include "mcu_periph/uart.h"
#include "subsystems/datalink/downlink.h"
#include "peripherals/ms2100.h"
#include "led.h"

static inline void main_init( void );
static inline void main_periodic_task( void );
static inline void main_event_task( void );

int main(void) {
main_init();

while(1) {
if (sys_time_check_and_ack_timer(0))
main_periodic_task();
main_event_task();
}

return 0;
}


static inline void main_init( void ) {
mcu_init();
sys_time_register_timer((1./50), NULL);

ms2100_init(&ms2100, &(MS2100_SPI_DEV), MS2100_SLAVE_IDX);

mcu_int_enable();
}

static inline void main_periodic_task( void ) {
RunOnceEvery(10,
{
DOWNLINK_SEND_BOOT(DefaultChannel, DefaultDevice, &sys_time.nb_sec);
LED_TOGGLE(2);
LED_PERIODIC();
});

ms2100_periodic(&ms2100);

}

static inline void main_event_task( void ) {
ms2100_event(&ms2100);
if (ms2100.status == MS2100_DATA_AVAILABLE) {
RunOnceEvery(10, {
DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice,
&ms2100.data.vect.x,
&ms2100.data.vect.y,
&ms2100.data.vect.z);
});
ms2100.status = MS2100_IDLE;
}
}

0 comments on commit ece92c0

Please sign in to comment.