⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 h2io.a51

📁 Vitesse 24port gigabit Switch Source Code
💻 A51
字号:
;*
;*
;*    Copyright (c) 2003-2005 Vitesse Semiconductor Corporation "Vitesse".  
;*    All Rights Reserved.  Unpublished rights reserved under the copyright laws
;*    of the United States of America, other countries and international treaties.
;*    The software is provided without a fee. Permission to use, copy, store and 
;*    modify, the software and its source code is granted. Permission to integrate
;*    into other products, disclose, transmit and distribute the software in an
;*    absolute machine readable format (e.g. HEX file) is also granted. 
;*
;*    The source code of the software may not be disclosed, transmitted or
;*    distributed without the written permission of Vitesse. The software and its
;*    source code may only be used in products utilizing a Vitesse VSC73xx product.
;* 
;*    This copyright notice must appear in any copy, modification, disclosure,
;*    transmission or distribution of the software. Vitesse retains all ownership,
;*    copyright, trade secret and proprietary rights in the software.  
;*
;*    THIS SOFTWARE HAS BEEN PROVIDED "AS IS," WITHOUT EXPRESS OR IMPLIED WARRANTY
;*    INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES OF MERCHANTABILITY,
;*    FITNESS FOR A PARTICULAR USE AND NON-INFRINGEMENT.
;*
;*
$NOMOD51
$INCLUDE (REG52.INC)
$INCLUDE (hwconf.inc)
NAME    H2IO

$IF (USE_PI = 1)
EXTRN  CODE (_pi_write, _pi_read)
$ELSE
$IF (USE_SI = 1)
EXTRN  CODE (_spi_write, _spi_read)
$ENDIF
$ENDIF

PUBLIC  _h2_read, _h2_write_, _h2_write_addr

H2IO_DATA       SEGMENT DATA
                RSEG    H2IO_DATA
;* For temporary storage of register address in conjunction with writes.
write_block:            DS      1
write_reg:              DS      1

PROG    SEGMENT CODE

        RSEG    PROG

;* ************************************************************************ */
; ulong h2_read (uchar block, uchar subblock, uchar addr) small;
_h2_read:
;* ------------------------------------------------------------------------ --
;* Purpose     : Read a register from the switch chip.
;* Remarks     : 
;* Restrictions:
;* See also    :
;* Example     :
; * ************************************************************************ */

        ;* Handle mapping of port into expansion port block, if
        ;* port number is larger than 15.
        cjne    r7, #LPORT_BLK_ID_MASK, L1_0    ; Check if port block
        mov     a, r5                           ; Get subblock
        jnb     acc.4, L1_0                     ; Check if subblock >= 16
        clr     acc.4                           ; If so, adjust subblock
        mov     r5, a                           ; 
        mov     r7, #HPORT_BLK_ID_MASK          ; and change block id
L1_0:

$IF (USE_SFR = 1)
        mov     a, r7
        add     a, r5
        mov     RA_BLK, a
        mov     RA_AD_RD, r3

rd_wait:jnb     RA_DONE, rd_wait
        setb    RA_DONE

        mov     r4, RA_DA3
        mov     r5, RA_DA2
        mov     r6, RA_DA1
        mov     r7, RA_DA0
        ret
$ENDIF
$IF (USE_PI = 1)
        ;* Build address "pointer" in r2 (block + subblock) 
        ;* and r1 (register address)
        mov     a, r7           ; Get block id (bit 7-5).
        add     a, r5           ; Add subblock number
        mov     r2, a           ; Pass in r2
        mov     a, r3           ; Get address within subblock
        mov     r1, a           ; Pass address in r1
        lcall   _pi_read
        ret
$ENDIF
$IF (USE_SI = 1)
        lcall   _spi_read
        ret
$ENDIF

;* ************************************************************************ */
; void h2_write_addr (uchar block, uchar subblock, uchar addr) small;
_h2_write_addr:
;* ------------------------------------------------------------------------ --
;* Purpose     : Save register address for writing. To be followed by call
;*               to _h2_write_ in order to complete the writing.
;* Remarks     : Writing to a register has been split in two functions in
;*               order to exploit the Keil c-compilers way of utilizing
;*               registers for parameters.
;* Restrictions: Use macro h2_write (in h2io.h) for access from c-modules.
;* See also    : _h2_write_
;* Example     :
; * ************************************************************************ */

        ;* Handle mapping of port into expansion port block, if
        ;* port number is larger than 15.
        cjne    r7, #LPORT_BLK_ID_MASK, L3_0    ; Check if port block
        mov     a, r5                           ; Get subblock
        jnb     acc.4, L3_0                     ; Check if subblock >= 16
        clr     acc.4                           ; If so, adjust subblock
        mov     r5, a                           ; 
        mov     r7, #HPORT_BLK_ID_MASK          ; and change block id
L3_0:
        ;* Save register address for coming call to h2_write
        mov     a, r7                           ; Get block
        add     a, r5                           ; Add subblock
        mov     write_block, a
        mov     write_reg, r3
        ret

;* ************************************************************************ */
; void h2_write_ (ulong value);
_h2_write_:
;* ------------------------------------------------------------------------ --
;* Purpose     : Completes a writing.
;* Remarks     : 
;* Restrictions: _h2_write_addr must have been called before calling _h2_write_.
;*               Use macro h2_write (in h2io.h) for access from c-modules.
;* See also    : _h2_write_addr
;* Example     :
; * ************************************************************************ */

$if (USE_SFR = 1)

        mov     RA_DA3, r4
        mov     RA_DA2, r5
        mov     RA_DA1, r6
        mov     RA_DA0, r7

        mov     a, write_block
        mov     RA_BLK, a
        mov     a, write_reg
        mov     RA_AD_WR, a

wr_wait:jnb     RA_DONE, wr_wait
        setb    RA_DONE

        ret
$ENDIF
$IF (USE_PI = 1)
        mov     r2, write_block
        mov     r1, write_reg
	
        lcall   _pi_write
        ret
$ENDIF
$IF (USE_SI = 1)
        mov     r2, write_block
        mov     r1, write_reg

        lcall   _spi_write
        ret
$ENDIF

        END


















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -