⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csi.c

📁 the csi control demo source for the NEC mcu
💻 C
字号:

#pragma sfr
#pragma di
#pragma ei
#pragma nop
#pragma asm
#pragma interrupt INTCSI10  CSI10_Interrupt
#pragma interrupt INTCSI11  CSI11_Interrupt

#include "serial_config.h"

unsigned char CSI10_ReceiveTemp;
unsigned char CSI11_ReceiveTemp;
unsigned char CSI10_SendEnd=0;

    
//*****************************************************
//                 CSI10 function
//*****************************************************

void CSI10_Init()
{
   CSI10_Operation_Disable();
   CSI_SCK10_Port_Mode = output;
   CSI_SCK10_Port_Level = high;
   CSI_SO10_Port_Mode = output;
   CSI_SO10_Port_Level = low;
   CSI_SI10_Port_Mode = input;
   CSI10_Interrupt_Enable();
   CSIC10 = CSI_Timing_Mode + CSI_Select_Clk;
   CSIM10 = CSI_Communication_Mode + CSI_First_Bit;
}

void CSI10_ReceiveData()
{
   CSI10_Operation_Enable();
   CSI10_ReceiveTemp = SIO10;
 	
}

void CSI10_SendData()
{
   CSI10_Operation_Enable();
   SOTB10 = *CSI10_SendBuf++;
   CSI10_SendCount--;
}


__interrupt void CSI10_Interrupt()
{
/*   if(CSI10_SendEnd==1 && CSI10_ReceiveCount > 0)
     {
       *CSI10_ReceiveBuf++ = SIO10;
       CSI10_ReceiveCount--;
     }
   
   if(CSI10_SendCount > 0)
     {
       SOTB10 = *CSI10_SendBuf++;
       CSI10_SendCount--;
     }
       else
       		{
       		 CSI10_ReceiveData(); 
       		 CSI10_SendEnd=1;
       		}*/
     	
   SOTB10 = 0x55;       
}


//*****************************************************
//                 CSI11 function
//*****************************************************

void CSI11_Init()
{
   CSI11_Operation_Disable();
   CSI_SCK11_Port_Mode = output;
   CSI_SCK11_Port_Level = high;
   CSI_SO11_Port_Mode = output;
   CSI_SO11_Port_Level = low;
   CSI_SI11_Port_Mode = input;
 #if (CSI11_SSI11_Pin_Select == CSI11_SSI11_Pin_Used)
   CSI_SSI11_Port_Mode = input;
 #endif      
   CSI11_Interrupt_Enable();
   CSIC11 = CSI_Timing_Mode + CSI_Select_Clk;
   CSIM11 = CSI_Communication_Mode + CSI_First_Bit + CSI11_SSI11_Pin_Select;	
}

void CSI11_ReceiveData()
{
   CSI11_Operation_Enable();
   CSI11_ReceiveTemp = SIO11;
 	
}

void CSI11_SendData()
{
   CSI11_Operation_Enable();
   SOTB11 = *CSI11_SendBuf++;
   CSI11_SendCount--;
}


__interrupt void CSI11_Interrupt()
{
    if(CSI11_ReceiveCount > 0)
     {
       *CSI11_ReceiveBuf++ = SIO11;
       CSI11_ReceiveCount--;
     } 
   
   if(CSI11_SendCount > 0)
     {
       SOTB11 = *CSI11_SendBuf++;
       CSI11_SendCount--;
     }
}

//*****************************************************
//                 main function
//*****************************************************


void main()
{
  DI();
  PCC = 0x00;  
  
  CSI10_Init();
  EI();	
  CSI10_SendData();
  
  while(1);
}

⌨️ 快捷键说明

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