Add the assembly blink to the sdk examble.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
f30f36420a
commit
5611462c08
3 changed files with 35 additions and 6 deletions
|
|
@ -13,6 +13,7 @@ pico_sdk_init()
|
|||
# rest of your project
|
||||
add_executable(hello_world
|
||||
hello_world.c
|
||||
led.s
|
||||
)
|
||||
|
||||
# Add pico_stdlib library which aggregates commonly used features
|
||||
|
|
|
|||
|
|
@ -41,13 +41,16 @@ void pico_set_led(bool led_on) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void blink();
|
||||
|
||||
int main() {
|
||||
int rc = pico_led_init();
|
||||
hard_assert(rc == PICO_OK);
|
||||
while (true) {
|
||||
pico_set_led(true);
|
||||
sleep_ms(LED_DELAY_MS);
|
||||
pico_set_led(false);
|
||||
sleep_ms(LED_DELAY_MS);
|
||||
}
|
||||
blink();
|
||||
/* while (true) { */
|
||||
/* pico_set_led(true); */
|
||||
/* sleep_ms(LED_DELAY_MS); */
|
||||
/* pico_set_led(false); */
|
||||
/* sleep_ms(LED_DELAY_MS); */
|
||||
/* } */
|
||||
}
|
||||
|
|
|
|||
25
led.s
Normal file
25
led.s
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
.section .text
|
||||
.equ sio_base, 0xd0000000
|
||||
.equ big_num, 0x00f00000 // For the delay.
|
||||
|
||||
.thumb_func
|
||||
.global blink
|
||||
blink:
|
||||
ldr r0, =sio_base
|
||||
mov r1, #1
|
||||
lsl r1, r1, #25
|
||||
led_loop:
|
||||
str r1, [r0, #0x18] // GPIO_OUT_SET
|
||||
ldr r3, =big_num
|
||||
bl delay
|
||||
|
||||
str r1, [r0, #0x20] // GPIO_OUT_CLR
|
||||
ldr r3, =big_num
|
||||
bl delay
|
||||
|
||||
b led_loop
|
||||
|
||||
delay:
|
||||
sub r3, #1
|
||||
bne delay
|
||||
bx lr
|
||||
Loading…
Add table
Add a link
Reference in a new issue