| arm wince 如何点亮ep9315的两个led灯 |
| |
| 作者:未知 来源:本站原创 点击数:304 更新时间:2007-11-28 |
|
您可以添加到网摘 让更多人关注此文章:
今天,做了 一个点亮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); }
|
没有任何评论
*只显示最新10条评论。评论内容只代表网友观点,与本站立场无关。 更多评论
|
|
发帖须知:
一.所发文章必须遵守《互联网电子公告服务管理规定》;
二.严禁发布供求代理信息,公司介绍,产品信息等广告宣传信息;
三.严禁恶意重复发帖;
四.严禁对个人,实体,民族,国家等进行漫骂,污蔑,诽谤。 |
|
|
|