Skip to content

Commit 2805c95

Browse files
authored
Merge pull request betaflight#1564 from blckmn/ppm_fix
PWM fix - and rename SKIP PWM and PPM to USE_PWM and USE_PPM
2 parents 0afecc4 + b1e04e7 commit 2805c95

File tree

9 files changed

+32
-10
lines changed

9 files changed

+32
-10
lines changed

src/main/config/config_master.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ typedef struct master_s {
151151
serialConfig_t serialConfig;
152152
telemetryConfig_t telemetryConfig;
153153

154-
#ifndef SKIP_RX_PWM_PPM
154+
#ifdef USE_PPM
155155
ppmConfig_t ppmConfig;
156+
#endif
157+
158+
#ifdef USE_PWM
156159
pwmConfig_t pwmConfig;
157160
#endif
158161

src/main/drivers/pwm_rx.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <platform.h>
2222

23-
#ifndef SKIP_RX_PWM_PPM
23+
#if defined(USE_PWM) || defined(USE_PPM)
2424

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

409409
IO_t io = IOGetByTag(pwmConfig->ioTags[channel]);
410410
IOInit(io, OWNER_PWMINPUT, RESOURCE_INDEX(channel));
411+
#ifdef STM32F1
411412
IOConfigGPIO(io, IOCFG_IPD);
413+
#else
414+
IOConfigGPIO(io, IOCFG_AF_PP);
415+
#endif
412416

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

473477
IO_t io = IOGetByTag(ppmConfig->ioTag);
474478
IOInit(io, OWNER_PPMINPUT, 0);
479+
#ifdef STM32F1
475480
IOConfigGPIO(io, IOCFG_IPD);
481+
#else
482+
IOConfigGPIO(io, IOCFG_AF_PP);
483+
#endif
476484

477485
#if defined(USE_HAL_DRIVER)
478486
pwmICConfig(timer->tim, timer->channel, TIM_ICPOLARITY_RISING);

src/main/fc/config.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void resetBeeperConfig(beeperConfig_t *beeperConfig)
361361
}
362362
#endif
363363

364-
#ifndef SKIP_RX_PWM_PPM
364+
#if defined(USE_PWM) || defined(USE_PPM)
365365
void resetPpmConfig(ppmConfig_t *ppmConfig)
366366
{
367367
#ifdef PPM_PIN
@@ -588,7 +588,7 @@ void createDefaultConfig(master_t *config)
588588

589589
resetBatteryConfig(&config->batteryConfig);
590590

591-
#ifndef SKIP_RX_PWM_PPM
591+
#if defined(USE_PWM) || defined(USE_PPM)
592592
resetPpmConfig(&config->ppmConfig);
593593
resetPwmConfig(&config->pwmConfig);
594594
#endif

src/main/io/serial_cli.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3763,7 +3763,7 @@ const cliResourceValue_t resourceTable[] = {
37633763
#ifdef USE_SERVOS
37643764
{ OWNER_SERVO, &masterConfig.servoConfig.ioTags[0], MAX_SUPPORTED_SERVOS },
37653765
#endif
3766-
#ifndef SKIP_RX_PWM_PPM
3766+
#if defined(USE_PWM) || defined(USE_PPM)
37673767
{ OWNER_PPMINPUT, &masterConfig.ppmConfig.ioTag, 0 },
37683768
{ OWNER_PWMINPUT, &masterConfig.pwmConfig.ioTags[0], PWM_INPUT_PORT_COUNT },
37693769
#endif

src/main/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ void init(void)
276276
}
277277
#endif
278278

279-
#ifndef SKIP_RX_PWM_PPM
279+
#if defined(USE_PWM) || defined(USE_PPM)
280280
if (feature(FEATURE_RX_PPM)) {
281281
ppmRxInit(&masterConfig.ppmConfig, masterConfig.motorConfig.motorPwmProtocol);
282282
} else if (feature(FEATURE_RX_PARALLEL_PWM)) {

src/main/rx/pwm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "platform.h"
2525

26-
#ifndef SKIP_RX_PWM_PPM
26+
#if defined(USE_PWM) || defined(USE_PPM)
2727

2828
#include "build/build_config.h"
2929

src/main/rx/rx.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void rxInit(const rxConfig_t *rxConfig, const modeActivationCondition_t *modeAct
256256
}
257257
#endif
258258

259-
#ifndef SKIP_RX_PWM_PPM
259+
#if defined(USE_PWM) || defined(USE_PPM)
260260
if (feature(FEATURE_RX_PPM) || feature(FEATURE_RX_PARALLEL_PWM)) {
261261
rxPwmInit(rxConfig, &rxRuntimeConfig);
262262
}
@@ -311,7 +311,7 @@ bool rxUpdateCheck(uint32_t currentTime, uint32_t currentDeltaTime)
311311
}
312312
}
313313

314-
#ifndef SKIP_RX_PWM_PPM
314+
#if defined(USE_PWM) || defined(USE_PPM)
315315
if (feature(FEATURE_RX_PPM)) {
316316
if (isPPMDataBeingReceived()) {
317317
rxSignalReceivedNotDataDriven = true;

src/main/target/CJMCU/target.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,17 @@
9191
//#define TELEMETRY
9292
//#define TELEMETRY_LTM
9393
//#define TELEMETRY_NRF24_LTM
94-
#define SKIP_RX_PWM_PPM
94+
#ifdef USE_PWM
95+
#undef USE_PWM
96+
#endif
97+
98+
#ifdef USE_PPM
99+
#undef USE_PPM
100+
#endif
101+
102+
#ifdef SERIAL_RX
95103
#undef SERIAL_RX
104+
#endif
96105
//#undef SKIP_TASK_STATISTICS
97106

98107
#else

src/main/target/common.h

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
#define USE_SERIALRX_SUMH // Graupner legacy protocol
5252
#define USE_SERIALRX_XBUS // JR
5353
#define USE_CLI
54+
#define USE_PWM
55+
#define USE_PPM
5456

5557
#if defined(STM_FAST_TARGET)
5658
#define MAX_AUX_CHANNELS 99

0 commit comments

Comments
 (0)