📄 dmx512rx.asm
字号:
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: `@INSTANCE_NAME`.asm
;; Version: 1.0, Updated on 2007/05/29 at 14:57:46
;; `@PSOC_VERSION`
;;
;; DESCRIPTION: DMX512Rx User Module software implementation file for
;; CY8CLED04/08/16 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 preserve 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 Semiconductor 2007. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
;-----------------------------------------------
; include instance specific register definitions
;-----------------------------------------------
include "m8c.inc"
include "memory.inc"
include "`@INSTANCE_NAME`.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export `@INSTANCE_NAME`_EnableInt
export _`@INSTANCE_NAME`_EnableInt
export `@INSTANCE_NAME`_DisableInt
export _`@INSTANCE_NAME`_DisableInt
export `@INSTANCE_NAME`_Start
export _`@INSTANCE_NAME`_Start
export `@INSTANCE_NAME`_Stop
export _`@INSTANCE_NAME`_Stop
export `@INSTANCE_NAME`_SetRamBuffer
export _`@INSTANCE_NAME`_SetRamBuffer
export `@INSTANCE_NAME`_SetStartSlotID
export _`@INSTANCE_NAME`_SetStartSlotID
export `@INSTANCE_NAME`_bGetBusActivity
export _`@INSTANCE_NAME`_bGetBusActivity
export `@INSTANCE_NAME`_bGetSlotActivity
export _`@INSTANCE_NAME`_bGetSlotActivity
AREA `@INSTANCE_NAME`_RAM(RAM,REL,CON)
area UserModules (ROM, REL)
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: `@INSTANCE_NAME`_Start(BYTE bParity)
; DESCRIPTION: Starts the DMX512Rx 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 preserve their values across calls to fastcall16
; functions.
;
`@INSTANCE_NAME`_Start:
_`@INSTANCE_NAME`_Start:
RAM_PROLOGUE RAM_USE_CLASS_4
RAM_SETPAGE_CUR >`@INSTANCE_NAME`_bBusActivity
mov [`@INSTANCE_NAME`_bBusActivity], 0x00
mov [`@INSTANCE_NAME`_bSlotActivity], 0x00
mov [`@INSTANCE_NAME`_StartSlotID + 0], (`@INSTANCE_NAME`_DEF_START_SLOT_ID & 0xFF00) >> 8
mov [`@INSTANCE_NAME`_StartSlotID + 1], (`@INSTANCE_NAME`_DEF_START_SLOT_ID & 0x00FF)
mov reg[`@INSTANCE_NAME`_RX_CONTROL_REG], 0x00
mov reg[`@INSTANCE_NAME`_PWD_CONTROL_REG], 0x01
RAM_EPILOGUE RAM_USE_CLASS_4
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: `@INSTANCE_NAME`_Stop
; DESCRIPTION: Disables DMX512Rx 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 preserve their values across calls to fastcall16
; functions.
;
`@INSTANCE_NAME`_Stop:
_`@INSTANCE_NAME`_Stop:
RAM_PROLOGUE RAM_USE_CLASS_1
mov reg[`@INSTANCE_NAME`_RX_CONTROL_REG], 0x00
mov reg[`@INSTANCE_NAME`_PWD_CONTROL_REG], 0x00
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: `@INSTANCE_NAME`_EnableInt
; DESCRIPTION: Enables this receiver's interrupts by setting the interrupt
; enable mask bits 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 preserve their values across calls to fastcall16
; functions.
;
`@INSTANCE_NAME`_EnableInt:
_`@INSTANCE_NAME`_EnableInt:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_EnableIntMask `@INSTANCE_NAME`_RX_ISR_REG, `@INSTANCE_NAME`_RX_ISR_MASK
M8C_EnableIntMask `@INSTANCE_NAME`_PWD_ISR_REG, `@INSTANCE_NAME`_PWD_ISR_MASK
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: `@INSTANCE_NAME`_DisableInt
; DESCRIPTION: Disables this User Module interrupts by clearing the interrupt
; enable mask bits 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 preserve their values across calls to fastcall16
; functions.
;
`@INSTANCE_NAME`_DisableInt:
_`@INSTANCE_NAME`_DisableInt:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_DisableIntMask `@INSTANCE_NAME`_RX_ISR_REG, `@INSTANCE_NAME`_RX_ISR_MASK
M8C_DisableIntMask `@INSTANCE_NAME`_PWD_ISR_REG, `@INSTANCE_NAME`_PWD_ISR_MASK
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: `@INSTANCE_NAME`_SetRamBuffer
; DESCRIPTION: Sets address & size for user-supplied buffer;
;-----------------------------------------------------------------------------
; ARGUMENTS:
; [SP-3] - Buffer size
; [SP-4] - Buffer adress (LSB)
; [SP-5] - Buffer adress (MSB)
; 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.
;
`@INSTANCE_NAME`_SetRamBuffer:
_`@INSTANCE_NAME`_SetRamBuffer:
RAM_PROLOGUE RAM_USE_CLASS_4
RAM_PROLOGUE RAM_USE_CLASS_2
RAM_SETPAGE_CUR >`@INSTANCE_NAME`_NumOfSlots
mov X,SP
mov A, [X-3]
mov [`@INSTANCE_NAME`_NumOfSlots], A
mov A, [X-4]
mov [`@INSTANCE_NAME`_pUserBuffer + 1], A
mov A, [X-5]
mov [`@INSTANCE_NAME`_pUserBuffer + 0], A
RAM_EPILOGUE RAM_USE_CLASS_2
RAM_EPILOGUE RAM_USE_CLASS_4
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: `@INSTANCE_NAME`_SetSrartSlotID
; DESCRIPTION: Sets starting slot number for DMX512Rx User Module
;-----------------------------------------------------------------------------
; ARGUMENTS: WORD SlotID in X(MSB) and A(LSB) registers
; 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.
;
`@INSTANCE_NAME`_SetStartSlotID:
_`@INSTANCE_NAME`_SetStartSlotID:
RAM_PROLOGUE RAM_USE_CLASS_4
RAM_SETPAGE_CUR >`@INSTANCE_NAME`_StartSlotID
mov [`@INSTANCE_NAME`_StartSlotID + 0], X
mov [`@INSTANCE_NAME`_StartSlotID + 1], A
RAM_EPILOGUE RAM_USE_CLASS_4
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: `@INSTANCE_NAME`_GetActivity
; DESCRIPTION:
; Return a non-zero value if the DMX512Rx hardware has seen activity on the bus.
; The activity flag will be cleared when calling this function.
;-----------------------------------------------------------------------------
; ARGUMENTS: none
; RETURNS:
; BYTE non-zero = Activity, zero = No Activity
;
; 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 preserve their values across calls to fastcall16
; functions.
;
`@INSTANCE_NAME`_bGetBusActivity:
_`@INSTANCE_NAME`_bGetBusActivity:
RAM_PROLOGUE RAM_USE_CLASS_4
RAM_SETPAGE_CUR >`@INSTANCE_NAME`_bBusActivity
mov A, 0
swap A, [`@INSTANCE_NAME`_bBusActivity]
RAM_EPILOGUE RAM_USE_CLASS_4
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: `@INSTANCE_NAME`_GetSlotActivity
; DESCRIPTION: Return a non-zero value if new data is available in buffer.
; The activity flag will be cleared when calling this function.
;-----------------------------------------------------------------------------
; ARGUMENTS: none
; RETURNS:
; BYTE non-zero = Activity, zero = No Activity
;
; 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 preserve their values across calls to fastcall16
; functions.
;
`@INSTANCE_NAME`_bGetSlotActivity:
_`@INSTANCE_NAME`_bGetSlotActivity:
RAM_PROLOGUE RAM_USE_CLASS_4
RAM_SETPAGE_CUR >`@INSTANCE_NAME`_bSlotActivity
mov A, 0
swap A, [`@INSTANCE_NAME`_bSlotActivity]
RAM_EPILOGUE RAM_USE_CLASS_4
ret
.ENDSECTION
; End of File `@INSTANCE_NAME`.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -