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

📄 dm_utils.c

📁 pxa270 NOR FLASH驱动代码
💻 C
字号:
#include <stdio.h>
#include "systypes.h"
#include "utils.h"

#define	OSCR0	*(volatile UINT *)0x40A00010
#define	OSSR	*(volatile UINT *)0x40A00014
#define	OWER	*(volatile UINT *)0x40A00018
#define	OIER	*(volatile UINT *)0x40A0001C
#define	OSCR4	*(volatile UINT *)0x40A00040
#define	OSMR4	*(volatile UINT *)0x40A00080
#define	OMCR4	*(volatile UINT *)0x40A000C0

void DM_WaitUs(int usVal)
{
	OMCR4  = (1<<7)|0;		//stop but don't reset counter after match
	OSMR4  = usVal;			//set match value
	OSCR4  = 0;				//reset counter
	OIER   = 1<<4;			//enable channel 4 int only
	OSSR   = 1<<4;			//clear status
	OMCR4 |= 4;				//start
	
	while(!(OSSR&(1<<4)));	//wait...
}

void DM_WaitMs(int msVal)
{
	OMCR4  = (1<<7)|0;		//stop but don't reset counter after match
	OSMR4  = msVal;			//set match value
	OSCR4  = 0;				//reset counter
	OIER   = 1<<4;			//enable channel 4 int only
	OSSR   = 1<<4;			//clear status
	OMCR4 |= 2;				//start
	
	while(!(OSSR&(1<<4)));	//wait...
}

void DM_WaitS(int sVal)
{
	OMCR4  = (1<<7)|0;		//stop but don't reset counter after match
	OSMR4  = sVal;			//set match value
	OSCR4  = 0;				//reset counter
	OIER   = 1<<4;			//enable channel 4 int only
	OSSR   = 1<<4;			//clear status
	OMCR4 |= 3;				//start
	
	while(!(OSSR&(1<<4)));	//wait...
}

int WaitKeyTimeoutS(int sec, int *ch)
{
	OMCR4  = (1<<7)|0;		//stop but don't reset counter after match
	OSMR4  = sec;			//set match value
	OSCR4  = 0;				//reset counter
	OIER   = 1<<4;			//enable channel 4 int only
	OSSR   = 1<<4;			//clear status
	OMCR4 |= 3;				//start
	
	while(!(OSSR&(1<<4))&&!kbhit());	//wait...
	
	if(kbhit()) {
		*ch = getc(stdin);
			return 1;
	}
	return -1;
}

/*************************************************************/
//#include "DM_Debug.h"

/*void DM_CwDbgPrintf (DM_ControlWordsBitsT bitId, char * fmt, ...)
{
}

INT DM_ControlWordsDebugPrintGetBit (DM_ControlWordsBitsT bitId)
{
	return 0;
}
*/
//#include "dm_errors.h"

//void XllpUtilityErrorRecord (XLLP_UINT32_T code, XLLP_UINT32_T param1, 
                            XLLP_UINT32_T param2, XLLP_UINT32_T param3)
//{
//}

/*************************************************************/
//
/*UINT SelectIrOperationMode (IrOperationT operation, IrPowerT param)
{
	return 1;
}
*/

⌨️ 快捷键说明

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