Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
servos_ppm_hw.h File Reference
#include "std.h"
#include "LPC21xx.h"
#include "mcu_periph/sys_time.h"
#include <BOARD_CONFIG>
+ Include dependency graph for servos_ppm_hw.h:

Go to the source code of this file.

Macros

#define SERVOS_TICS_OF_USEC(s)   cpu_ticks_of_usec(s)
 
#define ClipServo(x, a, b)   Clip(x, a, b)
 
#define _PPM_NB_CHANNELS   8
 
#define ActuatorPpmSet(_i, _v)   { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }
 
#define ActuatorsPpmCommit()   {}
 
#define ActuatorsPpmInit()   actuators_ppm_init()
 
#define SERVO_REFRESH_TICS   SERVOS_TICS_OF_USEC(22000)
 
#define PPM_WIDTH   SERVOS_TICS_OF_USEC(550)
 
#define ACTUATORS_IT   TIR_MR1I
 
#define ServosPPMMat_ISR()
 

Functions

void actuators_ppm_init (void)
 

Variables

uint16_t servos_values [_PPM_NB_CHANNELS]
 
uint8_t servos_PPM_idx
 
uint32_t servos_delay
 
uint8_t ppm_pulse
 

Detailed Description

Efficient driving of MAT0.1 (SERVO_CLOCK_PIN) using TIMER0 to produce PPM for a R/C receiver which has a microcontroller to drive the servos (not a 4015 or 4017 decade counter chip).

Definition in file servos_ppm_hw.h.

Macro Definition Documentation

◆ _PPM_NB_CHANNELS

#define _PPM_NB_CHANNELS   8

Definition at line 43 of file servos_ppm_hw.h.

◆ ActuatorPpmSet

#define ActuatorPpmSet (   _i,
  _v 
)    { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }

Definition at line 45 of file servos_ppm_hw.h.

◆ ACTUATORS_IT

#define ACTUATORS_IT   TIR_MR1I

Definition at line 59 of file servos_ppm_hw.h.

◆ ActuatorsPpmCommit

#define ActuatorsPpmCommit ( )    {}

Definition at line 48 of file servos_ppm_hw.h.

◆ ActuatorsPpmInit

#define ActuatorsPpmInit ( )    actuators_ppm_init()

Definition at line 49 of file servos_ppm_hw.h.

◆ ClipServo

#define ClipServo (   x,
  a,
  b 
)    Clip(x, a, b)

Definition at line 41 of file servos_ppm_hw.h.

◆ PPM_WIDTH

#define PPM_WIDTH   SERVOS_TICS_OF_USEC(550)

Definition at line 57 of file servos_ppm_hw.h.

◆ SERVO_REFRESH_TICS

#define SERVO_REFRESH_TICS   SERVOS_TICS_OF_USEC(22000)

Definition at line 55 of file servos_ppm_hw.h.

◆ SERVOS_TICS_OF_USEC

#define SERVOS_TICS_OF_USEC (   s)    cpu_ticks_of_usec(s)

Definition at line 40 of file servos_ppm_hw.h.

◆ ServosPPMMat_ISR

#define ServosPPMMat_ISR ( )
Value:
{ \
if (servos_PPM_idx == 0) { \
servos_delay = SERVO_REFRESH_TICS; \
} \
if (ppm_pulse) { \
T0MR1 += PPM_WIDTH; \
servos_delay -= PPM_WIDTH; \
} else { \
servos_delay -= servos_values[servos_PPM_idx] - PPM_WIDTH; \
servos_PPM_idx++; \
} \
} else { /* servos_PPM_idx=_PPM_NB_CHANNELS */ \
if (ppm_pulse) { \
T0MR1 += PPM_WIDTH; \
servos_delay -= PPM_WIDTH; \
} else { \
servos_PPM_idx = 0; \
T0MR1 += servos_delay - PPM_WIDTH; \
} \
} \
if (!ppm_pulse) { \
/* lower clock pin */ \
T0EMR &= ~TEMR_EM1; \
} \
/* toggle ppm_pulse flag */ \
ppm_pulse ^= 1; \
}

Definition at line 60 of file servos_ppm_hw.h.

Function Documentation

◆ actuators_ppm_init()

Variable Documentation

◆ ppm_pulse

uint8_t ppm_pulse

Definition at line 36 of file servos_ppm_hw.c.

◆ servos_delay

uint32_t servos_delay

Definition at line 33 of file servos_4015_MAT_hw.c.

Referenced by actuators_4015_init(), and actuators_ppm_init().

◆ servos_PPM_idx

uint8_t servos_PPM_idx

Definition at line 35 of file servos_ppm_hw.c.

Referenced by actuators_ppm_init().

◆ servos_values

ppm_pulse
uint8_t ppm_pulse
Definition: servos_ppm_hw.c:36
servos_delay
uint32_t servos_delay
Definition: servos_4015_MAT_hw.c:33
PPM_WIDTH
#define PPM_WIDTH
Definition: servos_ppm_hw.h:57
servos_PPM_idx
uint8_t servos_PPM_idx
Definition: servos_ppm_hw.c:35
TEMR_EM1
#define TEMR_EM1
Definition: lpcTMR.h:150
_PPM_NB_CHANNELS
#define _PPM_NB_CHANNELS
Definition: servos_ppm_hw.h:43
servos_values
uint16_t servos_values[_PPM_NB_CHANNELS]
Definition: servos_4015_hw.c:29
SERVO_REFRESH_TICS
#define SERVO_REFRESH_TICS
Definition: servos_ppm_hw.h:55