Advertisement
Guest User

Untitled

a guest
May 27th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 2.31 KB | None | 0 0
  1. .syntax unified
  2. .global main, EXTI0_IRQHandler, EXTI1_IRQHandler
  3.  
  4. .include "macros.s"
  5.  
  6.  
  7.  
  8. main:
  9.   bl init_gpio
  10.   bl init_audio
  11. starter:
  12.   GPIOx_ODR_set E, 12
  13.   mov r8, #0                    @ this will be our counter to ensure we only send 32 bits
  14.   mov r6, #0                    @ we will use this for the received message
  15.   mov r5, #32                   @ this will be our counter to ensure we only receive 32 bits
  16. @  mov r10, #31                  @ counter to ensure we lsl correctly to get the msb every loop
  17.   ldr r11, =0b10100001101110000111111111111111 @ store 440hz msg into r10
  18.   bl sender
  19.   bl clear_control_andCounter
  20.  
  21.  
  22.  
  23. sender:
  24.   push {lr}
  25.   cmp r8, #32
  26.   it ne
  27.   blne sender_message
  28.   pop {lr}
  29.   bl sender
  30.   bx lr
  31.  
  32. sender_message:
  33.   push {lr}
  34.   mov r12, #0
  35.   mov r12, r11  @r10 would be the binary msg
  36.   lsr r12, #31
  37.   cmp r12, #0
  38.   it eq
  39.   bleq write_bit_off
  40.   it ne
  41.   blne write_bit_on
  42.   pop {lr}
  43.   bx lr
  44.  
  45.  
  46.  
  47. write_bit_off:
  48.   GPIOx_ODR_clear E, 14
  49.   GPIOx_ODR_toggle E, 13
  50.   add r8, #1
  51.   lsl r11, #1
  52.   bx lr
  53.  
  54. write_bit_on:
  55.   GPIOx_ODR_set E, 14
  56.   GPIOx_ODR_toggle E, 13
  57.   add r8, #1
  58.   lsl r11, #1
  59.   bx lr
  60.  
  61.  
  62. clear_control_andCounter:
  63.   push {lr}
  64.   GPIOx_ODR_clear E, 12
  65.   mov r8, #0
  66.   pop {lr}
  67.   bx lr
  68.  
  69.  
  70.  
  71. data_reader:
  72.   push {lr}
  73.   GPIOx_IDR_read E, 11
  74.   it eq
  75.   bleq data_0_handler
  76.   it ne
  77.   blne data_1_handler
  78.   pop {lr}
  79.   bx lr
  80.  
  81. data_0_handler:
  82.   push {lr}
  83.   subs r5, #1
  84.   lsl r6, #1
  85.   pop {lr}
  86.   bx lr
  87.  
  88.  
  89. data_1_handler:
  90.   push {lr}
  91.   subs r5, #1
  92.   mov r4, #1
  93.   lsl r6, #1
  94.   orr r6, r6, r4
  95.   pop {lr}
  96.   bx lr
  97.  
  98. @  ldr r0, =storage
  99. @  ldr r1, [r0]
  100. @  lsl r1, #1
  101. @  str r1, [r0]
  102.  
  103. loop:
  104.   nop
  105.   b loop
  106.   @ good luck!
  107.  
  108.  
  109. continue:
  110.   push {lr}
  111.   cmp r5, #0
  112.   it ne
  113.   blne data_reader
  114.   pop {lr}
  115.   bx lr
  116.  
  117.  
  118. .type EXTI0_IRQHandler, %function
  119. EXTI0_IRQHandler:
  120.   push {lr}
  121.   @ mark this interrupt as "cleared" (i.e. no longer pending)
  122.   EXTI_PR_set_pending 0
  123.   mov r6, #4
  124.  
  125.   GPIOx_IDR_read H, 0
  126.   it eq
  127.   moveq r7, #0
  128.   it ne
  129.   movne r7, #1
  130.   pop {lr}
  131.   bx lr
  132.  
  133.  
  134. .type EXTI1_IRQHandler, %function
  135. EXTI1_IRQHandler:
  136.   push {lr}
  137.   @ mark this interrupt as "cleared" (i.e. no longer pending)
  138.   EXTI_PR_clear_pending 0
  139.   @ check if control is 0
  140.   it ne  @ if not, continue to data_receiver
  141.   blne continue
  142.   pop {lr}
  143.   bx lr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement