first commit

This commit is contained in:
Dana Markova
2025-07-28 13:21:36 +03:00
commit 0de214c9a1
547 changed files with 287132 additions and 0 deletions

37
dev/crsf.cpp Normal file
View File

@ -0,0 +1,37 @@
#include "crsf.hpp"
#include <algorithm>
#include "uart.h"
#include "tick.h"
uint32_t crsfLastUpdateTime;
constexpr uint32_t crsfSignalLoseTimeout = 100;
void CRSF_Init(void)
{
UART2_Init(CRSF_BAUDRATE);
crsfLastUpdateTime = 0;
}
bool CRSF_Update(CRSF_Data& data, bool& off)
{
uint8_t buf[CRSF_FRAME_SIZE_MAX + 1];
unsigned long size = UART2_Recv(buf, sizeof(buf));
if(size == 0)
return false;
uint16_t num;
bool isUpdated = crsf_parse(buf, size, reinterpret_cast<uint16_t*>(&data), &num, 18);
if(isUpdated)
crsfLastUpdateTime = TICK_GetCount();
else if(TICK_GetCount() - crsfLastUpdateTime > crsfSignalLoseTimeout)
{
off = true;
return true;
}
else
off = false;
return isUpdated;
}