Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pwm_input_arch.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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
28#include "mcu_periph/pwm_input_arch.h"
30#include "mcu_periph/gpio.h"
31#include <hal.h>
32#include BOARD_CONFIG
33
34#define ONE_MHZ_CLK 1000000
35
36#ifdef USE_PWM_INPUT1
37static void input1_period_cb(ICUDriver *icup) {
40}
41
42static void input1_width_cb(ICUDriver *icup) {
45}
46
48#if USE_PWM_INPUT1 == PWM_PULSE_TYPE_ACTIVE_LOW
50#elif USE_PWM_INPUT1 == PWM_PULSE_TYPE_ACTIVE_HIGH
52#else
53#error "Unknown PWM_INPUT1_PULSE_TYPE"
54#endif
58 NULL,
60 0,
61 0xFFFFFFFFU
62};
63#endif
64
65#ifdef USE_PWM_INPUT2
66static void input2_period_cb(ICUDriver *icup) {
69}
70
71static void input2_width_cb(ICUDriver *icup) {
74}
75
77#if USE_PWM_INPUT2 == PWM_PULSE_TYPE_ACTIVE_LOW
79#elif USE_PWM_INPUT2 == PWM_PULSE_TYPE_ACTIVE_HIGH
81#else
82#error "Unknown PWM_INPUT2_PULSE_TYPE"
83#endif
87 NULL,
89 0,
90 0xFFFFFFFFU
91};
92#endif
93
95{
96 int i;
97 // initialize the arrays to 0
98 for (i = 0; i < PWM_INPUT_NB; i++) {
103 }
104
105#ifdef USE_PWM_INPUT1
110#endif
111
112#ifdef USE_PWM_INPUT2
117#endif
118
119}
120
#define PWM_INPUT2_GPIO_PORT
Definition board.h:430
#define PWM_INPUT2_GPIO_AF
Definition board.h:432
#define PWM_INPUT2_GPIO_PIN
Definition board.h:431
#define PWM_INPUT2_ICU
Definition board.h:428
#define PWM_INPUT2_CHANNEL
Definition board.h:429
void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output)
Setup a gpio for input or output with alternate function.
Definition gpio_arch.c:65
void pwm_input_init(void)
#define ONE_MHZ_CLK
@ PWM_INPUT1
@ PWM_INPUT_NB
@ PWM_INPUT2
#define PWM_INPUT2_TICKS_PER_USEC
#define PWM_INPUT1_TICKS_PER_USEC
The default pwm counter is set-up to have 1/6 us resolution.
#define PWM_INPUT1_GPIO_PORT
#define PWM_INPUT1_CHANNEL
#define PWM_INPUT1_GPIO_AF
#define PWM_INPUT1_ICU
#define PWM_INPUT1_GPIO_PIN
Some architecture independent helper functions for GPIOs.
uint16_t foo
Definition main_demo5.c:58
volatile uint32_t pwm_input_duty_tics[PWM_INPUT_NB]
Definition pwm_input.c:34
volatile uint8_t pwm_input_period_valid[PWM_INPUT_NB]
Definition pwm_input.c:37
volatile uint8_t pwm_input_duty_valid[PWM_INPUT_NB]
Definition pwm_input.c:35
volatile uint32_t pwm_input_period_tics[PWM_INPUT_NB]
Definition pwm_input.c:36
arch independent PWM input capture API