kept only things for pwm input 1 and 2, 3 and 4 interfere with other resources for regular autopilot usage, can be added later if needed for something, cleaned up files a bit, fixed a couple mistakes (forgot a couple vars and changes on chan2)

This commit is contained in:
Stephen Dwyer
2011-11-08 11:12:29 -07:00
parent 1606b7e058
commit 986580b750
7 changed files with 19 additions and 124 deletions
-5
View File
@@ -196,11 +196,6 @@
<modules>
<load name="infrared_adc.xml"/>
<!-- <load name="pwm_measure.xml"/> -->
<load name="airspeed_adc.xml">
<configure name="ADC_AIRSPEED" value="1"/>
<define name="AIRSPEED_SCALE" value="1"/>
<define name="AIRSPEED_BIAS" value="0"/>
</load>
<load name="xtend_rssi.xml">
<configure name="XTEND_RSSI_PWM_INPUT_CHANNEL" value="1"/>
</load>
+4 -4
View File
@@ -11,14 +11,14 @@
<file name="xtend_rssi.h"/>
</header>
<init fun="xtend_rssi_init()"/>
<periodic fun="xtend_rssi_periodic()" freq="2."/>
<periodic fun="xtend_rssi_periodic()" freq="0.5"/>
<makefile target="ap">
<file name="xtend_rssi.c"/>
<file name="pwm_input.c" dir="mcu_periph"/>
<file_arch name="pwm_input_arch.c" dir="mcu_periph"/>
<define name="XTEND_RSSI_PWM_INPUT_CHANNEL" value="$(XTEND_RSSI_PWM_INPUT_CHANNEL)"/>
<define name="USE_PWM_INPUT"/>
<define name="USE_PWM_INPUT$(XTEND_RSSI_PWM_INPUT_CHANNEL)" value="PWM_PULSE_TYPE_ACTIVE_HIGH"/>
<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"/> <!-- needed to enable the pwm_input interrupts in sys_time_hw.c -->
<define name="USE_PWM_INPUT$(XTEND_RSSI_PWM_INPUT_CHANNEL)" value="PWM_PULSE_TYPE_ACTIVE_HIGH"/> <!-- rssi signal is active high -->
</makefile>
</module>
@@ -46,22 +46,6 @@
#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 )
{
@@ -84,27 +68,19 @@ void pwm_input_init ( void )
//enable capture 0.0 on rising 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 rising 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 rising edge + trigger interrupt
T0CCR |= TCCR_CR2_R | TCCR_CR2_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;
@@ -139,6 +115,11 @@ 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;
@@ -166,4 +147,4 @@ void pwm_input_isr2(void)
#endif //ACTIVE_LOW
}
}
#endif //USE_PWM_INPUT2
#endif //USE_PWM_INPUT2
@@ -32,11 +32,10 @@
#include "LPC21xx.h"
#include "interrupt_hw.h"
#define PWM_INPUT_NB 4 //this is architecture dependent
#define PWM_INPUT_NB 2 //this is architecture dependent
#include "mcu_periph/pwm_input.h"
//FIXME what about clock time overflow???
#ifdef USE_PWM_INPUT1
extern void pwm_input_isr1(void);
#define PWM_INPUT_IT1 TIR_CR3I
@@ -49,64 +48,4 @@ extern void pwm_input_isr2(void);
#define PWM_INPUT_ISR_2() pwm_input_isr2()
#endif //USE_PWM_INPUT2
/*
#ifdef USE_PWM_INPUT3
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;
#if USE_PWM_INPUT3 == PWM_PULSE_TYPE_ACTIVE_LOW
#else
pwm_input_duration[2] = t_fall - t_rise;
pwm_input_valid[2] = TRUE;
#endif //ACTIVE_HIGH
} else if (T0CCR & TCCR_CR1_R) {
t_rise = T0CR1;
T0CCR |= TCCR_CR1_F;
T0CCR &= ~TCCR_CR1_R;
#if USE_PWM_INPUT3 == PWM_PULSE_TYPE_ACTIVE_LOW
pwm_input_duration[2] = t_rise - t_fall;
pwm_input_valid[2] = TRUE;
#endif //ACTIVE_LOW
}
}
#define PWM_INPUT_IT3 TIR_CR1I
#define PWM_INPUT_IT4 TIR_CR2I
#endif //USE_PWM_INPUT3
#ifdef USE_PWM_INPUT4
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;
#if USE_PWM_INPUT4 == PWM_PULSE_TYPE_ACTIVE_LOW
#else
pwm_input_duration[3] = t_fall - t_rise;
pwm_input_valid[3] = TRUE;
#endif //ACTIVE_HIGH
} else if (T0CCR & TCCR_CR2_R) {
t_rise = T0CR2;
T0CCR |= TCCR_CR2_F;
T0CCR &= ~TCCR_CR2_R;
#if USE_PWM_INPUT4 == PWM_PULSE_TYPE_ACTIVE_LOW
pwm_input_duration[3] = t_rise - t_fall;
pwm_input_valid[3] = TRUE;
#endif //ACTIVE_LOW
}
}
#define PWM_INPUT_ISR_3() pwm_input_isr3()
#define PWM_INPUT_ISR_4() pwm_input_isr4()
#endif //USE_PWM_INPUT4
*/
#endif /* PWM_INPUT_ARCH_H */
#endif /* PWM_INPUT_ARCH_H */
-20
View File
@@ -43,12 +43,6 @@ uint32_t sys_time_chrono; /* T0TC ticks */
#ifndef USE_PWM_INPUT2
#define PWM_INPUT_IT2 0x00
#endif
#ifndef USE_PWM_INPUT3
#define PWM_INPUT_IT3 0x00
#endif
#ifndef USE_PWM_INPUT4
#define PWM_INPUT_IT4 0x00
#endif
#ifdef USE_AMI601
#include "peripherals/ami601.h"
@@ -71,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 ) {
@@ -132,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();
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* $Id$
*
* Copyright (C) 2010 2011 Stephen Dwyer, based on windturbine by Martin Mueller
* Copyright (C) 2011 The Paparazzi Team
*
* This file is part of paparazzi.
*
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* $Id$
*
* Copyright (C) 2011 Stephen Dwyer, based on windturbine by Martin Mueller
* Copyright (C) 2011 The Paparazzi Team
*
* This file is part of paparazzi.
*
@@ -35,4 +35,4 @@
void xtend_rssi_init( void );
void xtend_rssi_periodic( void );
#endif
#endif