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

📄 stepmotor.cpp

📁 2410/wince下应用程序例程brick,COMMApp,DAC,DCMotor,mediaplayer,spi,stepmotor,tictac
💻 CPP
字号:
#include "windows.h"
#include "s2410.h"


#define EXIO_BASE   			0xA2000000
#define STEPMOTOR_IOCTRL_RUN	1
#define STEPMOTOR_IOCTRL_STOP	2


typedef struct{
	
	unsigned int a;
	
}EXIO_TEST;
EXIO_TEST *exio=NULL;



bool   
DllEntry(HANDLE hinstdll, 
              DWORD dwreason, 
              LPVOID  lpvreserved )
{
	
    return true;
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool STM_Close(DWORD hopencontext)
{
    bool bret = true;
    
    return bret;
} 

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool STM_Deinit(DWORD hdevicecontext)
{
    bool bret = true;
    
    return bret;
} 

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD STM_Init(DWORD dwcontext)
{
	exio=(EXIO_TEST *)VirtualAlloc(0,sizeof(EXIO_TEST),MEM_RESERVE, PAGE_NOACCESS);
	if(!exio)
	{
		RETAILMSG(1,(TEXT("stepmotor: exio virualalloc failed\r\n")));
		return 0;
		
	}
	if(!VirtualCopy((PVOID)exio,(PVOID)(EXIO_BASE),sizeof(EXIO_TEST),PAGE_READWRITE | PAGE_NOCACHE ))
	{
		RETAILMSG(1,(TEXT("stepmotor:virtualcopy failed! \r\n")));
		return 0;
	}
	
	
	exio=(EXIO_TEST *)((unsigned char *)exio+0x100);
	
	exio->a = 0xFFFFFF0F;
	
    return 1;
    
} 

//-----------------------------------------------------------------------------
void SetExio(unsigned int phase)
{
	exio->a &=0x0000000f;
	exio->a |=phase;
	
}

//-----------------------------------------------------------------------------
DWORD STM_IOControl(
    DWORD Handle,
    DWORD dwIoControlCode,
    PBYTE pInBuf,
    DWORD nInBufSize,
    PBYTE pOutBuf,
    DWORD nOutBufSize,
    PDWORD pBytesReturned
    )
{
	int i=0;
    switch(dwIoControlCode)
    {
		case STEPMOTOR_IOCTRL_RUN :
		
				SetExio(*((unsigned int *)pInBuf));
			  break;
		case STEPMOTOR_IOCTRL_STOP :
				exio->a &= 0x0000000f;
				
				break;
				
		default :
		      return 0;
    }
    return 1;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD STM_Open(DWORD hdevicecontext, DWORD accesscode, DWORD sharemode)
{
    DWORD dwret = 0;
    

    dwret = 1; // have to make non-zero for this call to succeed.
    return dwret;
} 

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void STM_Powerdown(DWORD hdevicecontext)
{
    
} 

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
void STM_Powerup(DWORD hdevicecontext)
{
    
} 

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD STM_Read(DWORD hopencontext,LPVOID pbuffer, DWORD count)
{
    DWORD dwret = 0;
    
    return dwret;
} 

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD STM_Seek(DWORD hopencontext, long amount, DWORD type)
{
    DWORD dwret = 0;
    
    return dwret;
} 

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
DWORD STM_Write(DWORD hopencontext, LPVOID psourcebytes, DWORD numberofbytes)
{
    DWORD dwret = 0;
    

    return dwret;
}

⌨️ 快捷键说明

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