diff --git a/conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml b/conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml index 589699bda3..bdafdab212 100644 --- a/conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml +++ b/conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml @@ -46,6 +46,7 @@ + diff --git a/conf/firmwares/lisa_test_progs.makefile b/conf/firmwares/lisa_test_progs.makefile index eecffbceaf..c9e563afed 100644 --- a/conf/firmwares/lisa_test_progs.makefile +++ b/conf/firmwares/lisa_test_progs.makefile @@ -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 diff --git a/sw/airborne/lisa/test/lisa_test_ms2100.c b/sw/airborne/lisa/test/lisa_test_ms2100.c deleted file mode 100644 index 687efe2097..0000000000 --- a/sw/airborne/lisa/test/lisa_test_ms2100.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2010 Antoine Drouin - * - * 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 -#include -#include -#include -#include -#include - -#include BOARD_CONFIG -#include "mcu.h" -#include "mcu_periph/sys_time.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 ); - -static inline void main_spi2_init(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./PERIODIC_FREQUENCY), NULL); - ms2100_init(); - main_spi2_init(); -} - -static inline void main_periodic_task( void ) { - RunOnceEvery(10, - { - DOWNLINK_SEND_BOOT(DefaultChannel, DefaultDevice, &sys_time.nb_sec); - LED_PERIODIC(); - }); - - switch(ms2100_status) { - case MS2100_IDLE: - Ms2100SendReq(); - break; - case MS2100_WAITING_EOC: - if (Ms2100HasEOC()) { - Ms2100ReadRes(); - } - break; - } -} - -static inline void main_event_task( void ) { - if (ms2100_status == MS2100_DATA_AVAILABLE) { - RunOnceEvery(10, { - DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice, - &ms2100_values[0], - &ms2100_values[1], - &ms2100_values[2]); - }); - ms2100_status = MS2100_IDLE; - } -} - -static inline void main_spi2_init( void ) { - - /* set max1168 slave select as output and assert it ( on PB12) */ - GPIOB->BSRR = GPIO_Pin_12; - RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - /* Enable SPI2 Periph clock -------------------------------------------------*/ - RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); - - /* Configure GPIOs: SCK, MISO and MOSI --------------------------------*/ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO , ENABLE); - - - /* Enable SPI_2 DMA clock ---------------------------------------------------*/ - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); - - - -} - diff --git a/sw/airborne/test/peripherals/test_ms2100.c b/sw/airborne/test/peripherals/test_ms2100.c new file mode 100644 index 0000000000..b7a750a6ba --- /dev/null +++ b/sw/airborne/test/peripherals/test_ms2100.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2010 Antoine Drouin + * + * 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; + } +} +