Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
baro_board.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010 ENAC
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
24
/* driver for the analog Barometer Mpxa6115 using ADC ads1114 (16 bits I2C 860SpS max) from Texas instruments
25
* Navarro & Gorraz & Hattenberger
26
*/
27
28
#include "
std.h
"
29
#include "
baro_board.h
"
30
#include "
subsystems/sensors/baro.h
"
31
#include "
peripherals/mcp355x.h
"
32
#include "
subsystems/abi.h
"
33
#include "
led.h
"
34
45
#ifndef NAVGO_BARO_SENS
46
#define NAVGO_BARO_SENS 0.05298
47
#endif
48
49
#ifndef NAVGO_BARO_OFFSET
50
#define NAVGO_BARO_OFFSET 199229
51
#endif
52
53
/* Counter to init mcp355x at startup */
54
#define BARO_STARTUP_COUNTER 200
55
uint16_t
startup_cnt
;
56
57
void
baro_init
(
void
)
58
{
59
mcp355x_init
();
60
#ifdef BARO_LED
61
LED_OFF
(BARO_LED);
62
#endif
63
startup_cnt
=
BARO_STARTUP_COUNTER
;
64
}
65
66
void
baro_periodic
(
void
)
67
{
68
// Run some loops to get correct readings from the adc
69
if
(
startup_cnt
> 0) {
70
--
startup_cnt
;
71
#ifdef BARO_LED
72
LED_TOGGLE
(BARO_LED);
73
if
(
startup_cnt
== 0) {
74
LED_ON
(BARO_LED);
75
}
76
#endif
77
}
78
// Read the ADC (at 50/4 Hz, conversion time is 68 ms)
79
RunOnceEvery(4,
mcp355x_read
());
80
}
81
82
void
navgo_baro_event
(
void
)
83
{
84
mcp355x_event
();
85
if
(
mcp355x_data_available
) {
86
if
(
startup_cnt
== 0) {
87
// Send data when init phase is done
88
uint32_t
now_ts =
get_sys_time_usec
();
89
float
pressure
=
NAVGO_BARO_SENS
* (
mcp355x_data
+
NAVGO_BARO_OFFSET
);
90
AbiSendMsgBARO_ABS(
BARO_BOARD_SENDER_ID
, now_ts,
pressure
);
91
}
92
mcp355x_data_available
=
false
;
93
}
94
}
mcp355x.h
baro_board.h
uint16_t
unsigned short uint16_t
Definition:
types.h:16
BARO_BOARD_SENDER_ID
#define BARO_BOARD_SENDER_ID
default onboard baro
Definition:
abi_sender_ids.h:33
mcp355x_data_available
bool mcp355x_data_available
Definition:
mcp355x.c:30
LED_OFF
#define LED_OFF(i)
Definition:
led_hw.h:52
abi.h
mcp355x_data
int32_t mcp355x_data
Definition:
mcp355x.c:31
uint32_t
unsigned long uint32_t
Definition:
types.h:18
LED_ON
#define LED_ON(i)
Definition:
led_hw.h:51
LED_TOGGLE
#define LED_TOGGLE(i)
Definition:
led_hw.h:53
baro_init
void baro_init(void)
Definition:
baro_board.c:76
baro_periodic
void baro_periodic(void)
Definition:
baro_board.c:90
get_sys_time_usec
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition:
sys_time_arch.c:68
std.h
mcp355x_init
void mcp355x_init(void)
Definition:
mcp355x.c:36
led.h
arch independent LED (Light Emitting Diodes) API
NAVGO_BARO_SENS
#define NAVGO_BARO_SENS
scale factor to convert raw ADC measurement to pressure in Pascal.
Definition:
baro_board.c:46
baro.h
Bmp085::pressure
int32_t pressure
pressure in Pascal
Definition:
bmp085.h:73
NAVGO_BARO_OFFSET
#define NAVGO_BARO_OFFSET
Definition:
baro_board.c:50
navgo_baro_event
void navgo_baro_event(void)
Definition:
baro_board.c:82
mcp355x_read
void mcp355x_read(void)
Definition:
mcp355x.c:55
mcp355x_event
void mcp355x_event(void)
Definition:
mcp355x.c:60
BARO_STARTUP_COUNTER
#define BARO_STARTUP_COUNTER
Definition:
baro_board.c:54
startup_cnt
uint16_t startup_cnt
Definition:
baro_board.c:72
sw
airborne
boards
navgo
baro_board.c
Generated on Tue Feb 1 2022 13:51:13 for Paparazzi UAS by
1.8.17