Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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 "armVIC.h"
27 #include BOARD_CONFIG
28 
29 static void EXTINT0_ISR(void) __attribute__((naked));
30 
32 {
33 
34  /* connect P0.16 to extint0 (EOC) */
36  /* extint0 is edge trigered */
37  SetBit(EXTMODE, MAX1168_EOC_EINT);
38  /* extint0 is trigered on falling edge */
39  ClearBit(EXTPOLAR, MAX1168_EOC_EINT);
40  /* clear pending extint0 before enabling interrupts */
41  SetBit(EXTINT, MAX1168_EOC_EINT);
42 
43  /* initialize interrupt vector */
44  VICIntSelect &= ~VIC_BIT(MAX1168_EOC_VIC_IT); // EXTINT0 selected as IRQ
45  VICIntEnable = VIC_BIT(MAX1168_EOC_VIC_IT); // EXTINT0 interrupt enabled
46  _VIC_CNTL(MAX1168_EOC_VIC_SLOT) = VIC_ENABLE | MAX1168_EOC_VIC_IT;
47  _VIC_ADDR(MAX1168_EOC_VIC_SLOT) = (uint32_t)EXTINT0_ISR; // address of the ISR
48 }
49 
50 
51 void EXTINT0_ISR(void)
52 {
53  ISR_ENTRY();
54  //ASSERT((max1168_status == MAX1168_SENDING_REQ), DEBUG_MAX_1168, MAX1168_ERR_SPURIOUS_EOC);
55 
57 
58  //SetBit(EXTINT, MAX1168_EOC_EINT); /* clear extint0 */
59  EXTINT = (1 << MAX1168_EOC_EINT);
60  VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
61 
62  ISR_EXIT();
63 }
#define VICIntSelect
Definition: LPC21xx.h:430
#define MAX1168_EOC_PINSEL_VAL
Definition: booz_1.0.h:136
#define _VIC_CNTL(idx)
Definition: armVIC.h:19
#define EXTMODE
Definition: LPC21xx.h:419
#define MAX1168_EOC_EINT
Definition: booz_1.0.h:137
#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:135
#define MAX1168_EOC_PINSEL
Definition: booz_1.0.h:134
#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:138
static void EXTINT0_ISR(void)
Definition: max1168_arch.c:51
#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