grpC_RAMARA_CROS/PjtKEIL_StepSon/Src/GestionSon.s

95 lines
No EOL
1.6 KiB
ArmAsm

PRESERVE8
THUMB
INCLUDE DriverJeuLaser.inc
IMPORT Son
IMPORT LongueurSon
EXPORT callbackSon
EXPORT SortieSon
EXPORT IndiceCourrant
; ====================== zone de réservation de données, ======================================
;Section RAM (read only) :
area mesdata,data,readonly
;Section RAM (read write):
area maram,data,readwrite
SortieSon dcw 0
IndiceCourrant dcd 0
; ===============================================================================================
;Section ROM code (read only) :
area moncode,code,readonly
; écrire le code ici
;void callbackSon (void) {
; if (LongueurSon >= IndiceCourrant) {
; SortieSon = Son[IndiceCourrant];
; SortieSon += 32767;
; SortieSon = SortieSon/(65534/719);
; IndiceCourrant++;
; }
; PWM_Set_Value_TIM3_Ch3(SortieSon);
;}
EXPORT callbackSon
callbackSon proc
push {lr}
push {r4}
push {r5}
ldr r0, =Son
ldr r2, =IndiceCourrant
ldr r1, [r2]
ldr r5, =LongueurSon
ldr r5, [r5]
; if (LongueurSon >= IndiceCourrant) {
cmp r1,r5
bgt RienFaire
; SortieSon = Son[IndiceCourrant];
ldrsh r3, [r0, r1, lsl #1]
; IndiceCourrant++;
add r1, #1
str r1, [r2]
; SortieSon += 32768;
add r3, #32768
; SortieSon = SortieSon*719/65534;
mov r4, #719
mul r3, r4
asr r3, #16
ldr r0, =SortieSon
str r3, [r0] ; valeur de r3 à l'adresse dans r0 = adresse de SortieSon
; }
; PWM_Set_Value_TIM3_Ch3(SortieSon);
mov r0 , r3 ; passage de valeur de SortieSon en arg
bl PWM_Set_Value_TIM3_Ch3
RienFaire
pop {r5}
pop {r4}
pop {pc}
endp
;StartSon proc
; callbackSon();
; bl callbackSon
; endp
END