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

📄 iicmacro.inc

📁 用凌阳单片机的普通IO口
💻 INC
字号:
;====================================================================================
; The information contained herein is the exclusive property of
; Sunplus Technology Co. And shall not be distributed, reproduced,
; or disclosed in whole in part without prior written permission.
;       (C) COPYRIGHT 2004   SUNPLUS TECHNOLOGY CO.                                  
;                   ALL RIGHTS RESERVED
; The entire notice above must be reproduced on all authorized copies.
;====================================================================================

;==================================================================================
;  Program Name		:	SPIMacro.inc
;  Description		:	macro for IIC communication 		 
;  Reference		:   SPMC65P2404A Programming Guide
;  Revision history	:
;---------------------------------------------------------------------------------- 
;  Version		Date 		Description
;  1.0.0    	2004-10-27	First Edition
;==================================================================================																					

;====================================================================================
;Macro Name:		M_TxData
;Description:		transmit data 
;Parameters:		None
;Return Value:		None
;Usage:				M_TxData
;Example:			M_TxData	
;====================================================================================
M_TxData:		.MACRO
					ldx		GB_TxCnt	
					lda		GB_Address_Tx,x			;write the data to buffer
					sta		GP_IIC_TxBuf
					lda		#C_T08B_Timer
					sta		P_TMR0_1_Ctrl0			;enable Timer0						
				.ENDM
;====================================================================================
;Macro Name:		M_RxData
;Description:		receive data 
;Parameters:		None
;Return Value:		None
;Usage:				M_RxData
;Example:			M_RxData	
;====================================================================================
M_RxData:		.MACRO
					ldx		GB_RxCnt
					lda		GP_IIC_RxBuf			;read the data from buffer
					sta		GB_Address_Rx,x
				.ENDM
;====================================================================================
;Macro Name:		M_ClrSCL
;Description:		clear bit5
;Parameters:		None
;Return Value:		None
;Usage:				M_ClrSCL
;Example:			M_ClrSCL			
;====================================================================================
M_ClrSCL:		.MACRO
					lda		P_IOB_Buf
					and		#%11011111			
					sta		P_IOB_Data
				.ENDM
;====================================================================================
;Macro Name:		M_SetSCL
;Description:		set bit5
;Parameters:		None
;Return Value:		None
;Usage:				M_SetSCL
;Example:			M_SetSCL			
;====================================================================================
M_SetSCL:		.MACRO
					lda		P_IOB_Buf
					ora		#%00100000				
					sta		P_IOB_Data
				.ENDM
;====================================================================================
;Macro Name:		M_ClrSDA
;Description:		clear bit4
;Parameters:		None
;Return Value:		None
;Usage:				M_ClrSDA
;Example:			M_ClrSDA			
;====================================================================================
M_ClrSDA:		.MACRO
					lda		P_IOB_Buf
					and		#%11101111			
					sta		P_IOB_Data
				.ENDM				
;====================================================================================
;Macro Name:		M_SetSDA
;Description:		set bit4
;Parameters:		None
;Return Value:		None
;Usage:				M_SetSDA
;Example:			M_SetSDA			
;====================================================================================
M_SetSDA:		.MACRO
					lda		P_IOB_Buf
					ora		#%00010000				
					sta		P_IOB_Data
				.ENDM
;====================================================================================
;Macro Name:		M_SDA_Output
;Description:		set bit4  as output
;Parameters:		None
;Return Value:		None
;Usage:				M_SDA_Output
;Example:			M_SDA_Output			
;====================================================================================
M_SDA_Output:	.MACRO
					lda		P_IOB_Dir
					ora		#%00010000
					sta		P_IOB_Dir
				.ENDM
;====================================================================================
;Macro Name:		M_SDA_Input
;Description:		set bit4 as	input
;Parameters:		None
;Return Value:		None
;Usage:				M_SDA_Input
;Example:			M_SDA_Input			
;====================================================================================
M_SDA_Input:	.MACRO
					lda		P_IOB_Dir
					and		#%11101111
					sta		P_IOB_Dir
				.ENDM			
;====================================================================================
;Macro Name:		M_SCL_Output
;Description:		set bit5  as output
;Parameters:		None
;Return Value:		None
;Usage:				M_SCL_Output
;Example:			M_SCL_Output			
;====================================================================================
M_SCL_Output:	.MACRO
					lda		P_IOB_Dir
					ora		#%00100000
					sta		P_IOB_Dir
					
				.ENDM
;====================================================================================
;Macro Name:		M_SCL_Input
;Description:		set bit5  as input
;Parameters:		None
;Return Value:		None
;Usage:				M_SCL_Input
;Example:			M_SCL_Input			
;====================================================================================
M_SCL_Input:	.MACRO
					lda		P_IOB_Data
					ora		#%00100000
					sta		P_IOB_Data
					lda		P_IOB_Attrib
					and		#%11011111
					sta		P_IOB_Attrib
					lda		P_IOB_Dir
					and		#%11011111
					sta		P_IOB_Dir
				.ENDM
;====================================================================================
;Macro Name:		M_DisableT1
;Description:		
;Parameters:		None
;Return Value:		None
;Usage:				M_DisableT1
;Example:			M_DisableT1			
;====================================================================================
M_DisableT1:	.MACRO
					lda		#$00
					sta		P_TMR0_1_Ctrl0
				.ENDM						
;====================================================================================
;Macro Name:		M_BitClr
;Description:		clear bit
;Parameters:		None
;Return Value:		None
;Usage:				M_BitClr arg1,arg2
;Example:			M_BitClr $80,2			
;====================================================================================
M_BitClr:		.MACRO	arg1,arg2
					lda		#1<<arg2
					eor		#$FF		
					and		arg1		
					sta		arg1
				.ENDM
;====================================================================================
;Macro Name:		M_BitSet
;Description:		clear bit
;Parameters:		None
;Return Value:		None
;Usage:				M_BitSet arg1,arg2
;Example:			M_BitSet $80, 7			
;====================================================================================
M_BitSet:		.MACRO	arg1,arg2
					lda		#1<<arg2		
					ora		arg1		
					sta		arg1
				.ENDM
									

⌨️ 快捷键说明

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