Do not allocate memory for LUA Rx fifo from the USB ISR

Rather use explicit allocation when the serial is set as the on-demand method that was used previously.
This commit is contained in:
Raphael Coeffic
2022-03-20 16:30:59 +01:00
parent 55a08d2f9d
commit 9c9f77a2a9
3 changed files with 21 additions and 3 deletions
+15 -3
View File
@@ -103,13 +103,25 @@ static int luaRxFifoGetByte(void*, uint8_t* data)
return luaRxFifo->pop(*data);
}
void luaReceiveData(uint8_t* buf, uint32_t len)
void luaAllocRxFifo()
{
if (!luaRxFifo) {
luaRxFifo = new Fifo<uint8_t, LUA_FIFO_SIZE>();
auto fifo = new Fifo<uint8_t, LUA_FIFO_SIZE>();
luaRxFifo = fifo;
luaSetGetSerialByte(nullptr, luaRxFifoGetByte);
}
}
void luaFreeRxFifo()
{
auto fifo = luaRxFifo;
luaSetGetSerialByte(nullptr, nullptr);
luaRxFifo = nullptr;
delete(fifo);
}
void luaReceiveData(uint8_t* buf, uint32_t len)
{
if (luaRxFifo) {
while(len--) luaRxFifo->push(*buf++);
}