Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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
30
#include "
modules/datalink/xtend_rssi.h
"
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"
37
#include "
subsystems/datalink/downlink.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
44
void
xtend_rssi_periodic
(
void
)
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
52
uint32_t
duty_tics =
pwm_input_duty_tics
[
XTEND_RSSI_PWM_ARRAY_INDEX
];
53
uint8_t
duty_percent = 0;
54
uint8_t
rssi_dB_fade_margin = 0;
//shows dB fade margin above rated minimum sensitivity
55
56
if
(
pwm_input_duty_valid
[
XTEND_RSSI_PWM_ARRAY_INDEX
]) {
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
59
pwm_input_duty_valid
[
XTEND_RSSI_PWM_ARRAY_INDEX
] =
false
;
60
}
61
DOWNLINK_SEND_XTEND_RSSI(
DefaultChannel
,
DefaultDevice
,
62
&
datalink_time
,
63
&rssi_dB_fade_margin,
64
&duty_percent);
65
}
cpu_ticks_of_usec
static uint32_t cpu_ticks_of_usec(uint32_t usec)
Definition:
sys_time.h:178
uint32_t
unsigned long uint32_t
Definition:
types.h:18
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
sys_time.h
Architecture independent timing functions.
uint8_t
unsigned char uint8_t
Definition:
types.h:14
downlink.h
Common code for AP and FBW telemetry.
pwm_input.h
arch independent PWM input capture API
xtend_rssi.h
XTEND_RSSI_PWM_ARRAY_INDEX
#define XTEND_RSSI_PWM_ARRAY_INDEX
Definition:
xtend_rssi.c:42
XTEND_RSSI_PWM_PERIOD_USEC
#define XTEND_RSSI_PWM_PERIOD_USEC
Definition:
xtend_rssi.c:40
xtend_rssi_periodic
void xtend_rssi_periodic(void)
Definition:
xtend_rssi.c:44
datalink_time
uint16_t datalink_time
Definition:
sim_ap.c:41
DefaultChannel
#define DefaultChannel
Definition:
downlink.h:42
DefaultDevice
#define DefaultDevice
Definition:
downlink.h:46
pwm_input_duty_tics
volatile uint32_t pwm_input_duty_tics[PWM_INPUT_NB]
Definition:
pwm_input.c:34
pwm_input_duty_valid
volatile uint8_t pwm_input_duty_valid[PWM_INPUT_NB]
Definition:
pwm_input.c:35
sw
airborne
modules
datalink
xtend_rssi.c
Generated on Tue Feb 1 2022 13:51:15 for Paparazzi UAS by
1.8.17