Paparazzi UAS  v5.15_devel-99-g2ff7410
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
xtend_rssi.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 The Paparazzi Team
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  */
22 
31 #include "mcu_periph/pwm_input.h"
32 #include "mcu_periph/sys_time.h"
33 
34 
35 #include "mcu_periph/uart.h"
36 #include "pprzlink/messages.h"
38 
39 //from Digi XTend manual
40 #define XTEND_RSSI_PWM_PERIOD_USEC 8320 //rssi pwm period () in sys tics
41 
42 #define XTEND_RSSI_PWM_ARRAY_INDEX (XTEND_RSSI_PWM_INPUT_CHANNEL - 1)
43 
45 {
46 
47  /* get the last duty if valid then reset valid flag (this says if we got another pulse since the last one)
48  calculate the % and dB from the duty using datasheet specs
49  send the %, dB, datalink time
50  */
51 
53  uint8_t duty_percent = 0;
54  uint8_t rssi_dB_fade_margin = 0; //shows dB fade margin above rated minimum sensitivity
55 
57  duty_percent = (duty_tics * 100) / cpu_ticks_of_usec(XTEND_RSSI_PWM_PERIOD_USEC);
58  rssi_dB_fade_margin = (2 * duty_percent + 10) / 3; //not sure if this is right, datasheet isn't very informative
60  }
61  DOWNLINK_SEND_XTEND_RSSI(DefaultChannel, DefaultDevice,
63  &rssi_dB_fade_margin,
64  &duty_percent);
65 }
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
volatile uint32_t pwm_input_duty_tics[PWM_INPUT_NB]
Definition: pwm_input.c:34
arch independent PWM input capture API
volatile uint8_t pwm_input_duty_valid[PWM_INPUT_NB]
Definition: pwm_input.c:35
void xtend_rssi_periodic(void)
Definition: xtend_rssi.c:44
#define XTEND_RSSI_PWM_ARRAY_INDEX
Definition: xtend_rssi.c:42
#define XTEND_RSSI_PWM_PERIOD_USEC
Definition: xtend_rssi.c:40
Architecture independent timing functions.
This measures the rssi pwm signal from a Digi XTend radio modem and sends a message with the info...
unsigned long uint32_t
Definition: types.h:18
uint16_t datalink_time
Definition: sim_ap.c:41
unsigned char uint8_t
Definition: types.h:14
static uint32_t cpu_ticks_of_usec(uint32_t usec)
Definition: sys_time.h:178