ARM无痛苦起步(S3C44B0X)
//*****************************************
// init the port
//*****************************************
void PortInit(void)
{
rPDATC = 0xffff; //All IO is high
rPCONC = 0x0f55ff54;
rPUPC = 0x3000; //PULL UP RESISTOR should be enabled to I/O
}
// light led
//*****************************************
void LedDisp(int LedStatus)
{
if((LedStatus&0x01)==0x01)
rPDATC &= (~LED_PORTC10); //LED ON
else
rPDATC |= LED_PORTC10; //LED OFF
if((LedStatus&0x02)==0x02)
rPDATC &=(~LED_PORTC11); //LED ON
else
rPDATC |=LED_PORTC11; //LED OFF
}
// show the flash soft id
//*****************************************
void infoFlash()
{
int i,j;
INT16U *pFlash;
*((volatile INT16U *)FLASH_START_ADDR)=FLASH_SID_EXIT;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK1)=FLASH_DATA_UNLOCK1;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK2)=FLASH_DATA_UNLOCK2;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK1)=FLASH_SID_QUERY;
for(i=0;i pFlash=FLASH_START_ADDR;
i=0;j=0;
i=(INT16U)*pFlash++;
j=(INT16U)*pFlash;
}
//*****************************************
// erase hold flash
//*****************************************
int eraseChip()
{
*((volatile INT16U *)FLASH_START_ADDR)=FLASH_SID_EXIT;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK1)=FLASH_DATA_UNLOCK1;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK2)=FLASH_DATA_UNLOCK2;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK1)=FLASH_ERASE;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK1)=FLASH_DATA_UNLOCK1;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK2)=FLASH_DATA_UNLOCK2;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK1)=FLASH_ERASE_CHIP;
if( wait_flash_ready((INT16U *)FLASH_START_ADDR,0xffff) )
return 1;
else return 0;
}
// write one falsh word( 16bit)
//*****************************************
int writeFlash(INT16U *Address,INT16U Data)
{ *((volatile INT16U *)FLASH_START_ADDR)=FLASH_SID_EXIT;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK1)=FLASH_DATA_UNLOCK1;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK2)=FLASH_DATA_UNLOCK2;
*((volatile INT16U *)FLASH_START_ADDR+FLASH_ADDR_UNLOCK1)=FLASH_DATA_WRITE;
*Address=Data;
if(wait_flash_ready(Address,Data))
return 1;
else return 0;
}
// wait for operation finish
//*****************************************
int wait_flash_ready ( INT16U *address, INT16U data )
{
INT32U tmp;
INT16U *p;
tmp =0xff;
p=address;
while(((*p)&0x8080)!=(data&0x8080))
{tmp--;
if (tmp==0x0)
return 1; // timeout
}
return 0;
}
ARMS3C44B0 相关文章:
- ARM S3C44B0X 之 看门狗定时器(11-20)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)