Skip to content

Commit

Permalink
Merge pull request betaflight#1564 from blckmn/ppm_fix
Browse files Browse the repository at this point in the history
PWM fix - and rename SKIP PWM and PPM to USE_PWM and USE_PPM
  • Loading branch information
martinbudden authored Nov 15, 2016
2 parents 0afecc4 + b1e04e7 commit 2805c95
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/main/config/config_master.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ typedef struct master_s {
serialConfig_t serialConfig;
telemetryConfig_t telemetryConfig;

#ifndef SKIP_RX_PWM_PPM
#ifdef USE_PPM
ppmConfig_t ppmConfig;
#endif

#ifdef USE_PWM
pwmConfig_t pwmConfig;
#endif

Expand Down
10 changes: 9 additions & 1 deletion src/main/drivers/pwm_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <platform.h>

#ifndef SKIP_RX_PWM_PPM
#if defined(USE_PWM) || defined(USE_PPM)

#include "build/build_config.h"
#include "build/debug.h"
Expand Down Expand Up @@ -408,7 +408,11 @@ void pwmRxInit(const pwmConfig_t *pwmConfig)

IO_t io = IOGetByTag(pwmConfig->ioTags[channel]);
IOInit(io, OWNER_PWMINPUT, RESOURCE_INDEX(channel));
#ifdef STM32F1
IOConfigGPIO(io, IOCFG_IPD);
#else
IOConfigGPIO(io, IOCFG_AF_PP);
#endif

#if defined(USE_HAL_DRIVER)
pwmICConfig(timer->tim, timer->channel, TIM_ICPOLARITY_RISING);
Expand Down Expand Up @@ -472,7 +476,11 @@ void ppmRxInit(const ppmConfig_t *ppmConfig, uint8_t pwmProtocol)

IO_t io = IOGetByTag(ppmConfig->ioTag);
IOInit(io, OWNER_PPMINPUT, 0);
#ifdef STM32F1
IOConfigGPIO(io, IOCFG_IPD);
#else
IOConfigGPIO(io, IOCFG_AF_PP);
#endif

#if defined(USE_HAL_DRIVER)
pwmICConfig(timer->tim, timer->channel, TIM_ICPOLARITY_RISING);
Expand Down
4 changes: 2 additions & 2 deletions src/main/fc/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void resetBeeperConfig(beeperConfig_t *beeperConfig)
}
#endif

#ifndef SKIP_RX_PWM_PPM
#if defined(USE_PWM) || defined(USE_PPM)
void resetPpmConfig(ppmConfig_t *ppmConfig)
{
#ifdef PPM_PIN
Expand Down Expand Up @@ -588,7 +588,7 @@ void createDefaultConfig(master_t *config)

resetBatteryConfig(&config->batteryConfig);

#ifndef SKIP_RX_PWM_PPM
#if defined(USE_PWM) || defined(USE_PPM)
resetPpmConfig(&config->ppmConfig);
resetPwmConfig(&config->pwmConfig);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/main/io/serial_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -3763,7 +3763,7 @@ const cliResourceValue_t resourceTable[] = {
#ifdef USE_SERVOS
{ OWNER_SERVO, &masterConfig.servoConfig.ioTags[0], MAX_SUPPORTED_SERVOS },
#endif
#ifndef SKIP_RX_PWM_PPM
#if defined(USE_PWM) || defined(USE_PPM)
{ OWNER_PPMINPUT, &masterConfig.ppmConfig.ioTag, 0 },
{ OWNER_PWMINPUT, &masterConfig.pwmConfig.ioTags[0], PWM_INPUT_PORT_COUNT },
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void init(void)
}
#endif

#ifndef SKIP_RX_PWM_PPM
#if defined(USE_PWM) || defined(USE_PPM)
if (feature(FEATURE_RX_PPM)) {
ppmRxInit(&masterConfig.ppmConfig, masterConfig.motorConfig.motorPwmProtocol);
} else if (feature(FEATURE_RX_PARALLEL_PWM)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/rx/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "platform.h"

#ifndef SKIP_RX_PWM_PPM
#if defined(USE_PWM) || defined(USE_PPM)

#include "build/build_config.h"

Expand Down
4 changes: 2 additions & 2 deletions src/main/rx/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void rxInit(const rxConfig_t *rxConfig, const modeActivationCondition_t *modeAct
}
#endif

#ifndef SKIP_RX_PWM_PPM
#if defined(USE_PWM) || defined(USE_PPM)
if (feature(FEATURE_RX_PPM) || feature(FEATURE_RX_PARALLEL_PWM)) {
rxPwmInit(rxConfig, &rxRuntimeConfig);
}
Expand Down Expand Up @@ -311,7 +311,7 @@ bool rxUpdateCheck(uint32_t currentTime, uint32_t currentDeltaTime)
}
}

#ifndef SKIP_RX_PWM_PPM
#if defined(USE_PWM) || defined(USE_PPM)
if (feature(FEATURE_RX_PPM)) {
if (isPPMDataBeingReceived()) {
rxSignalReceivedNotDataDriven = true;
Expand Down
11 changes: 10 additions & 1 deletion src/main/target/CJMCU/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,17 @@
//#define TELEMETRY
//#define TELEMETRY_LTM
//#define TELEMETRY_NRF24_LTM
#define SKIP_RX_PWM_PPM
#ifdef USE_PWM
#undef USE_PWM
#endif

#ifdef USE_PPM
#undef USE_PPM
#endif

#ifdef SERIAL_RX
#undef SERIAL_RX
#endif
//#undef SKIP_TASK_STATISTICS

#else
Expand Down
2 changes: 2 additions & 0 deletions src/main/target/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#define USE_SERIALRX_SUMH // Graupner legacy protocol
#define USE_SERIALRX_XBUS // JR
#define USE_CLI
#define USE_PWM
#define USE_PPM

#if defined(STM_FAST_TARGET)
#define MAX_AUX_CHANNELS 99
Expand Down

0 comments on commit 2805c95

Please sign in to comment.