halx
読み取り中…
検索中…
一致する文字列を見つけられません
uart_poll.hpp
[詳解]
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5
6#include "halx/core.hpp"
7
8#include "common.hpp"
9
10namespace halx::peripheral {
11
12template <UART_HandleTypeDef *Handle> class UartTxPoll {
13public:
14 UartTxPoll() = default;
15
16 ~UartTxPoll() = default;
17
18 bool transmit(const uint8_t *data, size_t size, uint32_t timeout) {
19 return HAL_UART_Transmit(Handle, data, size, timeout) == HAL_OK;
20 }
21
22private:
23 UartTxPoll(const UartTxPoll &) = delete;
24 UartTxPoll &operator=(const UartTxPoll &) = delete;
25};
26
27template <UART_HandleTypeDef *Handle> class UartRxPoll {
28public:
29 UartRxPoll(size_t) {};
30
31 ~UartRxPoll() = default;
32
33 bool receive(uint8_t *data, size_t size, uint32_t timeout) {
34 return HAL_UART_Receive(Handle, data, size, timeout);
35 }
36
37 void flush() {}
38
39 size_t available() const { return 0; }
40
41private:
42 UartRxPoll(const UartRxPoll &) = delete;
43 UartRxPoll &operator=(const UartRxPoll &) = delete;
44};
45
46} // namespace halx::peripheral
Definition uart_poll.hpp:27
size_t available() const
Definition uart_poll.hpp:39
UartRxPoll(size_t)
Definition uart_poll.hpp:29
bool receive(uint8_t *data, size_t size, uint32_t timeout)
Definition uart_poll.hpp:33
void flush()
Definition uart_poll.hpp:37
Definition uart_poll.hpp:12
bool transmit(const uint8_t *data, size_t size, uint32_t timeout)
Definition uart_poll.hpp:18
Definition can.hpp:13