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
geiger_counter.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2011 Martin Mueller <martinmm@pfump.org>
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 
31 #include "mcu_periph/i2c.h"
32 #include "mcu_periph/uart.h"
33 #include "messages.h"
35 
36 #ifndef DOWNLINK_DEVICE
37 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
38 #endif
39 
40 #ifndef GEIGER_CNT_DEV
41 #define GEIGER_CNT_DEV i2c0
42 #endif
43 
44 #define GEIGER_CNT_I2C_ADDR 0x76
45 
49 
50 void geiger_counter_init( void ) {
51 }
52 
55 }
56 
57 void geiger_counter_event( void ) {
59  count_geiger_1 = (geiger_trans.buf[3] << 24) |
60  (geiger_trans.buf[2] << 16) |
61  (geiger_trans.buf[1] << 8) |
62  (geiger_trans.buf[0]);
63  count_geiger_2 = (geiger_trans.buf[7] << 24) |
64  (geiger_trans.buf[6] << 16) |
65  (geiger_trans.buf[5] << 8) |
66  (geiger_trans.buf[4]);
67  volt_geiger = (geiger_trans.buf[9] << 8) |
68  (geiger_trans.buf[8]);
70 
71  if (volt_geiger & 0x8000) {
72  volt_geiger &= 0x7FFF;
73  DOWNLINK_SEND_GEIGER_COUNTER(DefaultChannel, DefaultDevice,
75  }
76  }
77 }
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define I2CReceive(_p, _t, _s_addr, _len)
Definition: i2c.h:140
void geiger_counter_init(void)
#define GEIGER_CNT_DEV
void geiger_counter_event(void)
uint32_t count_geiger_2
#define GEIGER_CNT_I2C_ADDR
uint32_t count_geiger_1
unsigned long uint32_t
Definition: types.h:18
uint16_t volt_geiger
enum I2CTransactionStatus status
Definition: i2c.h:47
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:46
struct i2c_transaction geiger_trans
void geiger_counter_periodic(void)