usart.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. ******************************************************************************
  3. * File Name : USART.h
  4. * Description : This file provides code for the configuration
  5. * of the USART instances.
  6. ******************************************************************************
  7. * This notice applies to any and all portions of this file
  8. * that are not between comment pairs USER CODE BEGIN and
  9. * USER CODE END. Other portions of this file, whether
  10. * inserted by the user or by software development tools
  11. * are owned by their respective copyright owners.
  12. *
  13. * Copyright (c) 2019 STMicroelectronics International N.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted, provided that the following conditions are met:
  18. *
  19. * 1. Redistribution of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials provided with the distribution.
  24. * 3. Neither the name of STMicroelectronics nor the names of other
  25. * contributors to this software may be used to endorse or promote products
  26. * derived from this software without specific written permission.
  27. * 4. This software, including modifications and/or derivative works of this
  28. * software, must execute solely and exclusively on microcontroller or
  29. * microprocessor devices manufactured by or for STMicroelectronics.
  30. * 5. Redistribution and use of this software other than as permitted under
  31. * this license is void and will automatically terminate your rights under
  32. * this license.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
  35. * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  37. * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  38. * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
  39. * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  40. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  42. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  43. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  44. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  45. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. *
  47. ******************************************************************************
  48. */
  49. /* Define to prevent recursive inclusion -------------------------------------*/
  50. #ifndef __usart_H
  51. #define __usart_H
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. /* Includes ------------------------------------------------------------------*/
  56. #include "main.h"
  57. /* USER CODE BEGIN Includes */
  58. /* USER CODE END Includes */
  59. extern UART_HandleTypeDef huart4;
  60. extern UART_HandleTypeDef huart1;
  61. extern UART_HandleTypeDef huart2;
  62. extern UART_HandleTypeDef huart3;
  63. /* zhuzl 20211220 增加内蒙主动上送
  64. */
  65. extern uint32_t circle_send;
  66. #define CIRCLE_SEND_TIME 30000 //30s
  67. //zhuzl add end
  68. /* USER CODE BEGIN Private defines */
  69. #define BUF_SIZE 500u
  70. #define Uart1_BUF_SIZE 1024u
  71. #define Uart2_BUF_SIZE 1024u /*为UART2、3专门开一个DMA接收存储区 2021-4-12 by Daiyf*/
  72. #define Uart3_BUF_SIZE 256u
  73. extern volatile uint8_t usart1_rx_flag;
  74. extern volatile uint8_t usart2_rx_flag;
  75. extern volatile uint8_t usart3_rx_flag;
  76. extern volatile uint8_t usart4_rx_flag;
  77. extern uint16_t rx1_len;
  78. extern uint16_t rx2_len;
  79. extern uint16_t rx3_len;
  80. extern uint16_t rx3_len;
  81. extern uint16_t rx4_len;
  82. extern uint8_t USART_RX_BUF[Uart1_BUF_SIZE];
  83. extern uint8_t USART_TX_BUF[Uart1_BUF_SIZE];
  84. extern uint8_t USART1_RX_BUF[Uart1_BUF_SIZE];
  85. extern uint8_t USART1_TX_BUF[Uart1_BUF_SIZE];
  86. extern uint8_t USART2_RX_BUF[Uart2_BUF_SIZE];
  87. extern uint8_t USART2_TX_BUF[Uart2_BUF_SIZE];
  88. extern uint8_t USART3_RX_BUF[Uart3_BUF_SIZE];
  89. extern uint8_t USART3_TX_BUF[Uart3_BUF_SIZE];
  90. extern uint8_t UART4_RX_BUF[BUF_SIZE];
  91. extern uint8_t UART4_TX_BUF[BUF_SIZE];
  92. void SendChar2 (uint8_t ch);
  93. void SendChar4 (uint8_t ch);
  94. void UartWrite(UART_HandleTypeDef *uartHandle, uint8_t *buf , uint8_t len);
  95. void Uart_Mode_Init(void);
  96. /* USER CODE END Private defines */
  97. void MX_UART4_Init(void);
  98. void MX_USART1_UART_Init(void);
  99. void MX_USART2_UART_Init(void);
  100. void MX_USART3_UART_Init(void);
  101. /* USER CODE BEGIN Prototypes */
  102. void UsartReceive_IDLE(UART_HandleTypeDef *huart);
  103. /* USER CODE END Prototypes */
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif /*__ usart_H */
  108. /**
  109. * @}
  110. */
  111. /**
  112. * @}
  113. */
  114. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/