Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_BLHeli/blheli_4way_protocol.h
Views: 1798
/*1blheli 4way protocol. Based on serial_4way.c from betaflight2*/3/*4* Cleanflight is free software: you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation, either version 3 of the License, or7* (at your option) any later version.8*9* Cleanflight is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.16* Author: 471217*/1819// Interface related only20// establish and test connection to the Interface2122// Send Structure23// ESC + CMD PARAM_LEN [PARAM (if len > 0)] CRC16_Hi CRC16_Lo24// Return25// ESC CMD PARAM_LEN [PARAM (if len > 0)] + ACK (uint8_t OK or ERR) + CRC16_Hi CRC16_Lo2627#define cmd_Remote_Escape 0x2E // '.'28#define cmd_Local_Escape 0x2F // '/'2930// Test Interface still present31#define cmd_InterfaceTestAlive 0x30 // '0' alive32// RETURN: ACK3334// get Protocol Version Number 01..25535#define cmd_ProtocolGetVersion 0x31 // '1' version36// RETURN: uint8_t VersionNumber + ACK3738// get Version String39#define cmd_InterfaceGetName 0x32 // '2' name40// RETURN: String + ACK4142//get Version Number 01..25543#define cmd_InterfaceGetVersion 0x33 // '3' version44// RETURN: uint8_t AVersionNumber + ACK454647// Exit / Restart Interface - can be used to switch to Box Mode48#define cmd_InterfaceExit 0x34 // '4' exit49// RETURN: ACK5051// Reset the Device connected to the Interface52#define cmd_DeviceReset 0x35 // '5' reset53// RETURN: ACK5455// Get the Device ID connected56// #define cmd_DeviceGetID 0x36 //'6' device id removed since 06/10657// RETURN: uint8_t DeviceID + ACK5859// Initialize Flash Access for Device connected60#define cmd_DeviceInitFlash 0x37 // '7' init flash access61// RETURN: ACK6263// Erase the whole Device Memory of connected Device64#define cmd_DeviceEraseAll 0x38 // '8' erase all65// RETURN: ACK6667// Erase one Page of Device Memory of connected Device68#define cmd_DevicePageErase 0x39 // '9' page erase69// PARAM: uint8_t APageNumber70// RETURN: ACK7172// Read to Buffer from Device Memory of connected Device // Buffer Len is Max 256 Bytes73// BuffLen = 0 means 256 Bytes74#define cmd_DeviceRead 0x3A // ':' read Device75// PARAM: uint8_t ADRESS_Hi + ADRESS_Lo + BuffLen[0..255]76// RETURN: PARAM: uint8_t ADRESS_Hi + ADRESS_Lo + BUffLen + Buffer[0..255] ACK7778// Write to Buffer for Device Memory of connected Device // Buffer Len is Max 256 Bytes79// BuffLen = 0 means 256 Bytes80#define cmd_DeviceWrite 0x3B // ';' write81// PARAM: uint8_t ADRESS_Hi + ADRESS_Lo + BUffLen + Buffer[0..255]82// RETURN: ACK8384// Set C2CK low infinite ) permanent Reset state85#define cmd_DeviceC2CK_LOW 0x3C // '<'86// RETURN: ACK8788// Read to Buffer from Device Memory of connected Device //Buffer Len is Max 256 Bytes89// BuffLen = 0 means 256 Bytes90#define cmd_DeviceReadEEprom 0x3D // '=' read Device91// PARAM: uint8_t ADRESS_Hi + ADRESS_Lo + BuffLen[0..255]92// RETURN: PARAM: uint8_t ADRESS_Hi + ADRESS_Lo + BUffLen + Buffer[0..255] ACK9394// Write to Buffer for Device Memory of connected Device // Buffer Len is Max 256 Bytes95// BuffLen = 0 means 256 Bytes96#define cmd_DeviceWriteEEprom 0x3E // '>' write97// PARAM: uint8_t ADRESS_Hi + ADRESS_Lo + BUffLen + Buffer[0..255]98// RETURN: ACK99100// Set Interface Mode101#define cmd_InterfaceSetMode 0x3F // '?'102// #define imC2 0103// #define imSIL_BLB 1104// #define imATM_BLB 2105// #define imSK 3106// PARAM: uint8_t Mode107// RETURN: ACK or ACK_I_INVALID_CHANNEL108109//Write to Buffer for Verify Device Memory of connected Device //Buffer Len is Max 256 Bytes110//BuffLen = 0 means 256 Bytes111#define cmd_DeviceVerify 0x40 //'@' write112//PARAM: uint8_t ADRESS_Hi + ADRESS_Lo + BUffLen + Buffer[0..255]113//RETURN: ACK114115/*116local defines117*/118#define SERIAL_4WAY_VER_MAIN 20119#define SERIAL_4WAY_VER_SUB_1 (uint8_t) 0120#define SERIAL_4WAY_VER_SUB_2 (uint8_t) 05121122#define SERIAL_4WAY_PROTOCOL_VER 107123// *** end124125#if (SERIAL_4WAY_VER_MAIN > 24)126#error "beware of SERIAL_4WAY_VER_SUB_1 is uint8_t"127#endif128129#define SERIAL_4WAY_VERSION (uint16_t) ((SERIAL_4WAY_VER_MAIN * 1000) + (SERIAL_4WAY_VER_SUB_1 * 100) + SERIAL_4WAY_VER_SUB_2)130131#define SERIAL_4WAY_VERSION_HI (uint8_t) (SERIAL_4WAY_VERSION / 100)132#define SERIAL_4WAY_VERSION_LO (uint8_t) (SERIAL_4WAY_VERSION % 100)133134#define brSUCCESS 0x30135#define brERRORVERIFY 0xC0136#define brERRORCOMMAND 0xC1137#define brERRORCRC 0xC2138#define brNONE 0xFF139140#define CMD_RUN 0x00141#define CMD_PROG_FLASH 0x01142#define CMD_ERASE_FLASH 0x02143#define CMD_READ_FLASH_SIL 0x03144#define CMD_VERIFY_FLASH 0x03145#define CMD_VERIFY_FLASH_ARM 0x04146#define CMD_READ_EEPROM 0x04147#define CMD_PROG_EEPROM 0x05148#define CMD_READ_SRAM 0x06149#define CMD_READ_FLASH_ATM 0x07150#define CMD_KEEP_ALIVE 0xFD151#define CMD_SET_ADDRESS 0xFF152#define CMD_SET_BUFFER 0xFE153154#define RestartBootloader 0155#define ExitBootloader 1156157#define ACK_OK 0x00158#define ACK_I_INVALID_CMD 0x02159#define ACK_I_INVALID_CRC 0x03160#define ACK_I_VERIFY_ERROR 0x04161#define ACK_I_INVALID_CHANNEL 0x08162#define ACK_I_INVALID_PARAM 0x09163#define ACK_D_GENERAL_ERROR 0x0F164165// interface modes166#define imC2 0167#define imSIL_BLB 1168#define imATM_BLB 2169#define imSK 3170#define imARM_BLB 4171172173