first commit
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
#ifndef __USART_H__
|
||||
#define __USART_H__
|
||||
|
||||
//数据位
|
||||
#define USART_DATA_BIT_8 USART_WordLength_8b //数据位8
|
||||
#define USART_DATA_BIT_9 USART_WordLength_9b //数据位9
|
||||
|
||||
//停止位
|
||||
#define USART_STOP_BIT_1 USART_StopBits_1 //停止位1
|
||||
#define USART_STOP_BIT_0_5 USART_StopBits_0_5 //停止位0.5
|
||||
#define USART_STOP_BIT_2 USART_StopBits_2 //停止位2
|
||||
#define USART_STOP_BIT_1_5 USART_StopBits_1_5 //停止位1.5
|
||||
|
||||
//校验位
|
||||
#define USART_PARITY_NO USART_Parity_No //无校验
|
||||
#define USART_PRAITY_EVEN USART_Parity_Even //偶校验
|
||||
#define USART_PRAITY_ODD USART_Parity_Odd //奇校验
|
||||
|
||||
//USART
|
||||
#define USART_ENABLE
|
||||
#ifdef USART_ENABLE
|
||||
#define USE_USART1
|
||||
#undef USE_USART2
|
||||
#undef USE_USART3
|
||||
#undef USE_USART4
|
||||
#undef USE_USART5
|
||||
#undef USE_USART6
|
||||
#endif
|
||||
|
||||
/* **********串口相关********** */
|
||||
#ifdef USE_USART1
|
||||
#define COM0 USART1_BASE
|
||||
#define COM0_IRQN USART1_IRQn
|
||||
#define COM0_TX_PORT GPIOA
|
||||
#define COM0_RX_PORT GPIOA
|
||||
#define COM0_TX_PIN GPIO_Pin_9
|
||||
#define COM0_RX_PIN GPIO_Pin_10
|
||||
#endif
|
||||
#ifdef USE_USART2
|
||||
#define COM1 USART2_BASE
|
||||
#define COM1_IRQN USART2_IRQn
|
||||
#define COM1_TX_PORT GPIOA
|
||||
#define COM1_RX_PORT GPIOA
|
||||
#define COM1_TX_PIN GPIO_Pin_2
|
||||
#define COM1_RX_PIN GPIO_Pin_3
|
||||
#endif
|
||||
#ifdef USE_USART3
|
||||
#define COM2 USART3_BASE
|
||||
#define COM2_IRQN USART3_IRQn
|
||||
#define COM2_TX_PORT GPIOB
|
||||
#define COM2_RX_PORT GPIOB
|
||||
#define COM2_TX_PIN GPIO_Pin_10
|
||||
#define COM2_RX_PIN GPIO_Pin_11
|
||||
#endif
|
||||
#ifdef USE_USART4
|
||||
#define COM3 UART4_BASE
|
||||
#define COM3_IRQN UART4_IRQn
|
||||
#define COM3_TX_PORT GPIOC
|
||||
#define COM3_RX_PORT GPIOC
|
||||
#define COM3_TX_PIN GPIO_Pin_10
|
||||
#define COM3_RX_PIN GPIO_Pin_11
|
||||
#endif
|
||||
#ifdef USE_USART5
|
||||
#define COM4 UART5_BASE
|
||||
#define COM4_IRQN UART5_IRQn
|
||||
#define COM4_TX_PORT GPIOB
|
||||
#define COM4_RX_PORT GPIOD
|
||||
#define COM4_TX_PIN GPIO_Pin_12
|
||||
#define COM4_RX_PIN GPIO_Pin_2
|
||||
#endif
|
||||
|
||||
/* LetterShell */
|
||||
#define USE_SHELL
|
||||
#ifdef USE_SHELL
|
||||
#define TTY_COM COM0
|
||||
#define TTY_COM_IRQN COM0_IRQN
|
||||
#endif
|
||||
|
||||
/* 此BSP规定最多4路RS485 */
|
||||
#undef USE_RS4851
|
||||
#ifdef USE_RS4851
|
||||
#define RS4851_TRANS_PORT GPIOx
|
||||
#define RS4851_TRANS_PIN GPIO_Pin_x
|
||||
#define RS4851_TRANS_TX RESET
|
||||
#define RS4851_TRANS_RX SET
|
||||
#endif
|
||||
|
||||
#undef USE_RS4852
|
||||
#ifdef USE_RS4852
|
||||
#define RS4852_TRANS_PORT GPIOx
|
||||
#define RS4852_TRANS_PIN GPIO_Pin_x
|
||||
#define RS4852_TRANS_TX RESET
|
||||
#define RS4852_TRANS_RX SET
|
||||
#endif
|
||||
|
||||
#undef USE_RS4853
|
||||
#ifdef USE_RS4853
|
||||
#define RS4853_TRANS_PORT GPIOx
|
||||
#define RS4853_TRANS_PIN GPIO_Pin_x
|
||||
#define RS4853_TRANS_TX RESET
|
||||
#define RS4853_TRANS_RX SET
|
||||
#endif
|
||||
|
||||
#undef USE_RS4854
|
||||
#ifdef USE_RS4854
|
||||
#define RS4854_TRANS_PORT GPIOx
|
||||
#define RS4854_TRANS_PIN GPIO_Pin_x
|
||||
#define RS4854_TRANS_TX RESET
|
||||
#define RS4854_TRANS_RX SET
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user