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