Move PPM CR registers into #defines, which default to CR2 (previous value)

but can be overridden externally
This commit is contained in:
Allen Ibara
2009-05-22 04:16:14 +00:00
parent 8905f370ae
commit 5b54928e66
2 changed files with 28 additions and 8 deletions
+24 -3
View File
@@ -4,14 +4,35 @@
#include "LPC21xx.h"
#include CONFIG
#ifndef PPM_CRI
#define PPM_CRI TIR_CR2I
#endif
#ifndef PPM_CCR_CRF
#define PPM_CCR_CRF TCCR_CR2_F
#endif
#ifndef PPM_CCR_CRR
#define PPM_CCR_CRR TCCR_CR2_R
#endif
#ifndef PPM_CCR_CRI
#define PPM_CCR_CRI TCCR_CR2_I
#endif
#ifndef PPM_CR
#define PPM_CR T0CR2
#endif
static inline void ppm_init ( void ) {
/* select pin for capture */
PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT;
/* enable capture 0.2 on falling edge + trigger interrupt */
#if defined RADIO_CONTROL_TYPE && RADIO_CONTROL_TYPE == RC_FUTABA
T0CCR = TCCR_CR2_F | TCCR_CR2_I;
T0CCR = PPM_CCR_CRF | PPM_CCR_CRI;
#elif defined RADIO_CONTROL_TYPE && RADIO_CONTROL_TYPE == RC_JR
T0CCR = TCCR_CR2_R | TCCR_CR2_I;
T0CCR = PPM_CCR_CRR | PPM_CCR_CRI;
#else
#error "ppm_hw.h: Unknown RADIO_CONTROL_TYPE"
#endif
@@ -25,7 +46,7 @@ static inline void ppm_init ( void ) {
static uint8_t state = PPM_NB_CHANNEL; \
static uint32_t last; \
\
uint32_t now = T0CR2; \
uint32_t now = PPM_CR; \
uint32_t length = now - last; \
last = now; \
\
+4 -5
View File
@@ -20,9 +20,9 @@ uint32_t sys_time_chrono; /* T0TC ticks */
#ifdef MB_TACHO
#include "mb_tacho.h"
// FIXME : declared the scale interrupt here :(
#define TIMER0_IT_MASK (TIR_CR2I | TIR_MR1I | TIR_CR0I | TIR_CR3I)
#define TIMER0_IT_MASK (PPM_CRI | TIR_MR1I | TIR_CR0I | TIR_CR3I)
#else
#define TIMER0_IT_MASK (TIR_CR2I | TIR_MR1I)
#define TIMER0_IT_MASK (PPM_CRI | TIR_MR1I)
#endif /* MB_TACHO */
#ifdef USE_AMI601
@@ -36,13 +36,12 @@ uint32_t sys_time_chrono; /* T0TC ticks */
void TIMER0_ISR ( void ) {
ISR_ENTRY();
while (T0IR & TIMER0_IT_MASK) {
#ifdef RADIO_CONTROL
if (T0IR&TIR_CR2I) {
if (T0IR&PPM_CRI) {
PPM_ISR();
/* clear interrupt */
T0IR = TIR_CR2I;
T0IR = PPM_CRI;
}
#endif
#ifdef SERVOS_4017