diff --git a/make/source.mk b/make/source.mk
index 5bc8d2ee02..c68b6b5a4b 100644
--- a/make/source.mk
+++ b/make/source.mk
@@ -64,6 +64,7 @@ COMMON_SRC = \
pg/bus_i2c.c \
pg/flash.c \
pg/max7456.c \
+ pg/rx_pwm.c \
pg/pg.c \
scheduler/scheduler.c \
sensors/battery.c \
diff --git a/src/main/drivers/rx_pwm.c b/src/main/drivers/rx_pwm.c
index f3c05084d7..31eba0d427 100644
--- a/src/main/drivers/rx_pwm.c
+++ b/src/main/drivers/rx_pwm.c
@@ -27,15 +27,15 @@
#include "common/utils.h"
-#include "drivers/nvic.h"
#include "drivers/io.h"
-#include "timer.h"
+#include "drivers/nvic.h"
+#include "drivers/pwm_output.h"
+#include "drivers/timer.h"
+
+#include "pg/rx_pwm.h"
-#include "pwm_output.h"
#include "rx_pwm.h"
-#include "flight/mixer.h" //!!TODO remove dependency on this
-
#define DEBUG_PPM_ISR
#define PPM_CAPTURE_COUNT 12
diff --git a/src/main/drivers/rx_pwm.h b/src/main/drivers/rx_pwm.h
index 0943af6465..922b33435f 100644
--- a/src/main/drivers/rx_pwm.h
+++ b/src/main/drivers/rx_pwm.h
@@ -27,17 +27,10 @@ typedef enum {
#define PPM_RCVR_TIMEOUT 0
#define PWM_INPUT_PORT_COUNT 8
-typedef struct ppmConfig_s {
- ioTag_t ioTag;
-} ppmConfig_t;
-
-typedef struct pwmConfig_s {
- ioTag_t ioTags[PWM_INPUT_PORT_COUNT];
- inputFilteringMode_e inputFilteringMode;
-} pwmConfig_t;
-
-void ppmRxInit(const ppmConfig_t *ppmConfig);
-void pwmRxInit(const pwmConfig_t *pwmConfig);
+struct ppmConfig_s;
+void ppmRxInit(const struct ppmConfig_s *ppmConfig);
+struct pwmConfig_s;
+void pwmRxInit(const struct pwmConfig_s *pwmConfig);
uint16_t pwmRead(uint8_t channel);
uint16_t ppmRead(uint8_t channel);
diff --git a/src/main/fc/config.c b/src/main/fc/config.c
index 5a154e96c6..e1b967df5d 100644
--- a/src/main/fc/config.c
+++ b/src/main/fc/config.c
@@ -49,7 +49,6 @@
#include "drivers/max7456.h"
#include "drivers/pwm_esc_detect.h"
#include "drivers/pwm_output.h"
-#include "drivers/rx_pwm.h"
#include "drivers/rx_spi.h"
#include "drivers/sdcard.h"
#include "drivers/sensor.h"
@@ -144,13 +143,6 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
#endif
-#ifdef USE_PWM
-PG_REGISTER_WITH_RESET_FN(pwmConfig_t, pwmConfig, PG_PWM_CONFIG, 0);
-#endif
-#ifdef USE_PPM
-PG_REGISTER_WITH_RESET_FN(ppmConfig_t, ppmConfig, PG_PPM_CONFIG, 0);
-#endif
-
#ifdef USE_SDCARD
PG_REGISTER_WITH_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig, PG_SDCARD_CONFIG, 0);
@@ -162,36 +154,6 @@ PG_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig,
// no template required since defaults are zero
PG_REGISTER(vcdProfile_t, vcdProfile, PG_VCD_CONFIG, 0);
-#if defined(USE_PWM) || defined(USE_PPM)
-void pgResetFn_ppmConfig(ppmConfig_t *ppmConfig)
-{
-#ifdef PPM_PIN
- ppmConfig->ioTag = IO_TAG(PPM_PIN);
-#else
- for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) {
- if (timerHardware[i].usageFlags & TIM_USE_PPM) {
- ppmConfig->ioTag = timerHardware[i].tag;
- return;
- }
- }
-
- ppmConfig->ioTag = IO_TAG_NONE;
-#endif
-}
-
-void pgResetFn_pwmConfig(pwmConfig_t *pwmConfig)
-{
- pwmConfig->inputFilteringMode = INPUT_FILTERING_DISABLED;
- int inputIndex = 0;
- for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT && inputIndex < PWM_INPUT_PORT_COUNT; i++) {
- if (timerHardware[i].usageFlags & TIM_USE_PWM) {
- pwmConfig->ioTags[inputIndex] = timerHardware[i].tag;
- inputIndex++;
- }
- }
-}
-#endif
-
#ifdef SWAP_SERIAL_PORT_0_AND_1_DEFAULTS
#define FIRST_PORT_INDEX 1
#define SECOND_PORT_INDEX 0
diff --git a/src/main/fc/config.h b/src/main/fc/config.h
index 12c29f29f4..6379e9121b 100644
--- a/src/main/fc/config.h
+++ b/src/main/fc/config.h
@@ -23,7 +23,6 @@
#include "pg/pg.h"
#include "drivers/flash.h"
-#include "drivers/rx_pwm.h"
#include "drivers/sdcard.h"
#include "drivers/serial.h"
#include "drivers/bus_i2c.h"
@@ -84,8 +83,6 @@ typedef struct systemConfig_s {
PG_DECLARE(pilotConfig_t, pilotConfig);
PG_DECLARE(systemConfig_t, systemConfig);
PG_DECLARE(beeperDevConfig_t, beeperDevConfig);
-PG_DECLARE(ppmConfig_t, ppmConfig);
-PG_DECLARE(pwmConfig_t, pwmConfig);
PG_DECLARE(vcdProfile_t, vcdProfile);
PG_DECLARE(sdcardConfig_t, sdcardConfig);
diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c
index ff916233a4..b1917d71e8 100644
--- a/src/main/fc/fc_init.c
+++ b/src/main/fc/fc_init.c
@@ -30,8 +30,6 @@
#include "config/config_eeprom.h"
#include "config/feature.h"
-#include "pg/pg.h"
-#include "pg/pg_ids.h"
#include "cms/cms.h"
#include "cms/cms_types.h"
@@ -82,6 +80,9 @@
#include "pg/adc.h"
#include "pg/bus_i2c.h"
#include "pg/flash.h"
+#include "pg/pg.h"
+#include "pg/pg_ids.h"
+#include "pg/rx_pwm.h"
#include "rx/rx.h"
#include "rx/rx_spi.h"
diff --git a/src/main/interface/cli.c b/src/main/interface/cli.c
index 5785822319..e9a79ed934 100644
--- a/src/main/interface/cli.c
+++ b/src/main/interface/cli.c
@@ -66,7 +66,6 @@ extern uint8_t __config_end;
#include "drivers/io.h"
#include "drivers/io_impl.h"
#include "drivers/inverter.h"
-#include "drivers/rx_pwm.h"
#include "drivers/sdcard.h"
#include "drivers/sensor.h"
#include "drivers/serial.h"
@@ -117,11 +116,12 @@ extern uint8_t __config_end;
#include "pg/adc.h"
#include "pg/bus_i2c.h"
+#include "pg/rx_pwm.h"
#include "rx/rx.h"
#include "rx/spektrum.h"
-#include "../rx/cc2500_frsky_common.h"
-#include "../rx/cc2500_frsky_x.h"
+#include "rx/cc2500_frsky_common.h"
+#include "rx/cc2500_frsky_x.h"
#include "scheduler/scheduler.h"
diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c
index cfc5ab6512..f9c96fb7b3 100644
--- a/src/main/interface/settings.c
+++ b/src/main/interface/settings.c
@@ -65,6 +65,7 @@
#include "pg/max7456.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
+#include "pg/rx_pwm.h"
#include "rx/rx.h"
#include "rx/cc2500_frsky_common.h"
diff --git a/src/main/pg/rx_pwm.c b/src/main/pg/rx_pwm.c
new file mode 100644
index 0000000000..a4cf3bcca7
--- /dev/null
+++ b/src/main/pg/rx_pwm.c
@@ -0,0 +1,68 @@
+/*
+ * This file is part of Cleanflight.
+ *
+ * Cleanflight is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Cleanflight is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cleanflight. If not, see .
+ */
+
+#include
+
+#if defined(USE_PWM) || defined(USE_PPM)
+
+#include "drivers/io.h"
+#include "drivers/nvic.h"
+#include "drivers/rx_pwm.h"
+#include "drivers/timer.h"
+
+#include "pg/pg.h"
+#include "pg/pg_ids.h"
+
+#include "rx_pwm.h"
+
+#ifdef USE_PWM
+PG_REGISTER_WITH_RESET_FN(pwmConfig_t, pwmConfig, PG_PWM_CONFIG, 0);
+
+void pgResetFn_pwmConfig(pwmConfig_t *pwmConfig)
+{
+ pwmConfig->inputFilteringMode = INPUT_FILTERING_DISABLED;
+ int inputIndex = 0;
+ for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT && inputIndex < PWM_INPUT_PORT_COUNT; i++) {
+ if (timerHardware[i].usageFlags & TIM_USE_PWM) {
+ pwmConfig->ioTags[inputIndex] = timerHardware[i].tag;
+ inputIndex++;
+ }
+ }
+}
+#endif
+
+#ifdef USE_PPM
+PG_REGISTER_WITH_RESET_FN(ppmConfig_t, ppmConfig, PG_PPM_CONFIG, 0);
+
+void pgResetFn_ppmConfig(ppmConfig_t *ppmConfig)
+{
+#ifdef PPM_PIN
+ ppmConfig->ioTag = IO_TAG(PPM_PIN);
+#else
+ for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) {
+ if (timerHardware[i].usageFlags & TIM_USE_PPM) {
+ ppmConfig->ioTag = timerHardware[i].tag;
+ return;
+ }
+ }
+
+ ppmConfig->ioTag = IO_TAG_NONE;
+#endif
+}
+#endif
+
+#endif
diff --git a/src/main/pg/rx_pwm.h b/src/main/pg/rx_pwm.h
new file mode 100644
index 0000000000..ddaca6ed3c
--- /dev/null
+++ b/src/main/pg/rx_pwm.h
@@ -0,0 +1,36 @@
+/*
+ * This file is part of Cleanflight.
+ *
+ * Cleanflight is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Cleanflight is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cleanflight. If not, see .
+ */
+
+#pragma once
+
+#include "drivers/io_types.h"
+#include "drivers/rx_pwm.h"
+
+#include "pg/pg.h"
+
+typedef struct ppmConfig_s {
+ ioTag_t ioTag;
+} ppmConfig_t;
+
+PG_DECLARE(ppmConfig_t, ppmConfig);
+
+typedef struct pwmConfig_s {
+ ioTag_t ioTags[PWM_INPUT_PORT_COUNT];
+ inputFilteringMode_e inputFilteringMode;
+} pwmConfig_t;
+
+PG_DECLARE(pwmConfig_t, pwmConfig);