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