[airborne] removed unused and obsolete micromag

if the micromag sensor itself is still needed/used,
update the mag_micromag_fw module to use new spi subsystem
and make it arch/firmware independent
This commit is contained in:
Felix Ruess
2013-03-02 19:00:34 +01:00
parent b9bf2a5778
commit c24e221b6a
8 changed files with 0 additions and 496 deletions
-48
View File
@@ -79,30 +79,6 @@ test_max1168.CFLAGS += -DMAX1168_EOC_VIC_SLOT=11
test_max1168.srcs += peripherals/max1168.c \
$(SRC_ARCH)/peripherals/max1168_arch.c
#
# test MICROMAG
#
test_micromag.ARCHDIR = $(ARCH)
test_micromag.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH)
test_micromag.srcs += $(SRC_BOOZ_TEST)/booz2_test_micromag.c
test_micromag.CFLAGS += -DPERIODIC_FREQUENCY='512.' -DSYS_TIME_LED=1
test_micromag.CFLAGS += -DUSE_LED
test_micromag.srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c $(SRC_ARCH)/armVIC.c
test_micromag.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600
test_micromag.srcs += mcu_periph/uart.c
test_micromag.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
test_micromag.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=UART1
test_micromag.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
#test_micromag.CFLAGS += -I$(BOOZ)
#test_micromag.srcs += pprz_debug.c
test_micromag.CFLAGS += -DMICROMAG_DRDY_VIC_SLOT=12
test_micromag.srcs += micromag.c $(SRC_ARCH)/micromag_hw.c
#
@@ -287,30 +263,6 @@ test_crista.srcs += $(SRC_BOOZ)/booz2_imu_crista.c $(SRC_BOOZ_ARCH)/booz2_imu_cr
#
# test MICROMAG
#
test_micromag2.ARCHDIR = $(ARCH)
test_micromag2.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH)
test_micromag2.srcs += $(SRC_BOOZ_TEST)/booz2_test_micromag_2.c
test_micromag2.CFLAGS += -DMICROMAG_DRDY_VIC_SLOT=12
test_micromag2.CFLAGS += -DPERIODIC_FREQUENCY='50.' -DSYS_TIME_LED=1
test_micromag2.CFLAGS += -DUSE_LED
test_micromag2.srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c $(SRC_ARCH)/armVIC.c
test_micromag2.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600
test_micromag2.srcs += mcu_periph/uart.c
test_micromag2.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
test_micromag2.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=UART1
test_micromag2.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
#
# test IMU b2
#
-64
View File
@@ -1,64 +0,0 @@
/* PNI micromag3 connected on SPI1 */
/*
Twisted Logic
SS on P0.20
RESET on P0.29
DRDY on P0.30 ( EINT3 )
*/
/*
IMU v3
SS on P0.20
RESET on P1.21
DRDY on P0.15 ( EINT2 )
*/
/*
IMU b2
SS on P1.28
RESET on P1.19
DRDY on P0.30 ( EINT3)
*/
#include "micromag.h"
volatile uint8_t micromag_cur_axe;
static void EXTINT_ISR(void) __attribute__((naked));
void micromag_hw_init( void ) {
MmUnselect(); /* pin idles high */
/* configure SS pin */
SetBit(MM_SS_IODIR, MM_SS_PIN); /* pin is output */
/* configure RESET pin */
SetBit(MM_RESET_IODIR, MM_RESET_PIN); /* pin is output */
MmReset(); /* pin idles low */
/* configure DRDY pin */
/* connected pin to EXINT */
MM_DRDY_PINSEL |= MM_DRDY_PINSEL_VAL << MM_DRDY_PINSEL_BIT;
SetBit(EXTMODE, MM_DRDY_EINT); /* EINT is edge trigered */
SetBit(EXTPOLAR,MM_DRDY_EINT); /* EINT is trigered on rising edge */
SetBit(EXTINT,MM_DRDY_EINT); /* clear pending EINT */
/* initialize interrupt vector */
VICIntSelect &= ~VIC_BIT( MM_DRDY_VIC_IT ); /* select EINT as IRQ source */
VICIntEnable = VIC_BIT( MM_DRDY_VIC_IT ); /* enable it */
_VIC_CNTL(MICROMAG_DRDY_VIC_SLOT) = VIC_ENABLE | MM_DRDY_VIC_IT;
_VIC_ADDR(MICROMAG_DRDY_VIC_SLOT) = (uint32_t)EXTINT_ISR; // address of the ISR
}
void EXTINT_ISR(void) {
ISR_ENTRY();
/* no, we won't do anything asynchronously, so just notify */
micromag_status = MM_GOT_EOC;
/* clear EINT */
//SetBit(EXTINT,MM_DRDY_EINT);
EXTINT = (1<<MM_DRDY_EINT);
VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
ISR_EXIT();
}
-93
View File
@@ -1,93 +0,0 @@
#ifndef MICROMAG_HW_H
#define MICROMAG_HW_H
#include <stdlib.h> // for abs
#include "std.h"
#include "LPC21xx.h"
#include "interrupt_hw.h"
#include "ssp_hw.h"
#include BOARD_CONFIG
#include "generated/airframe.h"
#define MM_DIVISOR_128 2
#define MM_DIVISOR_256 3
#define MM_DIVISOR_512 4
#define MM_DIVISOR_1024 5
#define MM_DIVISOR MM_DIVISOR_512
extern volatile uint8_t micromag_cur_axe;
#define MmSelect() SetBit(MM_SS_IOCLR,MM_SS_PIN)
#define MmUnselect() SetBit(MM_SS_IOSET,MM_SS_PIN)
#define MmReset() SetBit(MM_RESET_IOCLR,MM_RESET_PIN)
#define MmSet() SetBit(MM_RESET_IOSET,MM_RESET_PIN)
#define MmOnSpiIt() { \
switch (micromag_status) { \
case MM_SENDING_REQ: \
{ \
/* read dummy control byte reply */ \
uint8_t foo __attribute__ ((unused)) = SSPDR; \
micromag_status = MM_WAITING_EOC; \
MmUnselect(); \
SSP_ClearRti(); \
SSP_DisableRti(); \
SSP_Disable(); \
} \
break; \
case MM_READING_RES: \
{ \
int16_t new_val; \
new_val = SSPDR << 8; \
new_val += SSPDR; \
if (abs(new_val) < 2000) \
micromag_values[micromag_cur_axe] = new_val; \
MmUnselect(); \
SSP_ClearRti(); \
SSP_DisableRti(); \
SSP_Disable(); \
micromag_cur_axe++; \
if (micromag_cur_axe > 2) { \
micromag_cur_axe = 0; \
micromag_status = MM_DATA_AVAILABLE; \
} \
else \
micromag_status = MM_IDLE; \
} \
break; \
} \
}
#define MmSendReq() { \
MmSelect(); \
micromag_status = MM_SENDING_REQ; \
MmSet(); \
SSP_ClearRti(); \
SSP_EnableRti(); \
MmReset(); \
uint8_t control_byte = (micromag_cur_axe+1) << 0 | MM_DIVISOR_1024 << 4; \
SSP_Send(control_byte); \
SSP_Enable(); \
}
#define MmReadRes() { \
micromag_status = MM_READING_RES; \
MmSelect(); \
/* trigger 2 bytes read */ \
SSP_Send(0); \
SSP_Send(0); \
SSP_Enable(); \
SSP_ClearRti(); \
SSP_EnableRti(); \
}
#endif /* MICROMAG_HW_H */
-40
View File
@@ -1,40 +0,0 @@
/*
* Copyright (C) 2008 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.
*
*/
/*
* Simulator hardware implementation of the PNI micromag magnetometer
*/
#include "micromag.h"
void micromag_hw_init( void ) {}
void micromag_read( void ) {}
void micromag_hw_feed_value(VEC* mag) {
micromag_values[0] = mag->ve[0];
micromag_values[1] = mag->ve[1];
micromag_values[2] = mag->ve[2];
micromag_status = MM_DATA_AVAILABLE;
}
-35
View File
@@ -1,35 +0,0 @@
/*
* Copyright (C) 2008 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.
*
*/
/*
* Simulator hardware implementation of the PNI micromag magnetometer
*/
#ifndef MICROMAG_HW_H
#define MICROMAG_HW_H
#include <matrix.h>
extern void micromag_hw_feed_value(VEC* mag);
#endif /* MICROMAG_HW_H */
-170
View File
@@ -1,170 +0,0 @@
/*
* Copyright (C) 2008-2009 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 <inttypes.h>
#include "std.h"
#include "mcu.h"
#include "mcu_periph/sys_time.h"
#include "led.h"
#include "mcu_periph/uart.h"
#include "messages.h"
#include "subsystems/datalink/downlink.h"
#include "interrupt_hw.h"
#include "armVIC.h"
#include "LPC21xx.h"
#include "micromag.h"
static inline void main_init( void );
static inline void main_periodic_task( void );
static inline void main_event_task( void );
static void main_init_ssp(void);
static void SSP_ISR(void) __attribute__((naked));
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);
led_init();
uart1_init_tx();
/* configure SS pin */
SetBit(IO0DIR, 20); /* pin is output */
SetBit(IO0SET, 20);
main_init_ssp();
micromag_init();
mcu_int_enable();
}
static inline void main_periodic_task( void ) {
static uint8_t cnt = 0;
if (micromag_status == MM_IDLE) {
LED_TOGGLE(4);
// uint8_t * tab = &cnt;
// DOWNLINK_SEND_DEBUG(1,tab);
cnt = 0;
MmSendReq();
}
else if (micromag_status == MM_GOT_EOC) {
LED_TOGGLE(2);
MmReadRes();
}
else if (micromag_status == MM_WAITING_EOC) {
cnt++;
if (cnt > 50) {cnt = 0; micromag_status = MM_IDLE;}
}
RunOnceEvery(10, {DOWNLINK_SEND_BOOT(&sys_time.nb_sec);});
}
static inline void main_event_task( void ) {
if (micromag_status == MM_DATA_AVAILABLE) {
LED_TOGGLE(3);
DOWNLINK_SEND_IMU_MAG_RAW(&micromag_values[0],
&micromag_values[1],
&micromag_values[2] );
micromag_status = MM_IDLE;
}
}
/* SSPCR0 settings */
#define SSP_DDS 0x07 << 0 /* data size : 8 bits */
#define SSP_FRF 0x00 << 4 /* frame format : SPI */
#define SSP_CPOL 0x00 << 6 /* clock polarity : data captured on first clock transition */
#define SSP_CPHA 0x00 << 7 /* clock phase : SCK idles low */
#define SSP_SCR 0x0F << 8 /* serial clock rate : divide by 16 */
/* SSPCR1 settings */
#define SSP_LBM 0x00 << 0 /* loopback mode : disabled */
#define SSP_SSE 0x00 << 1 /* SSP enable : disabled */
#define SSP_MS 0x00 << 2 /* master slave mode : master */
#define SSP_SOD 0x00 << 3 /* slave output disable : don't care when master */
#define SSPCR0_VAL (SSP_DDS | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR )
#define SSPCR1_VAL (SSP_LBM | SSP_SSE | SSP_MS | SSP_SOD )
#define SSP_PINSEL1_SCK (2<<2)
#define SSP_PINSEL1_MISO (2<<4)
#define SSP_PINSEL1_MOSI (2<<6)
#define SSP_Enable() SetBit(SSPCR1, SSE);
#define SSP_Disable() ClearBit(SSPCR1, SSE);
#define SSP_EnableRxi() SetBit(SSPIMSC, RXIM)
#define SSP_DisableRxi() ClearBit(SSPIMSC, RXIM)
#define SSP_EnableTxi() SetBit(SSPIMSC, TXIM)
#define SSP_DisableTxi() ClearBit(SSPIMSC, TXIM)
#define SSP_EnableRti() SetBit(SSPIMSC, RTIM);
#define SSP_DisableRti() ClearBit(SSPIMSC, RTIM);
#define SSP_ClearRti() SetBit(SSPICR, RTIC);
#ifndef SSP_VIC_SLOT
#define SSP_VIC_SLOT 7
#endif
static void main_init_ssp(void) {
/* setup pins for SSP (SCK, MISO, MOSI, SSEL) */
PINSEL1 |= SSP_PINSEL1_SCK | SSP_PINSEL1_MISO | SSP_PINSEL1_MOSI;
/* setup SSP */
SSPCR0 = SSPCR0_VAL;;
SSPCR1 = SSPCR1_VAL;
SSPCPSR = 0x02;
/* initialize interrupt vector */
VICIntSelect &= ~VIC_BIT( VIC_SPI1 ); /* SPI1 selected as IRQ */
VICIntEnable = VIC_BIT( VIC_SPI1 ); /* enable it */
_VIC_CNTL(SSP_VIC_SLOT) = VIC_ENABLE | VIC_SPI1;
_VIC_ADDR(SSP_VIC_SLOT) = (uint32_t)SSP_ISR; /* address of the ISR */
}
static void SSP_ISR(void) {
ISR_ENTRY();
MmOnSpiIt();
VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
ISR_EXIT();
}
-18
View File
@@ -1,18 +0,0 @@
#include "micromag.h"
volatile uint8_t micromag_status;
volatile int16_t micromag_values[MM_NB_AXIS];
void micromag_init( void ) {
micromag_hw_init();
uint8_t i;
for (i=0; i<MM_NB_AXIS; i++)
micromag_values[i] = 0;
micromag_status = MM_IDLE;
}
void micromag_reset() {
micromag_status = MM_IDLE;
}
-28
View File
@@ -1,28 +0,0 @@
#ifndef MICROMAG_H
#define MICROMAG_H
#include "std.h"
#define MM_NB_AXIS 3
extern void micromag_init( void );
extern void micromag_read( void );
extern void micromag_reset( void);
#define MM_IDLE 0
#define MM_BUSY 1
#define MM_SENDING_REQ 2
#define MM_WAITING_EOC 3
#define MM_GOT_EOC 4
#define MM_READING_RES 5
#define MM_DATA_AVAILABLE 6
extern volatile uint8_t micromag_status;
extern volatile int16_t micromag_values[MM_NB_AXIS];
extern void micromag_hw_init( void );
#include "micromag_hw.h"
#endif /* MICROMAG_H */