BCM2835 >> Assembly

Button


參考資料:
1. example
2. firmware
3. datasheet
4. rpi_software

Button連接到GPIO-31


暫存器


Alternate Function


提昇電阻設定



main.s

  .global _start
 
  .equiv GPFSEL2,   0x20200008
  .equiv GPFSEL3,   0x2020000c
  .equiv GPSET0,    0x2020001c
  .equiv GPCLR0,    0x20200028
  .equiv GPLEV0,    0x20200034
  .equiv GPPUD,     0x20200094
  .equiv GPPUDCLK0, 0x20200098

  .arm
  .text
_start:
  b reset
  b .
  b .
  b .
  b .
  b .
  b .
  b .
     
reset:
  ldr r0, =GPFSEL2
  ldr r1, =(1 << 27)
  str r1, [r0]

  ldr r0, =GPFSEL3
  ldr r1, =0x00000000
  str r1, [r0]

  ldr r0, =GPPUD
  ldr r1, =0x02
  str r1, [r0]

  ldr r0, =GPPUDCLK0
  ldr r1, =(1 << 31)
  str r1, [r0]

0:
  ldr r0, =GPLEV0
  ldr r1, [r0]
  and r1, #(1 << 31)
  cmp r1, #0
  ldrne r0, =GPSET0
  ldreq r0, =GPCLR0
  ldr r1, =(1 << 29)
  str r1, [r0]
  b 0b
  .end

完成


返回上一頁