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

📄 spi.c

📁 EMB91SAM7S64开发板(全套资料)
💻 C
字号:
/*----------------------------------------------------------------------------
*         ATMEL Microcontroller Software Support  -  ROUSSET  -
*----------------------------------------------------------------------------
* The software is delivered "AS IS" without warranty or condition of any
* kind, either express, implied or statutory. This includes without
* limitation any warranty or condition with respect to merchantability or
* fitness for any particular purpose, or against the infringements of
* intellectual property rights of others.
*----------------------------------------------------------------------------
* File Name           : Board.h
* Object              : AT91SAM7S Evaluation Board Features Definition File.
*
* Creation            : JPP   16/Jun/2004
*----------------------------------------------------------------------------
*/

#include "spi.h"    

//模拟SPI接口功能传输数据

void OutByte(uchar ByteVal)
{

	uchar i;
	SPI_CLK(0);
	
	for(i=0;i<8;i++)
	{
		if(ByteVal&0x80)	SPI_MOSI(1);	
		else 				SPI_MOSI(0);
		ByteVal=ByteVal<<1;
		SPI_CLK(1);	
		SPI_CLK(0);
	}	
}

uchar InByte()
{
	uchar i,val;
	SPI_CLK(0);
	val=0;
	for(i=0;i<8;i++)
	{
		val=val<<1;
		SPI_CLK(1);
		if(SPI_MISO==1)	val=val+1;
		SPI_CLK(0);
	}
	return val;
}




⌨️ 快捷键说明

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