⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_i2c.lst

📁 完成数据的采集
💻 LST
📖 第 1 页 / 共 5 页
字号:
    549            I2Cx->DR = Data;
   \                     I2C_SendData:
   \   00000000   C9B2               UXTB     R1,R1            ;; ZeroExtS R1,R1,#+24,#+24
   \   00000002   0182               STRH     R1,[R0, #+16]
    550          }
   \   00000004   7047               BX       LR               ;; return
    551          
    552          /*******************************************************************************
    553          * Function Name  : I2C_ReceiveData
    554          * Description    : Returns the most recent received data by the I2Cx peripheral.
    555          * Input          : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    556          * Output         : None
    557          * Return         : The value of the received data.
    558          *******************************************************************************/

   \                                 In section .XML, align 4, keep-with-next
    559          u8 I2C_ReceiveData(I2C_TypeDef* I2Cx)
    560          {
    561            /* Return the data in the DR register */
    562            return (u8)I2Cx->DR;
   \                     I2C_ReceiveData:
   \   00000000   008A               LDRH     R0,[R0, #+16]
   \   00000002   C0B2               UXTB     R0,R0            ;; ZeroExtS R0,R0,#+24,#+24
   \   00000004   7047               BX       LR               ;; return
    563          }
    564          
    565          /*******************************************************************************
    566          * Function Name  : I2C_Send7bitAddress
    567          * Description    : Transmits the address byte to select the slave device.
    568          * Input          : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    569          *                  - Address: specifies the slave address which will be transmitted
    570          *                  - I2C_Direction: specifies whether the I2C device will be a
    571          *                    Transmitter or a Receiver. 
    572          *                    This parameter can be one of the following values
    573          *                       - I2C_Direction_Transmitter: Transmitter mode
    574          *                       - I2C_Direction_Receiver: Receiver mode
    575          * Output         : None
    576          * Return         : None.
    577          *******************************************************************************/

   \                                 In section .XML, align 4, keep-with-next
    578          void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, u8 Address, u8 I2C_Direction)
    579          {
    580            /* Check the parameters */
    581            assert_param(IS_I2C_DIRECTION(I2C_Direction));
    582          
    583            /* Test on the direction to set/reset the read/write bit */
    584            if (I2C_Direction != I2C_Direction_Transmitter)
   \                     I2C_Send7bitAddress:
   \   00000000   D2B2               UXTB     R2,R2            ;; ZeroExtS R2,R2,#+24,#+24
   \   00000002   002A               CMP      R2,#+0
   \   00000004   02D0               BEQ.N    ??I2C_Send7bitAddress_0
    585            {
    586              /* Set the address ADD0 bit0 for read */
    587              Address |= OAR1_ADD0_Set;
   \   00000006   51F00101           ORRS     R1,R1,#0x1
   \   0000000A   01E0               B.N      ??I2C_Send7bitAddress_1
    588            }
    589            else
    590            {
    591              /* Reset the address bit0 for write */
    592              Address &= OAR1_ADD0_Reset;
   \                     ??I2C_Send7bitAddress_0:
   \   0000000C   11F0FE01           ANDS     R1,R1,#0xFE
    593            }
    594            /* Send the address */
    595            I2Cx->DR = Address;
   \                     ??I2C_Send7bitAddress_1:
   \   00000010   C9B2               UXTB     R1,R1            ;; ZeroExtS R1,R1,#+24,#+24
   \   00000012   0182               STRH     R1,[R0, #+16]
    596          }
   \   00000014   7047               BX       LR               ;; return
    597          
    598          /*******************************************************************************
    599          * Function Name  : I2C_ReadRegister
    600          * Description    : Reads the specified I2C register and returns its value.
    601          * Input1         : - I2C_Register: specifies the register to read.
    602          *                    This parameter can be one of the following values:
    603          *                       - I2C_Register_CR1:  CR1 register.
    604          *                       - I2C_Register_CR2:   CR2 register.
    605          *                       - I2C_Register_OAR1:  OAR1 register.
    606          *                       - I2C_Register_OAR2:  OAR2 register.
    607          *                       - I2C_Register_DR:    DR register.
    608          *                       - I2C_Register_SR1:   SR1 register.
    609          *                       - I2C_Register_SR2:   SR2 register.
    610          *                       - I2C_Register_CCR:   CCR register.
    611          *                       - I2C_Register_TRISE: TRISE register.
    612          * Output         : None
    613          * Return         : The value of the read register.
    614          *******************************************************************************/

   \                                 In section .XML, align 4, keep-with-next
    615          u16 I2C_ReadRegister(I2C_TypeDef* I2Cx, u8 I2C_Register)
    616          {
    617            /* Check the parameters */
    618            assert_param(IS_I2C_REGISTER(I2C_Register));
    619          
    620            /* Return the selected register value */
    621            return (*(u16 *)(*((u32 *)&I2Cx) + I2C_Register));
   \                     I2C_ReadRegister:
   \   00000000   C9B2               UXTB     R1,R1            ;; ZeroExtS R1,R1,#+24,#+24
   \   00000002   405A               LDRH     R0,[R0, R1]
   \   00000004   80B2               UXTH     R0,R0            ;; ZeroExtS R0,R0,#+16,#+16
   \   00000006   7047               BX       LR               ;; return
    622          }
    623          
    624          /*******************************************************************************
    625          * Function Name  : I2C_SoftwareResetCmd
    626          * Description    : Enables or disables the specified I2C software reset.
    627          * Input          : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    628          *                  - NewState: new state of the I2C software reset.
    629          *                    This parameter can be: ENABLE or DISABLE.
    630          * Output         : None
    631          * Return         : None
    632          *******************************************************************************/

   \                                 In section .XML, align 4, keep-with-next
    633          void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
    634          {
    635            /* Check the parameters */
    636            assert_param(IS_FUNCTIONAL_STATE(NewState));
    637          
    638            if (NewState != DISABLE)
   \                     I2C_SoftwareResetCmd:
   \   00000000   C9B2               UXTB     R1,R1            ;; ZeroExtS R1,R1,#+24,#+24
   \   00000002   0029               CMP      R1,#+0
   \   00000004   04D0               BEQ.N    ??I2C_SoftwareResetCmd_0
    639            {
    640              /* Peripheral under reset */
    641              I2Cx->CR1 |= CR1_SWRST_Set;
   \   00000006   0288               LDRH     R2,[R0, #+0]
   \   00000008   52F40042           ORRS     R2,R2,#0x8000
   \   0000000C   0280               STRH     R2,[R0, #+0]
   \   0000000E   03E0               B.N      ??I2C_SoftwareResetCmd_1
    642            }
    643            else
    644            {
    645              /* Peripheral not under reset */
    646              I2Cx->CR1 &= CR1_SWRST_Reset;
   \                     ??I2C_SoftwareResetCmd_0:
   \   00000010   0288               LDRH     R2,[R0, #+0]
   \   00000012   5204               LSLS     R2,R2,#+17       ;; ZeroExtS R2,R2,#+17,#+17
   \   00000014   520C               LSRS     R2,R2,#+17
   \   00000016   0280               STRH     R2,[R0, #+0]
    647            }
    648          }
   \                     ??I2C_SoftwareResetCmd_1:
   \   00000018   7047               BX       LR               ;; return
    649          
    650          /*******************************************************************************
    651          * Function Name  : I2C_SMBusAlertConfig
    652          * Description    : Drives the SMBusAlert pin high or low for the specified I2C.
    653          * Input          : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    654          *                  - I2C_SMBusAlert: specifies SMBAlert pin level. 
    655          *                    This parameter can be one of the following values:
    656          *                       - I2C_SMBusAlert_Low: SMBAlert pin driven low
    657          *                       - I2C_SMBusAlert_High: SMBAlert pin driven high
    658          * Output         : None
    659          * Return         : None
    660          *******************************************************************************/

   \                                 In section .XML, align 4, keep-with-next
    661          void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, u16 I2C_SMBusAlert)
    662          {
    663            /* Check the parameters */
    664            assert_param(IS_I2C_SMBUS_ALERT(I2C_SMBusAlert));
    665          
    666            if (I2C_SMBusAlert == I2C_SMBusAlert_Low)
   \                     I2C_SMBusAlertConfig:
   \   00000000   5FF40052           MOVS     R2,#+8192
   \   00000004   89B2               UXTH     R1,R1            ;; ZeroExtS R1,R1,#+16,#+16
   \   00000006   9142               CMP      R1,R2
   \   00000008   04D1               BNE.N    ??I2C_SMBusAlertConfig_0
    667            {
    668              /* Drive the SMBusAlert pin Low */
    669              I2Cx->CR1 |= I2C_SMBusAlert_Low;
   \   0000000A   0288               LDRH     R2,[R0, #+0]
   \   0000000C   52F40052           ORRS     R2,R2,#0x2000
   \   00000010   0280               STRH     R2,[R0, #+0]
   \   00000012   03E0               B.N      ??I2C_SMBusAlertConfig_1
    670            }
    671            else
    672            {
    673              /* Drive the SMBusAlert pin High  */
    674              I2Cx->CR1 &= I2C_SMBusAlert_High;
   \                     ??I2C_SMBusAlertConfig_0:
   \   00000014   0288               LDRH     R2,[R0, #+0]
   \   00000016   024B               LDR.N    R3,??I2C_SMBusAlertConfig_2  ;; 0xcfff
   \   00000018   1340               ANDS     R3,R3,R2
   \   0000001A   0380               STRH     R3,[R0, #+0]
    675            }
    676          }
   \                     ??I2C_SMBusAlertConfig_1:
   \   0000001C   7047               BX       LR               ;; return
   \   0000001E   00BF               Nop      
   \                     ??I2C_SMBusAlertConfig_2:
   \   00000020   FFCF0000           DC32     0xcfff
    677          
    678          /*******************************************************************************
    679          * Function Name  : I2C_TransmitPEC
    680          * Description    : Enables or disables the specified I2C PEC transfer.
    681          * Input          : - I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    682          *                  - NewState: new state of the I2C PEC transmission.
    683          *                    This parameter can be: ENABLE or DISABLE.
    684          * Output         : None
    685          * Return         : None
    686          *******************************************************************************/

   \                                 In section .XML, align 4, keep-with-next
    687          void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState)
    688          {
    689            /* Check the parameters */
    690            assert_param(IS_FUNCTIONAL_STATE(NewState));
    691          
    692            if (NewState != DISABLE)
   \                     I2C_TransmitPEC:
   \   00000000   C9B2               UXTB     R1,R1            ;; ZeroExtS R1,R1,#+24,#+24
   \   00000002   0029               CMP      R1,#+0
   \   00000004   04D0               BEQ.N    ??I2C_TransmitPEC_0
    693            {
    694              /* Enable the selected I2C PEC transmission */
    695              I2Cx->CR1 |= CR1_PEC_Set;
   \   00000006   0288               LDRH     R2,[R0, #+0]
   \   00000008   52F48052           ORRS     R2,R2,#0x1000
   \   0000000C   0280               STRH     R2,[R0, #+0]
   \   0000000E   03E0               B.N      ??I2C_TransmitPEC_1
    696            }
    697            else
    698        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -