rp2040

RP2040 Programming without SDK
Log | Files | Refs

start.s (999B)


      1 .cpu cortex-m0plus
      2 .thumb
      3 
      4 	.section .vectors
      5 	.global vectors
      6 vectors:
      7 	.word 0x20040000 // initial SP
      8 	.word (reset+1)  // entry point
      9 
     10 	.section .text
     11 reset:
     12 	bl main
     13 
     14 	.global led
     15 led:
     16 	// unreset gpio
     17 	mov r0, #1
     18 	lsl r0, r0, #5 // io_bank0
     19 	ldr r3, resets_base
     20 	ldr r1, atomic_clr
     21 	str r0, [r3, r1] // RESETS: RESET
     22 
     23 reset_chk:
     24 	ldr r1, [r3, #0x8] // RESETS: RESET_DONE
     25 	tst r0, r1
     26 	beq reset_chk
     27 
     28 	// set gpio functions
     29 	ldr r3, io_bank0_base
     30 	mov r0, #5 // sio
     31 	mov r1, #0xcc
     32 	str r0, [r3, r1] // IO_BANK0: GPIO25_CTRL
     33 
     34 	// enable gpio output
     35 	ldr r3, sio_base
     36 	mov r0, #1
     37 	lsl r0, r0, #25 // gpio25
     38 	str r0, [r3, #0x24] // SIO: GPIO_OE
     39 
     40 	// blink led on gpio25
     41 	ldr r4, sio_base
     42 	mov r5, r0
     43 loop:
     44 	str r5, [r4, #0x1c] // SIO_GPIO_OUT_XOR
     45 	bl delay
     46 	b loop
     47 
     48 delay:
     49 	mov r0, #1
     50 	lsl r0, r0, #20
     51 delay_loop:
     52 	sub r0, r0, #1
     53 	bne delay_loop
     54 	bx lr
     55 
     56 // literals
     57 	.align 2
     58 atomic_clr:
     59 	.word 0x00003000
     60 resets_base:
     61 	.word 0x4000c000
     62 io_bank0_base:
     63 	.word 0x40014000
     64 sio_base:
     65 	.word 0xd0000000
     66