You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
992 B
C

#include "p_serial_mgr.h"
#include "PCircularBuffer.h"
#define MAX_SERIAL_BUFFER_SIZE (256)
static uint8_t buffer[MAX_SERIAL_BUFFER_SIZE];
static p_cb_u8 serial_cb;
static UART_HandleTypeDef *_serial_huart_inst = NULL;
static uint8_t serial_cb_rxc = '\0';
void UART1_RxCpltCallback(UART_HandleTypeDef *huart)
{
serial_cb.push(&serial_cb, serial_cb_rxc);
// HAL_GPIO_WritePin(USART1_DE_GPIO_Port, USART1_DE_Pin, 1);
// huart2_rxc = huart1_rxc;
// HAL_UART_Transmit(&huart2, &huart2_rxc, 1, 500);
// HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
// HAL_GPIO_WritePin(USART1_DE_GPIO_Port, USART1_DE_Pin, 0);
}
void p_serial_mgr_init(UART_HandleTypeDef *huart)
{
_serial_huart_inst = huart;
_serial_huart_inst->RxCpltCallback = UART1_RxCpltCallback;
memset(buffer, 0, MAX_SERIAL_BUFFER_SIZE);
p_cb_u8_init(&serial_cb, buffer, MAX_SERIAL_BUFFER_SIZE);
}
void p_serial_mgr_service(void)
{
}
void p_serial_mgr_start()
{
HAL_UART_Receive_IT(_serial_huart_inst, &serial_cb_rxc, 1);
}