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

📄 i2c.asm

📁 cypress的触摸按键模块介绍calibrating_capsense_with_the_csr_user_module___an2355_13.
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME: I2C.asm
;;  Version: 1.0, Updated on 2005/09/29 at 12:44:08
;;  Generated by PSoC Designer ver 4.2  b1013 : 02 September, 2004
;;
;;  DESCRIPTION: EzI2Cs User Module software implementation file
;;               for the 22/24/27/29xxx PSoC family of devices
;;
;;  NOTE: User Module APIs conform to the fastcall16 convention for marshalling
;;        arguments and observe the associated "Registers are volatile" policy.
;;        This means it is the caller's responsibility to preserve any values
;;        in the X and A registers that are still needed after the API functions
;;        returns. For Large Memory Model devices it is also the caller's 
;;        responsibility to perserve any value in the CUR_PP, IDX_PP, MVR_PP and 
;;        MVW_PP registers. Even though some of these registers may not be modified
;;        now, there is no guarantee that will remain the case in future releases.
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress MicroSystems 2004. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************

include "m8c.inc"
include "memory.inc"
include "I2C.inc"

;-----------------------------------------------
; include instance specific register definitions
;-----------------------------------------------

;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
;-------------------------------------------------------------------
;  Declare the functions global for both assembler and C compiler.
;
;  Note that there are two names for each API. First name is
;  assembler reference. Name with underscore is name refence for
;  C compiler.  Calling function in C source code does not require
;  the underscore.
;-------------------------------------------------------------------

export    I2C_EnableInt
export   _I2C_EnableInt
export    I2C_Start
export   _I2C_Start

export    I2C_DisableInt
export   _I2C_DisableInt
export    I2C_Stop
export   _I2C_Stop
export    I2C_SetRamBuffer
export   _I2C_SetRamBuffer
export    I2C_GetAddr
export   _I2C_GetAddr
export    I2C_GetActivity
export   _I2C_GetActivity


IF (I2C_DYNAMIC_ADDR) ;; Enable this function only if Address is Dynamic
export    I2C_SetAddr
export   _I2C_SetAddr
ENDIF

IF (I2C_ROM_ENABLE)  ;; Enable only if alternate ROM Address is Enabled
export    I2C_SetRomBuffer
export   _I2C_SetRomBuffer
ENDIF


AREA UserModules (ROM, REL, CON)

.SECTION

;-----------------------------------------------------------------------------
;  FUNCTION NAME: I2C_Start
;
;  DESCRIPTION:
;   Initialize the I2C I2C bus interface.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;
;  RETURNS: none
;
;  SIDE EFFECTS:
;    REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;    IN THE LARGE MEMORY MODEL CURRENTLY ONLY THE PAGE POINTER 
;    REGISTERS LISTED BELOW ARE MODIFIED.  THIS DOES NOT GUARANTEE 
;    THAT IN FUTURE IMPLEMENTATIONS OF THIS FUNCTION OTHER PAGE POINTER 
;    REGISTERS WILL NOT BE MODIFIED.
;          
;    Page Pointer Registers Modified: 
;          CUR_PP
;
;  THEORY of OPERATION or PROCEDURE:
;

 I2C_Start:
_I2C_Start:
IF (I2C_DYNAMIC_ADDR)  ;; DYNAMIC ADDRESS
   RAM_PROLOGUE RAM_USE_CLASS_4
   RAM_SETPAGE_CUR >I2C_bAddr
   mov  [I2C_bAddr],I2C_SLAVE_ADDR
ELSE
   RAM_PROLOGUE RAM_USE_CLASS_1
ENDIF

   ;; Initialize pointers
   



   call I2C_EnableInt
   call I2C_EnableSlave
IF (I2C_DYNAMIC_ADDR)  ;; DYNAMIC ADDRESS
   RAM_EPILOGUE RAM_USE_CLASS_4
ELSE
   RAM_EPILOGUE RAM_USE_CLASS_1
ENDIF
   ret

.ENDSECTION

IF (I2C_DYNAMIC_ADDR)  ;; DYNAMIC ADDRESS
.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: I2C_SetAddr(BYTE bAddr)
;
;  DESCRIPTION:
;   Set the I2C slave address for the I2C I2C bus interface.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;      A =>  Slave address
;
;  RETURNS: none
;
;  SIDE EFFECTS;    
;    REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;    IN THE LARGE MEMORY MODEL CURRENTLY ONLY THE PAGE POINTER 
;    REGISTERS LISTED BELOW ARE MODIFIED.  THIS DOES NOT GUARANTEE 
;    THAT IN FUTURE IMPLEMENTATIONS OF THIS FUNCTION OTHER PAGE POINTER 
;    REGISTERS WILL NOT BE MODIFIED.
;          
;    Page Pointer Registers Modified: 
;          CUR_PP
;
;  THEORY of OPERATION or PROCEDURE:
;

 I2C_SetAddr:
_I2C_SetAddr:
   RAM_PROLOGUE RAM_USE_CLASS_4
   RAM_SETPAGE_CUR >I2C_bAddr
   asl   A
   mov   [I2C_bAddr],A
   RAM_EPILOGUE RAM_USE_CLASS_4
   ret

.ENDSECTION
ENDIF

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME:BYTE I2C_GetActivity(void)
;
;  DESCRIPTION:
;    Return a non-zero value if the I2C hardware has seen activity on the bus.
;    The activity flag will be cleared if set when calling this function.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:  none
;
;  RETURNS: 
;    BYTE  non-zero = Activity
;          zero     = No Activity
;
;  SIDE EFFECTS;    
;    REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;    IN THE LARGE MEMORY MODEL CURRENTLY ONLY THE PAGE POINTER 
;    REGISTERS LISTED BELOW ARE MODIFIED.  THIS DOES NOT GUARANTEE 
;    THAT IN FUTURE IMPLEMENTATIONS OF THIS FUNCTION OTHER PAGE POINTER 
;    REGISTERS WILL NOT BE MODIFIED.
;          
;    Page Pointer Registers Modified: 
;          CUR_PP
;
;  THEORY of OPERATION or PROCEDURE:
;

 I2C_GetActivity:
_I2C_GetActivity:
   RAM_PROLOGUE RAM_USE_CLASS_4
   RAM_SETPAGE_CUR >I2C_bState
   mov   A,[I2C_bState]
   and   A,I2C_ACTIVITY_MASK         ; Mask off activity bits
   and   [I2C_bState],~I2C_ACTIVITY_MASK ; Clear system activity bits

I2C_GetActivity_End:
   RAM_EPILOGUE RAM_USE_CLASS_4
   ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: BYTE I2C_GetAddr(Void)
;
;  DESCRIPTION:
;   Get the I2C slave address for the I2C I2C bus interface.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS: none
;
;  RETURNS: none
;
;  SIDE EFFECTS;    
;    REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;    IN THE LARGE MEMORY MODEL CURRENTLY ONLY THE PAGE POINTER 
;    REGISTERS LISTED BELOW ARE MODIFIED.  THIS DOES NOT GUARANTEE 
;    THAT IN FUTURE IMPLEMENTATIONS OF THIS FUNCTION OTHER PAGE POINTER 
;    REGISTERS WILL NOT BE MODIFIED.
;          
;    Page Pointer Registers Modified: 
;          CUR_PP
;
;
;  THEORY of OPERATION or PROCEDURE:
;

 I2C_GetAddr:
_I2C_GetAddr:

IF (I2C_DYNAMIC_ADDR)  ;; DYNAMIC ADDRESS
   RAM_PROLOGUE RAM_USE_CLASS_4
   RAM_SETPAGE_CUR >I2C_bAddr
   mov   A,[I2C_bAddr]
   asr   A                          ; Shift Addr to right to drop RW bit.
   and   A,0x7F                     ; Mask off bogus MSb
   RAM_EPILOGUE RAM_USE_CLASS_4
ELSE
   mov   A,0x38            
ENDIF
   ret

.ENDSECTION



.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: I2C_EnableInt
;
;  DESCRIPTION:
;     Enables SDA interrupt allowing start condition detection. Remember to call the
;     global interrupt enable function by using the macro: M8C_EnableGInt.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS: none
;
;  RETURNS: none
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;

 I2C_EnableInt:
_I2C_EnableInt:

⌨️ 快捷键说明

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