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
charge_sens.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
28
#include "
modules/meteo/charge_sens.h
"
29
#include "
mcu_periph/i2c.h
"
30
#include "
mcu_periph/uart.h
"
31
#include "pprzlink/messages.h"
32
#include "
subsystems/datalink/downlink.h
"
33
34
35
#ifndef CHARGE_SENS_DEV
36
#define CHARGE_SENS_DEV i2c0
37
#endif
38
39
#define CHARGE_SENS_I2C_ADDR 0x78
40
#define CHARGE_NB 10
41
42
struct
i2c_transaction
charge_trans
;
43
uint16_t
charge
[
CHARGE_NB
];
44
int32_t
charge_cnt
;
45
46
void
charge_sens_init
(
void
)
47
{
48
charge_cnt
= 0;
49
}
50
51
void
charge_sens_periodic
(
void
)
52
{
53
i2c_receive
(&
CHARGE_SENS_DEV
, &
charge_trans
,
CHARGE_SENS_I2C_ADDR
, 2);
54
}
55
56
void
charge_sens_event
(
void
)
57
{
58
if
(
charge_trans
.
status
==
I2CTransSuccess
) {
59
/* read two byte atmosphere charge */
60
charge
[
charge_cnt
] =
charge_trans
.
buf
[1] << 8;
61
charge
[
charge_cnt
] |=
charge_trans
.
buf
[0];
62
charge_trans
.
status
=
I2CTransDone
;
63
64
if
(++
charge_cnt
>=
CHARGE_NB
) {
65
DOWNLINK_SEND_ATMOSPHERE_CHARGE(
DefaultChannel
,
DefaultDevice
,
66
&
charge
[0], &
charge
[1], &
charge
[2], &
charge
[3], &
charge
[4],
67
&
charge
[5], &
charge
[6], &
charge
[7], &
charge
[8], &
charge
[9]);
68
charge_cnt
= 0;
69
}
70
}
71
}
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
charge_sens_init
void charge_sens_init(void)
Definition:
charge_sens.c:46
charge_trans
struct i2c_transaction charge_trans
Definition:
charge_sens.c:42
I2CTransSuccess
@ I2CTransSuccess
transaction successfully finished by I2C driver
Definition:
i2c.h:57
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
CHARGE_NB
#define CHARGE_NB
Definition:
charge_sens.c:40
CHARGE_SENS_I2C_ADDR
#define CHARGE_SENS_I2C_ADDR
Definition:
charge_sens.c:39
charge
uint16_t charge[CHARGE_NB]
Definition:
charge_sens.c:43
i2c_transaction::status
enum I2CTransactionStatus status
Transaction status.
Definition:
i2c.h:126
charge_sens_periodic
void charge_sens_periodic(void)
Definition:
charge_sens.c:51
i2c_transaction
I2C transaction structure.
Definition:
i2c.h:93
downlink.h
Common code for AP and FBW telemetry.
int32_t
signed long int32_t
Definition:
types.h:19
charge_sens_event
void charge_sens_event(void)
Definition:
charge_sens.c:56
I2CTransDone
@ I2CTransDone
transaction set to done by user level
Definition:
i2c.h:59
charge_sens.h
DefaultChannel
#define DefaultChannel
Definition:
downlink.h:42
DefaultDevice
#define DefaultDevice
Definition:
downlink.h:46
i2c.h
CHARGE_SENS_DEV
#define CHARGE_SENS_DEV
Definition:
charge_sens.c:36
charge_cnt
int32_t charge_cnt
Definition:
charge_sens.c:44
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
sw
airborne
modules
meteo
charge_sens.c
Generated on Tue Feb 1 2022 13:51:16 for Paparazzi UAS by
1.8.17