L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
usart_if.c File Reference

Configuration of UART driver interface for hyperterminal communication. More...

#include "usart_if.h"
#include "stm32_seq.h"
Include dependency graph for usart_if.c:

Go to the source code of this file.

Functions

UTIL_ADV_TRACE_Status_t vcom_Init (void(*cb)(void *))
 Init the UART and associated DMA.
UTIL_ADV_TRACE_Status_t vcom_DeInit (void)
 DeInit the UART and associated DMA.
void vcom_Trace (uint8_t *p_data, uint16_t size)
 send buffer p_data of size size to vcom in polling mode
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
void vcom_Resume (void)
 Resume the UART and associated DMA (used by LPM).
void HAL_UART_TxCpltCallback (UART_HandleTypeDef *huart)
void HAL_UART_RxCpltCallback (UART_HandleTypeDef *huart)
int HAL_UART_RxCharMT (UART_HandleTypeDef *huart, uint8_t charRx)
 called if char is ready from UART
UTIL_ADV_TRACE_Status_t Uart_Info (const char *strInfo)
 Write to UART1.
UTIL_ADV_TRACE_Status_t Uart_NextReceving ()
 continue with next reading if data arrived
UTIL_ADV_TRACE_Status_t Uart_StartReceving (UART_HandleTypeDef *uart)
 start reading

Variables

DMA_HandleTypeDef hdma_usart1_tx
 DMA handle.
UART_HandleTypeDef huart1
 UART handle.
uint8_t charRx
 buffer to receive 1 character
char uart_req_buf [100]
char * uart_req_w_ptr
static UART_HandleTypeDef * _curUart = NULL
const UTIL_ADV_TRACE_Driver_s UTIL_TraceDriver
 Trace driver callbacks handler.
static void(* TxCpltCallback )(void *)
 TX complete callback.
static void(* RxCpltCallback )(uint8_t *rxChar, uint16_t size, uint8_t error)
 RX complete callback.

Detailed Description

Configuration of UART driver interface for hyperterminal communication.

Author
MCD Application Team
Attention

Copyright (c) 2026 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file usart_if.c.

Function Documentation

◆ HAL_UART_RxCharMT()

int HAL_UART_RxCharMT ( UART_HandleTypeDef * huart,
uint8_t charRx )

called if char is ready from UART

Return values
-1- other UART, 0 - char is accepted, next receiving must start, 1 - data ready

Definition at line 279 of file usart_if.c.

References _curUart, CFG_SEQ_Prio_0, CFG_SEQ_Task_Uart_RX, charRx, uart_req_buf, and uart_req_w_ptr.

Referenced by HAL_UART_RxCpltCallback().

Here is the caller graph for this function:

◆ HAL_UART_RxCpltCallback()

void HAL_UART_RxCpltCallback ( UART_HandleTypeDef * huart)

Definition at line 255 of file usart_if.c.

References charRx, HAL_UART_RxCharMT(), and RxCpltCallback.

Here is the call graph for this function:

◆ HAL_UART_TxCpltCallback()

void HAL_UART_TxCpltCallback ( UART_HandleTypeDef * huart)

Definition at line 240 of file usart_if.c.

References TxCpltCallback.

Referenced by vcom_Trace_DMA().

Here is the caller graph for this function:

◆ Uart_Info()

UTIL_ADV_TRACE_Status_t Uart_Info ( const char * strInfo)

Write to UART1.

Definition at line 299 of file usart_if.c.

References vcom_Trace().

Referenced by writeLogNL().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Uart_NextReceving()

UTIL_ADV_TRACE_Status_t Uart_NextReceving ( )

continue with next reading if data arrived

Definition at line 306 of file usart_if.c.

References uart_req_buf, and uart_req_w_ptr.

Referenced by Uart_RxProcessing(), and Uart_StartReceving().

Here is the caller graph for this function:

◆ Uart_StartReceving()

UTIL_ADV_TRACE_Status_t Uart_StartReceving ( UART_HandleTypeDef * uart)

start reading

Parameters
uart- handle for the uart being used

Definition at line 313 of file usart_if.c.

References _curUart, Uart_NextReceving(), and vcom_ReceiveInit().

Referenced by uart_Start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcom_DeInit()

UTIL_ADV_TRACE_Status_t vcom_DeInit ( void )

DeInit the UART and associated DMA.

Returns
UTIL_ADV_TRACE_Status_t

Definition at line 120 of file usart_if.c.

References HAL_UART_MspDeInit(), and huart1.

Here is the call graph for this function:

◆ vcom_Init()

UTIL_ADV_TRACE_Status_t vcom_Init ( void(* cb )(void *))

Init the UART and associated DMA.

Parameters
cbTxCpltCallback
Returns
UTIL_ADV_TRACE_Status_t

Definition at line 105 of file usart_if.c.

References MX_DMA_Init(), MX_USART1_UART_Init(), and TxCpltCallback.

Here is the call graph for this function:

◆ vcom_ReceiveInit()

UTIL_ADV_TRACE_Status_t vcom_ReceiveInit ( void(* RxCb )(uint8_t *rxChar, uint16_t size, uint8_t error))

init receiver of vcom

Parameters
RxCbcallback when Rx char is received
Returns
UTIL_ADV_TRACE_Status_t

Definition at line 177 of file usart_if.c.

References charRx, huart1, and RxCpltCallback.

Referenced by Uart_StartReceving().

Here is the caller graph for this function:

◆ vcom_Resume()

void vcom_Resume ( void )

Resume the UART and associated DMA (used by LPM).

Definition at line 217 of file usart_if.c.

References Error_Handler(), hdma_usart1_tx, and huart1.

Referenced by PWR_ExitStopMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcom_Trace()

void vcom_Trace ( uint8_t * p_data,
uint16_t size )

send buffer p_data of size size to vcom in polling mode

Parameters
p_datadata to be sent
sizeof buffer p_data to be sent

Definition at line 145 of file usart_if.c.

References huart1.

Referenced by Uart_Info().

Here is the caller graph for this function:

◆ vcom_Trace_DMA()

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

Parameters
p_datadata to be sent
sizeof buffer p_data to be sent
Returns
UTIL_ADV_TRACE_Status_t

Definition at line 158 of file usart_if.c.

References HAL_UART_TxCpltCallback(), and huart1.

Here is the call graph for this function:

Variable Documentation

◆ _curUart

UART_HandleTypeDef* _curUart = NULL
static

Definition at line 48 of file usart_if.c.

Referenced by HAL_UART_RxCharMT(), and Uart_StartReceving().

◆ charRx

uint8_t charRx

buffer to receive 1 character

Definition at line 42 of file usart_if.c.

Referenced by HAL_UART_RxCharMT(), HAL_UART_RxCpltCallback(), vcom_DMA_TX_IRQHandler(), and vcom_ReceiveInit().

◆ hdma_usart1_tx

DMA_HandleTypeDef hdma_usart1_tx
extern

DMA handle.

Definition at line 31 of file usart.c.

◆ huart1

UART_HandleTypeDef huart1
extern

UART handle.

Definition at line 30 of file usart.c.

◆ RxCpltCallback

void(* RxCpltCallback) (uint8_t *rxChar, uint16_t size, uint8_t error) ( uint8_t * rxChar,
uint16_t size,
uint8_t error )
static

RX complete callback.

Parameters
rxCharptr of chars buffer sent by user
sizebuffer size
errorerrorcode
Returns
none

Definition at line 91 of file usart_if.c.

Referenced by HAL_UART_RxCpltCallback(), and vcom_ReceiveInit().

◆ TxCpltCallback

void(* TxCpltCallback) (void *) ( void * )
static

TX complete callback.

Returns
none

Definition at line 83 of file usart_if.c.

Referenced by HAL_UART_TxCpltCallback(), and vcom_Init().

◆ uart_req_buf

char uart_req_buf[100]

Definition at line 46 of file usart_if.c.

Referenced by HAL_UART_RxCharMT(), and Uart_NextReceving().

◆ uart_req_w_ptr

char* uart_req_w_ptr

Definition at line 47 of file usart_if.c.

Referenced by HAL_UART_RxCharMT(), and Uart_NextReceving().

◆ UTIL_TraceDriver

const UTIL_ADV_TRACE_Driver_s UTIL_TraceDriver
Initial value:
=
{
}
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
Definition usart_if.c:158
UTIL_ADV_TRACE_Status_t vcom_ReceiveInit(void(*RxCb)(uint8_t *rxChar, uint16_t size, uint8_t error))
init receiver of vcom
Definition usart_if.c:177
UTIL_ADV_TRACE_Status_t vcom_DeInit(void)
DeInit the UART and associated DMA.
Definition usart_if.c:120
UTIL_ADV_TRACE_Status_t vcom_Init(void(*cb)(void *))
Init the UART and associated DMA.
Definition usart_if.c:105

Trace driver callbacks handler.

Definition at line 56 of file usart_if.c.