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

📄 spi.c

📁 基于摩托罗拉(现在飞思卡尔)系列MC68HC908单片机开发车辆ECU系统!
💻 C
字号:
#include "SPI.h"



  
 

void SPIinit(void) {
 SPCR_SPMSTR=1;
 CS_33972=1;
 DDRD_DDRD0=1;
 CS_33689=1;
 DDRA_DDRA3=1;
 SPSCR_SPR=0x01;
 SPIenable;
 }
 

void SPI33972(UINT8 SPIbyte1, UINT8 SPIbyte2, UINT8 SPIbyte3, UINT8 SPIbyte4, UINT8 SPIbyte5, UINT8 SPIbyte6) {
UINT8 i=0xf;
DisableInt();
CS_33972=0;
while(i--); 
while (!SPSCR_SPTE);
SPDR=SPIbyte1;
while(!SPSCR_SPRF);
switchstatus[0]=SPDR;
while (!SPSCR_SPTE);
SPDR=SPIbyte2;
while(!SPSCR_SPRF);
switchstatus[1]=SPDR;
while (!SPSCR_SPTE);
SPDR=SPIbyte3;
while(!SPSCR_SPRF);
switchstatus[2]=SPDR;
while (!SPSCR_SPTE);
SPDR=SPIbyte4; 
while(!SPSCR_SPRF);
switchstatus[3]=SPDR;
while (!SPSCR_SPTE);
SPDR=SPIbyte5;
while(!SPSCR_SPRF);
switchstatus[4]=SPDR;
while (!SPSCR_SPTE);
SPDR=SPIbyte6;
while(!SPSCR_SPRF);
switchstatus[5]=SPDR;
i=0xf;
while(i--);
CS_33972=1;
EnableInt();
}

void SPI33689(UINT8 SPIbyte){
UINT16 i;
UINT8 temp;
DisableInt();
CS_33689=0;
i=0xf;
while(i--);
SPDR=SPIbyte;
while(!SPSCR_SPRF);
temp=SPDR;
i=0xf;
while(i--);
CS_33689=1;
EnableInt();
}


  

  

⌨️ 快捷键说明

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