usart.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef __DEBUG_USART_H
  2. #define __DEBUG_USART_H
  3. #include "stm32f2xx.h"
  4. #include <stdio.h>
  5. //繫祇貢왯多신땍屢
  6. /*******************************************************/
  7. #define DEBUG_USART USART6
  8. #define DEBUG_USART_CLK RCC_APB2Periph_USART6
  9. #define DEBUG_USART_BAUDRATE 115200 //눔왯꺼景쪽
  10. #define DEBUG_USART_RX_GPIO_PORT GPIOC
  11. #define DEBUG_USART_RX_GPIO_CLK RCC_AHB1Periph_GPIOC
  12. #define DEBUG_USART_RX_PIN GPIO_Pin_7
  13. #define DEBUG_USART_RX_AF GPIO_AF_USART6
  14. #define DEBUG_USART_RX_SOURCE GPIO_PinSource7
  15. #define DEBUG_USART_TX_GPIO_PORT GPIOC
  16. #define DEBUG_USART_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
  17. #define DEBUG_USART_TX_PIN GPIO_Pin_6
  18. #define DEBUG_USART_TX_AF GPIO_AF_USART6
  19. #define DEBUG_USART_TX_SOURCE GPIO_PinSource6
  20. #define DEBUG_USART_IRQHandler USART6_IRQHandler
  21. #define DEBUG_USART_IRQ USART6_IRQn
  22. //繫祇貢왯DMA
  23. #define DEBUG_USART_DR_BASE (USART6_BASE+0x04) //DR셍닸포
  24. #define DEBUG_USART_DMA_CLK RCC_AHB1Periph_DMA2
  25. #define DEBUG_USART_DMA_CHANNEL DMA_Channel_5
  26. #define DEBUG_USART_DMA_STREAM DMA2_Stream1
  27. #define BUFF_SIZE 5000 //dma왕쇌댕鬼
  28. /************************************************************/
  29. //232多신땍屢
  30. #define USART_232 USART1
  31. #define USART_232_CLK RCC_APB2Periph_USART1
  32. #define USART_232_BAUDRATE 115200 //눔왯꺼景쪽
  33. #define USART_232_RX_GPIO_PORT GPIOA
  34. #define USART_232_RX_GPIO_CLK RCC_AHB1Periph_GPIOA
  35. #define USART_232_RX_PIN GPIO_Pin_10
  36. #define USART_232_RX_AF GPIO_AF_USART1
  37. #define USART_232_RX_SOURCE GPIO_PinSource10
  38. #define USART_232_TX_GPIO_PORT GPIOA
  39. #define USART_232_TX_GPIO_CLK RCC_AHB1Periph_GPIOA
  40. #define USART_232_TX_PIN GPIO_Pin_9
  41. #define USART_232_TX_AF GPIO_AF_USART1
  42. #define USART_232_TX_SOURCE GPIO_PinSource9
  43. #define USART_232_IRQHandler USART1_IRQHandler
  44. #define USART_232_IRQ USART1_IRQn
  45. //485多신땍屢
  46. #define USART_485 USART3
  47. #define USART_485_CLK RCC_APB1Periph_USART3
  48. #define USART_485_BAUDRATE 9600 //눔왯꺼景쪽
  49. #define USART_485_RX_GPIO_PORT GPIOC
  50. #define USART_485_RX_GPIO_CLK RCC_AHB1Periph_GPIOC
  51. #define USART_485_RX_PIN GPIO_Pin_11
  52. #define USART_485_RX_AF GPIO_AF_USART3
  53. #define USART_485_RX_SOURCE GPIO_PinSource11
  54. #define USART_485_TX_GPIO_PORT GPIOC
  55. #define USART_485_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
  56. #define USART_485_TX_PIN GPIO_Pin_10
  57. #define USART_485_TX_AF GPIO_AF_USART3
  58. #define USART_485_TX_SOURCE GPIO_PinSource10
  59. #define USART_485_IRQHandler USART3_IRQHandler
  60. #define USART_485_IRQ USART3_IRQn
  61. //485왠齡多신
  62. #define USART_485_DE_GPIO_PORT GPIOC
  63. #define USART_485_DE_GPIO_CLK RCC_AHB1Periph_GPIOC
  64. #define USART_485_DE_PIN GPIO_Pin_12
  65. void Debug_USART_Config(void);
  66. void Usart_SendByte( USART_TypeDef * pUSARTx, uint8_t ch);
  67. void Usart_SendString( USART_TypeDef * pUSARTx, char *str);
  68. void Usart_SendHalfWord( USART_TypeDef * pUSARTx, uint16_t ch);
  69. void USART_DMA_Config(void);
  70. void DEBUG_USART_Config(void);
  71. void USART_232_config(void);
  72. void Usart_SendHex( USART_TypeDef * pUSARTx, uint8_t *str,uint16_t hexLength);
  73. void USART_485_config(void);
  74. extern uint8_t UART6_RX_BUF[BUFF_SIZE];
  75. extern uint8_t UART6_RX_STAT;
  76. extern uint32_t UART6_RX_NUM;
  77. #endif /* __USART1_H */