📄 stm32f10x_i2c.lst
字号:
584
585 /* Return the data in the DR register */
586 return (u8)I2Cx->DR;
\ I2C_ReceiveData:
\ 00000000 008A LDRH R0,[R0, #+16]
\ 00000002 C0B2 UXTB R0,R0
\ 00000004 7047 BX LR ;; return
587 }
588
589 /*******************************************************************************
590 * Function Name : I2C_Send7bitAddress
591 * Description : Transmits the address byte to select the slave device.
592 * Input : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
593 * - Address: specifies the slave address which will be transmitted
594 * - I2C_Direction: specifies whether the I2C device will be a
595 * Transmitter or a Receiver.
596 * This parameter can be one of the following values
597 * - I2C_Direction_Transmitter: Transmitter mode
598 * - I2C_Direction_Receiver: Receiver mode
599 * Output : None
600 * Return : None.
601 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
602 void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, u8 Address, u8 I2C_Direction)
603 {
604 /* Check the parameters */
605 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
606 assert_param(IS_I2C_DIRECTION(I2C_Direction));
607
608 /* Test on the direction to set/reset the read/write bit */
609 if (I2C_Direction != I2C_Direction_Transmitter)
\ I2C_Send7bitAddress:
\ 00000000 002A CMP R2,#+0
\ 00000002 02D0 BEQ.N ??I2C_Send7bitAddress_0
610 {
611 /* Set the address bit0 for read */
612 Address |= OAR1_ADD0_Set;
\ 00000004 51F00101 ORRS R1,R1,#0x1
\ 00000008 01E0 B.N ??I2C_Send7bitAddress_1
613 }
614 else
615 {
616 /* Reset the address bit0 for write */
617 Address &= OAR1_ADD0_Reset;
\ ??I2C_Send7bitAddress_0:
\ 0000000A 11F0FE01 ANDS R1,R1,#0xFE
618 }
619 /* Send the address */
620 I2Cx->DR = Address;
\ ??I2C_Send7bitAddress_1:
\ 0000000E 0182 STRH R1,[R0, #+16]
621 }
\ 00000010 7047 BX LR ;; return
622
623 /*******************************************************************************
624 * Function Name : I2C_ReadRegister
625 * Description : Reads the specified I2C register and returns its value.
626 * Input1 : - I2C_Register: specifies the register to read.
627 * This parameter can be one of the following values:
628 * - I2C_Register_CR1: CR1 register.
629 * - I2C_Register_CR2: CR2 register.
630 * - I2C_Register_OAR1: OAR1 register.
631 * - I2C_Register_OAR2: OAR2 register.
632 * - I2C_Register_DR: DR register.
633 * - I2C_Register_SR1: SR1 register.
634 * - I2C_Register_SR2: SR2 register.
635 * - I2C_Register_CCR: CCR register.
636 * - I2C_Register_TRISE: TRISE register.
637 * Output : None
638 * Return : The value of the read register.
639 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
640 u16 I2C_ReadRegister(I2C_TypeDef* I2Cx, u8 I2C_Register)
641 {
642 /* Check the parameters */
643 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
644 assert_param(IS_I2C_REGISTER(I2C_Register));
645
646 /* Return the selected register value */
647 return (*(vu16 *)(*((vu32 *)&I2Cx) + I2C_Register));
\ I2C_ReadRegister:
\ 00000000 405A LDRH R0,[R0, R1]
\ 00000002 7047 BX LR ;; return
648 }
649
650 /*******************************************************************************
651 * Function Name : I2C_SoftwareResetCmd
652 * Description : Enables or disables the specified I2C software reset.
653 * Input : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
654 * - NewState: new state of the I2C software reset.
655 * This parameter can be: ENABLE or DISABLE.
656 * Output : None
657 * Return : None
658 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
659 void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
660 {
661 /* Check the parameters */
662 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
663 assert_param(IS_FUNCTIONAL_STATE(NewState));
664
665 if (NewState != DISABLE)
\ I2C_SoftwareResetCmd:
\ 00000000 0029 CMP R1,#+0
\ 00000002 0188 LDRH R1,[R0, #+0]
\ 00000004 03D0 BEQ.N ??I2C_SoftwareResetCmd_0
666 {
667 /* Peripheral under reset */
668 I2Cx->CR1 |= CR1_SWRST_Set;
\ 00000006 51F40041 ORRS R1,R1,#0x8000
\ 0000000A 0180 STRH R1,[R0, #+0]
\ 0000000C 7047 BX LR
669 }
670 else
671 {
672 /* Peripheral not under reset */
673 I2Cx->CR1 &= CR1_SWRST_Reset;
\ ??I2C_SoftwareResetCmd_0:
\ 0000000E 4904 LSLS R1,R1,#+17
\ 00000010 490C LSRS R1,R1,#+17
\ 00000012 0180 STRH R1,[R0, #+0]
674 }
675 }
\ 00000014 7047 BX LR ;; return
676
677 /*******************************************************************************
678 * Function Name : I2C_SMBusAlertConfig
679 * Description : Drives the SMBusAlert pin high or low for the specified I2C.
680 * Input : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
681 * - I2C_SMBusAlert: specifies SMBAlert pin level.
682 * This parameter can be one of the following values:
683 * - I2C_SMBusAlert_Low: SMBAlert pin driven low
684 * - I2C_SMBusAlert_High: SMBAlert pin driven high
685 * Output : None
686 * Return : None
687 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
688 void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, u16 I2C_SMBusAlert)
689 {
690 /* Check the parameters */
691 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
692 assert_param(IS_I2C_SMBUS_ALERT(I2C_SMBusAlert));
693
694 if (I2C_SMBusAlert == I2C_SMBusAlert_Low)
\ I2C_SMBusAlertConfig:
\ 00000000 5FF40052 MOVS R2,#+8192
\ 00000004 9142 CMP R1,R2
\ 00000006 0188 LDRH R1,[R0, #+0]
\ 00000008 03D1 BNE.N ??I2C_SMBusAlertConfig_0
695 {
696 /* Drive the SMBusAlert pin Low */
697 I2Cx->CR1 |= I2C_SMBusAlert_Low;
\ 0000000A 51F40051 ORRS R1,R1,#0x2000
\ 0000000E 0180 STRH R1,[R0, #+0]
\ 00000010 7047 BX LR
698 }
699 else
700 {
701 /* Drive the SMBusAlert pin High */
702 I2Cx->CR1 &= I2C_SMBusAlert_High;
\ ??I2C_SMBusAlertConfig_0:
\ 00000012 024A LDR.N R2,??I2C_SMBusAlertConfig_1 ;; 0xdfff
\ 00000014 0A40 ANDS R2,R2,R1
\ 00000016 0280 STRH R2,[R0, #+0]
703 }
704 }
\ 00000018 7047 BX LR ;; return
\ 0000001A 00BF Nop
\ ??I2C_SMBusAlertConfig_1:
\ 0000001C FFDF0000 DC32 0xdfff
705
706 /*******************************************************************************
707 * Function Name : I2C_TransmitPEC
708 * Description : Enables or disables the specified I2C PEC transfer.
709 * Input : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
710 * - NewState: new state of the I2C PEC transmission.
711 * This parameter can be: ENABLE or DISABLE.
712 * Output : None
713 * Return : None
714 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
715 void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState)
716 {
717 /* Check the parameters */
718 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
719 assert_param(IS_FUNCTIONAL_STATE(NewState));
720
721 if (NewState != DISABLE)
\ I2C_TransmitPEC:
\ 00000000 0029 CMP R1,#+0
\ 00000002 0188 LDRH R1,[R0, #+0]
\ 00000004 03D0 BEQ.N ??I2C_TransmitPEC_0
722 {
723 /* Enable the selected I2C PEC transmission */
724 I2Cx->CR1 |= CR1_PEC_Set;
\ 00000006 51F48051 ORRS R1,R1,#0x1000
\ 0000000A 0180 STRH R1,[R0, #+0]
\ 0000000C 7047 BX LR
725 }
726 else
727 {
728 /* Disable the selected I2C PEC transmission */
729 I2Cx->CR1 &= CR1_PEC_Reset;
\ ??I2C_TransmitPEC_0:
\ 0000000E .... LDR.N R2,??DataTable7 ;; 0xefff
\ 00000010 0A40 ANDS R2,R2,R1
\ 00000012 0280 STRH R2,[R0, #+0]
730 }
731 }
\ 00000014 7047 BX LR ;; return
732
733 /*******************************************************************************
734 * Function Name : I2C_PECPositionConfig
735 * Description : Selects the specified I2C PEC position.
736 * Input : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
737 * - I2C_PECPosition: specifies the PEC position.
738 * This parameter can be one of the following values:
739 * - I2C_PECPosition_Next: indicates that the next
740 * byte is PEC
741 * - I2C_PECPosition_Current: indicates that current
742 * byte is PEC
743 * Output : None
744 * Return : None
745 *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -