Fix WS2812 led definition
[inav.git] / src / main / rx / msp.c
blobb338fbc2d970941c8eed77e592447c320b7f3f8f
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>
21 #include "platform.h"
23 #ifdef USE_RX_MSP
25 #include "build/build_config.h"
27 #include "common/utils.h"
29 #include "rx/rx.h"
30 #include "rx/msp.h"
32 static uint16_t mspFrame[MAX_SUPPORTED_RC_CHANNEL_COUNT];
33 static bool rxMspFrameDone = false;
35 static uint16_t rxMspReadRawRC(const rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t chan)
37 UNUSED(rxRuntimeConfigPtr);
38 return mspFrame[chan];
41 void rxMspFrameReceive(uint16_t *frame, int channelCount)
43 for (int i = 0; i < channelCount; i++) {
44 mspFrame[i] = frame[i];
47 // Any channels not provided will be reset to zero
48 for (int i = channelCount; i < MAX_SUPPORTED_RC_CHANNEL_COUNT; i++) {
49 mspFrame[i] = 0;
52 rxMspFrameDone = true;
55 static uint8_t rxMspFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig)
57 UNUSED(rxRuntimeConfig);
59 if (!rxMspFrameDone) {
60 return RX_FRAME_PENDING;
63 rxMspFrameDone = false;
64 return RX_FRAME_COMPLETE;
67 void rxMspInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
69 UNUSED(rxConfig);
71 rxRuntimeConfig->channelCount = MAX_SUPPORTED_RC_CHANNEL_COUNT;
72 rxRuntimeConfig->rxSignalTimeout = DELAY_5_HZ;
73 rxRuntimeConfig->rcReadRawFn = rxMspReadRawRC;
74 rxRuntimeConfig->rcFrameStatusFn = rxMspFrameStatus;
76 #endif