📄 init.c
字号:
}
#elif (BSP_TYPE == BSP_SMDK2450)
void Max1718_Init(int LatchOut_OnOff)
{
volatile S3C2450_IOPORT_REG *s2450IOP = (S3C2450_IOPORT_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE);
//////////////////////////////////////////////
// GPB2 GPC7 GPC6 GPC5 GPC0
// 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 S3C2450 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
if(LatchOut_OnOff == TRUE)
{
s2450IOP->GPCCON = (s2450IOP->GPCCON & ~((0x3f<<10)|(0x3<<0)))|(0x15<<10)|(0x1<<0); // GPC0, GPC5, GPC6, GPC7: OUTPUT
s2450IOP->GPBCON = (s2450IOP->GPBCON & ~(0x3<<4)) | (0x1<<4); // GPB2: OUTPUT
s2450IOP->GPFCON = s2450IOP->GPFCON & ~(0x3f<<10)|(0x15<<10); // GPF5(nARM_REG_LE), GPF6(CORE_REG_OE), GPF7(nINT_REG_LE): OUTPUT
s2450IOP->GPFUDP = s2450IOP->GPFUDP & ~(0x3f<<10); // pull up-down disable
s2450IOP->GPFDAT |= (1<<6); //Output enable
s2450IOP->GPFDAT&=~(1<<5); //Arm Latch enable
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(0<<6)|(0<<5)|(0<<0);//D3, D2, D1, D0 ---- 1.35V
s2450IOP->GPFDAT|=(1<<5); //Arm Latch disable
s2450IOP->GPFDAT &= ~(1<<7); //Int Latch enable
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(0<<6)|(1<<5)|(1<<0);//D3, D2, D1, D0 ---- 1.2V
s2450IOP->GPFDAT|=(1<<7); //Int Latch disable
}
else
{
s2450IOP->GPFDAT&=~(1<<6); //Output Disable
}
}
#endif
//------------------------------------------------
// MAX1718 ARM core, internal regulator setting
//------------------------------------------------
#if (BSP_TYPE == BSP_SMDK2443)
void Max1718_Set(int pwrsrc, int voltage) // add 060624
{
volatile S3C2450_IOPORT_REG *s2450IOP = (S3C2450_IOPORT_REG *)OALPAtoVA(S3C2450_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 S3C2450 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 = s2450IOP->GPFDAT;
vtg=voltage;
/*
s2450IOP->GPFCON = s2450IOP->GPFCON & ~(0x3ff<<6)|(0x155<<6); // GPF3 ~ 7(Data5 ~ 1): OUTPUT
s2450IOP->GPFUDP = s2450IOP->GPFUDP & ~(0x3ff<<6)|(0x2aa<<6); // pull down disable
s2450IOP->GPGCON = s2450IOP->GPGCON & ~(0xf<<12)|(0x5<<12); // GPG6(nARM_REG_LE), GPG7(CORE_REG_OE): OUTPUT
s2450IOP->GPGUDP = s2450IOP->GPGUDP & ~(0xf<<12)|(0xa<<12); // pull down disable
s2450IOP->GPBCON = s2450IOP->GPBCON & ~(0x3<<4)|(0x1<<4); // GPB2(nINT_REG_LE): OUTPUT
s2450IOP->GPBUDP = s2450IOP->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"),
// s2450IOP->GPFDAT, s2450IOP->GPFCON, s2450IOP->GPFUDP,
// s2450IOP->GPGDAT, s2450IOP->GPGCON, s2450IOP->GPGUDP,
// s2450IOP->GPBDAT, s2450IOP->GPBCON, s2450IOP->GPBUDP));
switch (vtg)
{
case V1750mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
case V1700mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V1650mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(0<<5)|(1<<6)|(0<<7); //D4~0
break;
case V1600mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V1550mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(1<<5)|(0<<6)|(0<<7); //D4~0
break;
case V1500mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V1450mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(1<<5)|(1<<6)|(0<<7); //D4~0
break;
case V1400mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(0<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
case V1350mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
case V1300mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V1250mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(1<<6)|(0<<7); //D4~0
break;
case V1200mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V1150mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(1<<5)|(0<<6)|(0<<7); //D4~0
break;
case V1100mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V1050mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(1<<5)|(1<<6)|(0<<7); //D4~0
break;
case V1000mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
case V950mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(0<<5)|(0<<6)|(1<<7); //D4~0
break;
case V925mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(0<<5)|(1<<6)|(0<<7); //D4~0
break;
case V900mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(0<<5)|(1<<6)|(1<<7); //D4~0
break;
case V850mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(1<<5)|(0<<6)|(1<<7); //D4~0
break;
case V825mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(1<<5)|(1<<6)|(0<<7); //D4~0
break;
case V800mV:
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(1<<3)|(0<<4)|(1<<5)|(1<<6)|(1<<7); //D4~0
break;
default: // 1.35V
s2450IOP->GPFDAT=(s2450IOP->GPFDAT&~(0x1f<<3))|(0<<3)|(1<<4)|(0<<5)|(0<<6)|(0<<7); //D4~0
break;
}
if(pwrsrc == ARM_VDD) s2450IOP->GPGDAT&=~(1<<6); //Arm Latch enable
else s2450IOP->GPBDAT&=~(1<<2); //Int Latch enable
s2450IOP->GPGDAT|=(1<<7); //Output enable
if(pwrsrc == ARM_VDD) s2450IOP->GPGDAT|=(1<<6); //Arm Latch disable
else s2450IOP->GPBDAT|=(1<<2); //Int Latch diaable
s2450IOP->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"),
// s2450IOP->GPFDAT, s2450IOP->GPFCON, s2450IOP->GPFUDP,
// s2450IOP->GPGDAT, s2450IOP->GPGCON, s2450IOP->GPGUDP,
// s2450IOP->GPBDAT, s2450IOP->GPBCON, s2450IOP->GPBUDP));
}
#elif (BSP_TYPE == BSP_SMDK2450)
void Max1718_Set(int pwr, int voltage) // add 060624
{
volatile S3C2450_IOPORT_REG *s2450IOP = (S3C2450_IOPORT_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE);
int vtg;
// GPB2 GPC7 GPC6 GPC5 GPC0
// 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 S3C2450 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_gpbdat;
UINT32 backup_gpcdat;
backup_gpbdat = s2450IOP->GPBDAT;
backup_gpcdat = s2450IOP->GPCDAT;
vtg=voltage;
s2450IOP->GPCCON = (s2450IOP->GPCCON & ~((0x3f<<10)|(0x3<<0)))|(0x15<<10)|(0x1<<0); // GPC0, GPC5, GPC6, GPC7: OUTPUT
s2450IOP->GPBCON = (s2450IOP->GPBCON & ~(0x3<<4)) | (0x1<<4); // GPB2: OUTPUT
s2450IOP->GPFCON = s2450IOP->GPFCON & ~(0x3f<<10)|(0x15<<10); // GPF5(nARM_REG_LE), GPF6(CORE_REG_OE), GPF7(nINT_REG_LE): OUTPUT
s2450IOP->GPFUDP = s2450IOP->GPFUDP & ~(0x3f<<10); // pull up-down disable
switch (vtg)
{
case V1750mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(0<<6)|(0<<5)|(0<<0);//D3, D2, D1, D0
break;
case V1700mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(0<<6)|(0<<5)|(1<<0);//D3, D2, D1, D0
break;
case V1650mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(0<<6)|(1<<5)|(0<<0);//D3, D2, D1, D0
break;
case V1600mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(0<<6)|(1<<5)|(1<<0);//D3, D2, D1, D0
break;
case V1550mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(1<<6)|(0<<5)|(0<<0);//D3, D2, D1, D0
break;
case V1500mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(1<<6)|(0<<5)|(1<<0);//D3, D2, D1, D0
break;
case V1450mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(1<<6)|(1<<5)|(0<<0);//D3, D2, D1, D0
break;
case V1400mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(1<<6)|(1<<5)|(1<<0);//D3, D2, D1, D0
break;
case V1350mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(0<<6)|(0<<5)|(0<<0);//D3, D2, D1, D0
break;
case V1300mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(0<<6)|(0<<5)|(1<<0);//D3, D2, D1, D0
break;
case V1250mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(0<<6)|(1<<5)|(0<<0);//D3, D2, D1, D0
break;
case V1200mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(0<<6)|(1<<5)|(1<<0);//D3, D2, D1, D0
break;
case V1150mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(1<<6)|(0<<5)|(0<<0);//D3, D2, D1, D0
break;
case V1100mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(1<<6)|(0<<5)|(1<<0);//D3, D2, D1, D0
break;
case V1050mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(1<<6)|(1<<5)|(0<<0);//D3, D2, D1, D0
break;
case V1000mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(1<<6)|(1<<5)|(1<<0);//D3, D2, D1, D0
break;
case V950mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(1<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(0<<6)|(0<<5)|(1<<0);//D3, D2, D1, D0
break;
case V925mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(1<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(0<<6)|(1<<5)|(0<<0);//D3, D2, D1, D0
break;
case V900mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(1<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(0<<6)|(1<<5)|(1<<0);//D3, D2, D1, D0
break;
case V850mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(1<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(1<<6)|(0<<5)|(1<<0);//D3, D2, D1, D0
break;
case V825mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(1<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(1<<6)|(1<<5)|(0<<0);//D3, D2, D1, D0
break;
case V800mV:
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(1<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(0<<7)|(1<<6)|(1<<5)|(1<<0);//D3, D2, D1, D0
break;
default: // 1.35V
s2450IOP->GPBDAT=(s2450IOP->GPBDAT&~(0x1<<2))|(0<<2);//D4
s2450IOP->GPCDAT=(s2450IOP->GPCDAT&~((0x7<<5)|(0x1<<0)))|(1<<7)|(0<<6)|(0<<5)|(0<<0);//D3, D2, D1, D0
break;
}
if(pwr) s2450IOP->GPFDAT&=~(1<<5); //Arm Latch enable
else s2450IOP->GPFDAT &= ~(1<<7); //Int Latch enable
s2450IOP->GPFDAT |= (1<<6); //Output enable
if(pwr) s2450IOP->GPFDAT|=(1<<5); //Arm Latch disable
else s2450IOP->GPFDAT|=(1<<7); //Int Latch disable
s2450IOP->GPBDAT = backup_gpbdat;
s2450IOP->GPCDAT = backup_gpcdat;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -