现在的位置: 首页 > 综合 > 正文

点亮arm ep9315的led灯的wince应用程序——转载

2013年06月17日 ⁄ 综合 ⁄ 共 1802字 ⁄ 字号 评论关闭

今天,做了 一个点亮arm ep9315的led灯的wince应用程序,是用evc4.0用的,为了这个小程序,花了我4天时间
主要是以前没有做过wince的应用程序。光装evc4.0就用了 我2天时间,刚开始装evc4.0,没有装evc4.0 sp3,ep9315sdk包用不成,已选就死机,后来发现是没装evc4 sp3的缘故,装了一个后,就不死机了,感觉很兴奋。

 有长了一个知识点。
下面是我在evc下驱动arm gpio的例子
BOOL ChangeGreenLed (void)
{
int fd;
unsigned char *gpio_base;
unsigned int *gpio_PEDDR, *gpio_PEDR;

OutputDebugString(L"TestDrv - LedDrive1/n");

//PUCHAR ioPortBase;
PHYSICAL_ADDRESS PortAddress = {0x80840000, 0};
gpio_base =(PUCHAR) MmMapIoSpace( PortAddress, 0x80,FALSE );

gpio_PEDR = (unsigned int *)(gpio_base + 0x20);
gpio_PEDDR = (unsigned int *)(gpio_base + 0x24);

*gpio_PEDR ^= 0x1;

for(int x = 0; x< 10 ; x++)
{
//gpio_PEDDR = 0xffffffff; // set port E to all output
*gpio_PEDR ^= 0x00000001; // invert green LED state

printf("PEDR = %d/n", *gpio_PEDR);

Sleep(1000);
}

OutputDebugString(L"TestDrv - LedDrive2/n");

return TRUE;
}

如果编译不过,可加上ceddk.h和ceddk.lib两个文件,就可以了。祝大家学习wince 快乐 。

#include <ceddk.h>
#pragma comment(lib,"ceddk.lib")

void OutPortFun(WORD wAddr,byte bValue)
{
 PHYSICAL_ADDRESS IoAddress;
 IoAddress.LowPart = wAddr;//硬件地址
 IoAddress.HighPart = 0;
 UCHAR * gpioPtr;
 gpioPtr = ( UCHAR *)MmMapIoSpace( IoAddress,1,FALSE );
 WRITE_PORT_UCHAR(gpioPtr,bValue);
}
//开始执行看门狗
void CWDTDlg::OnButtonEnableTimer()
{
 // TODO: Add your control notification handler code here
 //OUT 120H 0AH ; enter WDT function
 //OUT 120H 0BH ; enable WDT function
 OutPortFun(0x120,0xA);
 OutPortFun(0x120,0xB);
 //OUT 120 0NH ; N=1,2,3 or 4
 OutPortFun(0x120,2);
 //OUT 121 0MH ; M=0,1,2,…F
 OutPortFun(0x121,0);

}
//停止看门狗
void CWDTDlg::OnButtonDisableTimer()
{
 // TODO: Add your control notification handler code here
 //OUT 120 00H ; Can be disable at any time
 OutPortFun(0x120,0);
}
//复位看门狗
void CWDTDlg::OnButtonResetTimer()
{
 // TODO: Add your control notification handler code here
 //OUT 121 0MH ; M=0,1,2,…F
 OutPortFun(0x121,0);
}

//***************************************************************************************
来源:http://blog.csdn.net/suncilang/archive/2007/05/29/1630006.aspx

抱歉!评论已关闭.