This repository has been archived on 2024-05-28. You can view files and clone it, but cannot push or open issues or pull requests.
2023-11-14 16:25:09 -05:00

48 lines
1.4 KiB
C++
Executable File

/// @file uart.h
/// @brief uart driver for stm32u5xx
/// @date 2023-08-06
/// @copyright Copyright (c) 2023 ggeta. All rights reserved.
/// @version 0.1 init version - support block read/write and interrupt read/write
#ifndef STM32U5XX_HAL_UART_H
#define STM32U5XX_HAL_UART_H
#include "global_variable.h"
#include "queue.hpp"
#include "reg_uart.h"
#include "stm32u5xx.h"
class Usart {
private:
USART_TypeDef *instance = nullptr;
reg_uart_t *reg = nullptr;
queue20u8 receive_queue;
queue20u8 send_queue;
public:
Usart();
explicit Usart(USART_TypeDef *uart);
void setup(USART_TypeDef *uart);
// hal_status_e init_old(uart_init_options_s options) {
hal_status_e init(uint32_t baudrate = 115200, uint32_t send_buffer_size = 64,
uint32_t receive_buffer_size = 64,
LL_UART_DATA_LENGTH data_length = LL_UART_DATA_LENGTH_8,
LL_UART_PARITY parity = LL_UART_PARITY_NONE,
LL_UART_STOP_BITS stop_bits = LL_UART_STOP_BITS_1,
LL_UART_OVERSAMPLING oversampling = LL_UART_OVERSAMPLING_16);
hal_status_e send(uint8_t *data, uint32_t size);
hal_status_e receive(uint8_t *data, uint32_t size);
hal_status_e get_line(uint8_t *data, uint32_t &size);
hal_status_e send_massive(uint8_t *data, uint32_t *size);
hal_status_e interrupt();
};
#endif // STM32U5XX_HAL_UART_H