⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uartapp.c

📁 最近在國外網站抓到的作業系統 以Arm為基礎去開發的
💻 C
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#include "asixapp.h"
#include "asixwin.h"
#include "appicon.h"


#include "uartsrv.h"
#include "uartdrv.h"
#include "uartapp.h"


void UartServer(int flag, int count)
{
	
	char *pRecFile = NULL;
	char *pTraFile = NULL;
	
	int		n;
	char	s[] = "Welcome to ASIC Center!!!!\n";
	
 	
	SysOpenUart(DEVICE);
	
	
	if (flag == 1) {
		while(count--)		//for receive data
		{
			if((SysOpenUart(DEVICE)) == SYS_OK)
	 			prints(DEVICE, "ok\n");
	 		else
	 			printf("ERR\n");
	 		
	 		
	 		pRecFile = (char *)SysLmalloc((WRITENUM + 1)*sizeof(char));
			if(pRecFile == NULL)
			{	
				prints(DEVICE, "pRecFile == NULL\n");
				break; //return FALSE;
			}
			n = SysReadUart(DEVICE, pRecFile, WRITENUM, WAIT_TMO);
			if(n == SYS_OK)
			{
				*(pRecFile + WRITENUM) = '\0';
				prints(DEVICE, pRecFile);
			}
			else
				prints(DEVICE, "receive err\n");	
		}	
		SysLfree(pRecFile);
		return;					
	}
	
	while(count--)		//for transmit data
	{
		if((SysOpenUart(DEVICE)) == SYS_OK)
 			prints(DEVICE, "ok\n");
 		else
 			printf("ERR\n");
 			
 			
 		pTraFile = (char *)SysLmalloc(strlen(s));
		if(pTraFile == NULL)
		{
			prints(DEVICE, "pTraFile == NULL\n");
			break; //return FALSE;
		}
		strncpy(pTraFile, s,  strlen(s));
		n = SysWriteUart(DEVICE, pTraFile, strlen(s), WAIT_TMO);
		if(n == SYS_OK)
			prints(DEVICE, "transmit finish\n");
		else
			prints(DEVICE, "transmit err!\n");
	}
	SysLfree(pTraFile);

	return;  
}


















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -