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_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 <math.h>
26 
27 //Messages
28 #include "mcu_periph/uart.h"
29 #include "messages.h"
31 
32 #ifndef DOWNLINK_DEVICE
33 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
34 #endif
35 
36 #define BARO_HCA_ADDR 0xF0
37 #define BARO_HCA_MAX_PRESSURE 1100 // mBar
38 #define BARO_HCA_MIN_PRESSURE 800 // mBar
39 #define BARO_HCA_MAX_OUT 27852 //dec
40 #define BARO_HCA_MIN_OUT 1638 //dec
41 
42 #ifndef BARO_HCA_I2C_DEV
43 #define BARO_HCA_I2C_DEV i2c0
44 #endif
45 
46 // Global variables
49 float baro_hca_p;
50 
51 
53 
54 void baro_hca_init( void ) {
55  pBaroRaw = 0;
58 }
59 
60 
61 void baro_hca_read_periodic( void ) {
64  }
65 }
66 
67 
68 void baro_hca_read_event( void ) {
69  pBaroRaw = 0;
70  // Get raw altimeter from buffer
72 
73  if (pBaroRaw == 0)
75  else
77 
78 
79  if (baro_hca_valid) {
80  //Cut RAW Min and Max
85 
86  }
88 
89  uint16_t foo = 0;
90  float bar = 0;
91 #ifdef SENSOR_SYNC_SEND
92  DOWNLINK_SEND_BARO_ETS(DefaultChannel, DefaultDevice, &pBaroRaw, &foo, &bar)
93 #else
94  RunOnceEvery(10, DOWNLINK_SEND_BARO_ETS(DefaultChannel, DefaultDevice, &pBaroRaw, &foo, &bar));
95 #endif
96 
97 }
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
void baro_hca_read_event(void)
Definition: baro_hca.c:68
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define BARO_HCA_I2C_DEV
Definition: baro_hca.c:43
bool_t baro_hca_valid
Definition: baro_hca.c:48
struct i2c_transaction baro_hca_i2c_trans
Definition: baro_hca.c:52
uint16_t pBaroRaw
Definition: baro_hca.c:47
#define FALSE
Definition: imu_chimu.h:141
#define BARO_HCA_ADDR
Definition: baro_hca.c:36
void baro_hca_init(void)
Definition: baro_hca.c:54
uint16_t foo
Definition: main_demo5.c:54
enum I2CTransactionStatus status
Definition: i2c.h:83
#define TRUE
Definition: imu_chimu.h:144
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:82
#define BARO_HCA_MAX_OUT
Definition: baro_hca.c:39
#define BARO_HCA_MIN_OUT
Definition: baro_hca.c:40
float baro_hca_p
Definition: baro_hca.c:49
void baro_hca_read_periodic(void)
Definition: baro_hca.c:61
bool_t i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Definition: i2c.c:95
Architecture independent I2C (Inter-Integrated Circuit Bus) API.