ex4.asm (3474B)
1 ; 2 ; 3 ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 ; 5 ; Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 ; 7 ; 8 ;Here is an example program for programming the LEDs on the 5605. 9 ; 10 ;The situation is this: 11 ; 12 ; 26 ports (port 0-25) each have three LEDs. 13 ; led 0: RX 14 ; led 1: TX 15 ; led 2: speed 16 ; black if disabled 17 ; blinking amber if 10 Mbps but link down or disabled 18 ; solid on amber if 10 Mbps and link up 19 ; blinking green if 100 Mbps but link down or disabled 20 ; solid on green if 100 Mbps and link up 21 ; [ ports 24 and 25 are the gig ports and are slightly 22 ; different; they are green for 1G, and amber for 23 ; anything less, either 10Mbps or 100Mbps ]. 24 ; 25 ; Bicolor LEDs are really two LEDs with two inputs: with one LED 26 ; of the pair driven, the LED is green; with the other one driven, 27 ; the LED is red, with both driven, it is amber (yellow). 28 ; 29 ; The scan out order is RX, TX, inp1, inp2 for port 0, then 30 ; the same for port 1, and so on through port 25. Note that 31 ; ports 24 and 25 need slightly different handling than the 32 ; other ports. 33 ; 34 ; 35 ;-------------------------- start of program -------------------------- 36 37 begin: 38 ; update refresh phase within 1 Hz 39 ld A, phase 40 inc A ; next phase 41 cmp A, 30 ; see if 1 sec has gone by 42 jc chkblink 43 sub A, A ; A = 0 44 45 chkblink: 46 ld (phase),A 47 sub B, B ; B = 0 48 cmp A, 15 ; A already has the phase 49 jnc noblink 50 inc B ; B = 1 51 noblink: 52 ld (blink),B 53 54 sub A,A ; start with port 0 55 ld (portnum),A 56 57 portloop: 58 port A ; specify which port we're dealing with 59 60 pushst RX ; first put out RX status 61 pack ; send to output buffer 62 63 pushst TX ; next put out RX status 64 pack ; send to output buffer 65 66 ; here's the tricky part. to encode bicolor LED speed status, 67 ; we do the following: 68 ; inp1 inp2 69 ; 0 0 = off 70 ; 1 0 = green = full speed 71 ; 1 1 = amber = less than full speed 72 ; 0 1 = red = not used 73 74 pushst LINKEN ; link enabled 75 76 push (blink) 77 tand ; turn off LED if blinking 78 pop ; cy = LINKEN & blink 79 push cy ; put it back 80 pack ; inp1 81 82 push cy ; tos = LINKEN & blink 83 ld A,(portnum) 84 cmp A,24 85 jnc dogigs 86 pushst SPEED_C ; test for 100Mbps speed 87 jmp wrapup 88 ; ports 24 and 25 are the gigabit ports 89 dogigs: 90 pushst SPEED_M ; test for 1000Mbps speed 91 92 wrapup: 93 tinv ; make it a test for not full speed 94 tand ; combine with LINKEN & blink 95 pack ; inp2 96 97 inc (portnum) 98 ld A,(portnum) 99 cmp A,26 100 jnz portloop 101 102 send 104 ; send 26*4 LED pulses and halt 103 104 105 ; data storage 106 blink equ 0x7D ; 1 if blink on, 0 if blink off 107 108 phase equ 0x7E ; phase within 30 Hz 109 ; should be initialized to 0 on reset 110 111 portnum equ 0x7F ; temp to hold which port we're working on 112 113 114 ; symbolic labels 115 ; this gives symbolic names to the various bits of the port status fields 116 117 RX equ 0x0 ; received packet 118 TX equ 0x1 ; transmitted packet 119 COLL equ 0x2 ; collision indicator 120 SPEED_C equ 0x3 ; 100 Mbps 121 SPEED_M equ 0x4 ; 1000 Mbps 122 DUPLEX equ 0x5 ; half/full duplex 123 FLOW equ 0x6 ; flow control capable 124 LINKUP equ 0x7 ; link down/up status 125 LINKEN equ 0x8 ; link disabled/enabled status 126 ZERO equ 0xE ; always 0 127 ONE equ 0xF ; always 1 128 129 ;-------------------------- end of program -------------------------- 130 ; 131 ;This program is 62 bytes in length, but it is fairly complicatd. 132