@@ -36,8 +36,10 @@ typedef struct mspRxState_s {
3636 uint8_t lastChannelCount ;
3737} mspRxState_t ;
3838
39- static mspRxState_t mspRxStates [RX_LINK_COUNT ];
40- static mspRxState_t mspOverrideState ;
39+ // MSP+MSP is not a supported Dual RX pair, and the legacy MSP override is only
40+ // initialized when MSP is not a configured receiver. One state object therefore
41+ // covers all mutually-exclusive MSP RX roles.
42+ static mspRxState_t mspRxState ;
4143
4244static uint16_t rxMspReadRawRC (const rxRuntimeConfig_t * rxRuntimeConfig , uint8_t chan )
4345{
@@ -71,8 +73,7 @@ static void rxMspInitState(rxRuntimeConfig_t *rxRuntimeConfig, mspRxState_t *sta
7173
7274void rxMspFrameReceive (uint16_t * frame , int channelCount )
7375{
74- const int8_t mspLink = rxGetMspLink ();
75- mspRxState_t * state = mspLink >= 0 && mspLink < RX_LINK_COUNT ? & mspRxStates [mspLink ] : & mspOverrideState ;
76+ mspRxState_t * state = & mspRxState ;
7677
7778 channelCount = constrain (channelCount , 0 , MAX_SUPPORTED_RC_CHANNEL_COUNT );
7879 for (int i = 0 ; i < channelCount ; i ++ ) {
@@ -87,21 +88,22 @@ void rxMspFrameReceive(uint16_t *frame, int channelCount)
8788
8889uint8_t rxMspGetLastChannelCount (rxLink_e link )
8990{
90- return (unsigned )link < RX_LINK_COUNT ? mspRxStates [link ].lastChannelCount : 0 ;
91+ const int8_t mspLink = rxGetMspLink ();
92+ return mspLink >= 0 && link == (rxLink_e )mspLink ? mspRxState .lastChannelCount : 0 ;
9193}
9294
9395void rxMspInit (const rxConfig_t * rxConfig , rxRuntimeConfig_t * rxRuntimeConfig , rxLink_e link )
9496{
9597 UNUSED (rxConfig );
9698 if ((unsigned )link < RX_LINK_COUNT ) {
97- rxMspInitState (rxRuntimeConfig , & mspRxStates [ link ] , true);
99+ rxMspInitState (rxRuntimeConfig , & mspRxState , true);
98100 }
99101}
100102
101103void rxMspOverrideInit (const rxConfig_t * rxConfig , rxRuntimeConfig_t * rxRuntimeConfig )
102104{
103105 UNUSED (rxConfig );
104- rxMspInitState (rxRuntimeConfig , & mspOverrideState , false);
106+ rxMspInitState (rxRuntimeConfig , & mspRxState , false);
105107}
106108
107109#endif
0 commit comments