Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
dust_gp2y.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2010 Martin Mueller
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
34 #include "mcu_periph/i2c.h"
35 #include "mcu_periph/sys_time.h"
36 #include "mcu_periph/uart.h"
37 #include "messages.h"
39 
43 
45 
46 #ifndef DOWNLINK_DEVICE
47 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
48 #endif
49 
50 #ifndef GP2Y_I2C_DEV
51 #define GP2Y_I2C_DEV i2c0
52 #endif
53 
54 #define GP2Y_SLAVE_ADDR 0xED
55 
56 void dust_gp2y_init( void ) {
58 }
59 
60 void dust_gp2y_periodic( void ) {
63  }
64  else if (dust_gp2y_status == DUST_GP2Y_UNINIT && cpu_time_sec > 1) {
66  }
67 }
68 
69 void dust_gp2y_event( void ) {
71  /* read two byte particle density */
74 
75  /* "just for reference and not for guarantee" */
76  dust_gp2y_density_f = ((dust_gp2y_density / 1024.) * 3.3 * (51. / 33.) - 0.6) * (0.5 / 3.);
77  if (dust_gp2y_density_f < 0)
79 
80  DOWNLINK_SEND_GP2Y_STATUS(DefaultChannel, DefaultDevice, &dust_gp2y_density, &dust_gp2y_density_f);
81 
83  }
84 }
unsigned short uint16_t
Definition: types.h:16
#define GP2Y_I2C_DEV
Definition: dust_gp2y.c:51
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void dust_gp2y_event(void)
Definition: dust_gp2y.c:69
#define I2CReceive(_p, _t, _s_addr, _len)
Definition: i2c.h:140
void dust_gp2y_periodic(void)
Definition: dust_gp2y.c:60
#define DUST_GP2Y_UNINIT
Definition: dust_gp2y.h:6
#define cpu_time_sec
Definition: sys_time.h:64
float dust_gp2y_density_f
Definition: dust_gp2y.c:42
void dust_gp2y_init(void)
Definition: dust_gp2y.c:56
uint16_t dust_gp2y_density
Definition: dust_gp2y.c:41
Architecture independent timing functions.
enum I2CTransactionStatus status
Definition: i2c.h:47
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:46
unsigned char uint8_t
Definition: types.h:14
#define GP2Y_SLAVE_ADDR
Definition: dust_gp2y.c:54
#define DUST_GP2Y_IDLE
Definition: dust_gp2y.h:7
struct i2c_transaction gp2y_trans
Definition: dust_gp2y.c:44
uint8_t dust_gp2y_status
Definition: dust_gp2y.c:40