Initial commit
This commit is contained in:
28
Core/Inc/usart.hpp
Normal file
28
Core/Inc/usart.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <ranges>
|
||||
#include <sstream>
|
||||
#include <string_view>
|
||||
|
||||
#include "stm32f401xe.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4xx_hal_uart.h"
|
||||
|
||||
namespace driver::usart {
|
||||
class Usart {
|
||||
public:
|
||||
explicit Usart(USART_TypeDef* usart, uint32_t baudRate, uint32_t wordLength, uint32_t stopBits,
|
||||
uint32_t parity, uint32_t mode, uint32_t hwFlowCtl, uint32_t overSampling);
|
||||
~Usart() = default;
|
||||
|
||||
bool init();
|
||||
void print(const std::string_view str);
|
||||
void println(const std::string_view str);
|
||||
|
||||
private:
|
||||
UART_HandleTypeDef mHandle{};
|
||||
|
||||
void tx(std::string_view range);
|
||||
void flush();
|
||||
};
|
||||
} // namespace driver::usart
|
Reference in New Issue
Block a user