Skip to content

Commit

Permalink
simplify serialrx by Cesco
Browse files Browse the repository at this point in the history
fix bug in softserial with digitalIn usage (todo rewrite this properly)

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@425 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
  • Loading branch information
timecop@gmail.com committed Oct 2, 2013
1 parent fa810e9 commit 5332b78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/drv_softserial.c
Expand Up @@ -17,7 +17,7 @@ void onSerialTimer(uint8_t portIndex, uint16_t capture);

uint8_t readRxSignal(softSerial_t *softSerial)
{
return digitalIn(softSerial->rxTimerHardware->gpio, softSerial->rxTimerHardware->pin);
return !(digitalIn(softSerial->rxTimerHardware->gpio, softSerial->rxTimerHardware->pin) == 0);
}

void setTxSignal(softSerial_t *softSerial, uint8_t state)
Expand Down
15 changes: 6 additions & 9 deletions src/mw.c
Expand Up @@ -435,28 +435,25 @@ void loop(void)
uint16_t auxState = 0;
static uint8_t GPSNavReset = 1;
bool isThrottleLow = false;
bool rcReady = false;

// calculate rc stuff from serial-based receivers (spek/sbus)
if (feature(FEATURE_SERIALRX)) {
bool ready = false;
switch (mcfg.serialrx_type) {
case SERIALRX_SPEKTRUM1024:
case SERIALRX_SPEKTRUM2048:
ready = spektrumFrameComplete();
rcReady = spektrumFrameComplete();
break;
case SERIALRX_SBUS:
ready = sbusFrameComplete();
rcReady = sbusFrameComplete();
break;
}
if (ready)
computeRC();
}

if ((int32_t)(currentTime - rcTime) >= 0) { // 50Hz
if (((int32_t)(currentTime - rcTime) >= 0) || rcReady) { // 50Hz or data driven
rcReady = false;
rcTime = currentTime + 20000;
// TODO clean this up. computeRC should handle this check
if (!feature(FEATURE_SERIALRX))
computeRC();
computeRC();

// in 3D mode, we need to be able to disarm by switch at any time
if (feature(FEATURE_3D)) {
Expand Down

0 comments on commit 5332b78

Please sign in to comment.