usart.h 2.9 KB

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