tutrcos
読み取り中…
検索中…
一致する文字列を見つけられません
tutrcos::peripheral::UART クラス

#include <uart.hpp>

公開メンバ関数

 UART (UART_HandleTypeDef *huart, size_t rx_queue_size=64)
 
 ~UART ()
 
bool transmit (const uint8_t *data, size_t size, uint32_t timeout)
 
bool receive (uint8_t *data, size_t size, uint32_t timeout)
 
void flush ()
 
void enable_stdout ()
 
UART_HandleTypeDef * get_hal_handle ()
 

詳解

Connectivity -> USART(UART)x -> NVIC Settings -> USART(UART)x global interrupt を有効化してください。

#include <cstdio>
#include <tutrcos.hpp>
extern UART_HandleTypeDef huart2;
extern "C" void main_thread(void *) {
using namespace tutrcos::core;
using namespace tutrcos::peripheral;
UART uart2(&huart2);
uart2.enable_stdout();
while (true) {
// 7バイト送信
uint8_t data[] = {'h', 'e', 'l', 'l', 'o', '\r', '\n'};
uart2.transmit(data, sizeof(data), Kernel::MAX_DELAY);
// 1バイト受信
char c;
if (uart2.receive((uint8_t *)&c, 1, Kernel::MAX_DELAY)) {
printf("入力した文字: %c\r\n", c);
}
Thread::delay(10);
}
}
Definition uart.hpp:51
Definition kernel.hpp:8
Definition can.hpp:15

構築子と解体子

◆ UART()

tutrcos::peripheral::UART::UART ( UART_HandleTypeDef * huart,
size_t rx_queue_size = 64 )
inline

◆ ~UART()

tutrcos::peripheral::UART::~UART ( )
inline

関数詳解

◆ enable_stdout()

void tutrcos::peripheral::UART::enable_stdout ( )
inline

◆ flush()

void tutrcos::peripheral::UART::flush ( )
inline

◆ get_hal_handle()

UART_HandleTypeDef * tutrcos::peripheral::UART::get_hal_handle ( )
inline

◆ receive()

bool tutrcos::peripheral::UART::receive ( uint8_t * data,
size_t size,
uint32_t timeout )
inline

◆ transmit()

bool tutrcos::peripheral::UART::transmit ( const uint8_t * data,
size_t size,
uint32_t timeout )
inline

このクラス詳解は次のファイルから抽出されました: