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