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

📄 spi.inc

📁 汽车无钥进入系统设计,基于PIC单片机16F639,包括电路图和源码
💻 INC
字号:
	ifndef SPI_INC
#define	SPI_INC

;------------------------------------------------------------------------------+
;                                                                              |
;    Module SPI                                                                |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    SPI.asm                                                                   |
;    Jan Ornter                                                                |
;    DATE:   11-9-2005                                                         |
;    VER.:   1.0                                                               |
;    This class provides functions for the modified physical SPI-Layer         |
;                                                                              |
;                                                                              |
;------------------------------------------------------------------------------+
	extern SPI.BufferH
;------------------------------------------------------------------------------+
;                                                                              |
;    Field SPI.BufferL                                                         |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    Stores the least significant Byte                                         |
;                                                                              |
;                                                                              |
;------------------------------------------------------------------------------+
	extern SPI.BufferL
	extern SPI.Read, SPI.Write
	;extern SPI.ShiftOutBuffer, SPI.ShiftInBuffer
;------------------------------------------------------------------------------+
;                                                                              |
;    SPI.Init()                                                                |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    This macro initialises the SPI module                                     |
;                                                                              |
;                                                                              |
;------------------------------------------------------------------------------+
SPI.Init macro
	banksel TRISC
	movlw	b'11001110'		; Set LFDATA,ALERT, and CS as inputs 
	movwf	TRISC			; 
	banksel	PORTC
	bsf		AFECS			; Take AFE CS Line high
	endm
;
;	This macro shifts data out of the MCU through the SPI-Interface.
;
;
;	@param SPI.BufferH The most significant Byte of the Data
;	@param SPI.BufferL The least significant Byte of the Data
;
;	@example
;	pagesel SPI.BufferH
;	movlw	0xf0
;	movwf	SPI.BufferH
;	movlw	0x0f
;	movwf	SPI.BufferL
;	call	SPI.Write
;	@end-ex
;	@ex-desc This sends 0xf00f over the SPI-Bus
;
;	@status Written
;
;	@stacklevel +1
;
;
;
;SPI.Write macro
;	call	SPI.ShiftOutBuffer
;	endm
;
;	This macro reads two Bytes from the SPI-Bus.
;	Put the Read command and the address in the SPI.BufferH and SPI.BufferL Registers.
;	Then call SPI.Read.
;	Then read the returned values in SPI.BufferH and SPI.BufferL.
;
;
;	@param SPI.BufferH The most significant Byte of the Data
;	@param SPI.BufferL The least significant Byte of the Data
;
;
;	@return SPI.BufferH The most significant Byte of the Data
;	@return SPI.BufferL The least significant Byte of the Data
;
;	@example
;	pagesel SPI.BufferH
;	movlw	0xf0
;	movwf	SPI.BufferH
;	movlw	0x0f
;	movwf	SPI.BufferL
;	call	SPI.Read
;	@end-ex
;	@ex-desc This sends 0xf00f over the SPI-Bus, and reads the answer to SPI.BufferH and SPI.BufferL.
;
;	@status Written
;
;	@stacklevel +1
;
;
;
;SPI.Read macro
;	call	SPI.ShiftOutBuffer
;	call	SPI.ShiftInBuffer
;	endm
	endif

⌨️ 快捷键说明

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