diff --git a/src/SCRIPTS/BF/MSP/ghost.lua b/src/SCRIPTS/BF/MSP/ghost.lua new file mode 100644 index 0000000..f8f6131 --- /dev/null +++ b/src/SCRIPTS/BF/MSP/ghost.lua @@ -0,0 +1,28 @@ +-- GHOST Frame Types +local GHST_FRAMETYPE_MSP_REQ = 0x21 +local GHST_FRAMETYPE_MSP_WRITE = 0x22 +local GHST_FRAMETYPE_MSP_RESP = 0x28 + +ghstMspType = 0 + +protocol.mspSend = function(payload) + return protocol.push(ghstMspType, payload) +end + +protocol.mspRead = function(cmd) + ghstMspType = GHST_FRAMETYPE_MSP_REQ + return mspSendRequest(cmd, {}) +end + +protocol.mspWrite = function(cmd, payload) + ghstMspType = GHST_FRAMETYPE_MSP_WRITE + return mspSendRequest(cmd, payload) +end + +protocol.mspPoll = function() + local type, data = ghostTelemetryPop() + if type == GHST_FRAMETYPE_MSP_RESP then + return mspReceivedReply(data) + end + return nil +end diff --git a/src/SCRIPTS/BF/protocols.lua b/src/SCRIPTS/BF/protocols.lua index c415104..6426bbe 100644 --- a/src/SCRIPTS/BF/protocols.lua +++ b/src/SCRIPTS/BF/protocols.lua @@ -20,6 +20,16 @@ local supportedProtocols = saveMaxRetries = 2, saveTimeout = 150, cms = {}, + }, + ghost = + { + mspTransport = "MSP/ghost.lua", + push = ghostTelemetryPush, + maxTxBufferSize = 10, -- Tx -> Rx (Push) + maxRxBufferSize = 6, -- Rx -> Tx (Pop) + saveMaxRetries = 2, + saveTimeout = 250, + cms = {}, } } @@ -28,6 +38,8 @@ local function getProtocol() return supportedProtocols.smartPort elseif supportedProtocols.crsf.push() ~= nil then return supportedProtocols.crsf + elseif supportedProtocols.ghost.push() ~= nil then + return supportedProtocols.ghost end end