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
baro_board.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2012 Gautier Hattenberger
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
23 /* driver for the analog Barometer Mpxa6115 using ADC ads1114 (16 bits I2C 860SpS max) from Texas instruments
24  * Navarro & Gorraz & Hattenberger
25  */
26 
27 
28 
29 #ifndef BOARDS_UMARIM_BARO_H
30 #define BOARDS_UMARIM_BARO_H
31 
32 
33 #include "std.h"
34 #include "peripherals/ads1114.h"
35 
36 /* There is no differential pressure on the board but
37  * it can be available from an external sensor
38  * */
39 
40 #define BARO_ABS_ADS ads1114_1
41 
42 #define BaroAbs(_ads, _handler) { \
43  if (_ads.data_available) { \
44  baro.absolute = Ads1114GetValue(_ads); \
45  if (baro.status == BS_RUNNING) { \
46  _handler(); \
47  _ads.data_available = FALSE; \
48  } \
49  } \
50 }
51 
52 #ifndef BaroDiff // Allow custom redefinition ?
53 
54 #if USE_BARO_DIFF
55 
56 #ifndef BARO_DIFF_ADS
57 #define BARO_DIFF_ADS ads1114_2
58 #endif
59 #define BaroDiff(_ads, _handler) { \
60  if (_ads.data_available) { \
61  baro.differential = Ads1114GetValue(_ads); \
62  if (baro.status == BS_RUNNING) { \
63  _handler(); \
64  _ads.data_available = FALSE; \
65  } \
66  } \
67 }
68 
69 #else // Not using differential with ADS1114
70 #define BaroDiff(_a, _h) {}
71 #endif
72 
73 #endif // ifndef BaroDiff
74 
75 #define BaroEvent(_b_abs_handler, _b_diff_handler) { \
76  Ads1114Event(); \
77  BaroAbs(BARO_ABS_ADS,_b_abs_handler); \
78  BaroDiff(BARO_DIFF_ADS,_b_diff_handler); \
79 }
80 
81 #endif // BOARDS_UMARIM_BARO_H