📄 spim.lis
字号:
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
;-----------------------------------------------
0001 bfCONTROL_REG_START_BIT: equ 1 ; Control register start bit
0000
0000
area UserModules (ROM, REL)
0000 .SECTION
0000 ;-----------------------------------------------------------------------------
0000 ; FUNCTION NAME: SPIM_EnableInt
0000 ;
0000 ; DESCRIPTION:
0000 ; Enables the SPIM interrupt by setting the interrupt enable mask
0000 ; bit associated with this User Module.
0000 ;
0000 ; NOTE: Remember to enable the global interrupt by calling the
0000 ; M8C global macro: M8C_EnableGInt
0000 ;
0000 ;-----------------------------------------------------------------------------
0000 ;
0000 ; ARGUMENTS: none
0000 ;
0000 ; RETURNS: none
0000 ;
0000 ; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
0000 ;
0000 ; THEORY of OPERATION or PROCEDURE:
0000 ; Sets the specific user module interrupt enable mask bit.
0000 ;
0000 SPIM_EnableInt:
0000 _SPIM_EnableInt:
0000 43E180 or reg[SPIM_INT_REG], SPIM_bINT_MASK ; enable specified interrupt enable bit
0003 7F ret
0004
0004 .ENDSECTION
0004
0004 .SECTION
0004 ;-----------------------------------------------------------------------------
0004 ; FUNCTION NAME: SPIM_DisableInt
0004 ;
0004 ; DESCRIPTION:
0004 ; Disables this SPIM's interrupt by clearing the interrupt enable mask bit
0004 ; associated with this User Module.
0004 ;
0004 ;-----------------------------------------------------------------------------
0004 ;
0004 ; ARGUMENTS: none
0004 ;
0004 ; RETURNS: none
0004 ;
0004 ; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
0004 ;
0004 ; THEORY of OPERATION or PROCEDURE:
0004 ; Clears the specific user module interrupt enable mask bit.
0004 ;
0004 SPIM_DisableInt:
0004 _SPIM_DisableInt:
0004 41E17F and reg[SPIM_INT_REG], ~SPIM_bINT_MASK ; disable specified interrupt enable bit
0007 7F ret
0008
0008 .ENDSECTION
0008
0008 .SECTION
0008 ;-----------------------------------------------------------------------------
0008 ; FUNCTION NAME: SPIM_Start
0008 ;
0008 ; DESCRIPTION:
0008 ; Sets the start bit, SPI mode, and LSB/MSB first configuration of the SPIM
0008 ; user module.
0008 ;
0008 ; Transmission will begin transmitting when a byte is written into the TX buffer
0008 ; using the SPIM_SendTxData function.
0008 ;
0008 ;-----------------------------------------------------------------------------
0008 ;
0008 ; ARGUMENTS:
0008 ; BYTE bConfiguration - Consists of SPI Mode and LSB/MSB first bit.
0008 ; Use defined masks - masks can be OR'd together.
0008 ; PASSED in Accumulator.
0008 ;
0008 ; RETURNS: none
0008 ;
0008 ; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
0008 ;
0008 ; THEORY of OPERATION or PROCEDURE:
0008 ; 1) Set all Slave Select outputs high
0008 ; 2) Set the specified SPI configuration bits in the Control register.
0008 ;
0008 SPIM_Start:
0008 _SPIM_Start:
0008 ; setup the SPIM configuration setting
0008 2901 or A, bfCONTROL_REG_START_BIT
000A 603F mov REG[SPIM_CONTROL_REG], A
000C 7F ret
000D
000D .ENDSECTION
000D
000D .SECTION
000D ;-----------------------------------------------------------------------------
000D ; FUNCTION NAME: SPIM_Stop
000D ;
000D ; DESCRIPTION:
000D ; Disables SPIM operation.
000D ;
000D ;-----------------------------------------------------------------------------
000D ;
000D ; ARGUMENTS: none
000D ;
000D ; RETURNS: none
000D ;
000D ; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
000D ;
000D ; THEORY of OPERATION or PROCEDURE:
000D ; Clear the start bit in the Control register.
000D ;
000D SPIM_Stop:
000D _SPIM_Stop:
000D
000D ; clear the SPIM stop bits
000D 413FFE and REG[SPIM_CONTROL_REG], ~bfCONTROL_REG_START_BIT
0010 7F ret
0011
0011 .ENDSECTION
0011
0011 .SECTION
0011 ;-----------------------------------------------------------------------------
0011 ; FUNCTION NAME: SPIM_SendTxData
0011 ;
0011 ; DESCRIPTION:
0011 ; Initiates an SPI data transfer.
0011 ;
0011 ;-----------------------------------------------------------------------------
0011 ;
0011 ; ARGUMENTS:
0011 ; BYTE bTxData - data to transmit.
0011 ; Passed in Accumulator.
0011 ;
0011 ; RETURNS: none
0011 ;
0011 ; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
0011 ;
0011 ; THEORY of OPERATION or PROCEDURE:
0011 ; Writes data to the TX buffer register.
0011 ;
0011 SPIM_SendTxData:
0011 _SPIM_SendTxData:
0011
0011 ; Transmit the data!
0011 603D mov REG[SPIM_TX_BUFFER_REG], A
0013 7F ret
0014
0014 .ENDSECTION
0014
0014 .SECTION
0014 ;-----------------------------------------------------------------------------
0014 ; FUNCTION NAME: SPIM_bReadRxData
0014 ;
0014 ; DESCRIPTION:
0014 ; Reads the RX buffer register. Should check the status regiser to make
0014 ; sure data is valid.
0014 ;
0014 ;-----------------------------------------------------------------------------
0014 ;
0014 ; ARGUMENTS: none
0014 ;
0014 ; RETURNS:
0014 ; bRxData - returned in A.
0014 ;
0014 ; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
0014 ;
0014 ; THEORY of OPERATION or PROCEDURE:
0014 ;
0014 SPIM_bReadRxData:
0014 _SPIM_bReadRxData:
0014 bSPIM_ReadRxData:
0014 _bSPIM_ReadRxData:
0014 5D3E mov A, REG[SPIM_RX_BUFFER_REG]
0016 7F ret
0017
0017
0017 .ENDSECTION
0017
0017 .SECTION
0017 ;-----------------------------------------------------------------------------
0017 ; FUNCTION NAME: SPIM_ReadStatus
0017 ;
0017 ; DESCRIPTION:
0017 ; Reads the SPIM Status bits in the Control/Status register.
0017 ;
0017 ;-----------------------------------------------------------------------------
0017 ;
0017 ; ARGUMENTS: none
0017 ;
0017 ; RETURNS:
0017 ; BYTE bStatus - transmit status data. Use the defined bit masks.
0017 ; Returned in Accumulator.
0017 ;
0017 ; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
0017 ;
0017 ; THEORY of OPERATION or PROCEDURE:
0017 ; Read the status and control register.
0017 ;
0017 SPIM_bReadStatus:
0017 _SPIM_bReadStatus:
0017 bSPIM_ReadStatus:
0017 _bSPIM_ReadStatus:
0017 5D3F mov A, REG[SPIM_CONTROL_REG]
0019 7F ret
001A
001A .ENDSECTION
001A
001A ; End of File SPIM.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -