30
//switch GPIO multi-function pin
ucBuf = Get_W627DHG_Reg(0x2C);
ucBuf &= 0x1F;
Set_W627DHG_Reg(0x2C, ucBuf);
//clear
Set_W627DHG_LD(0x09);
//switch to logic device 9
//enable the GP3 group
ucBuf = Get_W627DHG_Reg(0x30);
ucBuf |= 0x02;
Set_W627DHG_Reg(0x30, ucBuf);
//input detect type
Set_W627DHG_Reg(0xFE, 0xFF);
}
//---------------------------------------------------------------------------
void Dio3SetOutput(unsigned char NewData)
{
Set_W627DHG_LD(0x09);
//switch to logic device 9
Set_W627DHG_Reg(0xF1, NewData);
}
//---------------------------------------------------------------------------
unsigned char Dio3GetInput(void)
{
unsigned char result;
Set_W627DHG_LD(0x09);
//switch to logic device 9
result = Get_W627DHG_Reg(0xF1);
return (result);
}
//---------------------------------------------------------------------------
void Dio3SetDirection(unsigned char NewData)
{
//NewData : 1 for input, 0 for output
Set_W627DHG_LD(0x09);
//switch to logic device 9
Set_W627DHG_Reg(0xF0, NewData);
}
//---------------------------------------------------------------------------
unsigned char Dio3GetDirection(void)
{
unsigned char result;
Set_W627DHG_LD(0x09);
//switch to logic device 9
result = Get_W627DHG_Reg(0xF0);
return (result);
}
//---------------------------------------------------------------------------
Filename
:
W627DHG.cpp
//---------------------------------------------------------------------------
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//
//---------------------------------------------------------------------------
#include "W627DHG.H"
#include <dos.h>
//---------------------------------------------------------------------------
unsigned int W627DHG_BASE;
void Unlock_W627DHG (void);
void Lock_W627DHG (void);
//---------------------------------------------------------------------------
unsigned int Init_W627DHG(void)
{
unsigned int result;
unsigned char ucDid;
W627DHG_BASE = 0x4E;
result = W627DHG_BASE;
ucDid = Get_W627DHG_Reg(0x20);
if (ucDid == 0xA0)
//W83627DHG
{
goto Init_Finish;
}
else if (ucDid == 0xB0)
//W83627DHG-P
{
goto Init_Finish;
}
W627DHG_BASE = 0x2E;
result = W627DHG_BASE;