65 bool init(UART_HandleTypeDef *huart,
size_t rx_queue_size = 64);
74 bool transmit(
const uint8_t *data,
size_t size);
84 bool receive(uint8_t *data,
size_t size, uint32_t timeout);
102 UART_HandleTypeDef *huart_;
103 osMutexId_t tx_mutex_;
104 osMutexId_t rx_mutex_;
105 osSemaphoreId_t tx_sem_;
106 osSemaphoreId_t rx_sem_;
107 osMutexId_t rx_queue_;
110 static std::unordered_map<UART_HandleTypeDef *, UART *> instances_;
111 static UART *uart_printf_;
112 friend void ::HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
113 friend void ::HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
114 friend void ::HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
115 friend int ::_write(
int file,
char *ptr,
int len);