uarts.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. *****************************************************************************
  3. * 系统串口设置相关的函数
  4. *
  5. * (C) Copyright 2000-2020, ***
  6. * All Rights Reserved
  7. *****************************************************************************
  8. *
  9. * @File : usart.h
  10. * @By : 陈桂东
  11. * @Version : V1.0
  12. * @Date : 2012 / 10 / 20
  13. *
  14. *****************************************************************************
  15. * Update
  16. * @Version : V1.0.1
  17. * @By : 陈桂东
  18. * @Date : 2014 / 05 / 24
  19. * @Brief : 增加对C++环境支持
  20. *
  21. * @Version : V1.1
  22. * @By : 陈桂东
  23. * @Date : 2015 / 10 / 03
  24. * @Brief : 增加103和407之间切换宏定义
  25. *
  26. * @Version : V1.2
  27. * @By : 陈桂东
  28. * @Date : 2016 / 04 / 27
  29. * @Brief : A、增加对STM32F0系列支持
  30. * B、增加对IAR环境支持
  31. *
  32. *****************************************************************************
  33. **/
  34. #ifndef _usart_h
  35. #define _usart_h
  36. /**
  37. ****************************** Support C++ **********************************
  38. **/
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. /**
  43. *****************************************************************************
  44. **/
  45. /******************************************************************************
  46. 外部函数头文件
  47. ******************************************************************************/
  48. #include <stdio.h> //printf函数头文件
  49. #include "sys.h"
  50. /******************************************************************************
  51. 定义串口是否接受外部数据
  52. ******************************************************************************/
  53. #define Printf_Support_En 1 //是否支持C标准库printf()函数
  54. //0: 不支持
  55. //1: 支持
  56. #define EN_USART1_RX 1 //串口接收使能。0:禁止接收
  57. // 1:允许接收
  58. #define USART_REC_LEN 64 //定义最大接收字节数
  59. /******************************************************************************
  60. 外部调用功能函数
  61. ******************************************************************************/
  62. #if EN_USART1_RX == 1 //使能接收
  63. extern uint8_t USART_RX_BUF[USART_REC_LEN]; //接收缓冲,最大USART_REC_LEN个字节
  64. extern uint16_t USART_RX_STA; //接收状态标记
  65. #endif
  66. void uart_init ( uint32_t bound ); //初始化IO 串口
  67. #if Printf_Support_En == 0
  68. void uart_sendbyte ( uint8_t byte ); //串口发送一个字节
  69. void uart_senfstring ( uint8_t * str ); //串口发送字符串
  70. void uart_printf ( char *format, ... ); //串口格式化打印
  71. #endif
  72. /**
  73. ****************************** Support C++ **********************************
  74. **/
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. /**
  79. *****************************************************************************
  80. **/
  81. #endif /* end usart.h */