@ lab5.S
@ 25 March 12:03 UTC lab5-g.kn5-
@ mynewparent https://wokwi.com/projects/360235948443318273 JUST MINTED 04:58z 26 March
@ esparent https://wokwi.com/projects/360233659888406529 PREV MINTED 04:22z 26 March
@ esparent https://wokwi.com/projects/360233198355573761
@ older esparent https://wokwi.com/projects/360170482994854913
@ THIS NEW ONE IS https://wokwi.com/projects/360233198355573761
@ saw 3569 was last four on screen when it got created 26 Mar 04:16z g.kn4-
@ here it is was only in bookmarks:
@ https://wokwi.com/projects/360172129597933569
@ and that one claims it is from:
@ 4854913 just as this one did (now renamed as an esparent). ;)
@ roger that.
.syntax unified @ unified assembly syntax
.cpu cortex-m0plus @ CPU type is Cortex M0+
.thumb @ thumb assembly for RP2040
.global main_asm @ Provide program starting address to the linker
.align 4 @ code alignment
.equ LED_GPIO_PIN, 9 @ 25
.equ ALT_LED_PIN, 25
.equ LIFTED_LED_PIN, 12
.equ LED_GPIO_OUT, 1
.equ LED_GPIO_IS_INPUT, 0
.equ LED_VALUE_ON, 1
.equ LED_VALUE_OFF, 0
#include "blinky_mecr-a.S" // @ mecrisp-stellaris blinky boot
#include "are5.S"
led_on:
push {lr}
bl ground_lifted_pin
ldr r0, =LED_GPIO_PIN
movs r1, LED_VALUE_ON
bl asm_gpio_put
pop {pc}
alt_led_on:
push {lr}
ldr r0, =ALT_LED_PIN
movs r1, LED_VALUE_ON
bl asm_gpio_put
bl nop_vlow
bl nop_vlow
pop {pc}
led_off:
push {lr}
bl lift_that_ground
ldr r0, =LED_GPIO_PIN
movs r1, LED_VALUE_OFF
bl asm_gpio_put
bl nop_vlow
bl ground_lifted_pin
pop {pc}
alt_led_off:
push {lr}
ldr r0, =ALT_LED_PIN
movs r1, LED_VALUE_OFF
bl asm_gpio_put
pop {pc}
ledofian: @ wow this one really hits the tempo
@ control tempo by lots of repeat bl led_off
push {lr}
@ - - - interdits - - -
bl led_off
bl led_off
bl led_off
bl led_off
@ its a wiggpulser when this list is low on members:
pop {pc}
toggle_leds_alt:
push {lr}
bl alt_led_on
bl ledofian
pop {pc}
toggle_leds_led:
push {lr}
bl alt_led_off
bl led_on
pop {pc}
large_led_brightest:
push {lr}
bl toggle_leds_led
bl nop_low
bl toggle_leds_alt
bl nop_hi
pop {pc}
alt_led_brightest:
push {lr}
bl toggle_leds_alt
bl nop_low
bl toggle_leds_led
bl nop_hi
pop {pc}
loop:
@ choose only one of the two lines below:
bl large_led_brightest @ default: enable
@ bl alt_led_brightest @ default: disable
@ or comment both lines for both LEDs
bl alt_led_off
bl nop_low
bl nop_low
bl nop_low
bl nop_low
b loop
init_gpio_led:
push {lr}
ldr r0, =LED_GPIO_PIN
bl asm_gpio_init
ldr r0, =LED_GPIO_PIN
movs r1, #LED_GPIO_OUT
bl asm_gpio_set_dir
bl led_off
bl led_on
pop {pc}
init_alt_led:
push {lr}
ldr r0, =ALT_LED_PIN
bl asm_gpio_init
ldr r0, =ALT_LED_PIN
movs r1, #LED_GPIO_OUT
bl asm_gpio_set_dir
bl alt_led_off
bl alt_led_on
pop {pc}
init_both_leds:
push {lr}
bl init_gpio_led
bl init_alt_led
pop {pc}
init_lifted_ground:
push {lr}
ldr r0, =LIFTED_LED_PIN
bl asm_gpio_init
ldr r0, =LIFTED_LED_PIN
movs r1, #LED_GPIO_OUT
bl asm_gpio_set_dir
ldr r0, =LIFTED_LED_PIN
movs r1, LED_VALUE_OFF
bl asm_gpio_put
pop {pc}
lift_that_ground:
push {lr}
ldr r0, =LIFTED_LED_PIN
movs r1, #LED_GPIO_IS_INPUT
bl asm_gpio_set_dir
ldr r0, =LIFTED_LED_PIN
movs r1, LED_VALUE_ON @ lift it
bl asm_gpio_put
pop {pc}
ground_lifted_pin:
push {lr}
ldr r0, =LIFTED_LED_PIN
movs r1, #LED_GPIO_OUT
bl asm_gpio_set_dir
ldr r0, =LIFTED_LED_PIN
movs r1, LED_VALUE_OFF
bl asm_gpio_put
pop {pc}
gpio09_lit:
push {lr}
bl setup_gpio09
str r0, [r1, #GPIO_OUT_XOR]
pop {pc}
gpio25_lit:
push {lr}
bl setup_gpio25
str r0, [r1, #GPIO_OUT_XOR]
pop {pc}
traploop:
// on
bl toggle_gpio09
bl nop_vlow
// off
bl toggle_gpio09
bl nop_vlow
bl nop_vlow
// on
bl toggle_gpio09
bl nop_vlow
// off
bl toggle_gpio09
bl nop_vlow
bl nop_vlow
// on
bl toggle_gpio09
bl nop_vlow
// long silence
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
// on
bl toggle_gpio09
bl nop_vlow
// off
bl toggle_gpio09
bl nop_vlow
bl nop_vlow
// on
bl toggle_gpio09
bl nop_vlow
// off
bl toggle_gpio09
bl nop_vlow
bl nop_vlow
bl toggle_gpio09
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
bl nop_vlow
b traploop
@ -------------------- main ------------------
main_asm:
bl gpio09_lit
bl gpio25_lit
b traploop
@ toggle_gpio09:
@ push {lr}
@ ldr r1, =SIO_BASE
@ ldr r0, =1<<9
@ str r0, [r1, #GPIO_OUT_XOR]
@ pop {pc}
b traploop
bl setup_gpio09
@ ldr r1, =GPIO_09_CTRL
@ so an ldr r1 with GPIO 09 CTRL won't do it alone.
@ something gets setup earlier that is damaged.
@ how r1 gets 'educated' (and what other register
@ contents are also required) is unknown (to this
@ attempt to Rev engineer it without 'looking' except
@ for glances at mecrisp source and such matters)
str r0, [r1, #GPIO_OUT_XOR]
@ ldr r1, =GPIO_25_CTRL
@ ldr r1, =GPIO_09_CTRL
@ str r0, [r1, #GPIO_OUT_XOR]
nop
nop
nop
nop
nop
nop
nop
b traploop
bl init_both_leds
bl init_gpio_led
bl init_lifted_ground
bl lift_that_ground
bl ground_lifted_pin
b loop
@ Set data alignment
.data
.align 4