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
baro_board.c
Go to the documentation of this file.
1 /* $Id$
2  *
3  * Copyright (C) 2010 The Paparazzi Team
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 
25 
26 #include "generated/airframe.h"
27 #include "led.h"
28 
29 /* threshold >0 && <1023 */
30 #ifndef BOOZ_ANALOG_BARO_THRESHOLD
31 #define BOOZ_ANALOG_BARO_THRESHOLD 850
32 #endif
33 
34 struct Baro baro;
36 
37 
38 void baro_init( void ) {
39 
41 
43  baro.absolute = 0;
44  baro.differential = 0; /* not handled on this board */
45 
46  baro_board.offset = 1023;
48 
51 #ifdef ROTORCRAFT_BARO_LED
52  LED_OFF(ROTORCRAFT_BARO_LED);
53 #endif
54 }
55 
56 void baro_periodic(void) {
57 
60  if (baro.status == BS_UNINITIALIZED) {
61  RunOnceEvery(10, { baro_board_calibrate();});
62  }
63  /* else */
65 }
66 
67 /* decrement offset until adc reading is over a threshold */
70  if (baro_board.value_filtered == 0 && baro_board.offset > 15)
71  baro_board.offset -= 15;
72  else
75 #ifdef ROTORCRAFT_BARO_LED
76  LED_TOGGLE(ROTORCRAFT_BARO_LED);
77 #endif
78  }
79  else {
81 #ifdef ROTORCRAFT_BARO_LED
82  LED_ON(ROTORCRAFT_BARO_LED);
83 #endif
84  }
85 }
86 
87 
88 
89 
struct BaroBoard baro_board
Definition: baro_board.c:35
Definition: baro.h:41
void baro_periodic(void)
Definition: baro_board.c:56
void baro_board_calibrate(void)
Definition: baro_board.c:68
#define LED_ON(i)
Definition: led_hw.h:28
uint8_t av_nb_sample
Definition: adc.h:64
uint16_t offset
Definition: baro_board.h:12
uint32_t sum
Definition: adc.h:61
#define FALSE
Definition: imu_chimu.h:141
uint16_t value_filtered
Definition: baro_board.h:13
int32_t absolute
Definition: baro.h:42
struct Baro baro
Definition: baro_board.c:34
int32_t differential
Definition: baro.h:43
#define BOOZ_ANALOG_BARO_THRESHOLD
Definition: baro_board.c:31
void baro_init(void)
Definition: baro_board.c:38
#define LED_TOGGLE(i)
Definition: led_hw.h:30
#define ADC_CHANNEL_BARO
Definition: booz_1.0.h:124
bool_t data_available
Definition: baro_board.h:14
#define TRUE
Definition: imu_chimu.h:144
static void DACSet(uint16_t x)
Definition: dac_arch.h:7
void adc_buf_channel(uint8_t adc_channel __attribute__((unused)), struct adc_buf *s __attribute__((unused)), uint8_t av_nb_sample __attribute__((unused)))
Required by infrared.c:ir_init()
Definition: jsbsim_ir.c:35
enum BaroStatus status
Definition: baro.h:44
struct adc_buf buf
Definition: baro_board.h:15
#define LED_OFF(i)
Definition: led_hw.h:29
arch independent LED (Light Emitting Diodes) API
#define DEFAULT_AV_NB_SAMPLE
Definition: adc.h:48