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

📄 spi.c

📁 contain many examples code for I2c,UART,string ,digital convert, read/write to EEprom in microchip P
💻 C
字号:


#include 	<pic.h>

#include	"c:\test\hard_def.h"
extern 		void putst(register const char *);


 void spi_send(uchar,uchar,uchar,uchar);

#define 	SPI_CS	RA5

void	spi_wait(void)
{
	#asm
	NOP
	NOP
	#endasm
}
void	spi_send(uchar  spi_cmd,uchar spi_add,uchar	spi_mask,uchar spi_data)
{

		SPI_CS=0;
	switch(spi_cmd)
		{
		
	case SPI_RESET	:	SSPBUF	=	0xC0;	
						spi_wait();
						break; 
	default			:	SSPBUF	=	spi_cmd;
						spi_wait();
						SSPBUF	=	spi_add;
						spi_wait();
						SSPBUF	=	spi_mask;
						//spi_wait();
						if(	spi_cmd != BIT_MODY) break;
						SSPBUF	=	spi_data;
						spi_wait();
						break;
						
		}
		//spi_wait();
		spi_wait();
		SPI_CS=1;
		
	
	}
	spi_initial()
	{
	
	spi_send(SPI_WRITE,CAN_CTRL,CONFIGURER_MODE,IDLE);
	//spi_send(SPI_WRITE,CAN_CTRL,CONFIGURER_MODE,IDLE);

	spi_send(SPI_READ,CAN_CTRL,IDLE,IDLE);	
	//putst(get_val);

	//spi_send(SPI_WRITE,CNF1,0x80,0xFF);
	

	}
	

⌨️ 快捷键说明

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