赞
踩
- /*·¢ËÍÒ»¸ö×Ö½ÚÊý¾Ý*/
- void UART2SendByte(unsigned char SendData)
- {
- USART_SendData(USART2,SendData);
- while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
- }
-
- /*½ÓÊÕÒ»¸ö×Ö½ÚÊý¾Ý*/
- unsigned char UART2GetByte(unsigned char* GetData)
- {
- if(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET)
- { return 0;//ûÓÐÊÕµ½Êý¾Ý
- }
- *GetData = USART_ReceiveData(USART2);
- return 1;//ÊÕµ½Êý¾Ý
- }
- /*½ÓÊÕÒ»¸öÊý¾Ý£¬ÂíÉÏ·µ»Ø½ÓÊÕµ½µÄÕâ¸öÊý¾Ý*/
- void UART2Test(void)
- {
- unsigned char i = 0;
-
- while(1)
- {
- while(UART2GetByte(&i))
- {
- USART_SendData(USART2,i);
- }
- }
- }
-
- #if 1
- #pragma import(__use_no_semihosting)
-
- struct __FILE
- {
- int handle;
-
- };
-
- FILE __stdout;
-
- void _sys_exit(int x)
- {
- x = x;
- }
- //fgetcÖض¨Ïò
- int fputc(int ch, FILE *f)
- {
-
- while(USART_GetFlagStatus(USART2,USART_FLAG_TC)==RESET);
- USART_SendData(USART2,(uint8_t)ch);
-
-
-
- return ch;
- }
- #endif
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。