Moved parameter group for rx_pwm to `pg` directory.

This commit is contained in:
mikeller 2017-12-24 10:04:45 +13:00
parent bf3dd1991d
commit 9cb4f6b097
10 changed files with 121 additions and 62 deletions

View File

@ -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 \

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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"

View File

@ -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"

View File

@ -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"

68
src/main/pg/rx_pwm.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <platform.h>
#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

36
src/main/pg/rx_pwm.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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);