add : USB CDC虚拟串口通讯

This commit is contained in:
2026-04-03 12:14:43 +08:00
parent da4e944bca
commit dc518cefed
59 changed files with 13943 additions and 673 deletions

View File

@@ -0,0 +1,38 @@
local uartReceiveCallbacks = {}
local uartSentCallbacks = {}
uart.on = function(id, event, callback)
if event == "receive" then
uartReceiveCallbacks[id] = callback
elseif event == "sent" then
uartSentCallbacks[id] = callback
end
end
rtos.on(rtos.MSG_UART_RXDATA, function(id, length)
if uartReceiveCallbacks[id] then
uartReceiveCallbacks[id](id, length)
end
end)
rtos.on(rtos.MSG_UART_TX_DONE, function(id)
if uartSentCallbacks[id] then
uartSentCallbacks[id](id)
end
end)