GPIO驱动程序及测试程序Word下载.docx
《GPIO驱动程序及测试程序Word下载.docx》由会员分享,可在线阅读,更多相关《GPIO驱动程序及测试程序Word下载.docx(11页珍藏版)》请在冰豆网上搜索。
![GPIO驱动程序及测试程序Word下载.docx](https://file1.bdocx.com/fileroot1/2022-10/27/7f39c726-1647-4bcc-8b08-2267f60836d5/7f39c726-1647-4bcc-8b08-2267f60836d51.gif)
GPACON=*(DWORD*)pBufIn;
//GPACONSET
break;
caseIO_CTL_GPIO_A_DAT_OUTPUT:
GPADAT=*(DWORD*)pBufIn;
//GPADATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_B_CON:
GPBCON=*(DWORD*)pBufIn;
//GPBCONSET
caseIO_CTL_GPIO_B_DAT_INPUT:
*(DWORD*)pBufOut=v_pIOPregs->
GPBDAT;
//GPBDATSET(INPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_B_DAT_OUTPUT:
GPBDAT=*(DWORD*)pBufIn;
//GPBDATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_B_UP:
GPBUP=*(DWORD*)pBufIn;
//GPBUPSET
caseIO_CTL_GPIO_C_CON:
GPCCON=*(DWORD*)pBufIn;
//GPCCONSET
caseIO_CTL_GPIO_C_DAT_INPUT:
GPCDAT;
//GPCDATSET(INPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_C_DAT_OUTPUT:
GPCDAT=*(DWORD*)pBufIn;
//GPCDATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_C_UP:
GPCUP=*(DWORD*)pBufIn;
//GPCUP
SET
caseIO_CTL_GPIO_D_CON:
GPDCON=*(DWORD*)pBufIn;
//GPDCONSET
caseIO_CTL_GPIO_D_DAT_INPUT:
GPDDAT;
//GPDDATSET(INPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_D_DAT_OUTPUT:
GPDDAT=*(DWORD*)pBufIn;
//GPDDATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_D_UP:
GPDUP=*(DWORD*)pBufIn;
//GPDUPSET
caseIO_CTL_GPIO_E_CON:
GPECON=*(DWORD*)pBufIn;
//GPECONSET
caseIO_CTL_GPIO_E_DAT_INPUT:
GPEDAT;
//GPEDATSET(INPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_E_DAT_OUTPUT:
GPEDAT=*(DWORD*)pBufIn;
//GPEDATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_E_UP:
GPEUP=*(DWORD*)pBufIn;
//GPEUPSET
caseIO_CTL_GPIO_F_CON:
GPFCON=*(DWORD*)pBufIn;
//GPFCONSET
caseIO_CTL_GPIO_F_DAT_INPUT:
GPFDAT;
//GPFDATSET(INPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_F_DAT_OUTPUT:
GPFDAT=*(DWORD*)pBufIn;
//GPFDATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_F_UP:
GPFUP=*(DWORD*)pBufIn;
//GPFUP
caseIO_CTL_GPIO_G_CON:
v_pIOPregs->
GPGCON=*(DWORD*)pBufIn;
//GPGCONSET
caseIO_CTL_GPIO_G_DAT_INPUT:
GPGDAT;
//GPGDATSET(INPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_G_DAT_OUTPUT:
GPGDAT=*(DWORD*)pBufIn;
//GPGDATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_G_UP:
GPGUP=*(DWORD*)pBufIn;
//GPGUPSET
caseIO_CTL_GPIO_H_CON:
GPHCON=*(DWORD*)pBufIn;
//GPHCONSET
caseIO_CTL_GPIO_H_DAT_INPUT:
GPHDAT;
//GPHDATSET(INPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_H_DAT_OUTPUT:
GPHDAT=*(DWORD*)pBufIn;
//GPHDATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_H_UP:
GPHUP=*(DWORD*)pBufIn;
//GPHUPSET
caseIO_CTL_GPIO_J_CON:
GPJCON=*(DWORD*)pBufIn;
//GPJCONSET
caseIO_CTL_GPIO_J_DAT_INPUT:
GPJDAT;
//GPJDATSET(INPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_J_DAT_OUTPUT:
GPJDAT=*(DWORD*)pBufIn;
//GPJDATSET(OUTPUT)alsoforFunctionalPin
caseIO_CTL_GPIO_J_UP:
GPJUP=*(DWORD*)pBufIn;
//GPJUP
default:
}
RETAILMSG(0,(TEXT("
GPIO_Control:
Ioctlcode=0x%x\r\n"
),dwCode));
returnTRUE;
}
测试程序,封装了2个输入输出GPIO函数,调用十分方便:
#include"
"
#ifdef_DEBUG
#definenewDEBUG_NEW
#endif
DWORDRData,BUFCON,BUFOUT,BUFIN;
structGPIO
{
DWORDGPIOCON;
DWORDGPIOIN;
DWORDGPIOOUT;
};
structGPIO
GPA={gpacon,NULL,gpaout},
GPB={gpbcon,gpbin,gpbout},
GPC={gpccon,gpcin,gpcout},
GPD={gpdcon,gpdin,gpdout},
GPE={gpecon,gpein,gpeout},
GPF={gpfcon,gpfin,gpfout},
GPG={gpgcon,gpgin,gpgout},
GPH={gphcon,gphin,gphout},
GPJ={gpjcon,gpjin,gpjout};
//defineandchooseGPIO
//CRelay2Dlg
对话框
CRelay2Dlg:
:
CRelay2Dlg(CWnd*pParent/*=NULL*/)
CDialog(CRelay2Dlg:
IDD,pParent)
m_hIcon=AfxGetApp()->
LoadIcon(IDR_MAINFRAME);
voidCRelay2Dlg:
DoDataExchange(CDataExchange*pDX)
CDialog:
DoDataExchange(pDX);
BEGIN_MESS