main.c

来自「S3C44B0X SIO功能模块的开发与应用」· C语言 代码 · 共 78 行

C
78
字号
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"

#define  BIT_SIO_START 1<<3

void SIO_Init(void)
{
   rPDATF=0x1ff;	//All is High
   rPCONF=0x1B6C00; //configure to SIO function
   rPUPF=0x000; // All SIO pins pull up enable

   rSIOCON=0x31;// 00110001,  internal clock, MSB, transmit/recept, up edge recept, auto run, SIO interrupt mode

   rSIODAT=0X00;
   rSBRDR=59; //Baud=500KHz,MCLK=60MHz,Baud=MCLK/2/(rSBRDR+1)
                    
   rIVTCNT=0;
   rDCNTZ=0;

   rI_ISPC|=BIT_SIO;//Clear the flag of SIO_INTPND

}



void SendSIOData(unsigned char data)
{
  rSIODAT=data; 
  rSIOCON|=BIT_SIO_START;//Start the  operation of transmition
  while(!(rINTPND&BIT_SIO));//Wait
  rI_ISPC|=BIT_SIO;//Clear the flag of SIO_INTPND
  Uart_Printf("Sended a data=%d \n",rSIODAT);
 
}


unsigned char ReceptSIOData(void)
{
  rSIOCON|=BIT_SIO_START;//Start to shift
  while(!(rINTPND&BIT_SIO));//wait the shift to complete
  rI_ISPC|=BIT_SIO;//Clear the flag of SIO_INTPND
  Uart_Printf("recepted a data=%d \n",rSIODAT);
  return rSIODAT;
}



void Main(void)
{
    unsigned char temp=0;

    rSYSCFG=CACHECFG;   // Using 8KB Cache//

    Port_Init();
    SIO_Init();
     
    Uart_Init(0,57600);//initalize UART0,baud=57600
    Delay(10);
    Uart_Select(0); //Select UART0
    Uart_Printf("Enter Main program \n"); 

    while(1)
    {
      SendSIOData(8);
      temp=ReceptSIOData();

      Led_Display(0x0);
      Delay(2000);
      Led_Display(0x7);
      Delay(2000);

      SendSIOData(50);
      temp=ReceptSIOData();        
    } 
     
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?