Flysky IBUS driver
Posted: 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
rx channel assignment
rx open port
rx driver
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