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
temp_tcouple_adc.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2011 Martin Mueller
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 "
mcu_periph/adc.h
"
32
#include "
mcu_periph/uart.h
"
33
#include "pprzlink/messages.h"
34
#include "
subsystems/datalink/downlink.h
"
35
#include "
modules/meteo/temp_tcouple_adc.h
"
36
37
#ifndef ADC_CHANNEL_TEMP_REF
38
#define ADC_CHANNEL_TEMP_REF ADC_4
39
#endif
40
#ifndef ADC_CHANNEL_TEMP_VAL
41
#define ADC_CHANNEL_TEMP_VAL ADC_3
42
#endif
43
44
#ifndef ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES
45
#define ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES 16
46
#endif
47
48
49
uint16_t
ref
[
TCOUPLE_NB
],
val
[
TCOUPLE_NB
];
50
float
fref
[
TCOUPLE_NB
],
fval
[
TCOUPLE_NB
];
51
int32_t
temp_cnt
;
52
53
static
struct
adc_buf
buf_temp_tcouple_ref
;
54
static
struct
adc_buf
buf_temp_tcouple_val
;
55
56
void
temp_tcouple_adc_init
(
void
)
57
{
58
adc_buf_channel
(
ADC_CHANNEL_TEMP_REF
,
59
&
buf_temp_tcouple_ref
,
60
ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES
);
61
adc_buf_channel
(
ADC_CHANNEL_TEMP_VAL
,
62
&
buf_temp_tcouple_val
,
63
ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES
);
64
temp_cnt
= 0;
65
}
66
67
void
temp_tcouple_adc_periodic
(
void
)
68
{
69
val
[
temp_cnt
] =
buf_temp_tcouple_val
.
sum
/
buf_temp_tcouple_val
.
av_nb_sample
;
70
ref
[
temp_cnt
] =
buf_temp_tcouple_ref
.
sum
/
buf_temp_tcouple_ref
.
av_nb_sample
;
71
72
/* no voltage divider, 10 bits adc, 3.3V max */
73
/* T = U * 52.288899706 - 7.977784737996595 */
74
fval
[
temp_cnt
] = ((float)(
val
[
temp_cnt
] * 3.3) / 1023.)
75
* 52.288899706 - 7.977784737996595;
76
fref
[
temp_cnt
] = ((float)(
ref
[
temp_cnt
] * 3.3) / 1023.)
77
* 100. - 13.;
78
79
if
(++
temp_cnt
>=
TCOUPLE_NB
) {
80
DOWNLINK_SEND_TEMP_TCOUPLE(
DefaultChannel
,
DefaultDevice
,
81
&
fval
[0], &
fval
[1], &
fval
[2], &
fval
[3],
82
&
fref
[0], &
fref
[1], &
fref
[2], &
fref
[3],
83
&
val
[0], &
val
[1], &
val
[2], &
val
[3],
84
&
ref
[0], &
ref
[1], &
ref
[2], &
ref
[3]);
85
temp_cnt
= 0;
86
}
87
}
88
uint16_t
unsigned short uint16_t
Definition:
types.h:16
val
uint16_t val[TCOUPLE_NB]
Definition:
temp_tcouple_adc.c:49
ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES
#define ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES
Definition:
temp_tcouple_adc.c:45
adc_buf_channel
void adc_buf_channel(uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample)
Link between ChibiOS ADC drivers and Paparazzi adc_buffers.
Definition:
adc_arch.c:289
buf_temp_tcouple_val
static struct adc_buf buf_temp_tcouple_val
Definition:
temp_tcouple_adc.c:54
fref
float fref[TCOUPLE_NB]
Definition:
temp_tcouple_adc.c:50
fval
float fval[TCOUPLE_NB]
Definition:
temp_tcouple_adc.c:50
adc.h
arch independent ADC (Analog to Digital Converter) API
adc_buf::sum
uint32_t sum
Definition:
adc.h:54
ADC_CHANNEL_TEMP_REF
#define ADC_CHANNEL_TEMP_REF
Definition:
temp_tcouple_adc.c:38
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
temp_tcouple_adc_init
void temp_tcouple_adc_init(void)
Definition:
temp_tcouple_adc.c:56
temp_tcouple_adc_periodic
void temp_tcouple_adc_periodic(void)
Definition:
temp_tcouple_adc.c:67
adc_buf::av_nb_sample
uint8_t av_nb_sample
Definition:
adc.h:57
downlink.h
Common code for AP and FBW telemetry.
int32_t
signed long int32_t
Definition:
types.h:19
TCOUPLE_NB
#define TCOUPLE_NB
Definition:
temp_tcouple_adc.h:6
temp_tcouple_adc.h
temp_cnt
int32_t temp_cnt
Definition:
temp_tcouple_adc.c:51
ADC_CHANNEL_TEMP_VAL
#define ADC_CHANNEL_TEMP_VAL
Definition:
temp_tcouple_adc.c:41
ref
uint16_t ref[TCOUPLE_NB]
Definition:
temp_tcouple_adc.c:49
DefaultChannel
#define DefaultChannel
Definition:
downlink.h:42
DefaultDevice
#define DefaultDevice
Definition:
downlink.h:46
buf_temp_tcouple_ref
static struct adc_buf buf_temp_tcouple_ref
Definition:
temp_tcouple_adc.c:53
adc_buf
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition:
adc.h:53
sw
airborne
modules
meteo
temp_tcouple_adc.c
Generated on Tue Feb 1 2022 13:51:16 for Paparazzi UAS by
1.8.17