Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
micromag_hw.c
Go to the documentation of this file.
1 /* PNI micromag3 connected on SPI1 */
2 /*
3  Twisted Logic
4  SS on P0.20
5  RESET on P0.29
6  DRDY on P0.30 ( EINT3 )
7 */
8 
9 /*
10  IMU v3
11  SS on P0.20
12  RESET on P1.21
13  DRDY on P0.15 ( EINT2 )
14 */
15 
16 /*
17  IMU b2
18  SS on P1.28
19  RESET on P1.19
20  DRDY on P0.30 ( EINT3)
21 */
22 
23 #include "micromag.h"
24 
26 
27 static void EXTINT_ISR(void) __attribute__((naked));
28 
29 void micromag_hw_init( void ) {
30 
31  MmUnselect(); /* pin idles high */
32  /* configure SS pin */
33  SetBit(MM_SS_IODIR, MM_SS_PIN); /* pin is output */
34 
35  /* configure RESET pin */
36  SetBit(MM_RESET_IODIR, MM_RESET_PIN); /* pin is output */
37  MmReset(); /* pin idles low */
38 
39  /* configure DRDY pin */
40  /* connected pin to EXINT */
41  MM_DRDY_PINSEL |= MM_DRDY_PINSEL_VAL << MM_DRDY_PINSEL_BIT;
42  SetBit(EXTMODE, MM_DRDY_EINT); /* EINT is edge trigered */
43  SetBit(EXTPOLAR,MM_DRDY_EINT); /* EINT is trigered on rising edge */
44  SetBit(EXTINT,MM_DRDY_EINT); /* clear pending EINT */
45 
46  /* initialize interrupt vector */
47  VICIntSelect &= ~VIC_BIT( MM_DRDY_VIC_IT ); /* select EINT as IRQ source */
48  VICIntEnable = VIC_BIT( MM_DRDY_VIC_IT ); /* enable it */
49  _VIC_CNTL(MICROMAG_DRDY_VIC_SLOT) = VIC_ENABLE | MM_DRDY_VIC_IT;
50  _VIC_ADDR(MICROMAG_DRDY_VIC_SLOT) = (uint32_t)EXTINT_ISR; // address of the ISR
51 
52 }
53 
54 void EXTINT_ISR(void) {
55  ISR_ENTRY();
56  /* no, we won't do anything asynchronously, so just notify */
58  /* clear EINT */
59  //SetBit(EXTINT,MM_DRDY_EINT);
60  EXTINT = (1<<MM_DRDY_EINT);
61  VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
62  ISR_EXIT();
63 }
64 
#define VICIntSelect
Definition: LPC21xx.h:398
void micromag_hw_init(void)
Definition: micromag_hw.c:32
#define MM_GOT_EOC
Definition: micromag.h:17
#define _VIC_CNTL(idx)
Definition: armVIC.h:19
#define MmUnselect()
Definition: micromag_hw.h:26
#define MmReset()
Definition: micromag_hw.h:28
static void EXTINT_ISR(void)
Definition: micromag_hw.c:27
#define EXTMODE
Definition: LPC21xx.h:387
#define _VIC_ADDR(idx)
Definition: armVIC.h:20
#define EXTPOLAR
Definition: LPC21xx.h:388
#define EXTINT
Definition: LPC21xx.h:385
volatile uint8_t micromag_cur_axe
Definition: micromag_hw.c:25
volatile uint8_t micromag_status
Definition: micromag.c:3
#define VICVectAddr
Definition: LPC21xx.h:404
unsigned long uint32_t
Definition: types.h:18
#define VIC_BIT(chan)
Definition: lpcVIC.h:105
unsigned char uint8_t
Definition: types.h:14
#define ISR_EXIT()
Definition: armVIC.h:61
#define VICIntEnable
Definition: LPC21xx.h:399
__attribute__((always_inline))
Definition: i2c_arch.c:35
#define ISR_ENTRY()
Definition: armVIC.h:40
#define VIC_ENABLE
Definition: lpcVIC.h:102