📄 stm32f10x_spi.lst
字号:
\ In section .XML, align 4, keep-with-next
420 u16 SPI_GetCRC(SPI_TypeDef* SPIx, u8 SPI_CRC)
421 {
\ SPI_GetCRC:
\ 00000000 0200 MOVS R2,R0
422 u16 crcreg = 0;
\ 00000002 0023 MOVS R3,#+0
\ 00000004 1800 MOVS R0,R3
423
424 /* Check the parameters */
425 assert_param(IS_SPI_CRC(SPI_CRC));
426
427 if (SPI_CRC != SPI_CRC_Rx)
\ 00000006 C9B2 UXTB R1,R1 ;; ZeroExtS R1,R1,#+24,#+24
\ 00000008 0129 CMP R1,#+1
\ 0000000A 02D0 BEQ.N ??SPI_GetCRC_0
428 {
429 /* Get the Tx CRC register */
430 crcreg = SPIx->TXCRCR;
\ 0000000C 138B LDRH R3,[R2, #+24]
\ 0000000E 1800 MOVS R0,R3
\ 00000010 01E0 B.N ??SPI_GetCRC_1
431 }
432 else
433 {
434 /* Get the Rx CRC register */
435 crcreg = SPIx->RXCRCR;
\ ??SPI_GetCRC_0:
\ 00000012 938A LDRH R3,[R2, #+20]
\ 00000014 1800 MOVS R0,R3
436 }
437
438 /* Return the selected CRC register */
439 return crcreg;
\ ??SPI_GetCRC_1:
\ 00000016 80B2 UXTH R0,R0 ;; ZeroExtS R0,R0,#+16,#+16
\ 00000018 7047 BX LR ;; return
440 }
441
442 /*******************************************************************************
443 * Function Name : SPI_GetCRCPolynomial
444 * Description : Returns the CRC Polynomial register value for the specified SPI.
445 * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
446 * Output : None
447 * Return : The CRC Polynomial register value.
448 *******************************************************************************/
\ In section .XML, align 4, keep-with-next
449 u16 SPI_GetCRCPolynomial(SPI_TypeDef* SPIx)
450 {
451 /* Return the CRC polynomial register */
452 return SPIx->CRCPR;
\ SPI_GetCRCPolynomial:
\ 00000000 008A LDRH R0,[R0, #+16]
\ 00000002 7047 BX LR ;; return
453 }
454
455 /*******************************************************************************
456 * Function Name : SPI_BiDirectionalLineConfig
457 * Description : Selects the data transfer direction in bi-directional mode
458 * for the specified SPI.
459 * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
460 * - SPI_Direction: specifies the data transfer direction in
461 * bi-directional mode.
462 * This parameter can be one of the following values:
463 * - SPI_Direction_Tx: Selects Tx transmission direction
464 * - SPI_Direction_Rx: Selects Rx receive direction
465 * Output : None
466 * Return : None
467 *******************************************************************************/
\ In section .XML, align 4, keep-with-next
468 void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, u16 SPI_Direction)
469 {
470 /* Check the parameters */
471 assert_param(IS_SPI_DIRECTION(SPI_Direction));
472
473 if (SPI_Direction == SPI_Direction_Tx)
\ SPI_BiDirectionalLineConfig:
\ 00000000 5FF48042 MOVS R2,#+16384
\ 00000004 89B2 UXTH R1,R1 ;; ZeroExtS R1,R1,#+16,#+16
\ 00000006 9142 CMP R1,R2
\ 00000008 04D1 BNE.N ??SPI_BiDirectionalLineConfig_0
474 {
475 /* Set the Tx only mode */
476 SPIx->CR1 |= SPI_Direction_Tx;
\ 0000000A 0288 LDRH R2,[R0, #+0]
\ 0000000C 52F48042 ORRS R2,R2,#0x4000
\ 00000010 0280 STRH R2,[R0, #+0]
\ 00000012 03E0 B.N ??SPI_BiDirectionalLineConfig_1
477 }
478 else
479 {
480 /* Set the Rx only mode */
481 SPIx->CR1 &= SPI_Direction_Rx;
\ ??SPI_BiDirectionalLineConfig_0:
\ 00000014 0288 LDRH R2,[R0, #+0]
\ 00000016 024B LDR.N R3,??SPI_BiDirectionalLineConfig_2 ;; 0xbfff
\ 00000018 1340 ANDS R3,R3,R2
\ 0000001A 0380 STRH R3,[R0, #+0]
482 }
483 }
\ ??SPI_BiDirectionalLineConfig_1:
\ 0000001C 7047 BX LR ;; return
\ 0000001E 00BF Nop
\ ??SPI_BiDirectionalLineConfig_2:
\ 00000020 FFBF0000 DC32 0xbfff
484
485 /*******************************************************************************
486 * Function Name : SPI_GetFlagStatus
487 * Description : Checks whether the specified SPI flag is set or not.
488 * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
489 * - SPI_FLAG: specifies the flag to check.
490 * This parameter can be one of the following values:
491 * - SPI_FLAG_BSY: Busy flag.
492 * - SPI_FLAG_OVR: Overrun flag.
493 * - SPI_FLAG_MODF: Mode Fault flag.
494 * - SPI_FLAG_CRCERR: CRC Error flag.
495 * - SPI_FLAG_TXE: Transmit buffer empty flag.
496 * - SPI_FLAG_RXNE: Receive buffer not empty flag.
497 * Output : None
498 * Return : The new state of SPI_FLAG (SET or RESET).
499 *******************************************************************************/
\ In section .XML, align 4, keep-with-next
500 FlagStatus SPI_GetFlagStatus(SPI_TypeDef* SPIx, u16 SPI_FLAG)
501 {
\ SPI_GetFlagStatus:
\ 00000000 11B4 PUSH {R0,R4}
\ 00000002 0200 MOVS R2,R0
502 FlagStatus bitstatus = RESET;
\ 00000004 0023 MOVS R3,#+0
\ 00000006 1800 MOVS R0,R3
503
504 /* Check the parameters */
505 assert_param(IS_SPI_GET_FLAG(SPI_FLAG));
506
507 /* Check the status of the specified SPI flag */
508 if ((SPIx->SR & SPI_FLAG) != (u16)RESET)
\ 00000008 1389 LDRH R3,[R2, #+8]
\ 0000000A 0B40 ANDS R3,R3,R1
\ 0000000C 1C00 MOVS R4,R3
\ 0000000E A4B2 UXTH R4,R4 ;; ZeroExtS R4,R4,#+16,#+16
\ 00000010 641E SUBS R4,R4,#+1
\ 00000012 A441 SBCS R4,R4,R4
\ 00000014 E443 MVNS R4,R4
\ 00000016 E40F LSRS R4,R4,#+31
\ 00000018 2000 MOVS R0,R4
509 {
510 /* SPI_FLAG is set */
511 bitstatus = SET;
512 }
513 else
514 {
515 /* SPI_FLAG is reset */
516 bitstatus = RESET;
517 }
518 /* Return the SPI_FLAG status */
519 return bitstatus;
\ 0000001A C0B2 UXTB R0,R0 ;; ZeroExtS R0,R0,#+24,#+24
\ 0000001C 01B0 ADD SP,SP,#+4
\ 0000001E 10BC POP {R4}
\ 00000020 7047 BX LR ;; return
520 }
521
522 /*******************************************************************************
523 * Function Name : SPI_ClearFlag
524 * Description : Clears the SPIx's pending flags.
525 * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
526 * - SPI_FLAG: specifies the flag to clear.
527 * This parameter can be any combination of the following values:
528 * - SPI_FLAG_OVR: Overrun flag.
529 * - SPI_FLAG_MODF: Mode Fault flag.
530 * - SPI_FLAG_CRCERR: CRC Error flag.
531 * Output : None
532 * Return : None
533 *******************************************************************************/
\ In section .XML, align 4, keep-with-next
534 void SPI_ClearFlag(SPI_TypeDef* SPIx, u16 SPI_FLAG)
535 {
536 /* Check the parameters */
537 assert_param(IS_SPI_CLEAR_FLAG(SPI_FLAG));
538
539 /* SPI_FLAG_MODF flag clear */
540 if(SPI_FLAG == SPI_FLAG_MODF)
\ SPI_ClearFlag:
\ 00000000 89B2 UXTH R1,R1 ;; ZeroExtS R1,R1,#+16,#+16
\ 00000002 2029 CMP R1,#+32
\ 00000004 05D1 BNE.N ??SPI_ClearFlag_0
541 {
542 /* Read SR register */
543 (void)SPIx->SR;
\ 00000006 0289 LDRH R2,[R0, #+8]
544 /* Write on CR1 register */
545 SPIx->CR1 |= CR1_SPE_Set;
\ 00000008 0388 LDRH R3,[R0, #+0]
\ 0000000A 53F04003 ORRS R3,R3,#0x40
\ 0000000E 0380 STRH R3,[R0, #+0]
\ 00000010 07E0 B.N ??SPI_ClearFlag_1
546 }
547 /* SPI_FLAG_OVR flag clear */
548 else if(SPI_FLAG == SPI_FLAG_OVR)
\ ??SPI_ClearFlag_0:
\ 00000012 89B2 UXTH R1,R1 ;; ZeroExtS R1,R1,#+16,#+16
\ 00000014 4029 CMP R1,#+64
\ 00000016 01D1 BNE.N ??SPI_ClearFlag_2
549 {
550 /* Read SR register */
551 (void)SPIx->SR;
\ 00000018 0289 LDRH R2,[R0, #+8]
\ 0000001A 02E0 B.N ??SPI_ClearFlag_1
552 }
553 else /* SPI_FLAG_CRCERR flag clear */
554 {
555 /* Clear the selected SPI flag */
556 SPIx->SR &= (u16)~SPI_FLAG;
\ ??SPI_ClearFlag_2:
\ 0000001C 0289 LDRH R2,[R0, #+8]
\ 0000001E 8A43 BICS R2,R2,R1
\ 00000020 0281 STRH R2,[R0, #+8]
557 }
558 }
\ ??SPI_ClearFlag_1:
\ 00000022 7047 BX LR ;; return
559
560 /*******************************************************************************
561 * Function Name : SPI_GetITStatus
562 * Description : Checks whether the specified SPI interrupt has occurred or not.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -