usart.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __DEBUG_USART_H
  2. #define __DEBUG_USART_H
  3. #include "stm32f2xx.h"
  4. #include <stdio.h>
  5. #include "main.h"
  6. #include "myFile.h"
  7. #include "main.h"
  8. extern UART_HandleTypeDef USART_InitStruct_485;
  9. extern UART_HandleTypeDef USART_InitStruct_232;
  10. extern UART_HandleTypeDef USART_InitStruct_DEBUG;
  11. extern DMA_HandleTypeDef DMA_DEBUG_RX;
  12. extern uint8_t recv_232_done;
  13. //繫祇貢왯多신땍屢
  14. /*******************************************************/
  15. #define DEBUG_USART USART6
  16. #define DEBUG_USART_BAUDRATE 115200 //눔왯꺼景쪽
  17. #define DEBUG_USART_RX_GPIO_PORT GPIOC
  18. #define DEBUG_USART_RX_PIN GPIO_PIN_7
  19. #define DEBUG_USART_TX_GPIO_PORT GPIOC
  20. #define DEBUG_USART_TX_PIN GPIO_PIN_6
  21. #define DEBUG_USART_IRQHandler USART6_IRQHandler
  22. #define DEBUG_USART_IRQ USART6_IRQn
  23. //繫祇貢왯DMA
  24. #define DEBUG_USART_DR_BASE (USART6_BASE+0x04) //DR셍닸포
  25. #define DEBUG_USART_DMA_CLK RCC_AHB1Periph_DMA2
  26. #define DEBUG_USART_DMA_CHANNEL DMA_CHANNEL_5
  27. #define DEBUG_USART_DMA_STREAM DMA2_Stream1
  28. #define BUFF_SIZE 5000//35 * 1024 //dma왕쇌댕鬼 64k
  29. /************************************************************/
  30. //232多신땍屢
  31. #define USART_232 USART1
  32. #define USART_232_BAUDRATE 115200 //눔왯꺼景쪽
  33. #define USART_232_RX_GPIO_PORT GPIOA
  34. #define USART_232_RX_PIN GPIO_PIN_10
  35. #define USART_232_TX_GPIO_PORT GPIOA
  36. #define USART_232_TX_PIN GPIO_PIN_9
  37. #define USART_232_IRQHandler USART1_IRQHandler
  38. #define USART_232_IRQ USART1_IRQn
  39. #define RX_BUFFER_SIZE 20 * 1024
  40. //485多신땍屢
  41. #define USART_485 USART3
  42. #define USART_485_BAUDRATE 115200 //눔왯꺼景쪽
  43. #define USART_485_RX_GPIO_PORT GPIOC
  44. #define USART_485_RX_PIN GPIO_PIN_11
  45. #define USART_485_TX_GPIO_PORT GPIOC
  46. #define USART_485_TX_PIN GPIO_PIN_10
  47. #define USART_485_IRQHandler USART3_IRQHandler
  48. #define USART_485_IRQ USART3_IRQn
  49. //485왠齡多신
  50. #define USART_485_DE_GPIO_PORT GPIOC
  51. #define USART_485_DE_PIN GPIO_PIN_12
  52. void DEBUG_USART_Config(void);
  53. void USART_DMA_Config(void);
  54. void USART_232_config(void);
  55. void USART_232_Send(uint8_t *message,uint16_t size);
  56. //void USART_232_task_creat(void);
  57. void USART_485_config(void);
  58. void USART_485_DE_TX(void);
  59. void USART_485_DE_RX(void);
  60. void Config_485_Port(uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_t parity, uint8_t flowcontrol);
  61. void USART_485_Send(uint8_t *message,uint16_t size);
  62. extern uint8_t UART6_RX_BUF[BUFF_SIZE];
  63. extern uint8_t UART6_RX_STAT;
  64. extern uint32_t UART6_RX_NUM;
  65. extern uint8_t rx_232_Buffer[RX_BUFFER_SIZE];
  66. #endif /* __USART_H */