working receive
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "stm32f1xx_it.h"
|
||||
|
||||
constexpr auto UART_PORT = GPIOA_BASE;
|
||||
#define UARTPORT GPIOA
|
||||
#define UARTTX_PIN GPIO_PIN_9
|
||||
@@ -37,8 +39,8 @@ struct uart_handler {
|
||||
HAL_GPIO_Init(reinterpret_cast<GPIO_TypeDef*>(port), &ua_rx);
|
||||
|
||||
/* USART1 interrupt Init */
|
||||
// HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
|
||||
// HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||
}
|
||||
|
||||
static bool enable_oscillators() {
|
||||
@@ -87,7 +89,7 @@ struct uart_handler {
|
||||
return false;
|
||||
}
|
||||
|
||||
// result = HAL_UART_Receive_IT(&s_UARTHandle, rx_buff, rx_buff_size);
|
||||
result = HAL_UART_Receive_IT(&s_UARTHandle, &rx_buff, rx_buff_size);
|
||||
|
||||
return result == HAL_OK;
|
||||
}
|
||||
@@ -122,15 +124,16 @@ struct uart_handler {
|
||||
|
||||
static UART_HandleTypeDef s_UARTHandle;
|
||||
|
||||
static uint8_t* get_buf() { return rx_buff; }
|
||||
static uint8_t* get_buf() { return &rx_buff; }
|
||||
static const uint8_t* get_buf_c() { return &rx_buff; }
|
||||
|
||||
private:
|
||||
static constexpr auto pin_tx = PinTX;
|
||||
static constexpr auto pin_rx = PinRX;
|
||||
static constexpr auto port = Port;
|
||||
static constexpr auto usart_base = UsartBase;
|
||||
static constexpr size_t rx_buff_size = 10;
|
||||
static inline uint8_t* rx_buff;
|
||||
static constexpr size_t rx_buff_size = 1;
|
||||
static uint8_t rx_buff;
|
||||
};
|
||||
|
||||
template <uint16_t PinTX, uint16_t PinRX, uint32_t Port, uint32_t UsartBase>
|
||||
@@ -139,12 +142,3 @@ UART_HandleTypeDef uart_handler<PinTX, PinRX, Port, UsartBase>::s_UARTHandle =
|
||||
|
||||
using uart_interface =
|
||||
uart_handler<UARTTX_PIN, UARTRX_PIN, UART_PORT, USART1_BASE>;
|
||||
|
||||
template <>
|
||||
uint8_t* uart_interface::rx_buff = new uint8_t[10];
|
||||
|
||||
// inline void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart) {
|
||||
// static int count = 0;
|
||||
// count++;
|
||||
// HAL_UART_Receive_IT(huart, uart_interface::get_buf(), 10);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user