mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
simplify serialrx by Cesco
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
This commit is contained in:
parent
fa810e907a
commit
5332b78200
2 changed files with 7 additions and 10 deletions
|
@ -17,7 +17,7 @@ void onSerialTimer(uint8_t portIndex, uint16_t capture);
|
||||||
|
|
||||||
uint8_t readRxSignal(softSerial_t *softSerial)
|
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)
|
void setTxSignal(softSerial_t *softSerial, uint8_t state)
|
||||||
|
|
13
src/mw.c
13
src/mw.c
|
@ -435,27 +435,24 @@ void loop(void)
|
||||||
uint16_t auxState = 0;
|
uint16_t auxState = 0;
|
||||||
static uint8_t GPSNavReset = 1;
|
static uint8_t GPSNavReset = 1;
|
||||||
bool isThrottleLow = false;
|
bool isThrottleLow = false;
|
||||||
|
bool rcReady = false;
|
||||||
|
|
||||||
// calculate rc stuff from serial-based receivers (spek/sbus)
|
// calculate rc stuff from serial-based receivers (spek/sbus)
|
||||||
if (feature(FEATURE_SERIALRX)) {
|
if (feature(FEATURE_SERIALRX)) {
|
||||||
bool ready = false;
|
|
||||||
switch (mcfg.serialrx_type) {
|
switch (mcfg.serialrx_type) {
|
||||||
case SERIALRX_SPEKTRUM1024:
|
case SERIALRX_SPEKTRUM1024:
|
||||||
case SERIALRX_SPEKTRUM2048:
|
case SERIALRX_SPEKTRUM2048:
|
||||||
ready = spektrumFrameComplete();
|
rcReady = spektrumFrameComplete();
|
||||||
break;
|
break;
|
||||||
case SERIALRX_SBUS:
|
case SERIALRX_SBUS:
|
||||||
ready = sbusFrameComplete();
|
rcReady = sbusFrameComplete();
|
||||||
break;
|
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;
|
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
|
// in 3D mode, we need to be able to disarm by switch at any time
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue