crb_lte/Core/Inc/usart.h
2025-08-01 14:35:49 +08:00

116 lines
2.8 KiB
C

/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file usart.h
* @brief This file contains all the function prototypes for
* the usart.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 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.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H__
#define __USART_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include <yfuns.h>
#include <string.h>
/* USER CODE END Includes */
extern UART_HandleTypeDef hlpuart1;
extern UART_HandleTypeDef huart1;
/* USER CODE BEGIN Private defines */
// #define LOG_APP_DEBUG
#define LOG_APP_ERROR
#define LOG_APP_LOG
#define LOG_APP_LTE
/**
* @brief Application general debug messages
*
* Enable by defining `LOG_APP_DEBUG` in config.h.
*/
#ifdef LOG_APP_DEBUG
# define APP_DEBUG_MSG(a, ...) printf(("DEBUG: " a), ##__VA_ARGS__)
#else
# define APP_DEBUG_MSG(...) ((void)0)
#endif
/**
* @brief Application error messages
*
* Enable by defining `LOG_APP_ERROR` in config.h.
*/
#ifdef LOG_APP_ERROR
# define APP_ERROR_MSG(a, ...) printf(("ERROR: "a), ##__VA_ARGS__)
#else
# define APP_ERROR_MSG(...) ((void)0)
#endif
/**
* @brief Application logging messages
*
* Enable by defining `LOG_APP_LOG` in config.h.
*/
#ifdef LOG_APP_LOG
# define APP_LOG_MSG(a, ...) printf((a), ##__VA_ARGS__)
#else
# define APP_LOG_MSG(...) ((void)0)
#endif
/**
* @brief Application logging lte messages
*
* Enable by defining `LOG_APP_LTE` in config.h.
*/
#ifdef LOG_APP_LTE
# define APP_LTE_MSG(a, ...) printf(("AT RSP:" a), ##__VA_ARGS__)
#else
# define APP_LTE_MSG(...) ((void)0)
#endif
/* USER CODE END Private defines */
void MX_LPUART1_UART_Init(void);
void MX_USART1_UART_Init(void);
/* USER CODE BEGIN Prototypes */
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle);
void LTE_ATSendCommand(const char *cmd);
void LTE_SendATCommand_Test(void);
int8_t LTE_UART_SetBaudrate(uint32_t baudrate);
void LTE_UART_FlushBuffer(void);
int16_t LTE_UART_SendData(uint8_t *pData, uint16_t length);
int16_t LTE_UART_ReceiveSingleData(uint8_t *pSingleData);
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __USART_H__ */