mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-01 04:46:51 +08:00
Move PPM CR registers into #defines, which default to CR2 (previous value)
but can be overridden externally
This commit is contained in:
@@ -4,14 +4,35 @@
|
|||||||
#include "LPC21xx.h"
|
#include "LPC21xx.h"
|
||||||
#include CONFIG
|
#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 ) {
|
static inline void ppm_init ( void ) {
|
||||||
/* select pin for capture */
|
/* select pin for capture */
|
||||||
PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT;
|
PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT;
|
||||||
/* enable capture 0.2 on falling edge + trigger interrupt */
|
/* enable capture 0.2 on falling edge + trigger interrupt */
|
||||||
#if defined RADIO_CONTROL_TYPE && RADIO_CONTROL_TYPE == RC_FUTABA
|
#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
|
#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
|
#else
|
||||||
#error "ppm_hw.h: Unknown RADIO_CONTROL_TYPE"
|
#error "ppm_hw.h: Unknown RADIO_CONTROL_TYPE"
|
||||||
#endif
|
#endif
|
||||||
@@ -25,7 +46,7 @@ static inline void ppm_init ( void ) {
|
|||||||
static uint8_t state = PPM_NB_CHANNEL; \
|
static uint8_t state = PPM_NB_CHANNEL; \
|
||||||
static uint32_t last; \
|
static uint32_t last; \
|
||||||
\
|
\
|
||||||
uint32_t now = T0CR2; \
|
uint32_t now = PPM_CR; \
|
||||||
uint32_t length = now - last; \
|
uint32_t length = now - last; \
|
||||||
last = now; \
|
last = now; \
|
||||||
\
|
\
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ uint32_t sys_time_chrono; /* T0TC ticks */
|
|||||||
#ifdef MB_TACHO
|
#ifdef MB_TACHO
|
||||||
#include "mb_tacho.h"
|
#include "mb_tacho.h"
|
||||||
// FIXME : declared the scale interrupt here :(
|
// 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
|
#else
|
||||||
#define TIMER0_IT_MASK (TIR_CR2I | TIR_MR1I)
|
#define TIMER0_IT_MASK (PPM_CRI | TIR_MR1I)
|
||||||
#endif /* MB_TACHO */
|
#endif /* MB_TACHO */
|
||||||
|
|
||||||
#ifdef USE_AMI601
|
#ifdef USE_AMI601
|
||||||
@@ -36,13 +36,12 @@ uint32_t sys_time_chrono; /* T0TC ticks */
|
|||||||
|
|
||||||
void TIMER0_ISR ( void ) {
|
void TIMER0_ISR ( void ) {
|
||||||
ISR_ENTRY();
|
ISR_ENTRY();
|
||||||
|
|
||||||
while (T0IR & TIMER0_IT_MASK) {
|
while (T0IR & TIMER0_IT_MASK) {
|
||||||
#ifdef RADIO_CONTROL
|
#ifdef RADIO_CONTROL
|
||||||
if (T0IR&TIR_CR2I) {
|
if (T0IR&PPM_CRI) {
|
||||||
PPM_ISR();
|
PPM_ISR();
|
||||||
/* clear interrupt */
|
/* clear interrupt */
|
||||||
T0IR = TIR_CR2I;
|
T0IR = PPM_CRI;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SERVOS_4017
|
#ifdef SERVOS_4017
|
||||||
|
|||||||
Reference in New Issue
Block a user