📄 spim_radio.asm
字号:
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: SPIM_Radio.asm
;; Version: 2.5, Updated on 2006/05/18 at 10:27:31
;; Generated by PSoC Designer ver 4.4 b1884 : 14 Jan, 2007
;;
;; DESCRIPTION: SPIM User Module software implementation file
;; for CY8C26xxx and related 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 2000-2003. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "memory.inc"
include "SPIM_Radio.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export SPIM_Radio_EnableInt
export _SPIM_Radio_EnableInt
export SPIM_Radio_DisableInt
export _SPIM_Radio_DisableInt
export SPIM_Radio_Start
export _SPIM_Radio_Start
export SPIM_Radio_Stop
export _SPIM_Radio_Stop
export SPIM_Radio_SendTxData
export _SPIM_Radio_SendTxData
export SPIM_Radio_bReadRxData
export _SPIM_Radio_bReadRxData
export SPIM_Radio_bReadStatus
export _SPIM_Radio_bReadStatus
// These globals will be removed in a future release
// Do not use
export bSPIM_Radio_ReadRxData
export _bSPIM_Radio_ReadRxData
export bSPIM_Radio_ReadStatus
export _bSPIM_Radio_ReadStatus
;-----------------------------------------------
; Constant Definitions
;-----------------------------------------------
bfCONTROL_REG_START_BIT: equ 1 ; Control register start bit
area UserModules (ROM, REL)
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_Radio_EnableInt
;
; DESCRIPTION:
; Enables the SPIM interrupt by setting the interrupt enable mask
; bit associated with this User Module.
;
; NOTE: Remember to enable the global interrupt by calling the
; M8C global 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.
;
; THEORY of OPERATION or PROCEDURE:
; Sets the specific user module interrupt enable mask bit.
;
SPIM_Radio_EnableInt:
_SPIM_Radio_EnableInt:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_EnableIntMask SPIM_Radio_INT_REG, SPIM_Radio_bINT_MASK
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_Radio_DisableInt
;
; DESCRIPTION:
; Disables this SPIM'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.
;
; THEORY of OPERATION or PROCEDURE:
; Clears the specific user module interrupt enable mask bit.
;
SPIM_Radio_DisableInt:
_SPIM_Radio_DisableInt:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_DisableIntMask SPIM_Radio_INT_REG, SPIM_Radio_bINT_MASK
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_Radio_Start
;
; DESCRIPTION:
; Sets the start bit, SPI mode, and LSB/MSB first configuration of the SPIM
; user module.
;
; Transmission will begin transmitting when a byte is written into the TX buffer
; using the SPIM_Radio_SendTxData function.
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; BYTE bConfiguration - Consists of SPI Mode and LSB/MSB first bit.
; Use defined masks - masks can be OR'd together.
; PASSED in Accumulator.
;
; 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:
; 1) Set all Slave Select outputs high
; 2) Set the specified SPI configuration bits in the Control register.
;
SPIM_Radio_Start:
_SPIM_Radio_Start:
RAM_PROLOGUE RAM_USE_CLASS_1
; setup the SPIM configuration setting
or A, bfCONTROL_REG_START_BIT
mov REG[SPIM_Radio_CONTROL_REG], A
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_Radio_Stop
;
; DESCRIPTION:
; Disables SPIM 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.
;
; THEORY of OPERATION or PROCEDURE:
; Clear the start bit in the Control register.
;
SPIM_Radio_Stop:
_SPIM_Radio_Stop:
RAM_PROLOGUE RAM_USE_CLASS_1
; clear the SPIM stop bits
and REG[SPIM_Radio_CONTROL_REG], ~bfCONTROL_REG_START_BIT
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_Radio_SendTxData
;
; DESCRIPTION:
; Initiates an SPI data transfer.
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; BYTE bTxData - data to transmit.
; Passed in Accumulator.
;
; 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:
; Writes data to the TX buffer register.
;
SPIM_Radio_SendTxData:
_SPIM_Radio_SendTxData:
RAM_PROLOGUE RAM_USE_CLASS_1
; Transmit the data!
mov REG[SPIM_Radio_TX_BUFFER_REG], A
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_Radio_bReadRxData
;
; DESCRIPTION:
; Reads the RX buffer register. Should check the status regiser to make
; sure data is valid.
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS: none
;
; RETURNS:
; bRxData - returned in A.
;
; 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:
;
SPIM_Radio_bReadRxData:
_SPIM_Radio_bReadRxData:
bSPIM_Radio_ReadRxData:
_bSPIM_Radio_ReadRxData:
RAM_PROLOGUE RAM_USE_CLASS_1
mov A, REG[SPIM_Radio_RX_BUFFER_REG]
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_Radio_ReadStatus
;
; DESCRIPTION:
; Reads the SPIM Status bits in the Control/Status register.
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS: none
;
; RETURNS:
; BYTE bStatus - transmit status data. Use the defined bit masks.
; Returned in Accumulator.
;
; 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:
; Read the status and control register.
;
SPIM_Radio_bReadStatus:
_SPIM_Radio_bReadStatus:
bSPIM_Radio_ReadStatus:
_bSPIM_Radio_ReadStatus:
RAM_PROLOGUE RAM_USE_CLASS_1
mov A, REG[SPIM_Radio_CONTROL_REG]
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
; End of File SPIM_Radio.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -