Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
baro_hca.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 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
23#include "sensors/baro_hca.h"
24#include "mcu_periph/i2c.h"
25#include "modules/core/abi.h"
26#include <math.h>
27
28//Messages
29#include "mcu_periph/uart.h"
30#include "pprzlink/messages.h"
32
33
34#define BARO_HCA_ADDR 0xF0
35#define BARO_HCA_MAX_PRESSURE 1100 // mBar
36#define BARO_HCA_MIN_PRESSURE 800 // mBar
37#define BARO_HCA_MAX_OUT 27852 //dec
38#define BARO_HCA_MIN_OUT 1638 //dec
39
40// FIXME
41#ifndef BARO_HCA_SCALE
42#define BARO_HCA_SCALE 1.0
43#endif
44
45// FIXME
46#ifndef BARO_HCA_PRESSURE_OFFSET
47#define BARO_HCA_PRESSURE_OFFSET 101325.0
48#endif
49
50#ifndef BARO_HCA_I2C_DEV
51#define BARO_HCA_I2C_DEV i2c0
52#endif
53
54// Global variables
58
59
61
62void baro_hca_init(void)
63{
64 pBaroRaw = 0;
65 baro_hca_valid = true;
67}
68
69
76
77
79{
80 pBaroRaw = 0;
81 // Get raw altimeter from buffer
83
84 if (pBaroRaw == 0) {
85 baro_hca_valid = false;
86 } else {
87 baro_hca_valid = true;
88 }
89
90
91 if (baro_hca_valid) {
92 //Cut RAW Min and Max
95 }
98 }
99
103 }
105
106 uint16_t foo = 0;
107 float bar = 0;
108#ifdef SENSOR_SYNC_SEND
110#else
112#endif
113
114}
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Main include for ABI (AirBorneInterface).
#define BARO_HCA_SENDER_ID
#define BARO_HCA_MIN_OUT
Definition baro_hca.c:38
void baro_hca_init(void)
Definition baro_hca.c:62
float baro_hca_p
Definition baro_hca.c:57
#define BARO_HCA_PRESSURE_OFFSET
Definition baro_hca.c:47
bool baro_hca_valid
Definition baro_hca.c:56
#define BARO_HCA_I2C_DEV
Definition baro_hca.c:51
#define BARO_HCA_ADDR
Definition baro_hca.c:34
#define BARO_HCA_SCALE
Definition baro_hca.c:42
#define BARO_HCA_MAX_OUT
Definition baro_hca.c:37
void baro_hca_read_event(void)
Definition baro_hca.c:78
uint16_t pBaroRaw
Definition baro_hca.c:55
void baro_hca_read_periodic(void)
Definition baro_hca.c:70
struct i2c_transaction baro_hca_i2c_trans
Definition baro_hca.c:60
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
Definition i2c.h:122
enum I2CTransactionStatus status
Transaction status.
Definition i2c.h:126
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
Definition i2c.c:212
@ I2CTransDone
transaction set to done by user level
Definition i2c.h:59
I2C transaction structure.
Definition i2c.h:93
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
uint16_t foo
Definition main_demo5.c:58
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.