76 lines
2.4 KiB
C
76 lines
2.4 KiB
C
|
/**
|
|||
|
****************************************************************************************************
|
|||
|
* @file usart.h
|
|||
|
* @author XX<EFBFBD>Ŷ<EFBFBD>
|
|||
|
* @version V1.0
|
|||
|
* @date 2021-10-14
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(һ<EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><EFBFBD><EFBFBD>1)<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>printf
|
|||
|
* @license Copyright (c) 2020-2032,
|
|||
|
****************************************************************************************************
|
|||
|
* @attention
|
|||
|
*
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>ϵͳƽ̨<EFBFBD><EFBFBD>STM32F407
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
*
|
|||
|
* <EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>
|
|||
|
|
|||
|
* <EFBFBD><EFBFBD>һ<EFBFBD>η<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
****************************************************************************************************
|
|||
|
*/
|
|||
|
|
|||
|
#ifndef _USART_H
|
|||
|
#define _USART_H
|
|||
|
|
|||
|
#include "stdio.h"
|
|||
|
#include "drv_sys.h"
|
|||
|
|
|||
|
|
|||
|
/*******************************************************************************************************/
|
|||
|
/* <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
* Ĭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USART1<EFBFBD><EFBFBD>.
|
|||
|
* ע<EFBFBD><EFBFBD>: ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>12<EFBFBD><EFBFBD><EFBFBD>궨<EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>USART1~UART7<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
*/
|
|||
|
|
|||
|
#define USART_TX_GPIO_PORT GPIOB
|
|||
|
#define USART_TX_GPIO_PIN GPIO_PIN_6
|
|||
|
#define USART_TX_GPIO_AF GPIO_AF7_USART1
|
|||
|
#define USART_TX_GPIO_CLK_ENABLE() do{ __HAL_RCC_GPIOB_CLK_ENABLE(); }while(0) /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ʹ<EFBFBD><CAB9> */
|
|||
|
|
|||
|
#define USART_RX_GPIO_PORT GPIOB
|
|||
|
#define USART_RX_GPIO_PIN GPIO_PIN_7
|
|||
|
#define USART_RX_GPIO_AF GPIO_AF7_USART1
|
|||
|
#define USART_RX_GPIO_CLK_ENABLE() do{ __HAL_RCC_GPIOB_CLK_ENABLE(); }while(0) /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ʹ<EFBFBD><CAB9> */
|
|||
|
|
|||
|
#define USART_UX USART1
|
|||
|
#define USART_UX_IRQn USART1_IRQn
|
|||
|
#define USART_UX_IRQHandler USART1_IRQHandler
|
|||
|
#define USART_UX_CLK_ENABLE() do{ __HAL_RCC_USART1_CLK_ENABLE(); }while(0) /* USART1 ʱ<><CAB1>ʹ<EFBFBD><CAB9> */
|
|||
|
|
|||
|
/*******************************************************************************************************/
|
|||
|
|
|||
|
#define USART_REC_LEN 200 /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD> 200 */
|
|||
|
#define USART_EN_RX 1 /* ʹ<>ܣ<EFBFBD>1<EFBFBD><31>/<2F><>ֹ<EFBFBD><D6B9>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD> */
|
|||
|
#define RXBUFFERSIZE 1 /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С */
|
|||
|
|
|||
|
extern UART_HandleTypeDef g_uart1_handle; /* UART<52><54><EFBFBD><EFBFBD> */
|
|||
|
|
|||
|
extern uint8_t g_usart_rx_buf[USART_REC_LEN]; /* <20><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>,<2C><><EFBFBD><EFBFBD>USART_REC_LEN<45><4E><EFBFBD>ֽ<EFBFBD>.ĩ<>ֽ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>з<EFBFBD> */
|
|||
|
extern uint16_t g_usart_rx_sta; /* <20><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD> */
|
|||
|
extern uint8_t g_rx_buffer[RXBUFFERSIZE]; /* HAL<41><4C>USART<52><54><EFBFBD><EFBFBD>Buffer */
|
|||
|
|
|||
|
|
|||
|
void usart_init(uint32_t baudrate); /* <20><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|