SENSORS: Gyro/accel aligmnet fix
[betaflight.git] / src / main / rx / pwm.c
blob894eb27a426e6cf8de44d4a13985814561fceb98
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdbool.h>
19 #include <stdint.h>
20 #include <stdlib.h>
22 #include <string.h>
24 #include "build_config.h"
26 #include "platform.h"
28 #include "drivers/gpio.h"
29 #include "drivers/timer.h"
30 #include "drivers/pwm_rx.h"
32 #include "config/config.h"
34 #include "rx/rx.h"
35 #include "rx/pwm.h"
37 static uint16_t pwmReadRawRC(rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t channel)
39 UNUSED(rxRuntimeConfigPtr);
40 return pwmRead(channel);
43 static uint16_t ppmReadRawRC(rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t channel)
45 UNUSED(rxRuntimeConfigPtr);
46 return ppmRead(channel);
49 void rxPwmInit(rxRuntimeConfig_t *rxRuntimeConfigPtr, rcReadRawDataPtr *callback)
51 UNUSED(rxRuntimeConfigPtr);
52 // configure PWM/CPPM read function and max number of channels. serial rx below will override both of these, if enabled
53 if (feature(FEATURE_RX_PARALLEL_PWM)) {
54 rxRuntimeConfigPtr->channelCount = MAX_SUPPORTED_RC_PARALLEL_PWM_CHANNEL_COUNT;
55 *callback = pwmReadRawRC;
57 if (feature(FEATURE_RX_PPM)) {
58 rxRuntimeConfigPtr->channelCount = MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT;
59 *callback = ppmReadRawRC;