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

📄 afe_639.inc

📁 汽车无钥进入系统设计,基于PIC单片机16F639,包括电路图和源码
💻 INC
📖 第 1 页 / 共 2 页
字号:
;
;*/
AFE.DisableChannelZ macro	;save some code with bsf :)
	banksel	AFE.ConfMap
	movf	AFE.ConfMap,w
	iorlw	0x04
	movwf	AFE.ConfMap
	movlw	0x00
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm


;/*
;
;	This macro sets the LFData output to data mode.
;
;	@example
;	AFE.setOutputData
;	@end-ex
;	@ex-desc This sets the LFData output to data mode
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setOutputData	macro
	banksel AFE.ConfMap
	bcf		(AFE.ConfMap+1),7
	bcf		(AFE.ConfMap+1),6
	movlw	0x01
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro sets the LFData output to clock mode.
;	The clock signal of the carrier frequency will now drive the LFdata pin.
;
;	@example
;	AFE.setOutputClk
;	@end-ex
;	@ex-desc This sets the LFData output to clock mode
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setOutputClk	macro
	banksel AFE.ConfMap
	bcf		(AFE.ConfMap+1),7
	bsf		(AFE.ConfMap+1),6
	movlw	0x01
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm


;/*
;
;	This macro sets the LFData output to RSSI mode.
;	The LFdata pin will put out a current proportional to the signal strength of the LF-Field.
;
;	@example
;	AFE.setOutputRSSI
;	@end-ex
;	@ex-desc This sets the LFData output to RSSI mode
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setOutputRSSI	macro
	banksel AFE.ConfMap
	bsf		(AFE.ConfMap+1),7
	movlw	0x01
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm


;/*
;
;	This macro sets the value for the tuning capacitors at channel X.
;	The input value must not exceed 63.
;
;	@param w The value of the tuning capacitor
;
;	@example
;	movlw	D'33'
;	AFE.setXTuningCap
;	@end-ex
;	@ex-desc This sets the tuning capacitor of channel X to 33pF(typ)
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setXTuningCap	macro	;make function out of it? Let's have a look at the running Code. The Stacklevel may be more critical
	banksel AFE.Buffer
	movwf	AFE.Buffer
	movf	(AFE.ConfMap+1),w
	andlw	B'11000000'
	iorwf	AFE.Buffer,w
	movwf	(AFE.ConfMap+1)
	movlw	0x01
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro sets the value for the tuning capacitors at channel Y.
;	The input value must not exceed 63.
;
;	@param w The value of the tuning capacitor
;
;	@example
;	movlw	D'33'
;	AFE.setYTuningCap
;	@end-ex
;	@ex-desc This sets the tuning capacitor of channel Y to 33pF(typ)
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setYTuningCap	macro
	banksel AFE.Buffer
	movwf	AFE.Buffer
	movf	(AFE.ConfMap+2),w
	andlw	B'11000000'
	iorwf	AFE.Buffer,w
	movwf	(AFE.ConfMap+2)
	movlw	0x02
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro sets the value for the tuning capacitors at channel Z.
;	The input value must not exceed 63.
;
;	@param w The value of the tuning capacitor
;
;	@example
;	movlw	D'33'
;	AFE.setZTuningCap
;	@end-ex
;	@ex-desc This sets the tuning capacitor of channel Z to 33pF(typ)
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setZTuningCap	macro
	banksel AFE.Buffer
	movwf	AFE.Buffer
	movf	(AFE.ConfMap+3),w
	andlw	B'11000000'
	iorwf	AFE.Buffer,w
	movwf	(AFE.ConfMap+3)
	movlw	0x03
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro sets the attenuation for channel X.
;	The input value must not exceed 15.
;
;	@param w Half the value of the attenuation in dB
;
;	@example
;	movlw	D'12'
;	AFE.setXSensitivity
;	@end-ex
;	@ex-desc This sets the attenuation for channel X to 24dB
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setXSensitivity	macro
	banksel AFE.Buffer
	movwf	AFE.Buffer
	swapf	AFE.Buffer,f
	movf	(AFE.ConfMap+4),w
	andlw	B'00001111'
	iorwf	AFE.Buffer,w
	movwf	(AFE.ConfMap+4)
	movlw	0x04
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro sets the attenuation for channel Y.
;	The input value must not exceed 15.
;
;	@param w Half the value of the attenuation in dB
;
;	@example
;	movlw	D'12'
;	AFE.setYSensitivity
;	@end-ex
;	@ex-desc This sets the attenuation for channel Y to 24dB
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setYSensitivity	macro
	banksel AFE.Buffer
	movwf	AFE.Buffer
	movf	(AFE.ConfMap+4),w
	andlw	B'11110000'
	iorwf	AFE.Buffer,w
	movwf	(AFE.ConfMap+4)
	movlw	0x04
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro sets the attenuation for channel Z.
;	The input value must not exceed 15.
;
;	@param w Half the value of the attenuation in dB
;
;	@example
;	movlw	D'12'
;	AFE.setZSensitivity
;	@end-ex
;	@ex-desc This sets the attenuation for channel Z to 24dB
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setZSensitivity	macro
	banksel AFE.Buffer
	movwf	AFE.Buffer
	movf	(AFE.ConfMap+5),w
	andlw	B'11110000'
	iorwf	AFE.Buffer,w
	movwf	(AFE.ConfMap+5)
	movlw	0x05
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro sets the modulation depth to accept incoming signals
;
;	@param w The code for the required modulation depth
;
;	@example
;	movlw	AFE.ModDepth50
;	AFE.setModDepth
;	@end-ex
;	@ex-desc This sets the modulation depth to 50%.
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.setModDepth macro
	banksel AFE.Buffer
	movwf	AFE.Buffer
	swapf	AFE.Buffer,f
	movf	(AFE.ConfMap+5),w
	andlw	B'11001111'
	iorwf	AFE.Buffer,w
	movwf	(AFE.ConfMap+5)
	movlw	0x05
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro configures the modulation depth.
;	Setting the TOEH and TOEL to zero, will result in disabling the Filter.
;
;	@param TOEH The time in ms the input signal has to be high
;	@param TOEL The time in ms the input signal has to be low
;
;	@example
;	AFE.confOEFilter	2,2
;	@end-ex
;	@ex-desc This sets the high and low time to 2 ms
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.updateColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.updateColumnParity /*/AFE.updateColumnParity
;
;
;*/
AFE.confOEFilter macro	TOEH, TOEL
	banksel AFE.ConfMap
	movf	AFE.ConfMap,w
	andlw	B'00001111'
	iorlw	(((TOEH<<6)&&B'11000000')||((TOEL<<4)&&B'00110000'))	;ensure that he does what I want
	movwf	AFE.ConfMap
	movlw	0x00
	call	AFE.WriteRegister
	AFE.updateColumnParity
	endm

;/*
;
;	This macro reads the status register of the AFE
;
;	@return w The current value of the Status register of the AFE
;
;	@example
;	AFE.getStatus			;get status register of AFE
;	andlw 0x01				;mask parity error bit
;	btfss	STATUS,Z		;error occured?
;	call	AFE.writeCfg	;write back RAM Map to AFE (Parity will be calculated)
;	@end-ex
;	@ex-desc This example checks whether a parity error occured or not.
;
;	@status Written
;
;	@stacklevel /*/AFE.ReadRegister
;	@registers /*/AFE.ReadRegister
;	@calls AFE.ReadRegister /*/AFE.ReadRegister
;
;
;*/
AFE.getStatus	macro
	movlw	0x07
	call	AFE.ReadRegister
	banksel	AFE.ConfMap
	movf	(AFE.ConfMap+7),w
	endm


;/*
;
;	This macro reads the status register of the AFE
;
;	@return w The current value of the Status register of the AFE
;
;	@example
;	movlw	0x03
;	call	AFE.WriteRegister
;	AFE.updateColumnParity
;	@end-ex
;	@ex-desc This example writes the new column parity to the AFE.ConfMap and to the device
;
;	@status Written
;
;	@stacklevel /*/AFE.WriteRegister /*/AFE.CalcColumnParity
;	@registers /*/AFE.WriteRegister /*/AFE.CalcColumnParity
;	@calls AFE.WriteRegister /*/AFE.WriteRegister AFE.CalcColumnParity /*/AFE.CalcColumnParity
;
;
;*/
AFE.updateColumnParity	macro
	call	AFE.CalcColumnParity
	movlw	0x06
	call	AFE.WriteRegister
	endm



#endif

⌨️ 快捷键说明

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