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

📄 stm32f10x_i2c.lst

📁 stm32+ucos-ii
💻 LST
📖 第 1 页 / 共 5 页
字号:
    461            * @param  Address: specifies the 7bit I2C own address2.
    462            * @retval None.
    463            */

   \                                 In section .text, align 2, keep-with-next
    464          void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, uint8_t Address)
    465          {
    466            uint16_t tmpreg = 0;
   \                     I2C_OwnAddress2Config:
   \   00000000   0022               MOVS     R2,#+0
    467          
    468            /* Check the parameters */
    469            assert_param(IS_I2C_ALL_PERIPH(I2Cx));
    470          
    471            /* Get the old register value */
    472            tmpreg = I2Cx->OAR2;
   \   00000002   8389               LDRH     R3,[R0, #+12]
   \   00000004   1A00               MOVS     R2,R3
    473          
    474            /* Reset I2Cx Own address2 bit [7:1] */
    475            tmpreg &= OAR2_ADD2_Reset;
   \   00000006   4FF60173           MOVW     R3,#+65281
   \   0000000A   1A40               ANDS     R2,R3,R2
    476          
    477            /* Set I2Cx Own address2 */
    478            tmpreg |= (uint16_t)((uint16_t)Address & (uint16_t)0x00FE);
   \   0000000C   C9B2               UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
   \   0000000E   11F0FE03           ANDS     R3,R1,#0xFE
   \   00000012   1A43               ORRS     R2,R3,R2
    479          
    480            /* Store the new register value */
    481            I2Cx->OAR2 = tmpreg;
   \   00000014   8281               STRH     R2,[R0, #+12]
    482          }
   \   00000016   7047               BX       LR               ;; return
    483          
    484          /**
    485            * @brief  Enables or disables the specified I2C dual addressing mode.
    486            * @param  I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    487            * @param  NewState: new state of the I2C dual addressing mode.
    488            *   This parameter can be: ENABLE or DISABLE.
    489            * @retval None
    490            */

   \                                 In section .text, align 2, keep-with-next
    491          void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
    492          {
    493            /* Check the parameters */
    494            assert_param(IS_I2C_ALL_PERIPH(I2Cx));
    495            assert_param(IS_FUNCTIONAL_STATE(NewState));
    496            if (NewState != DISABLE)
   \                     I2C_DualAddressCmd:
   \   00000000   C9B2               UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
   \   00000002   0029               CMP      R1,#+0
   \   00000004   04D0               BEQ.N    ??I2C_DualAddressCmd_0
    497            {
    498              /* Enable dual addressing mode */
    499              I2Cx->OAR2 |= OAR2_ENDUAL_Set;
   \   00000006   8289               LDRH     R2,[R0, #+12]
   \   00000008   52F00102           ORRS     R2,R2,#0x1
   \   0000000C   8281               STRH     R2,[R0, #+12]
   \   0000000E   04E0               B.N      ??I2C_DualAddressCmd_1
    500            }
    501            else
    502            {
    503              /* Disable dual addressing mode */
    504              I2Cx->OAR2 &= OAR2_ENDUAL_Reset;
   \                     ??I2C_DualAddressCmd_0:
   \   00000010   8289               LDRH     R2,[R0, #+12]
   \   00000012   4FF6FE73           MOVW     R3,#+65534
   \   00000016   1A40               ANDS     R2,R3,R2
   \   00000018   8281               STRH     R2,[R0, #+12]
    505            }
    506          }
   \                     ??I2C_DualAddressCmd_1:
   \   0000001A   7047               BX       LR               ;; return
    507          
    508          /**
    509            * @brief  Enables or disables the specified I2C general call feature.
    510            * @param  I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    511            * @param  NewState: new state of the I2C General call.
    512            *   This parameter can be: ENABLE or DISABLE.
    513            * @retval None
    514            */

   \                                 In section .text, align 2, keep-with-next
    515          void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
    516          {
    517            /* Check the parameters */
    518            assert_param(IS_I2C_ALL_PERIPH(I2Cx));
    519            assert_param(IS_FUNCTIONAL_STATE(NewState));
    520            if (NewState != DISABLE)
   \                     I2C_GeneralCallCmd:
   \   00000000   C9B2               UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
   \   00000002   0029               CMP      R1,#+0
   \   00000004   04D0               BEQ.N    ??I2C_GeneralCallCmd_0
    521            {
    522              /* Enable generall call */
    523              I2Cx->CR1 |= CR1_ENGC_Set;
   \   00000006   0288               LDRH     R2,[R0, #+0]
   \   00000008   52F04002           ORRS     R2,R2,#0x40
   \   0000000C   0280               STRH     R2,[R0, #+0]
   \   0000000E   04E0               B.N      ??I2C_GeneralCallCmd_1
    524            }
    525            else
    526            {
    527              /* Disable generall call */
    528              I2Cx->CR1 &= CR1_ENGC_Reset;
   \                     ??I2C_GeneralCallCmd_0:
   \   00000010   0288               LDRH     R2,[R0, #+0]
   \   00000012   4FF6BF73           MOVW     R3,#+65471
   \   00000016   1A40               ANDS     R2,R3,R2
   \   00000018   0280               STRH     R2,[R0, #+0]
    529            }
    530          }
   \                     ??I2C_GeneralCallCmd_1:
   \   0000001A   7047               BX       LR               ;; return
    531          
    532          /**
    533            * @brief  Enables or disables the specified I2C interrupts.
    534            * @param  I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    535            * @param  I2C_IT: specifies the I2C interrupts sources to be enabled or disabled. 
    536            *   This parameter can be any combination of the following values:
    537            *     @arg I2C_IT_BUF: Buffer interrupt mask
    538            *     @arg I2C_IT_EVT: Event interrupt mask
    539            *     @arg I2C_IT_ERR: Error interrupt mask
    540            * @param  NewState: new state of the specified I2C interrupts.
    541            *   This parameter can be: ENABLE or DISABLE.
    542            * @retval None
    543            */

   \                                 In section .text, align 2, keep-with-next
    544          void I2C_ITConfig(I2C_TypeDef* I2Cx, uint16_t I2C_IT, FunctionalState NewState)
    545          {
    546            /* Check the parameters */
    547            assert_param(IS_I2C_ALL_PERIPH(I2Cx));
    548            assert_param(IS_FUNCTIONAL_STATE(NewState));
    549            assert_param(IS_I2C_CONFIG_IT(I2C_IT));
    550            
    551            if (NewState != DISABLE)
   \                     I2C_ITConfig:
   \   00000000   D2B2               UXTB     R2,R2            ;; ZeroExt  R2,R2,#+24,#+24
   \   00000002   002A               CMP      R2,#+0
   \   00000004   03D0               BEQ.N    ??I2C_ITConfig_0
    552            {
    553              /* Enable the selected I2C interrupts */
    554              I2Cx->CR2 |= I2C_IT;
   \   00000006   8388               LDRH     R3,[R0, #+4]
   \   00000008   0B43               ORRS     R3,R1,R3
   \   0000000A   8380               STRH     R3,[R0, #+4]
   \   0000000C   02E0               B.N      ??I2C_ITConfig_1
    555            }
    556            else
    557            {
    558              /* Disable the selected I2C interrupts */
    559              I2Cx->CR2 &= (uint16_t)~I2C_IT;
   \                     ??I2C_ITConfig_0:
   \   0000000E   8388               LDRH     R3,[R0, #+4]
   \   00000010   8B43               BICS     R3,R3,R1
   \   00000012   8380               STRH     R3,[R0, #+4]
    560            }
    561          }
   \                     ??I2C_ITConfig_1:
   \   00000014   7047               BX       LR               ;; return
    562          
    563          /**
    564            * @brief  Sends a data byte through the I2Cx peripheral.
    565            * @param  I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    566            * @param  Data: Byte to be transmitted..
    567            * @retval None
    568            */

   \                                 In section .text, align 2, keep-with-next
    569          void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data)
    570          {
    571            /* Check the parameters */
    572            assert_param(IS_I2C_ALL_PERIPH(I2Cx));
    573            /* Write in the DR register the data to be sent */
    574            I2Cx->DR = Data;
   \                     I2C_SendData:
   \   00000000   C9B2               UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
   \   00000002   0182               STRH     R1,[R0, #+16]
    575          }
   \   00000004   7047               BX       LR               ;; return
    576          
    577          /**
    578            * @brief  Returns the most recent received data by the I2Cx peripheral.
    579            * @param  I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    580            * @retval The value of the received data.
    581            */

   \                                 In section .text, align 2, keep-with-next
    582          uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx)
    583          {
    584            /* Check the parameters */
    585            assert_param(IS_I2C_ALL_PERIPH(I2Cx));
    586            /* Return the data in the DR register */
    587            return (uint8_t)I2Cx->DR;
   \                     I2C_ReceiveData:
   \   00000000   008A               LDRH     R0,[R0, #+16]
   \   00000002   C0B2               UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
   \   00000004   7047               BX       LR               ;; return
    588          }
    589          
    590          /**
    591            * @brief  Transmits the address byte to select the slave device.
    592            * @param  I2Cx: where x can be 1 or 2 to select the I2C peripheral.
    593            * @param  Address: specifies the slave address which will be transmitted
    594            * @param  I2C_Direction: specifies whether the I2C device will be a
    595            *   Transmitter or a Receiver. This parameter can be one of the following values
    596            *     @arg I2C_Direction_Transmitter: Transmitter mode
    597            *     @arg I2C_Direction_Receiver: Receiver mode
    598            * @retval None.
    599            */

   \                                 In section .text, align 2, keep-with-next
    600          void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction)
    601          {
    602            /* Check the parameters */
    603            assert_param(IS_I2C_ALL_PERIPH(I2Cx));
    604            assert_param(IS_I2C_DIRECTION(I2C_Direction));
    605            /* Test on the direction to set/reset the read/write bit */
    606            if (I2C_Direction != I2C_Direction_Transmitter)
   \                     I2C_Send7bitAddress:
   \   00000000   D2B2               UXTB     R2,R2            ;; ZeroExt  R2,R2,#+24,#+24
   \   00000002   002A               CMP      R2,#+0
   \   00000004   02D0               BEQ.N    ??I2C_Send7bitAddress_0
    607            {
    608              /* Set the address bit0 for read */
    609              Address |= OAR1_ADD0_Set;
   \   00000006   51F00101           ORRS     R1,R1,#0x1
   \   0000000A   01E0               B.N      ??I2C_Send7bitAddress_1
    610            }
    611            else
    612            {
    613              /* Reset the address bit0 for write */
    614              Address &= OAR1_ADD0_Reset;
   \                     ??I2C_Send7bitAddress_0:
   \   0000000C   11F0FE01           ANDS     R1,R1,#0xFE
    615            }
    616            /* Send the address */
    617            I2Cx->DR = Address;
   \                     ??I2C_Send7bitAddress_1:
   \   00000010   C9B2               UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
   \   00000012   0182               STRH     R1,[R0, #+16]
    618          }
   \   00000014   7047               BX       LR               ;; return
    619          
    620          /**
    621            * @brief  Reads the specified I2C register and returns its value.

⌨️ 快捷键说明

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