NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pwm_rx.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <platform.h>
#include "build_config.h"
#include "debug.h"
#include "common/utils.h"
#include "config/config.h"
#include "system.h"
#include "nvic.h"
#include "gpio.h"
#include "timer.h"
#include "pwm_mapping.h"
#include "pwm_rx.h"
Include dependency graph for pwm_rx.c:

Data Structures

struct  pwmInputPort_t
 
struct  ppmDevice_s
 
struct  ppmISREvent_s
 

Macros

#define DEBUG_PPM_ISR
 
#define PPM_CAPTURE_COUNT   12
 
#define PWM_INPUT_PORT_COUNT   8
 
#define PWM_PORTS_OR_PPM_CAPTURE_COUNT   PPM_CAPTURE_COUNT
 
#define INPUT_FILTER_TO_HELP_WITH_NOISE_FROM_OPENLRS_TELEMETRY_RX   0x03
 
#define PPM_TIMER_PERIOD   0x10000
 
#define PWM_TIMER_PERIOD   0x10000
 
#define PPM_IN_MIN_SYNC_PULSE_US   2700
 
#define PPM_IN_MIN_CHANNEL_PULSE_US   750
 
#define PPM_IN_MAX_CHANNEL_PULSE_US   2250
 
#define PPM_STABLE_FRAMES_REQUIRED_COUNT   25
 
#define PPM_IN_MIN_NUM_CHANNELS   4
 
#define PPM_IN_MAX_NUM_CHANNELS   PWM_PORTS_OR_PPM_CAPTURE_COUNT
 
#define MIN_CHANNELS_BEFORE_PPM_FRAME_CONSIDERED_VALID   4
 
#define MAX_MISSED_PWM_EVENTS   10
 
#define UNUSED_PPM_TIMER_REFERENCE   0
 
#define FIRST_PWM_PORT   0
 

Typedefs

typedef struct ppmDevice_s ppmDevice_t
 
typedef struct ppmISREvent_s ppmISREvent_t
 

Enumerations

enum  pwmInputMode_t { INPUT_MODE_PPM, INPUT_MODE_PWM }
 
enum  eventSource_e { SOURCE_OVERFLOW = 0, SOURCE_EDGE = 1 }
 

Functions

void pwmICConfig (TIM_TypeDef *tim, uint8_t channel, uint16_t polarity)
 
void ppmAvoidPWMTimerClash (const timerHardware_t *timerHardwarePtr, TIM_TypeDef *sharedPwmTimer)
 
bool isPPMDataBeingReceived (void)
 
void resetPPMDataReceivedState (void)
 
void pwmRxInit (void)
 
bool isPWMDataBeingReceived (void)
 
void pwmInConfig (const timerHardware_t *timerHardwarePtr, uint8_t channel)
 
void ppmInConfig (const timerHardware_t *timerHardwarePtr)
 
uint16_t ppmRead (uint8_t channel)
 
uint16_t pwmRead (uint8_t channel)
 

Variables

ppmDevice_t ppmDev
 

Macro Definition Documentation

#define DEBUG_PPM_ISR
#define FIRST_PWM_PORT   0
#define INPUT_FILTER_TO_HELP_WITH_NOISE_FROM_OPENLRS_TELEMETRY_RX   0x03
#define MAX_MISSED_PWM_EVENTS   10
#define MIN_CHANNELS_BEFORE_PPM_FRAME_CONSIDERED_VALID   4
#define PPM_CAPTURE_COUNT   12
#define PPM_IN_MAX_CHANNEL_PULSE_US   2250
#define PPM_IN_MAX_NUM_CHANNELS   PWM_PORTS_OR_PPM_CAPTURE_COUNT
#define PPM_IN_MIN_CHANNEL_PULSE_US   750
#define PPM_IN_MIN_NUM_CHANNELS   4
#define PPM_IN_MIN_SYNC_PULSE_US   2700
#define PPM_STABLE_FRAMES_REQUIRED_COUNT   25
#define PPM_TIMER_PERIOD   0x10000
#define PWM_INPUT_PORT_COUNT   8
#define PWM_PORTS_OR_PPM_CAPTURE_COUNT   PPM_CAPTURE_COUNT
#define PWM_TIMER_PERIOD   0x10000
#define UNUSED_PPM_TIMER_REFERENCE   0

Typedef Documentation

typedef struct ppmDevice_s ppmDevice_t
typedef struct ppmISREvent_s ppmISREvent_t

Enumeration Type Documentation

Enumerator
SOURCE_OVERFLOW 
SOURCE_EDGE 
Enumerator
INPUT_MODE_PPM 
INPUT_MODE_PWM 

Function Documentation

bool isPPMDataBeingReceived ( void  )
bool isPWMDataBeingReceived ( void  )
void ppmAvoidPWMTimerClash ( const timerHardware_t timerHardwarePtr,
TIM_TypeDef sharedPwmTimer 
)
void ppmInConfig ( const timerHardware_t timerHardwarePtr)

Here is the call graph for this function:

uint16_t ppmRead ( uint8_t  channel)
void pwmICConfig ( TIM_TypeDef tim,
uint8_t  channel,
uint16_t  polarity 
)
void pwmInConfig ( const timerHardware_t timerHardwarePtr,
uint8_t  channel 
)

Here is the call graph for this function:

uint16_t pwmRead ( uint8_t  channel)
void pwmRxInit ( void  )
void resetPPMDataReceivedState ( void  )

Variable Documentation

ppmDevice_t ppmDev