Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
geiger_counter.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Martin Mueller <martinmm@pfump.org>
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 "mcu_periph/i2c.h"
30 #include "mcu_periph/uart.h"
31 #include "pprzlink/messages.h"
33 
34 
35 #ifndef GEIGER_CNT_DEV
36 #define GEIGER_CNT_DEV i2c0
37 #endif
38 
39 #define GEIGER_CNT_I2C_ADDR 0x76
40 
44 
46 {
47 }
48 
50 {
52 }
53 
55 {
57  count_geiger_1 = (geiger_trans.buf[3] << 24) |
58  (geiger_trans.buf[2] << 16) |
59  (geiger_trans.buf[1] << 8) |
60  (geiger_trans.buf[0]);
61  count_geiger_2 = (geiger_trans.buf[7] << 24) |
62  (geiger_trans.buf[6] << 16) |
63  (geiger_trans.buf[5] << 8) |
64  (geiger_trans.buf[4]);
65  volt_geiger = (geiger_trans.buf[9] << 8) |
66  (geiger_trans.buf[8]);
68 
69  if (volt_geiger & 0x8000) {
70  volt_geiger &= 0x7FFF;
71  DOWNLINK_SEND_GEIGER_COUNTER(DefaultChannel, DefaultDevice,
73  }
74  }
75 }
geiger_counter_event
void geiger_counter_event(void)
Definition: geiger_counter.c:54
uint16_t
unsigned short uint16_t
Definition: types.h:16
i2c_transaction::buf
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
Definition: i2c.h:122
count_geiger_1
uint32_t count_geiger_1
Definition: geiger_counter.c:42
geiger_counter_init
void geiger_counter_init(void)
Definition: geiger_counter.c:45
uint32_t
unsigned long uint32_t
Definition: types.h:18
volt_geiger
uint16_t volt_geiger
Definition: geiger_counter.c:43
I2CTransSuccess
@ I2CTransSuccess
transaction successfully finished by I2C driver
Definition: i2c.h:57
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
geiger_counter_periodic
void geiger_counter_periodic(void)
Definition: geiger_counter.c:49
i2c_transaction::status
enum I2CTransactionStatus status
Transaction status.
Definition: i2c.h:126
GEIGER_CNT_DEV
#define GEIGER_CNT_DEV
Definition: geiger_counter.c:36
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
geiger_counter.h
count_geiger_2
uint32_t count_geiger_2
Definition: geiger_counter.c:42
GEIGER_CNT_I2C_ADDR
#define GEIGER_CNT_I2C_ADDR
Definition: geiger_counter.c:39
I2CTransDone
@ I2CTransDone
transaction set to done by user level
Definition: i2c.h:59
i2c.h
geiger_trans
struct i2c_transaction geiger_trans
Definition: geiger_counter.c:41
i2c_receive
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:334