📄 init.c
字号:
vtg = voltage;
// port backup
backup_gpfdat = s2443IOP->GPFDAT;
s2443IOP->GPFDAT &=~(0x1f<<3);
switch (vtg)
{
case V135:
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
case V100:
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
case V175:
s2443IOP->GPFDAT |= (0<<3)|(0<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
case V170:
s2443IOP->GPFDAT |= (0<<3)|(0<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V165:
s2443IOP->GPFDAT |= (0<<3)|(0<<4)|(0<<5)|(1<<6)|(0<<7); //D4~0
break;
case V160:
s2443IOP->GPFDAT |= (0<<3)|(0<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V155:
s2443IOP->GPFDAT |= (0<<3)|(0<<4)|(1<<5)|(0<<6)|(0<<7); //D4~0
break;
case V150:
s2443IOP->GPFDAT |= (0<<3)|(0<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V145:
s2443IOP->GPFDAT |= (0<<3)|(0<<4)|(1<<5)|(1<<6)|(0<<7); //D4~0
break;
case V140:
s2443IOP->GPFDAT |= (0<<3)|(0<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
case V130:
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V125:
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(0<<5)|(1<<6)|(0<<7); //D4~0
break;
case V120:
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V115:
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(1<<5)|(0<<6)|(0<<7); //D4~0
break;
case V110:
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V105:
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(1<<5)|(1<<6)|(0<<7); //D4~0
break;
case V95:
s2443IOP->GPFDAT |= (1<<3)|(0<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V90:
s2443IOP->GPFDAT |= (1<<3)|(0<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V85:
s2443IOP->GPFDAT |= (1<<3)|(0<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V80:
s2443IOP->GPFDAT |= (1<<3)|(0<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
default: // 1.35V
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
}
if(pwr) s2443IOP->GPGDAT&=~(1<<6); //Arm Latch enable
else s2443IOP->GPBDAT&=~(1<<2); //Int Latch enable
s2443IOP->GPGDAT|=(1<<7); // on DVS, GPG7 must be 'high' --> non high Z output
// Output Enable, delay, LE propagation dealy typ. 5.3ns
if(pwr) s2443IOP->GPGDAT|=(1<<6); //Arm Latch disable
else s2443IOP->GPBDAT|=(1<<2); //Int Latch diaable
s2443IOP->GPFDAT = backup_gpfdat; // restore backuped GPFDAT's value
}
void Max1718_Init_o() // add 060624
{
volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
s2443IOP->GPFCON = s2443IOP->GPFCON & ~(0x3ff<<6)|(0x155<<6); // GPF3 ~ 7(Data5 ~ 1): OUTPUT
s2443IOP->GPFUDP = s2443IOP->GPFUDP | (0x3ff<<6); // disable pull down disable
s2443IOP->GPGCON = s2443IOP->GPGCON & ~(0xf<<12)|(0x5<<12); // GPG6(nARM_REG_LE), GPG7(CORE_REG_OE): OUTPUT
s2443IOP->GPGUDP = s2443IOP->GPGUDP | (0xf<<12); // pull down disable
s2443IOP->GPBCON = s2443IOP->GPBCON & ~(0x3<<4)|(0x1<<4); // GPB2(nINT_REG_LE): OUTPUT
s2443IOP->GPBUDP = s2443IOP->GPBUDP | (0x3<<4); // pull down disable
s2443IOP->GPGDAT|=(1<<7); //Output enable
s2443IOP->GPGDAT &= ~(1<<6); //Arm Latch enable
s2443IOP->GPFDAT &= ~(0x1f<<3);
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(0<<5)|(0<<6)|(0<<7); //1.35V
s2443IOP->GPGDAT |= (1<<6); //Arm Latch disable
s2443IOP->GPBDAT &= ~(1<<2); //Int Latch enable
s2443IOP->GPFDAT &= ~(0x1f<<3);
s2443IOP->GPFDAT |= (0<<3)|(1<<4)|(0<<5)|(1<<6)|(1<<7); //1.2V
s2443IOP->GPBDAT |= (1<<2); //Int Latch diaable
// RETAILMSG(1,(TEXT("E GPFDAT: %x, GPFCON: %x, GPFUDP: %x, GPGDAT: %x, GPGCON: %x, GPGUDP: %x, GPBDAT: %x, GPBCON: %x, GPBUDP: %x\n"),
// s2443IOP->GPFDAT, s2443IOP->GPFCON, s2443IOP->GPFUDP,
// s2443IOP->GPGDAT, s2443IOP->GPGCON, s2443IOP->GPGUDP,
// s2443IOP->GPBDAT, s2443IOP->GPBCON, s2443IOP->GPBUDP));
}
void Max1718_Init(void) // add 060624
{
volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
//////////////////////////////////////////////
// GPF3 GPF4 GPF5 GPF6 GPF7
// D4 D3 D2 D1 D0
// 0 0 0 0 0 // 1.75V
// 0 0 0 0 1 // 1.70V
// 0 0 0 1 0 // 1.65V
// 0 0 0 1 1 // 1.60V
// 0 0 1 0 0 // 1.55V
// 0 0 1 0 1 // 1.50V
// 0 0 1 1 0 // 1.45V, Max. voltage of S3C2443 VDDarm
// 0 0 1 1 1 // 1.40V
// 0 1 0 0 0 // 1.35V
// 0 1 0 0 1 // 1.30V
// 0 1 0 1 0 // 1.25V
// 0 1 0 1 1 // 1.20V
// 0 1 1 0 0 // 1.15V
// 0 1 1 0 1 // 1.10V
// 0 1 1 1 0 // 1.05V
// 0 1 1 1 1 // 1.00V
// 1 0 0 0 1 // 0.95V
// 1 0 0 1 1 // 0.90V
// 1 0 1 0 1 // 0.85V
// 1 0 1 1 1 // 0.80V
RETAILMSG(1,(TEXT("I GPFDAT: %x, GPFCON: %x, GPFUDP: %x, GPGDAT: %x, GPGCON: %x, GPGUDP: %x, GPBDAT: %x, GPBCON: %x, GPBUDP: %x\n"),
s2443IOP->GPFDAT, s2443IOP->GPFCON, s2443IOP->GPFUDP,
s2443IOP->GPGDAT, s2443IOP->GPGCON, s2443IOP->GPGUDP,
s2443IOP->GPBDAT, s2443IOP->GPBCON, s2443IOP->GPBUDP));
s2443IOP->GPFCON = s2443IOP->GPFCON & ~(0x3ff<<6)|(0x155<<6); // GPF3 ~ 7(Data5 ~ 1): OUTPUT
s2443IOP->GPGCON = s2443IOP->GPGCON & ~(0xf<<12)|(0x5<<12); // GPG6(nARM_REG_LE), GPG7(CORE_REG_OE): OUTPUT
s2443IOP->GPGUDP = s2443IOP->GPGUDP & ~(0xf<<12)|(0xa<<12); // pull down disable
s2443IOP->GPBCON = s2443IOP->GPBCON & ~(0x3<<4)|(0x1<<4); // GPB2(nINT_REG_LE): OUTPUT
s2443IOP->GPBUDP = s2443IOP->GPBUDP & ~(0x3<<4)|(0x2<<4); // pull down disable
s2443IOP->GPGDAT|=(1<<7); //Output enable
s2443IOP->GPGDAT&=~(1<<6); //Arm Latch enable
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(0<<6)|(0<<7); //1.35V
s2443IOP->GPGDAT|=(1<<6); //Arm Latch disable
s2443IOP->GPBDAT&=~(1<<2); //Int Latch enable
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(1<<6)|(1<<7); //1.2V
s2443IOP->GPBDAT|=(1<<2); //Int Latch diaable
RETAILMSG(1,(TEXT("E GPFDAT: %x, GPFCON: %x, GPFUDP: %x, GPGDAT: %x, GPGCON: %x, GPGUDP: %x, GPBDAT: %x, GPBCON: %x, GPBUDP: %x\n"),
s2443IOP->GPFDAT, s2443IOP->GPFCON, s2443IOP->GPFUDP,
s2443IOP->GPGDAT, s2443IOP->GPGCON, s2443IOP->GPGUDP,
s2443IOP->GPBDAT, s2443IOP->GPBCON, s2443IOP->GPBUDP));
}
//------------------------------------------------
// MAX1718 ARM core, internal regulator setting
//------------------------------------------------
void Max1718_Set(int pwr, int voltage) // add 060624
{
volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
int vtg;
//////////////////////////////////////////////
// GPF3 GPF4 GPF5 GPF6 GPF7
// D4 D3 D2 D1 D0
// 0 0 0 0 0 // 1.75V
// 0 0 0 0 1 // 1.70V
// 0 0 0 1 0 // 1.65V
// 0 0 0 1 1 // 1.60V
// 0 0 1 0 0 // 1.55V
// 0 0 1 0 1 // 1.50V
// 0 0 1 1 0 // 1.45V, Max. voltage of S3C2443 VDDarm
// 0 0 1 1 1 // 1.40V
// 0 1 0 0 0 // 1.35V
// 0 1 0 0 1 // 1.30V
// 0 1 0 1 0 // 1.25V
// 0 1 0 1 1 // 1.20V
// 0 1 1 0 0 // 1.15V
// 0 1 1 0 1 // 1.10V
// 0 1 1 1 0 // 1.05V
// 0 1 1 1 1 // 1.00V
// 1 0 0 0 1 // 0.95V
// 1 0 0 1 1 // 0.90V
// 1 0 1 0 1 // 0.85V
// 1 0 1 1 1 // 0.80V
UINT32 backup_gpfdat;
backup_gpfdat = s2443IOP->GPFDAT;
vtg=voltage;
/*
s2443IOP->GPFCON = s2443IOP->GPFCON & ~(0x3ff<<6)|(0x155<<6); // GPF3 ~ 7(Data5 ~ 1): OUTPUT
s2443IOP->GPFUDP = s2443IOP->GPFUDP & ~(0x3ff<<6)|(0x2aa<<6); // pull down disable
s2443IOP->GPGCON = s2443IOP->GPGCON & ~(0xf<<12)|(0x5<<12); // GPG6(nARM_REG_LE), GPG7(CORE_REG_OE): OUTPUT
s2443IOP->GPGUDP = s2443IOP->GPGUDP & ~(0xf<<12)|(0xa<<12); // pull down disable
s2443IOP->GPBCON = s2443IOP->GPBCON & ~(0x3<<4)|(0x1<<4); // GPB2(nINT_REG_LE): OUTPUT
s2443IOP->GPBUDP = s2443IOP->GPBUDP & ~(0x3<<4)|(0x2<<4); // pull down disable
*/
// RETAILMSG(1,(TEXT("A GPFDAT: %x, GPFCON: %x, GPFUDP: %x, GPGDAT: %x, GPGCON: %x, GPGUDP: %x, GPBDAT: %x, GPBCON: %x, GPBUDP: %x\n"),
// s2443IOP->GPFDAT, s2443IOP->GPFCON, s2443IOP->GPFUDP,
// s2443IOP->GPGDAT, s2443IOP->GPGCON, s2443IOP->GPGUDP,
// s2443IOP->GPBDAT, s2443IOP->GPBCON, s2443IOP->GPBUDP));
switch (vtg)
{
case V175:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
case V170:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V165:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(0<<5)|(1<<6)|(0<<7); //D4~0
break;
case V160:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V155:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(1<<5)|(0<<6)|(0<<7); //D4~0
break;
case V150:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V145:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(1<<5)|(1<<6)|(0<<7); //D4~0
break;
case V140:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
case V135:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
case V130:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V125:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(1<<6)|(0<<7); //D4~0
break;
case V120:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V115:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(1<<5)|(0<<6)|(0<<7); //D4~0
break;
case V110:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V105:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(1<<5)|(1<<6)|(0<<7); //D4~0
break;
case V100:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
case V95:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V90:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V85:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V80:
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
default: // 1.35V
s2443IOP->GPFDAT=(s2443IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
}
if(pwr) s2443IOP->GPGDAT&=~(1<<6); //Arm Latch enable
else s2443IOP->GPBDAT&=~(1<<2); //Int Latch enable
s2443IOP->GPGDAT|=(1<<7); //Output enable
if(pwr) s2443IOP->GPGDAT|=(1<<6); //Arm Latch disable
else s2443IOP->GPBDAT|=(1<<2); //Int Latch diaable
s2443IOP->GPFDAT = backup_gpfdat;
// RETAILMSG(1,(TEXT("B GPFDAT: %x, GPFCON: %x, GPFUDP: %x, GPGDAT: %x, GPGCON: %x, GPGUDP: %x, GPBDAT: %x, GPBCON: %x, GPBUDP: %x\n"),
// s2443IOP->GPFDAT, s2443IOP->GPFCON, s2443IOP->GPFUDP,
// s2443IOP->GPGDAT, s2443IOP->GPGCON, s2443IOP->GPGUDP,
// s2443IOP->GPBDAT, s2443IOP->GPBCON, s2443IOP->GPBUDP));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -