📄 stm32f10x_spi.lst
字号:
464 * - SPI_Direction_Rx: Selects Rx receive direction
465 * Output : None
466 * Return : None
467 *******************************************************************************/
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)
474 {
475 /* Set the Tx only mode */
476 SPIx->CR1 |= SPI_Direction_Tx;
477 }
478 else
479 {
480 /* Set the Rx only mode */
481 SPIx->CR1 &= SPI_Direction_Rx;
482 }
483 }
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 *******************************************************************************/
500 FlagStatus SPI_GetFlagStatus(SPI_TypeDef* SPIx, u16 SPI_FLAG)
501 {
502 FlagStatus bitstatus = RESET;
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)
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;
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 *******************************************************************************/
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)
541 {
542 /* Read SR register */
543 (void)SPIx->SR;
544 /* Write on CR1 register */
545 SPIx->CR1 |= CR1_SPE_Set;
546 }
547 /* SPI_FLAG_OVR flag clear */
548 else if(SPI_FLAG == SPI_FLAG_OVR)
549 {
550 /* Read SR register */
551 (void)SPIx->SR;
552 }
553 else /* SPI_FLAG_CRCERR flag clear */
554 {
555 /* Clear the selected SPI flag */
556 SPIx->SR &= (u16)~SPI_FLAG;
557 }
558 }
559
560 /*******************************************************************************
561 * Function Name : SPI_GetITStatus
562 * Description : Checks whether the specified SPI interrupt has occurred or not.
563 * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
564 * - SPI_IT: specifies the SPI interrupt source to check.
565 * This parameter can be one of the following values:
566 * - SPI_IT_OVR: Overrun interrupt.
567 * - SPI_IT_MODF: Mode Fault interrupt.
568 * - SPI_IT_CRCERR: CRC Error interrupt.
569 * - SPI_IT_TXE: Transmit buffer empty interrupt.
570 * - SPI_IT_RXNE: Receive buffer not empty interrupt.
571 * Output : None
572 * Return : The new state of SPI_IT (SET or RESET).
573 *******************************************************************************/
574 ITStatus SPI_GetITStatus(SPI_TypeDef* SPIx, u8 SPI_IT)
575 {
576 ITStatus bitstatus = RESET;
577 u16 itpos = 0, itmask = 0, enablestatus = 0;
578
579 /* Check the parameters */
580 assert_param(IS_SPI_GET_IT(SPI_IT));
581
582 /* Get the SPI IT index */
583 itpos = (u16)((u16)0x01 << (SPI_IT & (u8)0x0F));
584
585 /* Get the SPI IT index */
586 itmask = SPI_IT >> 4;
587 /* Set the IT mask */
588 itmask = (u16)((u16)0x01 << itmask);
589 /* Get the SPI_IT enable bit status */
590 enablestatus = (SPIx->CR2 & itmask) ;
591
592 /* Check the status of the specified SPI interrupt */
593 if (((SPIx->SR & itpos) != (u16)RESET) && enablestatus)
594 {
595 /* SPI_IT is set */
596 bitstatus = SET;
597 }
598 else
599 {
600 /* SPI_IT is reset */
601 bitstatus = RESET;
602 }
603 /* Return the SPI_IT status */
604 return bitstatus;
605 }
606
607 /*******************************************************************************
608 * Function Name : SPI_ClearITPendingBit
609 * Description : Clears the SPIx抯 interrupt pending bits.
610 * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
611 * - SPI_IT: specifies the SPI interrupt pending bit to clear.
612 * This parameter can be one of the following values:
613 * - SPI_IT_OVR: Overrun interrupt.
614 * - SPI_IT_MODF: Mode Fault interrupt.
615 * - SPI_IT_CRCERR: CRC Error interrupt.
616 * Output : None
617 * Return : None
618 *******************************************************************************/
619 void SPI_ClearITPendingBit(SPI_TypeDef* SPIx, u8 SPI_IT)
620 {
621 u16 itpos = 0;
622
623 /* Check the parameters */
624 assert_param(IS_SPI_CLEAR_IT(SPI_IT));
625
626 /* SPI_IT_MODF pending bit clear */
627 if(SPI_IT == SPI_IT_MODF)
628 {
629 /* Read SR register */
630 (void)SPIx->SR;
631 /* Write on CR1 register */
632 SPIx->CR1 |= CR1_SPE_Set;
633 }
634 else if(SPI_IT == SPI_IT_OVR) /* SPI_IT_OVR pending bit clear */
635 {
636 /* Read SR register */
637 (void)(SPIx->SR);
638 }
639 else /* SPI_IT_CRCERR pending bit clear */
640 {
641 /* Get the SPI IT index */
642 itpos = (u16)((u16)0x01 << (SPI_IT & (u8)0x0F));
643 /* Clear the selected SPI interrupt pending bits */
644 SPIx->SR &= (u16)~itpos;
645 }
646 }
647
648 /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
Maximum stack usage in bytes:
Function .cstack
-------- -------
SPI_BiDirectionalLineConfig 0
SPI_CalculateCRC 0
SPI_ClearFlag 0
SPI_ClearITPendingBit 8
SPI_Cmd 0
SPI_DMACmd 0
SPI_DataSizeConfig 0
SPI_DeInit 8
SPI_GetCRC 0
SPI_GetCRCPolynomial 0
SPI_GetFlagStatus 8
SPI_GetITStatus 24
SPI_ITConfig 8
SPI_Init 8
SPI_NSSInternalSoftwareConfig 0
SPI_ReceiveData 0
SPI_SSOutputCmd 0
SPI_SendData 0
SPI_StructInit 0
SPI_TransmitCRC 0
Section sizes:
Function/Label Bytes
-------------- -----
SPI_DeInit 68
SPI_Init 58
SPI_StructInit 38
SPI_Cmd 32
SPI_ITConfig 48
SPI_DMACmd 22
SPI_SendData 4
SPI_ReceiveData 4
SPI_NSSInternalSoftwareConfig 32
SPI_SSOutputCmd 32
SPI_DataSizeConfig 20
SPI_TransmitCRC 10
SPI_CalculateCRC 32
SPI_GetCRC 26
SPI_GetCRCPolynomial 4
SPI_BiDirectionalLineConfig 36
SPI_GetFlagStatus 34
SPI_ClearFlag 36
SPI_GetITStatus 82
SPI_ClearITPendingBit 56
674 bytes in section .text
674 bytes of CODE memory
Errors: none
Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -