微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > ARM无痛苦起步(S3C44B0X)

ARM无痛苦起步(S3C44B0X)

时间:11-20 来源:互联网 点击:


//*****************************************
//    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;
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top