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
bat_checker.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2012 Thomas Kolb
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
30
#include "
modules/energy/bat_checker.h
"
31
#include "generated/airframe.h"
32
#include "generated/modules.h"
33
#include "
subsystems/electrical.h
"
34
#include "
mcu_periph/gpio.h
"
35
#include "
led.h
"
36
37
#if (!defined BAT_CHECKER_GPIO && !defined BAT_CHECKER_LED)
38
#error You must define BAT_CHECKER_GPIO or BAT_CHECKER_LED in your airframe file.
39
#endif
40
41
// in case GPIO logic is inverted
42
#ifndef BAT_CHECKER_GPIO_ON
43
#define BAT_CHECKER_GPIO_ON gpio_set
44
#endif
45
#ifndef BAT_CHECKER_GPIO_OFF
46
#define BAT_CHECKER_GPIO_OFF gpio_clear
47
#endif
48
49
void
init_bat_checker
(
void
)
50
{
51
#ifdef BAT_CHECKER_LED
52
LED_INIT
(BAT_CHECKER_LED);
53
LED_OFF
(BAT_CHECKER_LED);
54
#endif
55
#ifdef BAT_CHECKER_GPIO
56
gpio_setup_output
(BAT_CHECKER_GPIO);
57
#endif
58
}
59
60
void
bat_checker_periodic
(
void
)
61
{
62
63
if
(
electrical
.
bat_critical
) {
64
#ifdef BAT_CHECKER_LED
65
LED_ON
(BAT_CHECKER_LED);
66
#endif
67
#ifdef BAT_CHECKER_GPIO
68
BAT_CHECKER_GPIO_ON
(BAT_CHECKER_GPIO);
69
#endif
70
}
else
if
(
electrical
.
bat_low
) {
71
#ifdef BAT_CHECKER_LED
72
LED_TOGGLE
(BAT_CHECKER_LED);
73
#endif
74
#ifdef BAT_CHECKER_GPIO
75
gpio_toggle
(BAT_CHECKER_GPIO);
76
#endif
77
}
else
{
78
#ifdef BAT_CHECKER_LED
79
LED_OFF
(BAT_CHECKER_LED);
80
#endif
81
#ifdef BAT_CHECKER_GPIO
82
BAT_CHECKER_GPIO_OFF
(BAT_CHECKER_GPIO);
83
#endif
84
}
85
86
}
electrical.h
LED_OFF
#define LED_OFF(i)
Definition:
led_hw.h:52
gpio_setup_output
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition:
gpio_arch.c:33
LED_ON
#define LED_ON(i)
Definition:
led_hw.h:51
LED_TOGGLE
#define LED_TOGGLE(i)
Definition:
led_hw.h:53
LED_INIT
#define LED_INIT(i)
Definition:
led_hw.h:50
BAT_CHECKER_GPIO_ON
#define BAT_CHECKER_GPIO_ON
Definition:
bat_checker.c:43
Electrical::bat_low
bool bat_low
battery low status
Definition:
electrical.h:49
bat_checker_periodic
void bat_checker_periodic(void)
Definition:
bat_checker.c:60
bat_checker.h
led.h
arch independent LED (Light Emitting Diodes) API
gpio_toggle
static void gpio_toggle(ioportid_t port, uint16_t pin)
Toggle a gpio output to low level.
Definition:
gpio_arch.h:118
Electrical::bat_critical
bool bat_critical
battery critical status
Definition:
electrical.h:50
gpio.h
init_bat_checker
void init_bat_checker(void)
Definition:
bat_checker.c:49
electrical
struct Electrical electrical
Definition:
electrical.c:66
BAT_CHECKER_GPIO_OFF
#define BAT_CHECKER_GPIO_OFF
Definition:
bat_checker.c:46
sw
airborne
modules
energy
bat_checker.c
Generated on Tue Feb 1 2022 13:51:15 for Paparazzi UAS by
1.8.17