123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef __USART_H__
- #define __USART_H__
- #include "STM32F10x.h"
- #include <string.h>
- #include <stdio.h>
- #define USART1_RECEIVE_BUFSIZE 100
- #define USART1_MAX_SIZE 96
- #define USART2_RECEIVE_BUFSIZE 2048
- #define USART2_MAX_SIZE 4996
- #define second 1000000
- #define L_TIME (1*second)
- #define Z_TIME (10*second)
- #define HH_TIME (90*second)
- #define H_TIME (30*second) //设置串口接收的等待时间
- #define Usart1ReadLen 20
- extern void UART_Config(void);
- #define USING_USART1 1
- #define USING_USART2 1
- #define USING_USART3 1
- /***************************USART1**************************/
- #if USING_USART1
- extern void UART1_bound(u32 bound);
- extern void uart1_putchar(u8 ch);
- extern void UART1Write(u8 *data,u32 len);
- extern u16 UART1_Receiver_buf(u8 *data,u32 len,u32 time); //等待接收数据 接收到的数据,接收到的个数等待接收的时间
- #define UASART1_INTOFF() USART_ITConfig(USART1, USART_IT_RXNE,DISABLE)
- #define UASART1_INTON() USART_ITConfig(USART1, USART_IT_RXNE,ENABLE)
- #endif
- /***************************USART2**************************/
- #if USING_USART2
- extern void UART2_bound(u32 bound);
- extern void uart2_putchar(u8 ch);
- extern void UART2Write(u8 *data,u32 len);
- extern u16 UART2_Receiver_buf(u8 *data,u32 len,u32 time);
- #define UASART2_INTOFF() USART_ITConfig(USART2, USART_IT_RXNE,DISABLE)
- #define UASART2_INTON() USART_ITConfig(USART2, USART_IT_RXNE,ENABLE)
- #endif
- /***************************USART3**************************/
- #if USING_USART3
- extern void UART3_bound(u32 bound);
- extern void uart3_putchar(u8 ch);
- extern void UART3Write(u8 *data,u32 len);
- extern u16 UART3_Receiver_buf(u8 *data,u32 len,u32 time);
- #endif
- void uart2_putchar(u8 ch); //发送一个字符
- extern u8 usa1_buf[USART1_RECEIVE_BUFSIZE];
- extern u8 gprs_buf[USART2_RECEIVE_BUFSIZE];
- extern vu8 IRQURA2,IRQURA1; //置中断标志位1主函数处理中断
- #endif
|