📄 stm8s_beep.ls
字号:
1 ; C Compiler for STM8 (COSMIC Software)
2 ; Parser V4.8.32.1 - 30 Mar 2010
3 ; Generator V4.3.4 - 23 Mar 2010
43 ; 64 void BEEP_DeInit(void)
43 ; 65 {
45 switch .text
46 0000 _BEEP_DeInit:
50 ; 66 BEEP->CSR = BEEP_CSR_RESET_VALUE;
52 0000 351f50f3 mov 20723,#31
53 ; 67 }
56 0004 81 ret
121 ; 83 void BEEP_Init(BEEP_Frequency_TypeDef BEEP_Frequency)
121 ; 84 {
122 switch .text
123 0005 _BEEP_Init:
125 0005 88 push a
126 00000000 OFST: set 0
129 ; 87 assert_param(IS_BEEP_FREQUENCY_OK(BEEP_Frequency));
131 ; 90 BEEP->CSR |= BEEP_CSR_BEEPEN;
133 0006 721a50f3 bset 20723,#5
134 ; 93 if ((BEEP->CSR & BEEP_CSR_BEEPDIV) == BEEP_CSR_BEEPDIV)
136 000a c650f3 ld a,20723
137 000d a41f and a,#31
138 000f a11f cp a,#31
139 0011 2610 jrne L15
140 ; 95 BEEP->CSR &= (u8)(~BEEP_CSR_BEEPDIV); /* Clear bits */
142 0013 c650f3 ld a,20723
143 0016 a4e0 and a,#224
144 0018 c750f3 ld 20723,a
145 ; 96 BEEP->CSR |= BEEP_CALIBRATION_DEFAULT;
147 001b c650f3 ld a,20723
148 001e aa0b or a,#11
149 0020 c750f3 ld 20723,a
150 0023 L15:
151 ; 100 BEEP->CSR &= (u8)(~BEEP_CSR_BEEPSEL);
153 0023 c650f3 ld a,20723
154 0026 a43f and a,#63
155 0028 c750f3 ld 20723,a
156 ; 101 BEEP->CSR |= (u8)(BEEP_Frequency);
158 002b c650f3 ld a,20723
159 002e 1a01 or a,(OFST+1,sp)
160 0030 c750f3 ld 20723,a
161 ; 103 }
164 0033 84 pop a
165 0034 81 ret
220 ; 118 void BEEP_Cmd(FunctionalState NewState)
220 ; 119 {
221 switch .text
222 0035 _BEEP_Cmd:
226 ; 120 if (NewState != DISABLE)
228 0035 4d tnz a
229 0036 2706 jreq L101
230 ; 123 BEEP->CSR |= BEEP_CSR_BEEPEN;
232 0038 721a50f3 bset 20723,#5
234 003c 2004 jra L301
235 003e L101:
236 ; 128 BEEP->CSR &= (u8)(~BEEP_CSR_BEEPEN);
238 003e 721b50f3 bres 20723,#5
239 0042 L301:
240 ; 130 }
243 0042 81 ret
290 .const: section .text
291 0000 L41:
292 0000 000003e8 dc.l 1000
293 ; 157 void BEEP_LSICalibrationConfig(u32 LSIFreqHz)
293 ; 158 {
294 switch .text
295 0043 _BEEP_LSICalibrationConfig:
297 0043 5206 subw sp,#6
298 00000006 OFST: set 6
301 ; 164 assert_param(IS_LSI_FREQUENCY_OK(LSIFreqHz));
303 ; 166 lsifreqkhz = (u16)(LSIFreqHz / 1000); /* Converts value in kHz */
305 0045 96 ldw x,sp
306 0046 1c0009 addw x,#OFST+3
307 0049 cd0000 call c_ltor
309 004c ae0000 ldw x,#L41
310 004f cd0000 call c_ludv
312 0052 be02 ldw x,c_lreg+2
313 0054 1f03 ldw (OFST-3,sp),x
314 ; 170 BEEP->CSR &= (u8)(~BEEP_CSR_BEEPDIV); /* Clear bits */
316 0056 c650f3 ld a,20723
317 0059 a4e0 and a,#224
318 005b c750f3 ld 20723,a
319 ; 172 A = (u16)(lsifreqkhz >> 3U); /* Division by 8, keep integer part only */
321 005e 1e03 ldw x,(OFST-3,sp)
322 0060 54 srlw x
323 0061 54 srlw x
324 0062 54 srlw x
325 0063 1f05 ldw (OFST-1,sp),x
326 ; 174 if ((8U * A) >= ((lsifreqkhz - (8U * A)) * (1U + (2U * A))))
328 0065 1e05 ldw x,(OFST-1,sp)
329 0067 58 sllw x
330 0068 58 sllw x
331 0069 58 sllw x
332 006a 1f01 ldw (OFST-5,sp),x
333 006c 1e03 ldw x,(OFST-3,sp)
334 006e 72f001 subw x,(OFST-5,sp)
335 0071 1605 ldw y,(OFST-1,sp)
336 0073 9058 sllw y
337 0075 905c incw y
338 0077 cd0000 call c_imul
340 007a 1605 ldw y,(OFST-1,sp)
341 007c 9058 sllw y
342 007e 9058 sllw y
343 0080 9058 sllw y
344 0082 bf00 ldw c_x,x
345 0084 90b300 cpw y,c_x
346 0087 250c jrult L521
347 ; 176 BEEP->CSR |= (u8)(A - 2U);
349 0089 7b06 ld a,(OFST+0,sp)
350 008b a002 sub a,#2
351 008d ca50f3 or a,20723
352 0090 c750f3 ld 20723,a
354 0093 2009 jra L721
355 0095 L521:
356 ; 180 BEEP->CSR |= (u8)(A - 1U);
358 0095 7b06 ld a,(OFST+0,sp)
359 0097 4a dec a
360 0098 ca50f3 or a,20723
361 009b c750f3 ld 20723,a
362 009e L721:
363 ; 184 AWU->CSR |= AWU_CSR_MR;
365 009e 721250f0 bset 20720,#1
366 ; 186 }
369 00a2 5b06 addw sp,#6
370 00a4 81 ret
444 switch .const
445 0004 L02:
446 0004 000186a0 dc.l 100000
447 0008 L22:
448 0008 00030d41 dc.l 200001
449 ; 204 ErrorStatus BEEP_AutoLSICalibration(void)
449 ; 205 {
450 switch .text
451 00a5 _BEEP_AutoLSICalibration:
453 00a5 5205 subw sp,#5
454 00000005 OFST: set 5
457 ; 211 fmaster = CLK_GetClockFreq();
459 00a7 cd0000 call _CLK_GetClockFreq
461 00aa 96 ldw x,sp
462 00ab 1c0002 addw x,#OFST-3
463 00ae cd0000 call c_rtol
465 ; 214 AWU->CSR |= AWU_CSR_MSR;
467 00b1 721050f0 bset 20720,#0
468 ; 217 lsi_freq_hz = TIM3_ComputeLsiClockFreq(fmaster);
470 00b5 1e04 ldw x,(OFST-1,sp)
471 00b7 89 pushw x
472 00b8 1e04 ldw x,(OFST-1,sp)
473 00ba 89 pushw x
474 00bb cd0000 call _TIM3_ComputeLsiClockFreq
476 00be 5b04 addw sp,#4
477 00c0 96 ldw x,sp
478 00c1 1c0002 addw x,#OFST-3
479 00c4 cd0000 call c_rtol
481 ; 220 AWU->CSR &= (u8)(~AWU_CSR_MSR);
483 00c7 721150f0 bres 20720,#0
484 ; 222 if ((lsi_freq_hz >= LSI_FREQUENCY_MIN) && (lsi_freq_hz <= LSI_FREQUENCY_MAX))
486 00cb 96 ldw x,sp
487 00cc 1c0002 addw x,#OFST-3
488 00cf cd0000 call c_ltor
490 00d2 ae0004 ldw x,#L02
491 00d5 cd0000 call c_lcmp
493 00d8 2520 jrult L361
495 00da 96 ldw x,sp
496 00db 1c0002 addw x,#OFST-3
497 00de cd0000 call c_ltor
499 00e1 ae0008 ldw x,#L22
500 00e4 cd0000 call c_lcmp
502 00e7 2411 jruge L361
503 ; 225 BEEP_LSICalibrationConfig(lsi_freq_hz);
505 00e9 1e04 ldw x,(OFST-1,sp)
506 00eb 89 pushw x
507 00ec 1e04 ldw x,(OFST-1,sp)
508 00ee 89 pushw x
509 00ef cd0043 call _BEEP_LSICalibrationConfig
511 00f2 5b04 addw sp,#4
512 ; 226 status = SUCCESS;
514 00f4 a601 ld a,#1
515 00f6 6b01 ld (OFST-4,sp),a
517 00f8 2002 jra L561
518 00fa L361:
519 ; 230 status = ERROR;
521 00fa 0f01 clr (OFST-4,sp)
522 00fc L561:
523 ; 233 return status;
525 00fc 7b01 ld a,(OFST-4,sp)
528 00fe 5b05 addw sp,#5
529 0100 81 ret
542 xdef _BEEP_AutoLSICalibration
543 xdef _BEEP_LSICalibrationConfig
544 xdef _BEEP_Cmd
545 xdef _BEEP_Init
546 xdef _BEEP_DeInit
547 xref _CLK_GetClockFreq
548 xref _TIM3_ComputeLsiClockFreq
549 xref.b c_lreg
550 xref.b c_x
569 xref c_lcmp
570 xref c_rtol
571 xref c_imul
572 xref c_ludv
573 xref c_ltor
574 end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -