93 lines
No EOL
1.6 KiB
ArmAsm
93 lines
No EOL
1.6 KiB
ArmAsm
PRESERVE8
|
||
THUMB
|
||
include ./Driver/DriverJeuLaser.inc
|
||
|
||
|
||
; ====================== zone de r<>servation de donn<6E>es, ======================================
|
||
;Section RAM (read only) :
|
||
area mesdata,data,readonly
|
||
extern Son
|
||
extern LongueurSon
|
||
|
||
;Section RAM (read write):
|
||
area maram,data,readwrite
|
||
|
||
export SortieSon
|
||
SortieSon dcw 0 ;Declaration d'une variable sur 16bits
|
||
index dcd 0
|
||
|
||
|
||
|
||
; ===============================================================================================
|
||
|
||
|
||
|
||
|
||
;Section ROM code (read only) :
|
||
area moncode,code,readonly
|
||
; <20>crire le code ici
|
||
|
||
export CallbackSon
|
||
CallbackSon proc
|
||
|
||
push {lr}
|
||
push {r5}
|
||
|
||
ldr r0, =Son ;r0=&Son
|
||
ldr r2, =index ; r2=&index
|
||
ldr r1, [r2] ; r1 = index
|
||
|
||
ldr r5, = LongueurSon ; r5 = &LongueurSon
|
||
ldr r5, [r5] ; r5 = LongueurSon ; r5 = LongueurSon
|
||
lsl r5, #1; r5 = 2 x LongueurSon
|
||
|
||
cmp r1, r5 ; compare index et length
|
||
bgt done
|
||
|
||
ldrsh r3, [r0, r1] ;r3=son[index]
|
||
; on aurait pu faire ldrsh r3, [r0, r1, lsl #1] et incrementer de 1
|
||
add r1, #2 ; index +=2
|
||
str r1, [r2] ; index en memoire=r1
|
||
|
||
;Normalisation de la valeur son [index]
|
||
add r3, #32768 ;r3+=32278
|
||
|
||
push {r4}
|
||
mov r4, #719 ; r4 = 719
|
||
mul r3,r4 ;r3*=719
|
||
asr r3, #16 ;r3/=65536
|
||
pop {r4}
|
||
|
||
;On met la valeur modifiee dans SortieSon
|
||
ldr r0, =SortieSon ;r0=&SortieSon
|
||
str r3, [r0]
|
||
|
||
push {r0-r3}
|
||
mov r0,r3
|
||
bl PWM_Set_Value_TIM3_Ch3
|
||
pop {r0-r3}
|
||
|
||
done
|
||
|
||
pop {r5}
|
||
pop {pc}
|
||
endp
|
||
|
||
|
||
export StartSon
|
||
StartSon proc
|
||
push {lr}
|
||
ldr r2, =index ; r2=&index
|
||
mov r1, #0 ;r1 =0
|
||
str r1, [r2] ;on ecrit 0 dans index
|
||
|
||
|
||
pop {pc}
|
||
endp
|
||
|
||
|
||
|
||
|
||
|
||
|
||
END
|