mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-28 01:53:48 +08:00
Merge pull request #88 from scdwyer/dev-xtend
Added xtend_rssi module, pwm_meas and pwm_input mcu peripheral for lpc21xx arch
This commit is contained in:
+5
-1
@@ -546,7 +546,11 @@
|
||||
<field name="AOA" type="float" unit="rad"></field>
|
||||
</message>
|
||||
|
||||
<!-- 70 is free -->
|
||||
<message name="XTEND_RSSI" id="70">
|
||||
<field name="datalink_time" type="uint16" unit="s"/>
|
||||
<field name="rssi_fade_margin" type="uint8" unit="dB"/>
|
||||
<field name="duty" type="uint8" unit="%"/>
|
||||
</message>
|
||||
<!-- 71 is free -->
|
||||
<!-- 72 is free -->
|
||||
<!-- 73 is free -->
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
<!-- Currently only available on LPC21xx arch
|
||||
pwm input measurement mcu periph access and init wrapper for other modules
|
||||
For LPC21xx on the TWOG:
|
||||
1 - INPUT CAPTURE CAP0.3 on P0.29 (TWOG ADC5, 5V->3.3V voltage divider)
|
||||
2 - INPUT CAPTURE CAP0.0 on P0.30 (TWOG ADC4, no voltage divider)
|
||||
-->
|
||||
<module name="pwm_meas" dir="core">
|
||||
<header>
|
||||
<file name="pwm_meas.h"/>
|
||||
</header>
|
||||
<init fun="pwm_meas_init()"/>
|
||||
<makefile target="ap">
|
||||
<file name="pwm_meas.c"/>
|
||||
<file name="pwm_input.c" dir="mcu_periph"/>
|
||||
<file_arch name="pwm_input_arch.c" dir="mcu_periph"/>
|
||||
<define name="USE_PWM_INPUT"/> <!-- needed to enable the pwm_input interrupts in sys_time_hw.c -->
|
||||
</makefile>
|
||||
</module>
|
||||
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
<!-- Currently only available on LPC21xx arch
|
||||
Digi Xtend RSSI PWM Module
|
||||
@configure XTEND_RSSI_PWM_INPUT_CHANNEL on which arch dep input the pwm line is connected
|
||||
For LPC21xx on the TWOG:
|
||||
1 - INPUT CAPTURE CAP0.3 on P0.29 (TWOG ADC5, 5V->3.3V voltage divider)
|
||||
2 - INPUT CAPTURE CAP0.0 on P0.30 (TWOG ADC4, no voltage divider)
|
||||
-->
|
||||
<module name="xtend_rssi" dir="datalink">
|
||||
<depend require="pwm_meas.xml"/>
|
||||
<header>
|
||||
<file name="xtend_rssi.h"/>
|
||||
</header>
|
||||
<periodic fun="xtend_rssi_periodic()" freq="0.5"/>
|
||||
<makefile target="ap">
|
||||
<file name="xtend_rssi.c"/>
|
||||
<define name="XTEND_RSSI_PWM_INPUT_CHANNEL" value="$(XTEND_RSSI_PWM_INPUT_CHANNEL)"/> <!-- configure the pwm input to be used in airframe file -->
|
||||
<define name="USE_PWM_INPUT$(XTEND_RSSI_PWM_INPUT_CHANNEL)" value="PWM_PULSE_TYPE_ACTIVE_HIGH"/> <!-- rssi signal is active high -->
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \brief handling of arm7 PWM input using a timer with capture
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mcu_periph/pwm_input_arch.h"
|
||||
|
||||
#include "LPC21xx.h"
|
||||
#include "interrupt_hw.h"
|
||||
|
||||
//UPDATE THESE TO BE MORE ACCESSIBLE AND BE WARY OF EXISTING USAGE
|
||||
//POSSIBLY MAKE MORE INPUTS ACCESSIBLE
|
||||
#ifdef USE_PWM_INPUT1
|
||||
//INPUT CAPTURE CAP0.3 on P0.29
|
||||
#define PWM_INPUT1_PINSEL PINSEL1
|
||||
#define PWM_INPUT1_PINSEL_BIT 26
|
||||
#define PWM_INPUT1_PINSEL_VAL (0x2 << PWM_INPUT1_PINSEL_BIT)
|
||||
#define PWM_INPUT1_PINSEL_MASK (0x3 <<PWM_INPUT1_PINSEL_BIT)
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT2
|
||||
//INPUT CAPTURE CAP0.0 on P0.30
|
||||
#define PWM_INPUT2_PINSEL PINSEL1
|
||||
#define PWM_INPUT2_PINSEL_BIT 28
|
||||
#define PWM_INPUT2_PINSEL_VAL (0x3 << PWM_INPUT2_PINSEL_BIT)
|
||||
#define PWM_INPUT2_PINSEL_MASK (0x3 <<PWM_INPUT2_PINSEL_BIT)
|
||||
#endif
|
||||
|
||||
void pwm_input_init ( void )
|
||||
{
|
||||
// initialize the arrays to 0 to avoid junk
|
||||
for (int i=0; i < PWM_INPUT_NB; i++)
|
||||
{
|
||||
pwm_input_duty_tics[i] = 0;
|
||||
pwm_input_duty_valid[i] = 0;
|
||||
pwm_input_period_tics[i] = 0;
|
||||
pwm_input_period_valid[i] = 0;
|
||||
}
|
||||
/* select pin for capture */
|
||||
#ifdef USE_PWM_INPUT1
|
||||
PWM_INPUT1_PINSEL = (PWM_INPUT1_PINSEL & ~PWM_INPUT1_PINSEL_MASK) | PWM_INPUT1_PINSEL_VAL;
|
||||
//enable capture 0.3 on rising edge + trigger interrupt
|
||||
T0CCR |= TCCR_CR3_R | TCCR_CR3_I;
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT2
|
||||
PWM_INPUT2_PINSEL = (PWM_INPUT2_PINSEL & ~PWM_INPUT2_PINSEL_MASK) | PWM_INPUT2_PINSEL_VAL;
|
||||
//enable capture 0.0 on rising edge + trigger interrupt
|
||||
T0CCR |= TCCR_CR0_R | TCCR_CR0_I;
|
||||
#endif
|
||||
}
|
||||
|
||||
//FIXME what about clock time overflow???
|
||||
#ifdef USE_PWM_INPUT1
|
||||
void pwm_input_isr1(void)
|
||||
{
|
||||
static uint32_t t_rise;
|
||||
static uint32_t t_fall;
|
||||
#if USE_PWM_INPUT1 == PWM_PULSE_TYPE_ACTIVE_HIGH
|
||||
static uint32_t t_oldrise = 0;
|
||||
#elif USE_PWM_INPUT1 == PWM_PULSE_TYPE_ACTIVE_LOW
|
||||
static uint32_t t_oldfall = 0;
|
||||
#endif
|
||||
|
||||
if (T0CCR & TCCR_CR3_F) {
|
||||
t_fall = T0CR3;
|
||||
T0CCR |= TCCR_CR3_R;
|
||||
T0CCR &= ~TCCR_CR3_F;
|
||||
#if USE_PWM_INPUT1 == PWM_PULSE_TYPE_ACTIVE_HIGH
|
||||
pwm_input_duty_tics[0] = t_fall - t_rise;
|
||||
pwm_input_duty_valid[0] = TRUE;
|
||||
#elif USE_PWM_INPUT1 == PWM_PULSE_TYPE_ACTIVE_LOW
|
||||
pwm_input_period_tics[0] = t_fall - t_oldfall;
|
||||
pwm_input_period_valid[0] = TRUE;
|
||||
t_oldfall = t_fall;
|
||||
#endif //ACTIVE_HIGH
|
||||
} else if (T0CCR & TCCR_CR3_R) {
|
||||
t_rise = T0CR3;
|
||||
T0CCR |= TCCR_CR3_F;
|
||||
T0CCR &= ~TCCR_CR3_R;
|
||||
#if USE_PWM_INPUT1 == PWM_PULSE_TYPE_ACTIVE_LOW
|
||||
pwm_input_duty_tics[0] = t_rise - t_fall;
|
||||
pwm_input_duty_valid[0] = TRUE;
|
||||
#elif USE_PWM_INPUT1 == PWM_PULSE_TYPE_ACTIVE_HIGH
|
||||
pwm_input_period_tics[0] = t_rise - t_oldrise;
|
||||
pwm_input_period_valid[0] = TRUE;
|
||||
t_oldrise = t_rise;
|
||||
#endif //ACTIVE_LOW
|
||||
}
|
||||
}
|
||||
#endif //USE_PWM_INPUT1
|
||||
|
||||
#ifdef USE_PWM_INPUT2
|
||||
void pwm_input_isr2(void)
|
||||
{
|
||||
static uint32_t t_rise;
|
||||
static uint32_t t_fall;
|
||||
#if USE_PWM_INPUT2 == PWM_PULSE_TYPE_ACTIVE_HIGH
|
||||
static uint32_t t_oldrise = 0;
|
||||
#elif USE_PWM_INPUT2 == PWM_PULSE_TYPE_ACTIVE_LOW
|
||||
static uint32_t t_oldfall = 0;
|
||||
#endif
|
||||
|
||||
if (T0CCR & TCCR_CR0_F) {
|
||||
t_fall = T0CR0;
|
||||
T0CCR |= TCCR_CR0_R;
|
||||
T0CCR &= ~TCCR_CR0_F;
|
||||
#if USE_PWM_INPUT2 == PWM_PULSE_TYPE_ACTIVE_HIGH
|
||||
pwm_input_duty_tics[1] = t_fall - t_rise;
|
||||
pwm_input_duty_valid[1] = TRUE;
|
||||
#elif USE_PWM_INPUT2 == PWM_PULSE_TYPE_ACTIVE_LOW
|
||||
pwm_input_period_tics[1] = t_fall - t_oldfall;
|
||||
pwm_input_period_valid[1] = TRUE;
|
||||
t_oldfall = t_fall;
|
||||
#endif //ACTIVE_HIGH
|
||||
} else if (T0CCR & TCCR_CR0_R) {
|
||||
t_rise = T0CR0;
|
||||
T0CCR |= TCCR_CR0_F;
|
||||
T0CCR &= ~TCCR_CR0_R;
|
||||
#if USE_PWM_INPUT2 == PWM_PULSE_TYPE_ACTIVE_LOW
|
||||
pwm_input_duty_tics[1] = t_rise - t_fall;
|
||||
pwm_input_duty_valid[1] = TRUE;
|
||||
#elif USE_PWM_INPUT2 == PWM_PULSE_TYPE_ACTIVE_HIGH
|
||||
pwm_input_period_tics[1] = t_rise - t_oldrise;
|
||||
pwm_input_period_valid[1] = TRUE;
|
||||
t_oldrise = t_rise;
|
||||
#endif //ACTIVE_LOW
|
||||
}
|
||||
}
|
||||
#endif //USE_PWM_INPUT2
|
||||
@@ -0,0 +1,51 @@
|
||||
/* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \brief handling of arm7 PWM input using a timer with capture
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PWM_INPUT_ARCH_H
|
||||
#define PWM_INPUT_ARCH_H
|
||||
|
||||
#include "std.h"
|
||||
#include "LPC21xx.h"
|
||||
#include "interrupt_hw.h"
|
||||
|
||||
#define PWM_INPUT_NB 2 //this is architecture dependent
|
||||
|
||||
#include "mcu_periph/pwm_input.h"
|
||||
|
||||
#ifdef USE_PWM_INPUT1
|
||||
extern void pwm_input_isr1(void);
|
||||
#define PWM_INPUT_IT1 TIR_CR3I
|
||||
#define PWM_INPUT_ISR_1() pwm_input_isr1()
|
||||
#endif //USE_PWM_INPUT1
|
||||
|
||||
#ifdef USE_PWM_INPUT2
|
||||
extern void pwm_input_isr2(void);
|
||||
#define PWM_INPUT_IT2 TIR_CR0I
|
||||
#define PWM_INPUT_ISR_2() pwm_input_isr2()
|
||||
#endif //USE_PWM_INPUT2
|
||||
|
||||
#endif /* PWM_INPUT_ARCH_H */
|
||||
@@ -1,62 +0,0 @@
|
||||
#include "pwm_input.h"
|
||||
|
||||
#include "LPC21xx.h"
|
||||
|
||||
#include "interrupt_hw.h"
|
||||
|
||||
volatile uint32_t pwm_input_duration[PWM_INPUT_NB];
|
||||
volatile uint8_t pwm_input_valid[PWM_INPUT_NB];
|
||||
|
||||
#ifdef USE_PWM_INPUT1
|
||||
/* INPUT CAPTURE CAP0.3 on P0.29 */
|
||||
#define PWM_INPUT1_PINSEL PINSEL1
|
||||
#define PWM_INPUT1_PINSEL_BIT 26
|
||||
#define PWM_INPUT1_PINSEL_VAL (0x2 << PWM_INPUT1_PINSEL_BIT)
|
||||
#define PWM_INPUT1_PINSEL_MASK (0x3 <<PWM_INPUT1_PINSEL_BIT)
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT2
|
||||
/* INPUT CAPTURE CAP0.0 on P0.30 */
|
||||
#define PWM_INPUT2_PINSEL PINSEL1
|
||||
#define PWM_INPUT2_PINSEL_BIT 28
|
||||
#define PWM_INPUT2_PINSEL_VAL (0x3 << PWM_INPUT2_PINSEL_BIT)
|
||||
#define PWM_INPUT2_PINSEL_MASK (0x3 <<PWM_INPUT2_PINSEL_BIT)
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT3
|
||||
/* INPUT CAPTURE CAP0.1 on P0.27 */
|
||||
#define PWM_INPUT3_PINSEL PINSEL1
|
||||
#define PWM_INPUT3_PINSEL_BIT 22
|
||||
#define PWM_INPUT3_PINSEL_VAL (0x2 << PWM_INPUT3_PINSEL_BIT)
|
||||
#define PWM_INPUT3_PINSEL_MASK (0x3 <<PWM_INPUT3_PINSEL_BIT)
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT4
|
||||
/* INPUT CAPTURE CAP0.2 on P0.28 */
|
||||
#define PWM_INPUT4_PINSEL PINSEL1
|
||||
#define PWM_INPUT4_PINSEL_BIT 24
|
||||
#define PWM_INPUT4_PINSEL_VAL (0x2 << PWM_INPUT4_PINSEL_BIT)
|
||||
#define PWM_INPUT4_PINSEL_MASK (0x3 <<PWM_INPUT4_PINSEL_BIT)
|
||||
#endif
|
||||
|
||||
void pwm_input_init ( void )
|
||||
{
|
||||
/* select pin for capture */
|
||||
#ifdef USE_PWM_INPUT1
|
||||
PWM_INPUT1_PINSEL = (PWM_INPUT1_PINSEL & ~PWM_INPUT1_PINSEL_MASK) | PWM_INPUT1_PINSEL_VAL;
|
||||
/* enable capture 0.3 on falling edge + trigger interrupt */
|
||||
T0CCR |= TCCR_CR3_R | TCCR_CR3_I;
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT2
|
||||
PWM_INPUT2_PINSEL = (PWM_INPUT2_PINSEL & ~PWM_INPUT2_PINSEL_MASK) | PWM_INPUT2_PINSEL_VAL;
|
||||
/* enable capture 0.0 on falling edge + trigger interrupt */
|
||||
T0CCR |= TCCR_CR0_R | TCCR_CR0_I;
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT3
|
||||
PWM_INPUT3_PINSEL = (PWM_INPUT3_PINSEL & ~PWM_INPUT3_PINSEL_MASK) | PWM_INPUT3_PINSEL_VAL;
|
||||
/* enable capture 0.1 on falling edge + trigger interrupt */
|
||||
T0CCR |= TCCR_CR1_R | TCCR_CR1_I;
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT4
|
||||
PWM_INPUT4_PINSEL = (PWM_INPUT4_PINSEL & ~PWM_INPUT4_PINSEL_MASK) | PWM_INPUT4_PINSEL_VAL;
|
||||
/* enable capture 0.2 on falling edge + trigger interrupt */
|
||||
T0CCR |= TCCR_CR2_R | TCCR_CR2_I;
|
||||
#endif
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
#ifndef PWM_INPUT_H
|
||||
#define PWM_INPUT_H
|
||||
|
||||
#include "std.h"
|
||||
#include "LPC21xx.h"
|
||||
#include "interrupt_hw.h"
|
||||
|
||||
#define PWM_INPUT_NB 4
|
||||
|
||||
void pwm_input_init ( void );
|
||||
|
||||
/* tracks of length of positive pulse duration */
|
||||
extern volatile uint32_t pwm_input_duration[PWM_INPUT_NB];
|
||||
extern volatile uint8_t pwm_input_valid[PWM_INPUT_NB];
|
||||
|
||||
static inline void pwm_input_isr1()
|
||||
{
|
||||
static uint32_t t_rise;
|
||||
static uint32_t t_fall;
|
||||
|
||||
if (T0CCR & TCCR_CR3_F) {
|
||||
t_fall = T0CR3;
|
||||
T0CCR |= TCCR_CR3_R;
|
||||
T0CCR &= ~TCCR_CR3_F;
|
||||
pwm_input_duration[0] = t_fall - t_rise;
|
||||
pwm_input_valid[0] = TRUE;
|
||||
} else if (T0CCR & TCCR_CR3_R) {
|
||||
t_rise = T0CR3;
|
||||
T0CCR |= TCCR_CR3_F;
|
||||
T0CCR &= ~TCCR_CR3_R;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void pwm_input_isr2()
|
||||
{
|
||||
static uint32_t t_rise;
|
||||
static uint32_t t_fall;
|
||||
|
||||
if (T0CCR & TCCR_CR0_F) {
|
||||
t_fall = T0CR0;
|
||||
T0CCR |= TCCR_CR0_R;
|
||||
T0CCR &= ~TCCR_CR0_F;
|
||||
pwm_input_duration[1] = t_fall - t_rise;
|
||||
pwm_input_valid[1] = TRUE;
|
||||
} else if (T0CCR & TCCR_CR0_R) {
|
||||
t_rise = T0CR0;
|
||||
T0CCR |= TCCR_CR0_F;
|
||||
T0CCR &= ~TCCR_CR0_R;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void pwm_input_isr3()
|
||||
{
|
||||
static uint32_t t_rise;
|
||||
static uint32_t t_fall;
|
||||
|
||||
if (T0CCR & TCCR_CR1_F) {
|
||||
t_fall = T0CR1;
|
||||
T0CCR |= TCCR_CR1_R;
|
||||
T0CCR &= ~TCCR_CR1_F;
|
||||
pwm_input_duration[2] = t_fall - t_rise;
|
||||
pwm_input_valid[2] = TRUE;
|
||||
} else if (T0CCR & TCCR_CR1_R) {
|
||||
t_rise = T0CR1;
|
||||
T0CCR |= TCCR_CR1_F;
|
||||
T0CCR &= ~TCCR_CR1_R;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void pwm_input_isr4()
|
||||
{
|
||||
static uint32_t t_rise;
|
||||
static uint32_t t_fall;
|
||||
|
||||
if (T0CCR & TCCR_CR2_F) {
|
||||
t_fall = T0CR2;
|
||||
T0CCR |= TCCR_CR2_R;
|
||||
T0CCR &= ~TCCR_CR2_F;
|
||||
pwm_input_duration[3] = t_fall - t_rise;
|
||||
pwm_input_valid[3] = TRUE;
|
||||
} else if (T0CCR & TCCR_CR2_R) {
|
||||
t_rise = T0CR2;
|
||||
T0CCR |= TCCR_CR2_F;
|
||||
T0CCR &= ~TCCR_CR2_R;
|
||||
}
|
||||
}
|
||||
|
||||
#define PWM_INPUT_IT1 TIR_CR3I
|
||||
#define PWM_INPUT_IT2 TIR_CR0I
|
||||
#define PWM_INPUT_IT3 TIR_CR1I
|
||||
#define PWM_INPUT_IT4 TIR_CR2I
|
||||
#define PWM_INPUT_ISR_1() pwm_input_isr1()
|
||||
#define PWM_INPUT_ISR_2() pwm_input_isr2()
|
||||
#define PWM_INPUT_ISR_3() pwm_input_isr3()
|
||||
#define PWM_INPUT_ISR_4() pwm_input_isr4()
|
||||
|
||||
#endif /* PWM_INPUT_H */
|
||||
@@ -35,12 +35,13 @@ uint32_t sys_time_chrono; /* T0TC ticks */
|
||||
#endif
|
||||
|
||||
#ifdef USE_PWM_INPUT
|
||||
#include "pwm_input.h"
|
||||
#else
|
||||
#include "mcu_periph/pwm_input.h"
|
||||
#endif
|
||||
#ifndef USE_PWM_INPUT1
|
||||
#define PWM_INPUT_IT1 0x00
|
||||
#endif
|
||||
#ifndef USE_PWM_INPUT2
|
||||
#define PWM_INPUT_IT2 0x00
|
||||
#define PWM_INPUT_IT3 0x00
|
||||
#define PWM_INPUT_IT4 0x00
|
||||
#endif
|
||||
|
||||
#ifdef USE_AMI601
|
||||
@@ -64,8 +65,6 @@ uint32_t sys_time_chrono; /* T0TC ticks */
|
||||
MB_TACHO_IT |\
|
||||
PWM_INPUT_IT1 |\
|
||||
PWM_INPUT_IT2 |\
|
||||
PWM_INPUT_IT3 |\
|
||||
PWM_INPUT_IT4 |\
|
||||
AMI601_IT)
|
||||
|
||||
void TIMER0_ISR ( void ) {
|
||||
@@ -125,18 +124,6 @@ LED_TOGGLE(3);
|
||||
T0IR = PWM_INPUT_IT2;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT3
|
||||
if (T0IR&PWM_INPUT_IT3) {
|
||||
PWM_INPUT_ISR_3();
|
||||
T0IR = PWM_INPUT_IT3;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_PWM_INPUT4
|
||||
if (T0IR&PWM_INPUT_IT4) {
|
||||
PWM_INPUT_ISR_4();
|
||||
T0IR = PWM_INPUT_IT4;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_AMI601
|
||||
if (T0IR&AMI601_IT) {
|
||||
AMI601_ISR();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Paparazzi $Id$
|
||||
*
|
||||
* Copyright (C) 2011 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file mcu_periph/pwm_input.c
|
||||
* \brief arch independent PWM input capture API */
|
||||
|
||||
#include "std.h"
|
||||
#include "mcu_periph/pwm_input.h"
|
||||
|
||||
volatile uint32_t pwm_input_duty_tics[PWM_INPUT_NB];
|
||||
volatile uint8_t pwm_input_duty_valid[PWM_INPUT_NB];
|
||||
volatile uint32_t pwm_input_period_tics[PWM_INPUT_NB];
|
||||
volatile uint8_t pwm_input_period_valid[PWM_INPUT_NB];
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Paparazzi $Id$
|
||||
*
|
||||
* Copyright (C) 2011 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file mcu_periph/pwm_input.h
|
||||
* \brief arch independent PWM input capture API */
|
||||
|
||||
|
||||
#ifndef PWM_INPUT_H
|
||||
#define PWM_INPUT_H
|
||||
|
||||
#ifdef USE_PWM_INPUT
|
||||
|
||||
#include "std.h"
|
||||
#include "mcu_periph/pwm_input_arch.h"
|
||||
|
||||
#define PWM_PULSE_TYPE_ACTIVE_HIGH 0
|
||||
#define PWM_PULSE_TYPE_ACTIVE_LOW 1
|
||||
|
||||
extern volatile uint32_t pwm_input_duty_tics[PWM_INPUT_NB];
|
||||
extern volatile uint8_t pwm_input_duty_valid[PWM_INPUT_NB];
|
||||
extern volatile uint32_t pwm_input_period_tics[PWM_INPUT_NB];
|
||||
extern volatile uint8_t pwm_input_period_valid[PWM_INPUT_NB];
|
||||
|
||||
extern void pwm_input_init(void);
|
||||
|
||||
#endif /* USE_PWM_INPUT */
|
||||
|
||||
#endif /* PWM_INPUT_H */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file pwm_meas.c
|
||||
*
|
||||
* Wrapper to access pwm_input mcu peripheral from other modules
|
||||
*/
|
||||
|
||||
|
||||
#include "modules/core/pwm_meas.h"
|
||||
#include "mcu_periph/pwm_input.h"
|
||||
#include "sys_time.h"
|
||||
|
||||
void pwm_meas_init( void )
|
||||
{
|
||||
pwm_input_init();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file pwm_meas.h
|
||||
*
|
||||
* Wrapper to access pwm_input mcu peripheral from other modules
|
||||
*/
|
||||
|
||||
#ifndef PWM_MEAS_H
|
||||
#define PWM_MEAS_H
|
||||
|
||||
void pwm_meas_init( void );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file xtend_rssi.c
|
||||
*
|
||||
* This measures the rssi pwm signal from a Digi XTend radio modem
|
||||
* and sends a message with the info.
|
||||
*/
|
||||
|
||||
|
||||
#include "modules/datalink/xtend_rssi.h"
|
||||
#include "mcu_periph/pwm_input.h"
|
||||
#include "sys_time.h"
|
||||
|
||||
#ifndef DOWNLINK_DEVICE
|
||||
#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
|
||||
#endif
|
||||
|
||||
#include "mcu_periph/uart.h"
|
||||
#include "messages.h"
|
||||
#include "downlink.h"
|
||||
|
||||
//from Digi XTend manual
|
||||
#define XTEND_RSSI_PWM_PERIOD_USEC 8320 //rssi pwm period () in sys tics
|
||||
|
||||
#define XTEND_RSSI_PWM_ARRAY_INDEX (XTEND_RSSI_PWM_INPUT_CHANNEL - 1)
|
||||
|
||||
void xtend_rssi_periodic( void ) {
|
||||
|
||||
/* get the last duty if valid then reset valid flag (this says if we got another pulse since the last one)
|
||||
calculate the % and dB from the duty using datasheet specs
|
||||
send the %, dB, datalink time
|
||||
*/
|
||||
|
||||
uint32_t duty_tics = pwm_input_duty_tics[XTEND_RSSI_PWM_ARRAY_INDEX];
|
||||
uint8_t duty_percent = 0;
|
||||
uint8_t rssi_dB_fade_margin = 0; //shows dB fade margin above rated minimum sensitivity
|
||||
|
||||
if (pwm_input_duty_valid[XTEND_RSSI_PWM_ARRAY_INDEX])
|
||||
{
|
||||
duty_percent = (duty_tics * 100) / SYS_TICS_OF_USEC(XTEND_RSSI_PWM_PERIOD_USEC);
|
||||
rssi_dB_fade_margin = (2 * duty_percent + 10) / 3; //not sure if this is right, datasheet isn't very informative
|
||||
pwm_input_duty_valid[XTEND_RSSI_PWM_ARRAY_INDEX] = FALSE;
|
||||
}
|
||||
DOWNLINK_SEND_XTEND_RSSI(DefaultChannel,
|
||||
&datalink_time,
|
||||
&rssi_dB_fade_margin,
|
||||
&duty_percent );
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file xtend_rssi.h
|
||||
*
|
||||
* This measures the rssi pwm signal from a Digi XTend radio modem
|
||||
* and sends a message with the info.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef XTEND_RSSI_H
|
||||
#define XTEND_RSSI_H
|
||||
|
||||
void xtend_rssi_periodic( void );
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user