Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
ppm_arch.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 AggieAir, A Remote Sensing Unmanned Aerial System for Scientific Applications
3  * Utah State University, http://aggieair.usu.edu/
4  *
5  * Michal Podhradsky (michal.podhradsky@aggiemail.usu.edu)
6  * Calvin Coopmans (c.r.coopmans@ieee.org)
7  *
8  *
9  * This file is part of paparazzi.
10  *
11  * paparazzi is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2, or (at your option)
14  * any later version.
15  *
16  * paparazzi is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with paparazzi; see the file COPYING. If not, write to
23  * the Free Software Foundation, 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  */
34 
39 
40 #ifndef PPM_TIMER_FREQUENCY
41 #error "Undefined PPM_TIMER_FREQUENCY"
42 #endif
43 
44 #ifndef PPM_CHANNEL
45 #error "PPM channel undefined"
46 #endif
47 
48 
52 static void icuperiodcb(ICUDriver *icup)
53 {
54  ppm_decode_frame_width(icuGetPeriodX(icup));
55 }
56 
60 static void icuoverflowcb(ICUDriver *icup)
61 {
62  (void)icup;
63  // TODO do something with this ?
64 }
65 
73 static ICUConfig ppm_icucfg = {
74 #if defined PPM_PULSE_TYPE && PPM_PULSE_TYPE == PPM_PULSE_TYPE_POSITIVE
75  ICU_INPUT_ACTIVE_HIGH,
76 #elif defined PPM_PULSE_TYPE && PPM_PULSE_TYPE == PPM_PULSE_TYPE_NEGATIVE
77  ICU_INPUT_ACTIVE_LOW,
78 #else
79 #error "Unknown PPM_PULSE_TYPE"
80 #endif
82  NULL,
86  0,
87  0xFFFFFFFFU
88 };
89 
90 void ppm_arch_init(void)
91 {
95 
96  icuStart(&PPM_TIMER, &ppm_icucfg);
97  icuStartCapture(&PPM_TIMER);
98  icuEnableNotifications(&PPM_TIMER);
99 }
radio_control.h
ppm_data_valid
bool ppm_data_valid
Definition: ppm_arch.c:37
PPM_CHANNEL
#define PPM_CHANNEL
Definition: board.h:447
PPM_TIMER
#define PPM_TIMER
Definition: board.h:448
uint32_t
unsigned long uint32_t
Definition: types.h:18
icuoverflowcb
static void icuoverflowcb(ICUDriver *icup)
PPM Overflow callback.
Definition: ppm_arch.c:60
ppm_cur_pulse
uint8_t ppm_cur_pulse
Definition: ppm_arch.c:35
ppm_last_pulse_time
uint32_t ppm_last_pulse_time
Definition: ppm_arch.c:36
icuperiodcb
static void icuperiodcb(ICUDriver *icup)
PPM Pulse period callback.
Definition: ppm_arch.c:52
timer_rollover_cnt
static uint32_t timer_rollover_cnt
Definition: ppm_arch.c:38
uint8_t
unsigned char uint8_t
Definition: types.h:14
RADIO_CONTROL_NB_CHANNEL
#define RADIO_CONTROL_NB_CHANNEL
Definition: intermcu_ap.h:49
PPM_TIMER_FREQUENCY
#define PPM_TIMER_FREQUENCY
Definition: board.h:446
ppm.h
ppm_arch_init
void ppm_arch_init(void)
Architecture dependant code.
Definition: ppm_arch.c:90
ppm_decode_frame_width
void ppm_decode_frame_width(uint32_t ppm_width)
Decode a PPM frame from last width.
Definition: ppm.c:114
ppm_icucfg
static ICUConfig ppm_icucfg
ICU timer configuration.
Definition: ppm_arch.c:73