Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
baro_board.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2013 Gautier Hattenberger (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
29#include "std.h"
31#include "peripherals/mpl3115.h"
32
33// to get MPU status
35
36#include "modules/core/abi.h"
37#include "led.h"
38
39// sd-log
40#if APOGEE_BARO_SDLOG
42#include "modules/gps/gps.h"
44#endif
45
46
51#ifndef BARO_BOARD_APOGEE_FREQ
52#define BARO_BOARD_APOGEE_FREQ 5
53#endif
54
59#ifdef BARO_PERIODIC_FREQUENCY
60#define MPL_PRESCALER ((BARO_PERIODIC_FREQUENCY)/BARO_BOARD_APOGEE_FREQ)
61#else
62#ifdef PERIODIC_FREQUENCY
63#define MPL_PRESCALER ((PERIODIC_FREQUENCY)/BARO_BOARD_APOGEE_FREQ)
64#else
65// default: assuming 60Hz for a 5Hz baro update
66#define MPL_PRESCALER 12
67#endif
68#endif
69
71#define BARO_STARTUP_COUNTER (200/(MPL_PRESCALER))
73
75
76void baro_init(void)
77{
79#ifdef BARO_LED
81#endif
83
84#if APOGEE_BARO_SDLOG
86#endif
87
88}
89
90void baro_periodic(void)
91{
92
93 // Baro is slave of the MPU, only start reading it after MPU is configured
95
97 // Run some loops to get correct readings from the adc
100#ifdef BARO_LED
102 if (startup_cnt == 0) {
104 }
105#endif
106 }
107 // Read the sensor
109 }
110}
111
113{
117 float pressure = ((float)apogee_baro.pressure / (1 << 2));
119 float temp = apogee_baro.temperature / 16.0f;
122
123#if APOGEE_BARO_SDLOG
124 if (pprzLogFile != -1) {
126 sdLogWriteLog(pprzLogFile, "APOGEE_BARO: Pres(Pa) Temp(degC) GPS_fix TOW(ms) Week Lat(1e7deg) Lon(1e7deg) HMSL(mm) gpseed(cm/s) course(1e7deg) climb(cm/s)\n");
128 }
129 sdLogWriteLog(pprzLogFile, "apogee_baro: %9.4f %9.4f %d %d %d %d %d %d %d %d %d\n",
130 pressure,temp,
131 gps.fix, gps.tow, gps.week,
134 }
135#endif
136
137
138 }
139}
140
Main include for ABI (AirBorneInterface).
#define BARO_BOARD_SENDER_ID
default onboard baro
void baro_periodic(void)
Definition baro_board.c:90
#define MPL_PRESCALER
Baro periodic prescaler.
Definition baro_board.c:66
struct Mpl3115 apogee_baro
Definition baro_board.c:74
#define BARO_STARTUP_COUNTER
Counter to init ads1114 at startup.
Definition baro_board.c:71
void baro_init(void)
Definition baro_board.c:76
void apogee_baro_event(void)
Definition baro_board.c:112
uint16_t startup_cnt
Definition baro_board.c:72
Common barometric sensor implementation.
#define LED_ON(i)
Definition led_hw.h:51
#define LED_OFF(i)
Definition led_hw.h:52
#define LED_TOGGLE(i)
Definition led_hw.h:53
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
struct GpsState gps
global GPS state
Definition gps.c:74
Device independent GPS code (interface)
uint32_t tow
GPS time of week in ms.
Definition gps.h:109
int32_t hmsl
height above mean sea level (MSL) in mm
Definition gps.h:94
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition gps.h:92
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Definition gps.h:99
struct NedCoor_i ned_vel
speed NED in cm/s
Definition gps.h:96
uint16_t gspeed
norm of 2d ground speed in cm/s
Definition gps.h:97
uint16_t week
GPS week.
Definition gps.h:108
uint8_t fix
status of fix
Definition gps.h:107
int32_t lat
in degrees*1e7
int32_t z
Down.
int32_t lon
in degrees*1e7
struct ImuApogee imu_apogee
Definition imu_apogee.c:86
Driver for the IMU on the Apogee board.
struct Mpu60x0_I2c mpu
Definition imu_apogee.h:51
arch independent LED (Light Emitting Diodes) API
uint16_t foo
Definition main_demo5.c:58
void mpl3115_periodic(struct Mpl3115 *mpl)
Definition mpl3115.c:153
void mpl3115_init(struct Mpl3115 *mpl, struct i2c_periph *i2c_p, uint8_t addr)
Definition mpl3115.c:31
void mpl3115_event(struct Mpl3115 *mpl)
Definition mpl3115.c:107
Driver for the baro MPL3115A2 from Freescale (i2c)
uint32_t pressure
pressure in 1/4 Pascal
Definition mpl3115.h:80
int16_t temperature
temperature in 1/16 degrees Celcius
Definition mpl3115.h:79
#define MPL3115_I2C_ADDR
Definition mpl3115.h:35
volatile bool data_available
data ready flag
Definition mpl3115.h:76
bool initialized
config done flag
Definition mpu60x0.h:149
struct Mpu60x0Config config
Definition mpu60x0_i2c.h:68
FileDes pprzLogFile
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.