3189|8

71

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

帮忙看看这是什么意思? [复制链接]

#include
//#include
#include
#include
#include
#include "pmplatform.h"
#include "Pkfuncs.h"
#include "s2440.h"


#define IO_CTL_LED_1_ON 0x01
#define IO_CTL_LED_2_ON 0x02
#define IO_CTL_LED_3_ON 0x03
#define IO_CTL_LED_4_ON 0x04
#define IO_CTL_LED_ALL_ON 0x05
#define IO_CTL_LED_1_OFF 0x06
#define IO_CTL_LED_2_OFF 0x07
#define IO_CTL_LED_3_OFF 0x08
#define IO_CTL_LED_4_OFF 0x09
#define IO_CTL_LED_ALL_OFF 0x0a


volatile IOPreg         *s2440IOP = (IOPreg *)IOP_BASE;
volatile INTreg         *s2440INT = (INTreg *)INT_BASE;



BOOL mInitialized;
void Virtual_Alloc();                                                // Virtual allocation



void Virtual_Alloc()
{

    // GPIO Virtual alloc
        s2440IOP = (volatile IOPreg *) VirtualAlloc(0,sizeof(IOPreg),MEM_RESERVE, PAGE_NOACCESS);
        if(s2440IOP == NULL) {
                RETAILMSG(1,(TEXT("For s2440IOP: VirtualAlloc faiLED!\r\n")));
        }
        else {
                if(!VirtualCopy((PVOID)s2440IOP,(PVOID)(IOP_BASE),sizeof(IOPreg),PAGE_READWRITE | PAGE_NOCACHE )) {
                        RETAILMSG(1,(TEXT("For s2440IOP: VirtualCopy faiLED!\r\n")));
                }
        }

       
}


BOOL WINAPI  
DllEntry(HANDLE        hinstDLL,
                        DWORD dwReason,
                        LPVOID /* lpvReserved */)
{
        switch(dwReason)
        {
        case DLL_PROCESS_ATTACH:
                DEBUGREGISTER((HINSTANCE)hinstDLL);
                return TRUE;
        case DLL_THREAD_ATTACH:
                break;
        case DLL_THREAD_DETACH:
                break;
        case DLL_PROCESS_DETACH:
                break;
#ifdef UNDER_CE
        case DLL_PROCESS_EXITING:
                break;
        case DLL_SYSTEM_STARTED:
                break;
#endif
        }

        return TRUE;
}


BOOL LED_Deinit(DWORD hDeviceContext)
{
        BOOL bRet = TRUE;
       
        RETAILMSG(1,(TEXT("USERLED: LED_Deinit\r\n")));

        return TRUE;
}




BOOL LEDGpioInit()
{
        RETAILMSG(1,(TEXT("LED_Gpio_Setting----\r\n")));
        s2440IOP->rGPBCON  = (s2440IOP->rGPBCON  &~(3 << 10)) | (1<< 10);        // GPB5 == OUTPUT.
        s2440IOP->rGPBCON  = (s2440IOP->rGPBCON  &~(3 << 12)) | (1<< 12);        // GPB6 == OUTPUT.
        s2440IOP->rGPBCON  = (s2440IOP->rGPBCON  &~(3 << 14)) | (1<< 14);        // GPB7 == OUTPUT.
        s2440IOP->rGPBCON  = (s2440IOP->rGPBCON  &~(3 << 16)) | (1<< 16);        // GPB8 == OUTPUT.
        return TRUE;
}




DWORD LED_Init(DWORD dwContext)
{
       
        RETAILMSG(1,(TEXT("LED_Init----\r\n")));

        // 1. Virtual Alloc
        Virtual_Alloc();
       
        LEDGpioInit();
       
       
        mInitialized = TRUE;
        return TRUE;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
BOOL LED_IOControl(DWORD hOpenContext,
                                   DWORD dwCode,
                                   PBYTE pBufIn,
                                   DWORD dwLenIn,
                                   PBYTE pBufOut,
                                   DWORD dwLenOut,
                                   PDWORD pdwActualOut)
{
        switch(dwCode)
        {
        case IO_CTL_LED_1_ON:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT&~(0x1<<5);
                break;
        case IO_CTL_LED_2_ON:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT&~(0x1<<6);
                break;
        case IO_CTL_LED_3_ON:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT&~(0x1<<7);
                break;
        case IO_CTL_LED_4_ON:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT&~(0x1<<8);
                break;
        case IO_CTL_LED_ALL_ON:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT&~(0xF<<5);
                break;
        case IO_CTL_LED_1_OFF:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT|(0x1<<5);
                break;
        case IO_CTL_LED_2_OFF:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT|(0x1<<6);
                break;
        case IO_CTL_LED_3_OFF:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT|(0x1<<7);
                break;
        case IO_CTL_LED_4_OFF:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT|(0x1<<8);
                break;
        case IO_CTL_LED_ALL_OFF:
                s2440IOP->rGPBDAT=s2440IOP->rGPBDAT|(0xF<<5);
                break;
        default:
                break;               
        }
   
        RETAILMSG(1,(TEXT("LED:Ioctl code = 0x%x\r\n"), dwCode));
        return TRUE;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD LED_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode)
{
        RETAILMSG(1,(TEXT("USERLED: LED_Open\r\n")));
        return TRUE;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
BOOL LED_Close(DWORD hOpenContext)
{
        s2440IOP->rGPBDAT=s2440IOP->rGPBDAT&(0xF<<5);
        RETAILMSG(1,(TEXT("USERLED: LED_Close\r\n")));
        return TRUE;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void LED_PowerDown(DWORD hDeviceContext)
{
        RETAILMSG(1,(TEXT("USERLED: LED_PowerDown\r\n")));
       
        //RETAILMSG(1,(TEXT("CAMERA: LED_PowerDown, m_Dx = D%u, init %d \r\n"), m_Dx, mInitialized));
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void LED_PowerUp(DWORD hDeviceContext)
{
        RETAILMSG(1,(TEXT("USERLED: LED_PowerUp\r\n")));

}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD LED_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count)
{
        RETAILMSG(1,(TEXT("USERLED: LED_Read\r\n")));
        return TRUE;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD LED_Seek(DWORD hOpenContext, long Amount, DWORD Type)
{
        RETAILMSG(1,(TEXT("USERLED: LED_Seek\r\n")));
        return 0;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD LED_Write(DWORD hOpenContext, LPCVOID pSourceBytes, DWORD NumberOfBytes)
{
        RETAILMSG(1,(TEXT("USERLED: LED_Write\r\n")));
        return 0;
}




最新回复

volatile IOPreg *s2440IOP = (IOPreg *)IOP_BASE; volatile INTreg *s2440INT = (INTreg *)INT_BASE; 急啊,请问这是什么意思???  详情 回复 发表于 2009-8-11 11:15
点赞 关注

回复
举报

82

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
....................................................................这么长...没法看
 
 

回复

81

帖子

0

TA的资源

一粒金砂(初级)

板凳
 
这就是一个控制4个LED的流驱动程序,应用程序可以通过调用BOOL DeviceIoControl(
    HANDLE hDevice,
    DWORD dwIoControlCode,
    LPVOID lpInBuffer,
    DWORD nInBufferSize,
    LPVOID lpOutBuffer,
    DWORD nOutBufferSize,
    LPDWORD lpBytesReturned,
    LPOVERLAPPED lpOverlapped
);

控制LED灯的亮或灭。
 
 
 

回复

59

帖子

0

TA的资源

一粒金砂(初级)

4
 
void Virtual_Alloc()
{

    // GPIO Virtual alloc
s2440IOP = (volatile IOPreg *) VirtualAlloc(0,sizeof(IOPreg),MEM_RESERVE, PAGE_NOACCESS);
if(s2440IOP == NULL) {
RETAILMSG(1,(TEXT("For s2440IOP: VirtualAlloc faiLED!\r\n")));
}
else {
if(!VirtualCopy((PVOID)s2440IOP,(PVOID)(IOP_BASE),sizeof(IOPreg),PAGE_READWRITE | PAGE_NOCACHE )) {
RETAILMSG(1,(TEXT("For s2440IOP: VirtualCopy faiLED!\r\n")));
}
}


}
这个函数具体是做什么的???
 
 
 

回复

69

帖子

0

TA的资源

一粒金砂(初级)

5
 
因为WINCE系统不能直接访问物理地址,所以要给IO寄存器分配虚拟地址。
 
 
 

回复

76

帖子

0

TA的资源

一粒金砂(初级)

6
 
BOOL WINAPI  
DllEntry(HANDLE hinstDLL,
DWORD dwReason,
LPVOID /* lpvReserved */)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
DEBUGREGISTER((HINSTANCE)hinstDLL);
return TRUE;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
#ifdef UNDER_CE
case DLL_PROCESS_EXITING:
break;
case DLL_SYSTEM_STARTED:
break;
#endif
}

return TRUE;
}
 
 
 

回复

63

帖子

0

TA的资源

一粒金砂(初级)

7
 
BOOL WINAPI  
DllEntry(HANDLE hinstDLL,
DWORD dwReason,
LPVOID /* lpvReserved */)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
DEBUGREGISTER((HINSTANCE)hinstDLL);
return TRUE;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
#ifdef UNDER_CE
case DLL_PROCESS_EXITING:
break;
case DLL_SYSTEM_STARTED:
break;
#endif
}

return TRUE;
}
这个是用来干什么的???
 
 
 

回复

68

帖子

0

TA的资源

一粒金砂(初级)

8
 
这是驱动程序的入口,你不用管它。
 
 
 

回复

82

帖子

0

TA的资源

一粒金砂(初级)

9
 
volatile IOPreg *s2440IOP = (IOPreg *)IOP_BASE;
volatile INTreg *s2440INT = (INTreg *)INT_BASE;

急啊,请问这是什么意思???
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

关闭
站长推荐上一条 1/10 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表