Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
max1168_arch.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
3  * Copyright (C) 2012 Gautier Hattenberger
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
23 #include "peripherals/max1168.h"
24 
25 #include "LPC21xx.h"
26 #include "interrupt_hw.h"
27 #include BOARD_CONFIG
28 
29 static void EXTINT0_ISR(void) __attribute__((naked));
30 
31 void max1168_arch_init( void ) {
32 
33  /* connect P0.16 to extint0 (EOC) */
35  /* extint0 is edge trigered */
36  SetBit(EXTMODE, MAX1168_EOC_EINT);
37  /* extint0 is trigered on falling edge */
38  ClearBit(EXTPOLAR, MAX1168_EOC_EINT);
39  /* clear pending extint0 before enabling interrupts */
40  SetBit(EXTINT, MAX1168_EOC_EINT);
41 
42  /* initialize interrupt vector */
43  VICIntSelect &= ~VIC_BIT( MAX1168_EOC_VIC_IT ); // EXTINT0 selected as IRQ
44  VICIntEnable = VIC_BIT( MAX1168_EOC_VIC_IT ); // EXTINT0 interrupt enabled
45  _VIC_CNTL(MAX1168_EOC_VIC_SLOT) = VIC_ENABLE | MAX1168_EOC_VIC_IT;
46  _VIC_ADDR(MAX1168_EOC_VIC_SLOT) = (uint32_t)EXTINT0_ISR; // address of the ISR
47 }
48 
49 
50 void EXTINT0_ISR(void) {
51  ISR_ENTRY();
52  //ASSERT((max1168_status == MAX1168_SENDING_REQ), DEBUG_MAX_1168, MAX1168_ERR_SPURIOUS_EOC);
53 
55 
56  //SetBit(EXTINT, MAX1168_EOC_EINT); /* clear extint0 */
57  EXTINT = (1<<MAX1168_EOC_EINT);
58  VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
59 
60  ISR_EXIT();
61 }
#define VICIntSelect
Definition: LPC21xx.h:430
#define MAX1168_EOC_PINSEL_VAL
Definition: booz_1.0.h:149
#define _VIC_CNTL(idx)
Definition: armVIC.h:19
#define EXTMODE
Definition: LPC21xx.h:419
#define MAX1168_EOC_EINT
Definition: booz_1.0.h:150
#define _VIC_ADDR(idx)
Definition: armVIC.h:20
#define EXTPOLAR
Definition: LPC21xx.h:420
#define EXTINT
Definition: LPC21xx.h:417
#define MAX1168_EOC_PINSEL_BIT
Definition: booz_1.0.h:148
#define MAX1168_EOC_PINSEL
Definition: booz_1.0.h:147
#define VICVectAddr
Definition: LPC21xx.h:436
unsigned long uint32_t
Definition: types.h:18
void max1168_arch_init(void)
Definition: max1168_arch.c:31
#define MAX1168_EOC_VIC_IT
Definition: booz_1.0.h:151
static void EXTINT0_ISR(void)
Definition: max1168_arch.c:50
#define VIC_BIT(chan)
Definition: lpcVIC.h:105
volatile uint8_t max1168_status
Definition: max1168.c:27
#define ISR_EXIT()
Definition: armVIC.h:61
#define VICIntEnable
Definition: LPC21xx.h:431
#define MAX1168_GOT_EOC
Definition: max1168.h:61
#define ISR_ENTRY()
Definition: armVIC.h:40
#define VIC_ENABLE
Definition: lpcVIC.h:102