Flysky IBUS driver

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download

Flysky IBUS driver

Postby Plüschi » Fri Jan 16, 2015 9:25 am

IBUS is the new flysky serial protocol. Pretty simple.
You might have to patch that in by yourself since i do use my own branch of mwii.

config
Code: Select all
    /*******************************    IBUS RECIVER    ************************************/
      /* The following line apply only for FLYSKY IBus Receiver */
      #define IBUS

    #if defined(SPEKTRUM) | defined(SBUS) | defined(SUMD) | defined(IBUS)
      #define RX_SERIAL
      #define RX_SERIAL_PORT 1
    #endif


rx channel assignment
Code: Select all
#elif defined(IBUS)
  static uint8_t rcChannel[RC_CHANS] = {ROLL,PITCH,THROTTLE,YAW,AUX1,AUX2,AUX3,AUX4};

rx open port
Code: Select all
  // Init IBUS RX
  #if defined(IBUS)
    SerialOpen(RX_SERIAL_PORT,115200);
  #endif


rx driver
Code: Select all
/**************************************************************************************/
/***************                    IBUS                           ********************/
/**************************************************************************************/

#if defined(IBUS)
#define IBUS_BUFFSIZE 32
static uint8_t ibusIndex=0;
static uint8_t ibus[IBUS_BUFFSIZE]={0};

void readSerialRX(void)
{
  uint8_t i;
  uint8_t chksum;
  while (SerialAvailable(RX_SERIAL_PORT))
  {
    uint8_t val = SerialRead(RX_SERIAL_PORT);
    if(ibusIndex == 0 && val != 0x20) { continue; }
    if(ibusIndex == 1 && val != 0x40) { ibusIndex = 0; continue; }
    if(ibusIndex < IBUS_BUFFSIZE) ibus[ibusIndex] = val;
    ibusIndex++;
   
    if(ibusIndex == IBUS_BUFFSIZE)
    {
      ibusIndex = 0;
      chksum = 159;
      for (i=2;i<30;i++) chksum -= ibus[i];
      if (chksum == ibus[30])
      {
        rcValue[0] = (ibus[ 3]<<8) + ibus[ 2];
        rcValue[1] = (ibus[ 5]<<8) + ibus[ 4];
        rcValue[2] = (ibus[ 7]<<8) + ibus[ 6];
        rcValue[3] = (ibus[ 9]<<8) + ibus[ 8];
        rcValue[4] = (ibus[11]<<8) + ibus[10];
        rcValue[5] = (ibus[13]<<8) + ibus[12];
        rcValue[6] = (ibus[15]<<8) + ibus[14];
        rcValue[7] = (ibus[17]<<8) + ibus[16];     
        spekFrameDone = 0x01;
      }
    }
  }
}
#endif
User avatar
Plüschi
 
Posts: 433
Joined: Thu Feb 21, 2013 6:09 am

Re: Flysky IBUS driver

Postby Plüschi » Tue Jan 27, 2015 3:53 pm

Updates checksum calculation. NO FAILSAFE since failsafe doesent work with IBUS.

Code: Select all
#if defined(IBUS)
#define IBUS_BUFFSIZE 32
static uint8_t ibusIndex=0;
static uint8_t ibus[IBUS_BUFFSIZE]={0};

void readSerialRX(void)
{
  uint8_t i;
  uint16_t chksum,rxsum;
  while (SerialAvailable(RX_SERIAL_PORT))
  {
    uint8_t val = SerialRead(RX_SERIAL_PORT);
    if(ibusIndex == 0 && val != 0x20) { continue; }
    if(ibusIndex == 1 && val != 0x40) { ibusIndex = 0; continue; }
    if(ibusIndex < IBUS_BUFFSIZE) ibus[ibusIndex] = val;
    ibusIndex++;
   
    if(ibusIndex == IBUS_BUFFSIZE)
    {
      ibusIndex = 0;
      chksum = 0xFFFF;
      for (i=0;i<30;i++) chksum -= ibus[i];
      rxsum = ibus[30] + (ibus[31]<<8);
      if (chksum == rxsum)
      {
        rcValue[0] = (ibus[ 3]<<8) + ibus[ 2];
        rcValue[1] = (ibus[ 5]<<8) + ibus[ 4];
        rcValue[2] = (ibus[ 7]<<8) + ibus[ 6];
        rcValue[3] = (ibus[ 9]<<8) + ibus[ 8];
        rcValue[4] = (ibus[11]<<8) + ibus[10];
        rcValue[5] = (ibus[13]<<8) + ibus[12];
        rcValue[6] = (ibus[15]<<8) + ibus[14];
        rcValue[7] = (ibus[17]<<8) + ibus[16];     
        spekFrameDone = 0x01;
      }
    }
  }
}
#endif


F330 frame, 6chan IBUS receiver, 32u4 FC running mwii 2.2
Image
User avatar
Plüschi
 
Posts: 433
Joined: Thu Feb 21, 2013 6:09 am


Return to Software development

Who is online

Users browsing this forum: No registered users and 1 guest