120 lines
2.7 KiB
C
120 lines
2.7 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) 2023 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 */
|
|
|
|
|
|
|
|
#define UART_PE_IRQ 0
|
|
#define UART_FE_IRQ 1
|
|
#define UART_NE_IRQ 2
|
|
#define UART_ORE_IRQ 3
|
|
#define UART_IDLE_IRQ 4
|
|
#define UART_RXEN_IRQ 5
|
|
#define UART_TXE_IRQ 7
|
|
|
|
|
|
#define LPUART_MAX_LENGTH 1200
|
|
#define USART1_MAX_LENGTH 1200
|
|
#define USART2_MAX_LENGTH 1200
|
|
#define USART4_MAX_LENGTH 1200 //
|
|
#define USART5_MAX_LENGTH 255
|
|
|
|
|
|
typedef enum Uart_t{
|
|
LpUart1 = 0,
|
|
LpUart2 = 1,
|
|
Uart1 = 2,
|
|
Uart2 = 3,
|
|
Uart3 = 4,
|
|
Uart4 = 5,
|
|
Uart5 = 6,
|
|
Uart6 = 7,
|
|
UartMax = 8,
|
|
}Uart_t;
|
|
|
|
typedef struct UartBuff_t{
|
|
char * rxBuf;
|
|
uint16_t rxMaxLen;
|
|
uint16_t rxLen;
|
|
char * txBuf;
|
|
uint16_t txMaxLen;
|
|
uint16_t txLen;
|
|
}UartBuff_t;
|
|
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
extern UART_HandleTypeDef hlpuart1;
|
|
|
|
extern UART_HandleTypeDef hlpuart2;
|
|
|
|
extern UART_HandleTypeDef huart1;
|
|
|
|
extern UART_HandleTypeDef huart2;
|
|
|
|
extern UART_HandleTypeDef huart3;
|
|
|
|
extern UART_HandleTypeDef huart4;
|
|
|
|
extern UART_HandleTypeDef huart5;
|
|
|
|
extern UART_HandleTypeDef huart6;
|
|
|
|
/* USER CODE BEGIN Private defines */
|
|
|
|
/* USER CODE END Private defines */
|
|
|
|
void MX_LPUART1_UART_Init(void);
|
|
void MX_LPUART2_UART_Init(void);
|
|
void MX_USART1_UART_Init(void);
|
|
void MX_USART2_UART_Init(void);
|
|
void MX_USART3_UART_Init(void);
|
|
void MX_USART4_UART_Init(void);
|
|
void MX_USART5_UART_Init(void);
|
|
void MX_USART6_UART_Init(void);
|
|
|
|
/* USER CODE BEGIN Prototypes */
|
|
int dbg_printf (char* fmt, ...);
|
|
extern void uart_SystemTick (void);
|
|
extern int MX_UART_IsReady(Uart_t uart);
|
|
extern int MX_UART_ReadData(Uart_t uart, char * buff, int maxLength);
|
|
void MX_UART_Clear(Uart_t uart);
|
|
void MX_UART_PutChar(Uart_t uart, char ch);
|
|
void MX_UART_PutBuffer(Uart_t uart, char *buff,int size);
|
|
/* USER CODE END Prototypes */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __USART_H__ */
|
|
|