📄 spim.asm
字号:
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: SPIM.asm
;; Version: 2.2, Updated on 2003/11/24 at 14:06:41
;; Generated by PSoC Designer ver 4.1 BETA b923 : 11 December, 2003
;;
;; DESCRIPTION: SPIM User Module software implementation file
;; for CY8C26xxx and related devices.
;;
;; NOTE: User Module APIs conform to the fastcall 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
;; function returns. Even though these registers may be preserved now,
;; there is no guarantee they will be preserved in future releases.
;;-----------------------------------------------------------------------------
;; Copyright (c) Cypress MicroSystems 2000-2003. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "SPIM.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export SPIM_EnableInt
export _SPIM_EnableInt
export SPIM_DisableInt
export _SPIM_DisableInt
export SPIM_Start
export _SPIM_Start
export SPIM_Stop
export _SPIM_Stop
export SPIM_SendTxData
export _SPIM_SendTxData
export SPIM_bReadRxData
export _SPIM_bReadRxData
export SPIM_bReadStatus
export _SPIM_bReadStatus
// These globals will be removed in a future release
// Do not use
export bSPIM_ReadRxData
export _bSPIM_ReadRxData
export bSPIM_ReadStatus
export _bSPIM_ReadStatus
;-----------------------------------------------
; Constant Definitions
;-----------------------------------------------
bfCONTROL_REG_START_BIT: equ 1 ; Control register start bit
area UserModules (ROM, REL)
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_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: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
; Sets the specific user module interrupt enable mask bit.
;
SPIM_EnableInt:
_SPIM_EnableInt:
M8C_EnableIntMask SPIM_INT_REG, SPIM_bINT_MASK
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_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: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
; Clears the specific user module interrupt enable mask bit.
;
SPIM_DisableInt:
_SPIM_DisableInt:
M8C_DisableIntMask SPIM_INT_REG, SPIM_bINT_MASK
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_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_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: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
; 1) Set all Slave Select outputs high
; 2) Set the specified SPI configuration bits in the Control register.
;
SPIM_Start:
_SPIM_Start:
; setup the SPIM configuration setting
or A, bfCONTROL_REG_START_BIT
mov REG[SPIM_CONTROL_REG], A
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_Stop
;
; DESCRIPTION:
; Disables SPIM operation.
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS: none
;
; RETURNS: none
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
; Clear the start bit in the Control register.
;
SPIM_Stop:
_SPIM_Stop:
; clear the SPIM stop bits
and REG[SPIM_CONTROL_REG], ~bfCONTROL_REG_START_BIT
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_SendTxData
;
; DESCRIPTION:
; Initiates an SPI data transfer.
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; BYTE bTxData - data to transmit.
; Passed in Accumulator.
;
; RETURNS: none
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
; Writes data to the TX buffer register.
;
SPIM_SendTxData:
_SPIM_SendTxData:
; Transmit the data!
mov REG[SPIM_TX_BUFFER_REG], A
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_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: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
SPIM_bReadRxData:
_SPIM_bReadRxData:
bSPIM_ReadRxData:
_bSPIM_ReadRxData:
mov A, REG[SPIM_RX_BUFFER_REG]
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SPIM_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: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
; Read the status and control register.
;
SPIM_bReadStatus:
_SPIM_bReadStatus:
bSPIM_ReadStatus:
_bSPIM_ReadStatus:
mov A, REG[SPIM_CONTROL_REG]
ret
.ENDSECTION
; End of File SPIM.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -