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

📄 comemadm.cpp

📁 一个amccs5933芯片的驱动程序开发源程序和部分文档
💻 CPP
字号:
// This ComemAdm.cpp.  It contains the timeout, and report error
// routines located in comemlit and used by Perf42.
//

#include "afxwin.h"
#include <sys\timeb.h>
#include <stdio.h>
#include "comemDevice.h"

int serial_device_addr = 0x50;



int timeout(unsigned long time, unsigned timer)
{
	#define DIVISOR	18L
	static struct timeb oldtimebuff[10];
	struct timeb timebuff;

	/* get the time B4 we let them have control, so we get at least one*/
	/* good one before a timeout occurs */
	ftime(&timebuff);

	if (time)
		{
		/* save current time */
		memmove(&(oldtimebuff[timer]), &timebuff, sizeof(struct timeb));

		if ((oldtimebuff[timer].millitm += (unsigned short)((time % DIVISOR) * 1000L/DIVISOR)) >= 1000)
			{
			oldtimebuff[timer].millitm -= 1000;
			time += DIVISOR;
			}

		oldtimebuff[timer].time += time / DIVISOR;
		return(0);
		}

	if (timebuff.time > oldtimebuff[timer].time)
		return(1);
	
	if (timebuff.time == oldtimebuff[timer].time)
		if (timebuff.millitm > oldtimebuff[timer].millitm)
			return(1);

	return(0);
}


void reportErrorCode(DWORD status, char * whereAmI)
{
	char buf[0x1000];

	switch(status)
		{
      case  ERROR_INVALID_REGION:
         strcpy(buf, "Invalid region detected");
         break;
         
      case  ERROR_INVALID_ADDIN_ADDR:
         strcpy(buf, "Invalid Local processor address detected");
         break;
         
      case  ERROR_OVERLAID_REGION:
         strcpy(buf, "Region was totally obscured by another");
         break;
         
      case  ERROR_BAD_PAGE_TABLE:
         strcpy(buf, "Bad page table detected");
         break;
         
      case  ERROR_MEMORY_ALLOC:
         strcpy(buf, "Memory allocation error");
         break;
         
      case  ERROR_ALLOC_EXISTS:
         strcpy(buf, "Memory alread allocated.  Must deallocate before allocating.");
         break;
         
      case  ERROR_NO_DRIVER:
         strcpy(buf, "Driver is not resident");
         break;
         
      case  ERROR_INVALID_COMEM_ID:
         strcpy(buf, "Invalid comem ID");
         break;
         
      case  ERROR_DEVICE_NOT_FOUND:
         strcpy(buf, "Device not found");
         break;
         
      case  ERROR_UNKNOWN:
         strcpy(buf, "Unknown error code detected");
         break;
         
      default:
				 sprintf(buf, "Encountered error code (%d)", status);
         //strcpy(buf, "An error was reported that is not in our table");
         break;
         
		}
      
   if (whereAmI)
     {
      strcat(buf, " while ");
      strcat(buf, whereAmI);
     }
   else  
      strcat(buf, ".");
            
	AfxMessageBox(buf, MB_OK | MB_ICONEXCLAMATION);
}

void report_error(const char *fmt, ...)
{
	char buf[0x1000];
	va_list va;
	va_start( va, fmt );
	vsprintf( buf, fmt, va );
	va_end( va );
	AfxMessageBox(buf, MB_OK | MB_ICONEXCLAMATION);
}



⌨️ 快捷键说明

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