import time
from machine import Pin, mem32

def set_bit(offset, bit):
    mask = 1 << bit
    mem32[GPIO_ADDRESS + offset] |= mask      
    # A |= B   is  A = A | B   

def reset_bit(offset, bit):
    mask = 1 << bit
    mem32[GPIO_ADDRESS + offset] &= ~mask

# objects to describe all LEDs
leds = [
    Pin(0, Pin.OUT),
    Pin(1, Pin.OUT),
    Pin(2, Pin.OUT),
    Pin(3, Pin.OUT),
    Pin(4, Pin.OUT),
    Pin(5, Pin.OUT),
    Pin(6, Pin.OUT),
    Pin(7, Pin.OUT),
]
# https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
# address of memory mapped registers
GPIO_ADDRESS = 0xd0000000
# GPIO_OUTPUT have offset 0x010 (p. 42 of reference manual) 
# mem32[GPIO_ADDRESS + 0x010] = 0b11110111

# set_bit(0x010, 3)
# reset_bit(0x010, 3)
# use GPIO_OUT_CLR, offset 0x018
# set_bit(0x018, 3)

def cicrcular_shift(number, shift):
     return number << shift | number >> (8 - shift)

a = 0b00000101

while True:
    a = cicrcular_shift(a, 1)
    mem32[GPIO_ADDRESS + 0x010] = a
    time.sleep(1)
    
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT