1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #ifndef __DEBUG_USART_H
- #define __DEBUG_USART_H
- #include "stm32f2xx.h"
- #include <stdio.h>
- //通讯网口引脚定义
- /*******************************************************/
- #define DEBUG_USART USART6
- #define DEBUG_USART_CLK RCC_APB2Periph_USART6
- #define DEBUG_USART_BAUDRATE 115200 //串口波特率
- #define DEBUG_USART_RX_GPIO_PORT GPIOC
- #define DEBUG_USART_RX_GPIO_CLK RCC_AHB1Periph_GPIOC
- #define DEBUG_USART_RX_PIN GPIO_Pin_7
- #define DEBUG_USART_RX_AF GPIO_AF_USART6
- #define DEBUG_USART_RX_SOURCE GPIO_PinSource7
- #define DEBUG_USART_TX_GPIO_PORT GPIOC
- #define DEBUG_USART_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
- #define DEBUG_USART_TX_PIN GPIO_Pin_6
- #define DEBUG_USART_TX_AF GPIO_AF_USART6
- #define DEBUG_USART_TX_SOURCE GPIO_PinSource6
- #define DEBUG_USART_IRQHandler USART6_IRQHandler
- #define DEBUG_USART_IRQ USART6_IRQn
- //通讯网口DMA
- #define DEBUG_USART_DR_BASE (USART6_BASE+0x04) //DR寄存器
- #define DEBUG_USART_DMA_CLK RCC_AHB1Periph_DMA2
- #define DEBUG_USART_DMA_CHANNEL DMA_Channel_5
- #define DEBUG_USART_DMA_STREAM DMA2_Stream1
- #define BUFF_SIZE 5000 //dma空间大小
- /************************************************************/
- //232引脚定义
- #define USART_232 USART1
- #define USART_232_CLK RCC_APB2Periph_USART1
- #define USART_232_BAUDRATE 115200 //串口波特率
- #define USART_232_RX_GPIO_PORT GPIOA
- #define USART_232_RX_GPIO_CLK RCC_AHB1Periph_GPIOA
- #define USART_232_RX_PIN GPIO_Pin_10
- #define USART_232_RX_AF GPIO_AF_USART1
- #define USART_232_RX_SOURCE GPIO_PinSource10
- #define USART_232_TX_GPIO_PORT GPIOA
- #define USART_232_TX_GPIO_CLK RCC_AHB1Periph_GPIOA
- #define USART_232_TX_PIN GPIO_Pin_9
- #define USART_232_TX_AF GPIO_AF_USART1
- #define USART_232_TX_SOURCE GPIO_PinSource9
- #define USART_232_IRQHandler USART1_IRQHandler
- #define USART_232_IRQ USART1_IRQn
- //485引脚定义
- #define USART_485 USART3
- #define USART_485_CLK RCC_APB1Periph_USART3
- #define USART_485_BAUDRATE 9600 //串口波特率
- #define USART_485_RX_GPIO_PORT GPIOC
- #define USART_485_RX_GPIO_CLK RCC_AHB1Periph_GPIOC
- #define USART_485_RX_PIN GPIO_Pin_11
- #define USART_485_RX_AF GPIO_AF_USART3
- #define USART_485_RX_SOURCE GPIO_PinSource11
- #define USART_485_TX_GPIO_PORT GPIOC
- #define USART_485_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
- #define USART_485_TX_PIN GPIO_Pin_10
- #define USART_485_TX_AF GPIO_AF_USART3
- #define USART_485_TX_SOURCE GPIO_PinSource10
- #define USART_485_IRQHandler USART3_IRQHandler
- #define USART_485_IRQ USART3_IRQn
- //485控制引脚
- #define USART_485_DE_GPIO_PORT GPIOC
- #define USART_485_DE_GPIO_CLK RCC_AHB1Periph_GPIOC
- #define USART_485_DE_PIN GPIO_Pin_12
- void Debug_USART_Config(void);
- void Usart_SendByte( USART_TypeDef * pUSARTx, uint8_t ch);
- void Usart_SendString( USART_TypeDef * pUSARTx, char *str);
- void Usart_SendHalfWord( USART_TypeDef * pUSARTx, uint16_t ch);
- void USART_DMA_Config(void);
- void DEBUG_USART_Config(void);
- void USART_232_config(void);
- void Usart_SendHex( USART_TypeDef * pUSARTx, uint8_t *str,uint16_t hexLength);
- void USART_485_config(void);
- extern uint8_t UART6_RX_BUF[BUFF_SIZE];
- extern uint8_t UART6_RX_STAT;
- extern uint32_t UART6_RX_NUM;
- #endif /* __USART1_H */
|