Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
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
31#include "generated/airframe.h"
32#include "generated/modules.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
50{
51#ifdef BAT_CHECKER_LED
54#endif
55#ifdef BAT_CHECKER_GPIO
57#endif
58}
59
61{
62
64#ifdef BAT_CHECKER_LED
66#endif
67#ifdef BAT_CHECKER_GPIO
69#endif
70 } else if (electrical.bat_low) {
71#ifdef BAT_CHECKER_LED
73#endif
74#ifdef BAT_CHECKER_GPIO
76#endif
77 } else {
78#ifdef BAT_CHECKER_LED
80#endif
81#ifdef BAT_CHECKER_GPIO
83#endif
84 }
85
86}
void init_bat_checker(void)
Definition bat_checker.c:49
void bat_checker_periodic(void)
Definition bat_checker.c:60
#define BAT_CHECKER_GPIO_ON
Definition bat_checker.c:43
#define BAT_CHECKER_GPIO_OFF
Definition bat_checker.c:46
#define LED_ON(i)
Definition led_hw.h:51
#define LED_INIT(i)
Definition led_hw.h:50
#define LED_OFF(i)
Definition led_hw.h:52
#define LED_TOGGLE(i)
Definition led_hw.h:53
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
static void gpio_toggle(ioportid_t port, uint16_t pin)
Toggle a gpio output to low level.
Definition gpio_arch.h:124
struct Electrical electrical
Definition electrical.c:92
Interface for electrical status: supply voltage, current, battery status, etc.
bool bat_low
battery low status
Definition electrical.h:50
bool bat_critical
battery critical status
Definition electrical.h:51
Some architecture independent helper functions for GPIOs.
arch independent LED (Light Emitting Diodes) API
uint16_t foo
Definition main_demo5.c:58