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

📄 led3428.asm

📁 Led控制,这是一个不错的东东,希望对这方面的朋友有帮助
💻 ASM
字号:
;
;LED program for DES3428
;
;LED sequence:
;      
;LED for manager 
;Bit NO.	 0						    1	              2	                  3	           
;Function	 2G/7_SEG_LED	    2F/7_SEG_LED	  2E/7_SEG_LED	      2D/7_SEG_LED
;Bit NO.	 4						    5	              6	                  7 	           
;Function	 2C/7_SEG_LED	    2B/7_SEG_LED	  2A/7_SEG_LED	      1A/1B/7_SEG_LED
;LED for XE
;Bit NO.	 8						    9	              10	                11	           
;Function	 LNK/ACT1000_5	  LNK/ACT100_5	  LNK/ACT1000_4	    	LNK/ACT100_4
;LED for SFP
;Bit NO.	 12						    13	            14	                15	           
;Function	 LNK/ACT1000_2	  LNK/ACT100_2	  LNK/ACT1000_1	    	LNK/ACT100_1
;LED for FE
;Bit NO.	 16						    17	            18	                19	           
;Function	 LNK/ACT100_29	  LNK/ACT10_29	  LNK/ACT100_28	    	LNK/ACT10_28
;...
;Bit NO.	 60						    61	            62	              	63	           
;Function	 LNK/ACT100_7	  	LNK/ACT10_7	  	LNK/ACT100_6	    	LNK/ACT10_6

;                                           
LED_FE_END         equ     36                
LED_COPPER_END	   equ     10   ;            
LED_SFP_END        equ     12          
LED_MANAGE_END     equ     8        
;LED_XFP_END        equ     44      
LED_TOTAL_NUMBERS  equ     36      
LED_TOTAL_BITS     equ     64  


;Host fill this according DES33428_LED_PORTMAP
;DES3428_LED_PORTMAP[LED_TOTAL_BITS] = {
;  0,1,2,3,4,5,6,7,
;  5,4,2,1,29,28,
;  27,26,25,24,
;  23,22,21,20,
;  19,18,17,16,
;  15,14,13,12,
;  11,10,9 ,8 ,7 ,6
;}; 
;DGS3627G_LED_PORTMAP[LED_TOTAL_BITS] = {
;  23,22,21,20,23,22,21,20,23,22,21,20,
;  19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,
;  0,1,2,3,4,5,6,7,8,
;  26,25,24,};
LED_PORTMAP        equ     0xC0 

;Host update LED_LINK according link state
;bit0: 0=linkdown, 1=linkup; bit1:10/100M; bit2:1000M; bit3: 0=copper, 1=fiber
;bit4:XFP link; bit5:7 segment manage.
;one byte per port, total 27 bytes
LED_LINK           equ     0xe0

;local runtime database. one byte per port
LED_TIMER          equ     0xF0

;local global variables in this module
counter            equ     0xF8 
link_status        equ     0xFA    
phyport            equ     0xFB

; Symbolic names for the bits of the port status fields
;
RX                 equ     0x0     ; received packet
TX                 equ     0x1     ; transmitted packet
COLL               equ     0x2     ; collision indicator
SPEED_C            equ     0x3     ; 100 Mbps
SPEED_M            equ     0x4     ; 1000 Mbps
DUPLEX             equ     0x5     ; half/full duplex
FLOW               equ     0x6     ; flow control capable
LINKUP             equ     0x7     ; link down/up status
LINKEN             equ     0x8     ; link disabled/enabled status
ZERO               equ     0xE     ; always 0
ONE                equ     0xF     ; always 1

begin:
    ;initialize
    ld      A, 0
    ld      (counter), A   
ledloop:
    ;Assign the first port
    ld      B, 0
    ld      (link_status), B  
    add     A, LED_PORTMAP ; A= LED_PORTMAP + counter
    ld      A, (A)         ; port = LED_PORTMAP[counter]
    port    A 
    ld      (phyport), A
    add     A, LED_LINK	  ; A = LED_LINK[phyport]
    call    Led_Link_Status
    inc     (counter)
    ld      A, (counter)
    cmp     A, LED_TOTAL_NUMBERS
    jnz     ledloop

sendto:
    send LED_TOTAL_BITS

Led_Link_Status:
    ld      B,(counter)
    ld     (link_status), (A)
;COPPER:
;    cmp     B, LED_COPPER_END  ; if (counter >= LED_GE_PORT_END) jmp SFP
;    jnc     SFP 
;    tst     (A), 3            ; if(copper port and sfp=1) led of copper turn off
;    jc      LED_OFF_ONEBIT
COPPER_FE:
	cmp     B, LED_FE_END
;	jnc     COPPER_GE   
	jnc     SFP
	tst     (A), 1
	jc      CHECK_LINK
	jmp     LED_OFF_ONEBIT
COPPER_GE:
	tst    (A), 2
	jc     CHECK_LINK
	jmp    LED_OFF_ONEBIT
SFP:
    cmp     B, LED_SFP_END    ; if (counter >= LED_SFP_END) jmp MANAGE
    jnc     MANAGE
    tst     (A), 3
    jc      CHECK_LINK
    jmp     LED_OFF_TWOBIT
MANAGE:
    cmp     B,LED_MANAGE_END   ; if(counter >= LED_MANAGE_END) jmp XFP
;    jnc     XFP
    jnc     LED_END
    tst     (A),5
    jc      LED_ON_ONEBIT
    jmp     LED_OFF_ONEBIT
;XFP:    
;    cmp     B,LED_XFP_END
;    jnc     LED_END         ; if (counter >= LED_XFP_END) jmp LED_END
;    tst     (A), 4	    ; check xfp
;    jc      CHECK_LINK
;    jmp	    LED_OFF_ONEBIT
LED_END:
    ret

CHECK_LINK:
    tst    (A), 0
    jnc    LINK_DOWN
TRAFFIC:
    pushst  RX
    pushst  TX
    tor
    pop     
    jc      LINK_BLINK
    ld      A,(counter)
    add     A, LED_TIMER
    ld	    (A), 0    ;reset led timer
LINK_UP:
    ld      B, (link_status)
    tst     B, 3
    jc      LED_ON_GREEN   ;sfp link up
    jmp     LED_ON_ONEBIT
    
LINK_BLINK:
    ld      A, (counter)
    add     A, LED_TIMER
    inc     (A)
    ld      B,(A)
    cmp     B,2
    jc      LINK_DOWN
    cmp     B,3
    jc      LINK_UP
    ld      (A),0
    jmp     LINK_BLINK   

LINK_DOWN:
	ld      B, (link_status)
    tst     B, 3
    jnc     LED_OFF_ONEBIT
LED_OFF_TWOBIT:
    pushst    ONE
    pack
LED_OFF_ONEBIT:
    pushst    ONE
    pack
    ret 

LED_ON_ONEBIT:
    pushst    ZERO
    pack
    ret
    
LED_ON_GREEN:
    pushst    ONE
    pack
    pushst    ZERO
    pack
    ret
 

   
  
    
    

⌨️ 快捷键说明

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