1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Large code re-organization which separates some key tasks in the rx

code.

Tested with X8R in SBus and PWM, and Spek Sat, GR-24 PPM, PWM and SUMD,
Spek PPM
This commit is contained in:
Dominic Clifton 2015-08-18 06:25:30 +01:00
parent 5142ff032a
commit 2c79b9777e
8 changed files with 140 additions and 89 deletions

View file

@ -162,6 +162,11 @@ bool isPPMDataBeingReceived(void)
return false;
}
bool isPWMDataBeingReceived(void)
{
return false;
}
void resetPPMDataReceivedState(void)
{
}

View file

@ -28,6 +28,7 @@ extern "C" {
void rxInit(rxConfig_t *rxConfig);
void rxResetFlightChannelStatus(void);
bool rxHaveValidFlightChannels(void);
bool isPulseValid(uint16_t pulseDuration);
void rxUpdateFlightChannelStatus(uint8_t channel, uint16_t pulseDuration);
}
@ -36,6 +37,7 @@ extern "C" {
typedef struct testData_s {
bool isPPMDataBeingReceived;
bool isPWMDataBeingReceived;
} testData_t;
static testData_t testData;
@ -58,7 +60,8 @@ TEST(RxTest, TestValidFlightChannels)
rxResetFlightChannelStatus();
for (uint8_t channelIndex = 0; channelIndex < MAX_SUPPORTED_RC_CHANNEL_COUNT; channelIndex++) {
rxUpdateFlightChannelStatus(channelIndex, 1500);
bool validPulse = isPulseValid(1500);
rxUpdateFlightChannelStatus(channelIndex, validPulse);
}
// then
@ -98,7 +101,8 @@ TEST(RxTest, TestInvalidFlightChannels)
// when
for (uint8_t channelIndex = 0; channelIndex < MAX_SUPPORTED_RC_CHANNEL_COUNT; channelIndex++) {
rxUpdateFlightChannelStatus(channelIndex, channelPulses[channelIndex]);
bool validPulse = isPulseValid(channelPulses[channelIndex]);
rxUpdateFlightChannelStatus(channelIndex, validPulse);
}
// then
@ -114,7 +118,8 @@ TEST(RxTest, TestInvalidFlightChannels)
// when
for (uint8_t channelIndex = 0; channelIndex < MAX_SUPPORTED_RC_CHANNEL_COUNT; channelIndex++) {
rxUpdateFlightChannelStatus(channelIndex, channelPulses[channelIndex]);
bool validPulse = isPulseValid(channelPulses[channelIndex]);
rxUpdateFlightChannelStatus(channelIndex, validPulse);
}
// then
@ -138,6 +143,10 @@ extern "C" {
return testData.isPPMDataBeingReceived;
}
bool isPWMDataBeingReceived(void) {
return testData.isPWMDataBeingReceived;
}
void resetPPMDataReceivedState(void) {}
bool rxMspFrameComplete(void) { return false; }