37extern UART_HandleTypeDef
huart1;
113 LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_26);
114 return UTIL_ADV_TRACE_OK;
123 if (
huart1.Instance == NULL)
124 return UTIL_ADV_TRACE_HW_ERROR;
128 __HAL_RCC_USART1_FORCE_RESET();
129 __HAL_RCC_USART1_RELEASE_RESET();
136 HAL_NVIC_DisableIRQ(DMA1_Channel5_IRQn);
138 return UTIL_ADV_TRACE_OK;
148 if (
huart1.Instance == NULL)
152 HAL_UART_Transmit(&
huart1, p_data, size, 1000);
161 if (
huart1.Instance == NULL)
162 return UTIL_ADV_TRACE_HW_ERROR;
164 HAL_UART_Transmit(&
huart1, p_data, size, 10000);
166 return UTIL_ADV_TRACE_OK;
170 HAL_UART_Transmit_DMA(&
huart1, p_data, size);
171 return UTIL_ADV_TRACE_OK;
177UTIL_ADV_TRACE_Status_t
vcom_ReceiveInit(
void (*RxCb)(uint8_t *rxChar, uint16_t size, uint8_t error))
181 if (
huart1.Instance == NULL)
182 return UTIL_ADV_TRACE_HW_ERROR;
186 UART_WakeUpTypeDef WakeUpSelection;
192 WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_STARTBIT;
194 HAL_UARTEx_StopModeWakeUpSourceConfig(&
huart1, WakeUpSelection);
197 while (__HAL_UART_GET_FLAG(&
huart1, USART_ISR_BUSY) == SET);
200 while (__HAL_UART_GET_FLAG(&
huart1, USART_ISR_REACK) == RESET);
203 __HAL_UART_ENABLE_IT(&
huart1, UART_IT_WUF);
206 HAL_UARTEx_EnableStopMode(&
huart1);
211 return UTIL_ADV_TRACE_OK;
220 if (
huart1.Instance == NULL)
225 if (HAL_UART_Init(&
huart1) != HAL_OK)
246 if (huart->Instance == USART1)
260 if (huart->Instance == USART1)
262 if ((NULL !=
RxCpltCallback) && (HAL_UART_ERROR_NONE == huart->ErrorCode))
266 HAL_UART_Receive_IT(huart, &
charRx, 1);
301 UTIL_ADV_TRACE_Status_t status = UTIL_ADV_TRACE_OK;
302 vcom_Trace((uint8_t*) strInfo, strlen(strInfo));
310 return UTIL_ADV_TRACE_OK;
void MX_DMA_Init(void)
Initialise DMA1 channels used by USART1 (TX via DMA) and other peripherals. Must be called before MX_...
void Error_Handler(void)
Default error handler called by HAL on unrecoverable errors. Disables interrupts and enters an infini...
DMA_HandleTypeDef hdma_usart1_tx
void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
UART_HandleTypeDef huart1
void MX_USART1_UART_Init(void)
Initialise USART1 (huart1) as configured by STM32CubeMX. Sets baud rate, word length,...
const UTIL_ADV_TRACE_Driver_s UTIL_TraceDriver
Trace driver callbacks handler.
UTIL_ADV_TRACE_Status_t vcom_Trace_DMA(uint8_t *p_data, uint16_t size)
send buffer p_data of size size to vcom using DMA
void vcom_Resume(void)
Resume the UART and associated DMA (used by LPM).
static void(* RxCpltCallback)(uint8_t *rxChar, uint16_t size, uint8_t error)
RX complete callback.
UTIL_ADV_TRACE_Status_t Uart_Info(const char *strInfo)
Write to UART1.
int HAL_UART_RxCharMT(UART_HandleTypeDef *huart, uint8_t charRx)
called if char is ready from UART
void vcom_Trace(uint8_t *p_data, uint16_t size)
send buffer p_data of size size to vcom in polling mode
static void(* TxCpltCallback)(void *)
TX complete callback.
UTIL_ADV_TRACE_Status_t Uart_NextReceving()
continue with next reading if data arrived
UTIL_ADV_TRACE_Status_t vcom_ReceiveInit(void(*RxCb)(uint8_t *rxChar, uint16_t size, uint8_t error))
init receiver of vcom
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
UTIL_ADV_TRACE_Status_t Uart_StartReceving(UART_HandleTypeDef *uart)
start reading
UTIL_ADV_TRACE_Status_t vcom_DeInit(void)
DeInit the UART and associated DMA.
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
static UART_HandleTypeDef * _curUart
UTIL_ADV_TRACE_Status_t vcom_Init(void(*cb)(void *))
Init the UART and associated DMA.
uint8_t charRx
buffer to receive 1 character
Header for USART interface configuration.
UTIL_ADV_TRACE_Status_t vcom_Trace_DMA(uint8_t *p_data, uint16_t size)
send buffer p_data of size size to vcom using DMA
UTIL_ADV_TRACE_Status_t vcom_ReceiveInit(void(*RxCb)(uint8_t *rxChar, uint16_t size, uint8_t error))
init receiver of vcom
UTIL_ADV_TRACE_Status_t vcom_DeInit(void)
DeInit the UART and associated DMA.
UTIL_ADV_TRACE_Status_t vcom_Init(void(*cb)(void *))
Init the UART and associated DMA.