Files
MicroH7Board.Firmware/UartReader.h
T
2025-05-13 02:03:18 +03:00

26 lines
587 B
C++

#pragma once
#include <cstddef>
#include <cstdint>
#include <stm32h7xx_hal.h>
#include <functional>
class UartReader {
public:
using LineCallback = std::function<void(const char*, std::size_t)>;
UartReader();
void start(LineCallback lineCallback);
void onDataRx();
private:
static const int BufferSize = 128;
LineCallback _lineCallback;
std::uint8_t buffer0[BufferSize];
std::uint8_t buffer1[BufferSize];
std::uint8_t* _writeBuffer = buffer0;
std::uint8_t* _readBuffer = buffer1;
std::size_t _rxSize = 0;
//LF_TERMINAL_STREAM_USART
};