Skip to content

Commit

Permalink
- make SPEKTRUM / SUMD / SBUS RX code more generic via SERIAL_RX def
Browse files Browse the repository at this point in the history
- solve a bug in LCD conf for SERIAL RX

git-svn-id: http://multiwii.googlecode.com/svn/trunk/MultiWii_shared@1720 02679b44-d973-9852-f2fa-63770883b36c
  • Loading branch information
dubusal committed Nov 3, 2014
1 parent 4cee672 commit 5ec5a6a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 23 deletions.
5 changes: 3 additions & 2 deletions LCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,8 +1546,9 @@ void configurationLoop() {
ConfigRefresh(p);
refreshLCD = 0;
}
#if defined(SPEKTRUM)
readRawRC(1); delay(44); // For digital receivers like Spektrum, SBUS, and Serial, to ensure that an "old" frame does not cause immediate exit at startup.
#if defined(SERIAL_RX)
if (spekFrameFlags == 0x01) readSerial_RX();
delay(44); // For digital receivers , to ensure that an "old" frame does not cause immediate exit at startup.
#endif
#if defined(LCD_TEXTSTAR) || defined(LCD_VT100) || defined(LCD_TTY) // textstar, vt100 and tty can send keys
key = ( SerialAvailable(LCD_SERIAL_PORT) ? SerialRead(LCD_SERIAL_PORT) : 0 );
Expand Down
17 changes: 5 additions & 12 deletions MultiWii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ uint8_t rcSerialCount = 0; // a counter to select legacy RX when there is no m
int16_t lookupPitchRollRC[5];// lookup table for expo & RC rate PITCH+ROLL
int16_t lookupThrottleRC[11];// lookup table for expo & mid THROTTLE

#if defined(SPEKTRUM) || defined(SBUS) || defined(SUMD)
#if defined(SERIAL_RX)
volatile uint8_t spekFrameFlags;
volatile uint32_t spekTimeLast;
uint8_t spekFrameDone;
Expand Down Expand Up @@ -536,7 +536,7 @@ void annexCode() { // this code is excetuted at each loop and won't interfere wi
}
}

#if !(defined(SPEKTRUM) && defined(PROMINI)) //Only one serial port on ProMini. Skip serial com if Spektrum Sat in use. Note: Spek code will auto-call serialCom if GUI data detected on serial0.
#if !(defined(SERIAL_RX) && defined(PROMINI)) //Only one serial port on ProMini. Skip serial com if SERIAL RX in use. Note: Spek code will auto-call serialCom if GUI data detected on serial0.
serialCom();
#endif

Expand Down Expand Up @@ -815,21 +815,14 @@ void loop () {
int16_t rc;
int32_t prop = 0;

#if defined(SPEKTRUM)
if (spekFrameFlags == 0x01) readSpektrum();
#endif

#if defined(SBUS)
if (spekFrameFlags == 0x01) readSBus();
#endif
#if defined(SUMD)
if (spekFrameFlags == 0x01) readSumD();
#if defined(SERIAL_RX)
if (spekFrameFlags == 0x01) readSerial_RX();
#endif
#if defined(OPENLRSv2MULTI)
Read_OpenLRS_RC();
#endif

#if defined(SPEKTRUM) || defined(SBUS) || defined(SUMD)
#if defined(SERIAL_RX)
if ((spekFrameDone == 0x01) || ((int16_t)(currentTime-rcTime) >0 )) {
spekFrameDone = 0x00;
#else
Expand Down
2 changes: 1 addition & 1 deletion Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void serialCom() {
for(port=0;port<UART_NUMBER;port++) {
CURRENTPORT=port;
#define RX_COND
#if (defined(SPEKTRUM) || defined(SBUS) || defined(SUMD)) && (UART_NUMBER > 1)
#if defined(SERIAL_RX) && (UART_NUMBER > 1)
#define RX_COND && (RX_SERIAL_PORT != port)
#endif
cc = SerialAvailable(port);
Expand Down
6 changes: 3 additions & 3 deletions RX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void configureReceiver() {
static uint16_t sbusIndex=0;
static uint16_t sbus[25]={0};

void readSBus(){
void readSerial_RX(){
while(SerialAvailable(RX_SERIAL_PORT)){
int val = SerialRead(RX_SERIAL_PORT);
if(sbusIndex==0 && val != SBUS_SYNCBYTE)
Expand Down Expand Up @@ -372,7 +372,7 @@ static uint8_t sumdIndex=0;
static uint8_t sumdSize=0;
static uint8_t sumd[SUMD_BUFFSIZE]={0};

void readSumD(void) {
void readSerial_RX(void) {
while (SerialAvailable(RX_SERIAL_PORT)) {
int val = SerialRead(RX_SERIAL_PORT);
if(sumdIndex == 0 && val != SUMD_SYNCBYTE) continue;
Expand Down Expand Up @@ -402,7 +402,7 @@ void readSumD(void) {
/*************** combine and sort the RX Datas ********************/
/**************************************************************************************/
#if defined(SPEKTRUM)
void readSpektrum(void) {
void readSerial_RX(void) {
if ((!f.ARMED) &&
#if defined(FAILSAFE) || (RX_SERIAL_PORT != 0)
(failsafeCnt > 5) &&
Expand Down
4 changes: 1 addition & 3 deletions RX.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
void configureReceiver();
void computeRC();
uint16_t readRawRC(uint8_t chan);
void readSpektrum(void);
void readSBus(void);
void readSumD(void);
void readSerial_RX(void);
#if defined(OPENLRSv2MULTI)
void initOpenLRS(void);
void Read_OpenLRS_RC(void);
Expand Down
4 changes: 2 additions & 2 deletions Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void SerialEnd(uint8_t port) {

// we don't care about ring buffer overflow (head->tail) to avoid a test condition : data is lost anyway if it happens
void store_uart_in_buf(uint8_t data, uint8_t portnum) {
#if defined(SPEKTRUM) || defined(SBUS) || defined(SUMD)
#if defined(SERIAL_RX)
if (portnum == RX_SERIAL_PORT) {
if (!spekFrameFlags) {
sei();
Expand Down Expand Up @@ -207,7 +207,7 @@ uint8_t SerialRead(uint8_t port) {
return c;
}

#if defined(SPEKTRUM)
#if defined(SERIAL_RX)
uint8_t SerialPeek(uint8_t port) {
uint8_t c = serialBufferRX[serialTailRX[port]][port];
if ((serialHeadRX[port] != serialTailRX[port])) return c; else return 0;
Expand Down
4 changes: 4 additions & 0 deletions def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,10 @@
#define STANDARD_RX
#endif

#if defined(SPEKTRUM) || defined(SBUS) || defined(SUMD)
#define SERIAL_RX
#endif

// Spektrum Satellite
#if defined(SPEKTRUM)
#define SPEK_FRAME_SIZE 16
Expand Down

0 comments on commit 5ec5a6a

Please sign in to comment.