📄 uart_1.asm
字号:
;;*****************************************************************************
;;*****************************************************************************
;; Filename: UART_1.asm
;; Version: 5.2, Updated on 2005/09/30 at 16:26:37
;; Generated by PSoC Designer ver 4.2 b1013 : 02 September, 2004
;;
;; DESCRIPTION: UART User Module software implementation file for the
;; 22/24/25/26/27xxx families.
;;
;;
;; 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 2000-2003. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "memory.inc"
include "UART_1.inc"
;-----------------------------------------------
; 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 UART_1_SetTxIntMode
export _UART_1_SetTxIntMode
export UART_1_EnableInt
export _UART_1_EnableInt
export UART_1_DisableInt
export _UART_1_DisableInt
export UART_1_Start
export _UART_1_Start
export UART_1_Stop
export _UART_1_Stop
export UART_1_SendData
export _UART_1_SendData
export UART_1_bReadTxStatus
export _UART_1_bReadTxStatus
export UART_1_bReadRxData
export _UART_1_bReadRxData
export UART_1_bReadRxStatus
export _UART_1_bReadRxStatus
export UART_1_IntCntl
export _UART_1_IntCntl
export UART_1_TxIntMode
export _UART_1_TxIntMode
export UART_1_PutSHexByte
export _UART_1_PutSHexByte
export UART_1_PutSHexInt
export _UART_1_PutSHexInt
export UART_1_CPutString
export _UART_1_CPutString
export UART_1_PutString
export _UART_1_PutString
export UART_1_PutChar
export _UART_1_PutChar
export UART_1_Write
export _UART_1_Write
export UART_1_CWrite
export _UART_1_CWrite
export UART_1_cGetChar
export _UART_1_cGetChar
export UART_1_cReadChar
export _UART_1_cReadChar
export UART_1_iReadChar
export _UART_1_iReadChar
export UART_1_PutCRLF
export _UART_1_PutCRLF
IF (UART_1_RXBUF_ENABLE)
export UART_1_CmdReset
export _UART_1_CmdReset
export UART_1_bCmdCheck
export _UART_1_bCmdCheck
export UART_1_bCmdLength
export _UART_1_bCmdLength
export UART_1_bErrCheck
export _UART_1_bErrCheck
export UART_1_szGetParam
export _UART_1_szGetParam
export UART_1_szGetRestOfParams
export _UART_1_szGetRestOfParams
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WARNING WARNING WARNING
; The following exports are for backwards compatibility only and should
; not be used for new designs. They may be eliminated in a future release.
; Their status is "NO FURTHER MAINTENANCE".
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
export bUART_1_ReadTxStatus
export _bUART_1_ReadTxStatus
export bUART_1_ReadRxData
export _bUART_1_ReadRxData
export bUART_1_ReadRxStatus
export _bUART_1_ReadRxStatus
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; END WARNING
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;-----------------------------------------------
; Variable Allocation
;-----------------------------------------------
IF (UART_1_RXBUF_ENABLE)
area UART_1_RAM (RAM, REL, CON)
ptrParam: BLK 1
ENDIF
area text (ROM,REL)
;-----------------------------------------------
; EQUATES
;-----------------------------------------------
bfCONTROL_REG_START_BIT: equ 1 ; Control register start bit
bfFUNCTION_REG_TX_INT_MODE_BIT: equ 0x10 ; the TX Int Mode bit
area UserModules (ROM, REL, CON)
;=============================================================================
;=============================================================================
;
; Low-Level Commands
;
;=============================================================================
;=============================================================================
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: UART_1_EnableInt
;
; DESCRIPTION:
; Enables this UART's interrupt by setting the interrupt enable mask
; bit associated with this User Module. Remember to call the global
; interrupt enable function by using the macro: M8C_EnableGInt.
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; none.
;
; RETURNS:
; none.
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
UART_1_EnableInt:
_UART_1_EnableInt:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_EnableIntMask UART_1_TX_INT_REG, UART_1_TX_INT_MASK
M8C_EnableIntMask UART_1_RX_INT_REG, UART_1_RX_INT_MASK
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: UART_1_DisableInt
;
; DESCRIPTION:
; Disables this UART's interrupt by clearing the interrupt enable mask bit
; associated with this User Module.
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; none.
;
; RETURNS:
; none.
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
UART_1_DisableInt:
_UART_1_DisableInt:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_DisableIntMask UART_1_TX_INT_REG, UART_1_TX_INT_MASK
M8C_DisableIntMask UART_1_RX_INT_REG, UART_1_RX_INT_MASK
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: UART_1_SetTxIntMode(BYTE bTxIntMode)
;
; DESCRIPTION:
; Sets the Tx Interrupt Mode bit in the Function Register.
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; BYTE bTxIntMode - The TX Interrupt mode setting. Use defined masks.
; Passed in the A register
;
; RETURNS:
; none.
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
; THEORY of OPERATION OR PROCEDURE:
; Sets the TX interrupt mode bit to define whether the interrupt occurs
; on TX register empty or TX transmit complete
;
UART_1_SetTxIntMode:
_UART_1_SetTxIntMode:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_SetBank1
and A, UART_1_INT_MODE_TX_COMPLETE
jz .SetModeRegEmpty
or REG[UART_1_TX_FUNC_REG], bfFUNCTION_REG_TX_INT_MODE_BIT
M8C_SetBank0
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.SetModeRegEmpty:
and REG[UART_1_TX_FUNC_REG], ~bfFUNCTION_REG_TX_INT_MODE_BIT
M8C_SetBank0
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: UART_1_Start(BYTE bParity)
;
; DESCRIPTION:
; Sets the start bit and parity in the Control register of this user module.
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; BYTE bParity - parity setting for the Transmitter and receiver. Use defined masks.
; Passed in the A register.
;
; RETURNS:
; none.
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
UART_1_Start:
_UART_1_Start:
RAM_PROLOGUE RAM_USE_CLASS_1
; Note, Proxy Class 4 only if receive buffer used; otherwise Proxy Class 1.
or A, bfCONTROL_REG_START_BIT
mov REG[UART_1_TX_CONTROL_REG], A
mov REG[UART_1_RX_CONTROL_REG], A
IF ( UART_1_RXBUF_ENABLE )
call _UART_1_CmdReset
ENDIF
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: UART_1_Stop
;
; DESCRIPTION:
; Disables UART operation.
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; none.
;
; RETURNS:
; none.
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
UART_1_Stop:
_UART_1_Stop:
RAM_PROLOGUE RAM_USE_CLASS_1
and REG[UART_1_TX_CONTROL_REG], ~bfCONTROL_REG_START_BIT
and REG[UART_1_RX_CONTROL_REG], ~bfCONTROL_REG_START_BIT
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: UART_1_SendData
;
; DESCRIPTION:
; Initiates a transmission of data.
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; BYTE TxData - data to transmit. PASSED in A register.
;
; RETURNS:
; none.
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -