Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Data Structures
Data Structure Index
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
m
n
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
humid_dpicco.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2005-2012 The Paparazzi Team
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
31
#include "
modules/meteo/humid_dpicco.h
"
32
33
#include "
mcu_periph/i2c.h
"
34
#include "
led.h
"
35
#include "
mcu_periph/uart.h
"
36
#include "pprzlink/messages.h"
37
#include "
subsystems/datalink/downlink.h
"
38
39
40
#ifndef DPICCO_I2C_DEV
41
#define DPICCO_I2C_DEV i2c0
42
#endif
43
44
#define DPICCO_SLAVE_ADDR 0xF0
45
46
uint16_t
dpicco_val
[2];
47
48
float
dpicco_humid
;
49
float
dpicco_temp
;
50
51
struct
i2c_transaction
dpicco_trans
;
52
53
54
void
dpicco_init
(
void
)
55
{
56
dpicco_trans
.
status
=
I2CTransDone
;
57
}
58
59
void
dpicco_periodic
(
void
)
60
{
61
/* init read */
62
i2c_receive
(&
DPICCO_I2C_DEV
, &
dpicco_trans
,
DPICCO_SLAVE_ADDR
, 4);
63
}
64
65
void
dpicco_event
(
void
)
66
{
67
68
if
(
dpicco_trans
.
status
==
I2CTransSuccess
) {
69
//LED_TOGGLE(2);
70
71
dpicco_val
[0] = (
dpicco_trans
.
buf
[0] << 8) |
dpicco_trans
.
buf
[1];
72
dpicco_val
[1] = (
dpicco_trans
.
buf
[2] << 8) |
dpicco_trans
.
buf
[3];
73
74
dpicco_humid
= (
dpicco_val
[0] *
DPICCO_HUMID_RANGE
) /
DPICCO_HUMID_MAX
;
75
dpicco_temp
= ((
dpicco_val
[1] *
DPICCO_TEMP_RANGE
) /
DPICCO_TEMP_MAX
) +
DPICCO_TEMP_OFFS
;
76
77
DOWNLINK_SEND_DPICCO_STATUS(
DefaultChannel
,
DefaultDevice
, &
dpicco_val
[0], &
dpicco_val
[1], &
dpicco_humid
, &
dpicco_temp
);
78
dpicco_trans
.
status
=
I2CTransDone
;
79
}
80
}
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
dpicco_val
uint16_t dpicco_val[2]
Definition:
humid_dpicco.c:46
humid_dpicco.h
DigiPicco I2C sensor interface.
dpicco_periodic
void dpicco_periodic(void)
Definition:
humid_dpicco.c:59
DPICCO_SLAVE_ADDR
#define DPICCO_SLAVE_ADDR
Definition:
humid_dpicco.c:44
dpicco_trans
struct i2c_transaction dpicco_trans
Definition:
humid_dpicco.c:51
DPICCO_TEMP_RANGE
#define DPICCO_TEMP_RANGE
Definition:
humid_dpicco.h:39
DPICCO_HUMID_MAX
#define DPICCO_HUMID_MAX
Definition:
humid_dpicco.h:35
dpicco_init
void dpicco_init(void)
Definition:
humid_dpicco.c:54
dpicco_event
void dpicco_event(void)
Definition:
humid_dpicco.c:65
I2CTransSuccess
@ I2CTransSuccess
transaction successfully finished by I2C driver
Definition:
i2c.h:57
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
i2c_transaction::status
enum I2CTransactionStatus status
Transaction status.
Definition:
i2c.h:126
led.h
arch independent LED (Light Emitting Diodes) API
DPICCO_HUMID_RANGE
#define DPICCO_HUMID_RANGE
Definition:
humid_dpicco.h:36
i2c_transaction
I2C transaction structure.
Definition:
i2c.h:93
downlink.h
Common code for AP and FBW telemetry.
dpicco_humid
float dpicco_humid
Definition:
humid_dpicco.c:48
I2CTransDone
@ I2CTransDone
transaction set to done by user level
Definition:
i2c.h:59
DefaultChannel
#define DefaultChannel
Definition:
downlink.h:42
DefaultDevice
#define DefaultDevice
Definition:
downlink.h:46
dpicco_temp
float dpicco_temp
Definition:
humid_dpicco.c:49
DPICCO_TEMP_OFFS
#define DPICCO_TEMP_OFFS
Definition:
humid_dpicco.h:40
DPICCO_I2C_DEV
#define DPICCO_I2C_DEV
Definition:
humid_dpicco.c:41
i2c.h
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
DPICCO_TEMP_MAX
#define DPICCO_TEMP_MAX
Definition:
humid_dpicco.h:38
sw
airborne
modules
meteo
humid_dpicco.c
Generated on Tue Feb 1 2022 13:51:16 for Paparazzi UAS by
1.8.17