Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .syntax unified
- .global main, EXTI0_IRQHandler, EXTI1_IRQHandler
- .include "macros.s"
- main:
- bl init_gpio
- bl init_audio
- bl FourFortySender
- @ we will use r11 to keep track of control
- set_counter:
- mov r7, #31 @sender_counter
- bx lr
- FourFortySender:
- bl set_counter
- @ good luck!
- @lsl r6, #1
- ldr r6, =message
- ldr r9, =#FourFortyHz
- GPIOx_ODR_set E, 12
- bl sender
- sender:
- ldr r8, [r9]
- lsr r8, r7 @ bit loaded
- ands r8, #1 @ get the most significant bit
- it ne
- blne sendOne
- it eq @ send
- bleq sendZero
- GPIOx_ODR_toggle E, 13
- @ orr r6, r8
- cmp r7, #-1
- it eq
- bleq loop
- it ne
- blne sender
- sendOne:
- GPIOx_ODR_set E, 14
- bx lr
- sendZero:
- GPIOx_ODR_clear E, 14
- bx lr
- thinker:
- @ good luck!
- @lsl r6, #1
- ldr r8, [r9]
- lsr r8, r7 @ bit loaded, send
- lsl r8, #31
- lsr r8, #31
- @ orr r6, r8
- cmp r7, #-1
- it eq
- bleq loop
- it ne
- blne receiveOne
- loop:
- GPIOx_ODR_clear E, 12
- ldr r6, =message
- ldr r5, [r6]
- nop
- b loop
- .type EXTI0_IRQHandler, %function
- EXTI0_IRQHandler:
- push {lr}
- EXTI_PR_clear_pending 0
- GPIOx_IDR_read H, 0
- it eq
- moveq r11, #0
- it ne
- movne r11, #1
- pop {lr}
- bx lr
- .type EXTI1_IRQHandler, %function
- EXTI1_IRQHandler:
- push {lr}
- EXTI_PR_set_pending 0
- cmp r7, #0
- it ne
- blne checker
- pop {lr}
- bx lr
- checker:
- GPIOx_IDR_read E, 11
- bne receiveOne
- beq receiveZero
- receiveOne:
- ldr r6, =message
- ldr r5, [r6]
- lsl r5, #1
- orr r5, #1
- str r5, [r6]
- @ lsl r6, #1
- @ orr r6, #1
- @ sub r7, #1
- bx lr
- receiveZero:
- ldr r6, =message
- ldr r5, [r6]
- lsl r5, #1
- str r5, [r6]
- @ lsl r6, #1
- @ orr r6, 0b00000000000000000000000000000000
- sub r7, #1
- bx lr
- message:
- .word 0
- delay:
- .word 0b00000000000000000111111111111111 @ 0Hz in binary (for the delay)
- ThreeNinetyTwoHz: @ the least significant 16 bits of each of these are the amplitude 0x7FFF
- .word 0b00000001100010000111111111111111 @ 392Hz in binary
- FourNinetyFourHz:
- .word 0b00000001111011100111111111111111 @ 494Hz in binary
- FiveTwentyThreeHz:
- .word 0b00000010000010110111111111111111 @ 523Hz in binary
- FourFortyHz:
- .word 0b00000001101110000111111111111111 @ 440Hz in binary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement