Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
max1168_arch.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
24 
25 #ifndef MAX1168_ARCH_H
26 #define MAX1168_ARCH_H
27 
28 
29 /*
30  MAX1168 SPI ADC connected on SPI1
31  SS on P0.20
32  EOC on P0.16 ( EINT0 )
33 */
34 
35 #include "std.h"
36 #include "LPC21xx.h"
37 #include "interrupt_hw.h"
38 #include "ssp_hw.h"
39 
40 #include "pprz_debug.h"
41 
42 #define MAX1168_ERR_ISR_STATUS 0
43 #define MAX1168_ERR_READ_OVERUN 1
44 #define MAX1168_ERR_SPURIOUS_EOC 2
45 
46 #define MAX1168_SS_PIN 20
47 #define MAX1168_SS_IODIR IO0DIR
48 #define MAX1168_SS_IOSET IO0SET
49 #define MAX1168_SS_IOCLR IO0CLR
50 
51 #define MAX1168_EOC_PIN 16
52 #define MAX1168_EOC_PINSEL PINSEL1
53 #define MAX1168_EOC_PINSEL_BIT 0
54 #define MAX1168_EOC_PINSEL_VAL 1
55 #define MAX1168_EOC_EINT 0
56 
57 #define Max1168Unselect() SetBit(MAX1168_SS_IOSET, MAX1168_SS_PIN)
58 #define Max1168Select() SetBit(MAX1168_SS_IOCLR, MAX1168_SS_PIN)
59 
60 #define Max1168OnSpiInt() { \
61  ASSERT((max1168_status == STA_MAX1168_READING_RES), \
62  DEBUG_MAX_1168, MAX1168_ERR_ISR_STATUS); \
63  /* store convertion result */ \
64  max1168_values[0] = SSPDR; \
65  max1168_values[1] = SSPDR; \
66  max1168_values[2] = SSPDR; \
67  max1168_values[3] = SSPDR; \
68  max1168_values[4] = SSPDR; \
69  max1168_values[5] = SSPDR; \
70  max1168_values[6] = SSPDR; \
71  max1168_values[7] = SSPDR; \
72  SSP_ClearRti(); \
73  SSP_DisableRti(); \
74  SSP_Disable(); \
75  Max1168Unselect(); \
76  max1168_status = STA_MAX1168_DATA_AVAILABLE; \
77  }
78 
79 #endif /* MAX1168_ARCH_H */