Paparazzi UAS  v7.0_unstable
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 }
#define PPM_TIMER_FREQUENCY
Definition: board.h:387
#define PPM_CHANNEL
Definition: board.h:388
#define PPM_TIMER
Definition: board.h:389
#define RADIO_CONTROL_NB_CHANNEL
static void icuoverflowcb(ICUDriver *icup)
PPM Overflow callback.
Definition: ppm_arch.c:60
static ICUConfig ppm_icucfg
ICU timer configuration.
Definition: ppm_arch.c:73
uint32_t ppm_last_pulse_time
Definition: ppm_arch.c:36
static uint32_t timer_rollover_cnt
Definition: ppm_arch.c:38
bool ppm_data_valid
Definition: ppm_arch.c:37
static void icuperiodcb(ICUDriver *icup)
PPM Pulse period callback.
Definition: ppm_arch.c:52
void ppm_arch_init(void)
Architecture dependant code.
Definition: ppm_arch.c:90
uint8_t ppm_cur_pulse
Definition: ppm_arch.c:35
void ppm_decode_frame_width(uint32_t ppm_width)
Decode a PPM frame from last width.
Definition: ppm.c:120
Generic interface for radio control modules.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98