Paparazzi UAS  v5.15_devel-113-g1b57ff1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 };
88 
89 void ppm_arch_init(void)
90 {
94 
95  icuStart(&PPM_TIMER, &ppm_icucfg);
96  icuStartCapture(&PPM_TIMER);
97  icuEnableNotifications(&PPM_TIMER);
98 }
static uint32_t timer_rollover_cnt
Definition: ppm_arch.c:38
#define RADIO_CONTROL_NB_CHANNEL
Definition: intermcu_ap.h:49
uint8_t ppm_cur_pulse
Definition: ppm_arch.c:35
#define PPM_TIMER
Definition: board.h:427
unsigned long uint32_t
Definition: types.h:18
static void icuoverflowcb(ICUDriver *icup)
PPM Overflow callback.
Definition: ppm_arch.c:60
void ppm_arch_init(void)
Architecture dependant code.
Definition: ppm_arch.c:89
uint32_t ppm_last_pulse_time
Definition: ppm_arch.c:36
#define PPM_TIMER_FREQUENCY
Definition: board.h:425
void ppm_decode_frame_width(uint32_t ppm_width)
Decode a PPM frame from last width.
Definition: ppm.c:114
unsigned char uint8_t
Definition: types.h:14
bool ppm_data_valid
Definition: ppm_arch.c:37
#define PPM_CHANNEL
Definition: board.h:426
static void icuperiodcb(ICUDriver *icup)
PPM Pulse period callback.
Definition: ppm_arch.c:52
static ICUConfig ppm_icucfg
ICU timer configuration.
Definition: ppm_arch.c:73