from rp2 import *
from machine import *
import uarray
l = Pin(0, Pin.OUT)
regdata = uarray.array('i',[
0xd0000000 + 0x010, # 0 SIO OUT
0xd0000000 + 0x018, # 4 SIO OUT_CLR
0xd0000000 + 0x014, # 8 SIO OUT_SET
1 << 0 # 12 GP0
])
@micropython.asm_thumb
def led_off(r0):
mov(r1,r0) # store argument (16B array) to r1
ldr(r2,[r1,4]) # load OUT_CLR address
ldr(r0,[r1,12]) # mask data to store on OUT_CLR address
str(r0,[r2,0]) # store 0x00000001 on [OUT_CLR]
@micropython.asm_thumb
def led_on(r0):
mov(r1,r0) # store argument (16B array) to r1
ldr(r2,[r1,8]) # load OUT_SET address from array
ldr(r0,[r1,12]) # mask data to store on OUT_SET address
str(r0,[r2,0]) # store 0x00000001 on [OUT_SET]
@micropython.asm_thumb
def asm_delay(r0):
mov(r4, r0) # move argument (number of iterations) to r4
label(delay_off) # define delay as a part of the loop
sub(r4, r4, 1) # substract 1 from content of r4 (decrement)
cmp(r4, 0) # compare r4 with 0
bgt(delay_off) # if r4 is bigger than 0, jump back to label
while True:
led_on(regdata)
asm_delay(5599900)
led_off(regdata)
asm_delay(5599900)