Skip to content

Commit ae5c924

Browse files
authored
Merge pull request betaflight#7853 from mikeller/fix_sumd_v3
Fixed bug in SUMD V3 channel number handling.
2 parents fe7de1b + 32bcf60 commit ae5c924

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/main/rx/sumd.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ static uint8_t sumdFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig)
112112
{
113113
UNUSED(rxRuntimeConfig);
114114

115-
uint8_t channelIndex;
116-
117115
uint8_t frameStatus = RX_FRAME_PENDING;
118116

119117
if (!sumdFrameDone) {
@@ -139,10 +137,9 @@ static uint8_t sumdFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig)
139137
return frameStatus;
140138
}
141139

142-
if (sumdChannelCount > MAX_SUPPORTED_RC_CHANNEL_COUNT)
143-
sumdChannelCount = MAX_SUPPORTED_RC_CHANNEL_COUNT;
140+
unsigned channelsToProcess = MIN(sumdChannelCount, MAX_SUPPORTED_RC_CHANNEL_COUNT);
144141

145-
for (channelIndex = 0; channelIndex < sumdChannelCount; channelIndex++) {
142+
for (unsigned channelIndex = 0; channelIndex < channelsToProcess; channelIndex++) {
146143
sumdChannels[channelIndex] = (
147144
(sumd[SUMD_BYTES_PER_CHANNEL * channelIndex + SUMD_OFFSET_CHANNEL_1_HIGH] << 8) |
148145
sumd[SUMD_BYTES_PER_CHANNEL * channelIndex + SUMD_OFFSET_CHANNEL_1_LOW]

0 commit comments

Comments
 (0)