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

📄 stm32f10x_i2c.txt

📁 STM32外部SRAM用作datamemery的程序 开发环境MDK
💻 TXT
📖 第 1 页 / 共 3 页
字号:
;;;823        /* Enable the selected I2C ARP */
;;;824        I2Cx->CR1 |= CR1_ENARP_Set;
000002  8801              LDRH     r1,[r0,#0]
000004  d002              BEQ      |L24.12|
000006  f041f041          ORR      r1,r1,#0x10
00000a  e001              B        |L24.16|
                  |L24.12|
;;;825      }
;;;826      else
;;;827      {
;;;828        /* Disable the selected I2C ARP */
;;;829        I2Cx->CR1 &= CR1_ENARP_Reset;
00000c  f021f021          BIC      r1,r1,#0x10
                  |L24.16|
000010  8001              STRH     r1,[r0,#0]            ;824
;;;830      }
;;;831    }
000012  4770              BX       lr
;;;832    
                          ENDP


                          AREA ||i.I2C_StretchClockCmd||, CODE, READONLY, ALIGN=1

                  I2C_StretchClockCmd PROC
;;;847    
;;;848      if (NewState == DISABLE)
000000  2900              CMP      r1,#0
;;;849      {
;;;850        /* Enable the selected I2C Clock stretching */
;;;851        I2Cx->CR1 |= CR1_NOSTRETCH_Set;
000002  8801              LDRH     r1,[r0,#0]
000004  d102              BNE      |L25.12|
000006  f041f041          ORR      r1,r1,#0x80
00000a  e001              B        |L25.16|
                  |L25.12|
;;;852      }
;;;853      else
;;;854      {
;;;855        /* Disable the selected I2C Clock stretching */
;;;856        I2Cx->CR1 &= CR1_NOSTRETCH_Reset;
00000c  f021f021          BIC      r1,r1,#0x80
                  |L25.16|
000010  8001              STRH     r1,[r0,#0]            ;851
;;;857      }
;;;858    }
000012  4770              BX       lr
;;;859    
                          ENDP


                          AREA ||i.I2C_FastModeDutyCycleConfig||, CODE, READONLY, ALIGN=1

                  I2C_FastModeDutyCycleConfig PROC
;;;876    
;;;877      if (I2C_DutyCycle != I2C_DutyCycle_16_9)
000000  f5b1f5b1          CMP      r1,#0x4000
;;;878      {
;;;879        /* I2C fast mode Tlow/Thigh=2 */
;;;880        I2Cx->CCR &= I2C_DutyCycle_2;
000004  8b81              LDRH     r1,[r0,#0x1c]
000006  d002              BEQ      |L26.14|
000008  f421f421          BIC      r1,r1,#0x4000
00000c  e001              B        |L26.18|
                  |L26.14|
;;;881      }
;;;882      else
;;;883      {
;;;884        /* I2C fast mode Tlow/Thigh=16/9 */
;;;885        I2Cx->CCR |= I2C_DutyCycle_16_9;
00000e  f441f441          ORR      r1,r1,#0x4000
                  |L26.18|
000012  8381              STRH     r1,[r0,#0x1c]         ;880
;;;886      }
;;;887    }
000014  4770              BX       lr
;;;888    
                          ENDP


                          AREA ||i.I2C_GetLastEvent||, CODE, READONLY, ALIGN=1

                  I2C_GetLastEvent PROC
;;;904      /* Read the I2Cx status register */
;;;905      flag1 = I2Cx->SR1;
000000  8a81              LDRH     r1,[r0,#0x14]
;;;906      flag2 = I2Cx->SR2;
000002  8b00              LDRH     r0,[r0,#0x18]
;;;907      flag2 = flag2 << 16;
;;;908    
;;;909      /* Get the last event value from I2C status register */
;;;910      lastevent = (flag1 | flag2) & FLAG_Mask;
000004  ea41ea41          ORR      r1,r1,r0,LSL #16
000008  f021f021          BIC      r0,r1,#0xff000000
;;;911    
;;;912      /* Return status */
;;;913      return lastevent;
;;;914    }
00000c  4770              BX       lr
;;;915    
                          ENDP


                          AREA ||i.I2C_CheckEvent||, CODE, READONLY, ALIGN=1

                  I2C_CheckEvent PROC
;;;938    ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, u32 I2C_EVENT)
;;;939    {
000000  4602              MOV      r2,r0
;;;940      u32 lastevent = 0;
;;;941      u32 flag1 = 0, flag2 = 0;
;;;942      ErrorStatus status = ERROR;
;;;943    
;;;944      /* Check the parameters */
;;;945      assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;946      assert_param(IS_I2C_EVENT(I2C_EVENT));
;;;947    
;;;948      /* Read the I2Cx status register */
;;;949      flag1 = I2Cx->SR1;
000002  8a93              LDRH     r3,[r2,#0x14]
000004  2000              MOVS     r0,#0                 ;942
;;;950      flag2 = I2Cx->SR2;
000006  8b12              LDRH     r2,[r2,#0x18]
;;;951      flag2 = flag2 << 16;
;;;952    
;;;953      /* Get the last event value from I2C status register */
;;;954      lastevent = (flag1 | flag2) & FLAG_Mask;
000008  ea43ea43          ORR      r3,r3,r2,LSL #16
00000c  f023f023          BIC      r2,r3,#0xff000000
;;;955    
;;;956      /* Check whether the last event is equal to I2C_EVENT */
;;;957      if (lastevent == I2C_EVENT )
000010  428a              CMP      r2,r1
000012  d100              BNE      |L28.22|
;;;958      {
;;;959        /* SUCCESS: last event is equal to I2C_EVENT */
;;;960        status = SUCCESS;
000014  2001              MOVS     r0,#1
                  |L28.22|
;;;961      }
;;;962      else
;;;963      {
;;;964        /* ERROR: last event is different from I2C_EVENT */
;;;965        status = ERROR;
;;;966      }
;;;967    
;;;968      /* Return status */
;;;969      return status;
;;;970    }
000016  4770              BX       lr
;;;971    
                          ENDP


                          AREA ||i.I2C_GetFlagStatus||, CODE, READONLY, ALIGN=1

                  I2C_GetFlagStatus PROC
;;;1003   FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, u32 I2C_FLAG)
;;;1004   {
000000  4602              MOV      r2,r0
;;;1005     FlagStatus bitstatus = RESET;
;;;1006     u32 i2cstatus = 0;
;;;1007     u32 flag1 = 0, flag2 = 0;
;;;1008   
;;;1009     /* Check the parameters */
;;;1010     assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;1011     assert_param(IS_I2C_GET_FLAG(I2C_FLAG));
;;;1012   
;;;1013     /* Read the I2Cx status register */
;;;1014     flag1 = I2Cx->SR1;
000002  8a93              LDRH     r3,[r2,#0x14]
000004  2000              MOVS     r0,#0                 ;1005
;;;1015     flag2 = I2Cx->SR2;
000006  8b12              LDRH     r2,[r2,#0x18]
;;;1016     flag2 = (flag2 & FLAG_Mask) << 16;
;;;1017   
;;;1018     /* Get the I2C status value */
;;;1019     i2cstatus = flag1 | flag2;
;;;1020   
;;;1021     /* Get bit[23:0] of the flag */
;;;1022     I2C_FLAG &= FLAG_Mask;
000008  f021f021          BIC      r1,r1,#0xff000000
00000c  ea43ea43          ORR      r3,r3,r2,LSL #16      ;1019
;;;1023   
;;;1024     /* Check the status of the specified I2C flag */
;;;1025     if ((i2cstatus & I2C_FLAG) != (u32)RESET)
000010  420b              TST      r3,r1
000012  d000              BEQ      |L29.22|
;;;1026     {
;;;1027       /* I2C_FLAG is set */
;;;1028       bitstatus = SET;
000014  2001              MOVS     r0,#1
                  |L29.22|
;;;1029     }
;;;1030     else
;;;1031     {
;;;1032       /* I2C_FLAG is reset */
;;;1033       bitstatus = RESET;
;;;1034     }
;;;1035     /* Return the I2C_FLAG status */
;;;1036     return  bitstatus;
;;;1037   }
000016  4770              BX       lr
;;;1038   
                          ENDP


                          AREA ||i.I2C_ClearFlag||, CODE, READONLY, ALIGN=1

                  I2C_ClearFlag PROC
;;;1070     /* Get the I2C flag position */
;;;1071     flagpos = I2C_FLAG & FLAG_Mask;
000000  f021f021          BIC      r2,r1,#0xff000000
;;;1072   
;;;1073     /* Get the I2C flag index */
;;;1074     flagindex = I2C_FLAG >> 28;
000004  0f09              LSRS     r1,r1,#28
;;;1075   
;;;1076     /* Clear the flag by writing 0 */
;;;1077     if (flagindex == 1)
000006  2901              CMP      r1,#1
000008  d102              BNE      |L30.16|
;;;1078     {
;;;1079       /* Clear the selected I2C flag */
;;;1080       I2Cx->SR1 = (u16)~flagpos;
00000a  43d1              MVNS     r1,r2
00000c  8281              STRH     r1,[r0,#0x14]
;;;1081     }
;;;1082     /* Flags that need a read of the SR1 register to be cleared */
;;;1083     else if (flagindex == 2)
;;;1084     {
;;;1085       /* Read the SR1 register */
;;;1086       (void)I2Cx->SR1;
;;;1087     }
;;;1088     /* Flags that need a read of SR1 and a write on CR1 registers to be cleared */
;;;1089     else if (flagindex == 6)
;;;1090     {
;;;1091       /* Read the SR1 register */
;;;1092       (void)I2Cx->SR1;
;;;1093   
;;;1094       /* Write on the CR1 register */
;;;1095       I2Cx->CR1 |= CR1_PE_Set;
;;;1096     }
;;;1097     /* Flags that need a read of SR1 and SR2 registers to be cleared */
;;;1098     else /*flagindex == 0xA*/
;;;1099     {
;;;1100       /* Read the SR1 register */
;;;1101       (void)I2Cx->SR1;
;;;1102   
;;;1103       /* Read the SR2 register */
;;;1104       (void)I2Cx->SR2;
;;;1105     }
;;;1106   }
00000e  4770              BX       lr
                  |L30.16|
000010  2902              CMP      r1,#2                 ;1083
000012  d101              BNE      |L30.24|
000014  8a80              LDRH     r0,[r0,#0x14]         ;1086
000016  4770              BX       lr
                  |L30.24|
000018  2906              CMP      r1,#6                 ;1089
00001a  8a81              LDRH     r1,[r0,#0x14]         ;1092
00001c  d104              BNE      |L30.40|
00001e  8801              LDRH     r1,[r0,#0]            ;1095
000020  f041f041          ORR      r1,r1,#1              ;1095
000024  8001              STRH     r1,[r0,#0]            ;1095
000026  4770              BX       lr
                  |L30.40|
000028  8b00              LDRH     r0,[r0,#0x18]         ;1104
00002a  4770              BX       lr
;;;1107   
                          ENDP


                          AREA ||i.I2C_GetITStatus||, CODE, READONLY, ALIGN=1

                  I2C_GetITStatus PROC
;;;1132   ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, u32 I2C_IT)
;;;1133   {
000000  4602              MOV      r2,r0
;;;1134     ITStatus bitstatus = RESET;
;;;1135     u32 i2cstatus = 0;
;;;1136     u32 flag1 = 0, flag2 = 0;
;;;1137   
;;;1138     /* Check the parameters */
;;;1139     assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;1140     assert_param(IS_I2C_GET_IT(I2C_IT));
;;;1141   
;;;1142     /* Read the I2Cx status register */
;;;1143     flag1 = I2Cx->SR1;
000002  8a93              LDRH     r3,[r2,#0x14]
000004  2000              MOVS     r0,#0                 ;1134
;;;1144     flag2 = I2Cx->SR2;
000006  8b12              LDRH     r2,[r2,#0x18]
;;;1145     flag2 = (flag2 & FLAG_Mask) << 16;
;;;1146   
;;;1147     /* Get the I2C status value */
;;;1148     i2cstatus = flag1 | flag2;
;;;1149   
;;;1150     /* Get bit[23:0] of the flag */
;;;1151     I2C_IT &= FLAG_Mask;
000008  f021f021          BIC      r1,r1,#0xff000000
00000c  ea43ea43          ORR      r3,r3,r2,LSL #16      ;1148
;;;1152   
;;;1153     /* Check the status of the specified I2C flag */
;;;1154     if ((i2cstatus & I2C_IT) != (u32)RESET)
000010  420b              TST      r3,r1
000012  d000              BEQ      |L31.22|
;;;1155     {
;;;1156       /* I2C_IT is set */
;;;1157       bitstatus = SET;
000014  2001              MOVS     r0,#1
                  |L31.22|
;;;1158     }
;;;1159     else
;;;1160     {
;;;1161       /* I2C_IT is reset */
;;;1162       bitstatus = RESET;
;;;1163     }
;;;1164     /* Return the I2C_IT status */
;;;1165     return  bitstatus;
;;;1166   }
000016  4770              BX       lr
;;;1167   
                          ENDP


                          AREA ||i.I2C_ClearITPendingBit||, CODE, READONLY, ALIGN=1

                  I2C_ClearITPendingBit PROC
;;;1199     /* Get the I2C flag position */
;;;1200     flagpos = I2C_IT & FLAG_Mask;
000000  f021f021          BIC      r2,r1,#0xff000000
;;;1201   
;;;1202     /* Get the I2C flag index */
;;;1203     flagindex = I2C_IT >> 28;
000004  0f09              LSRS     r1,r1,#28
;;;1204   
;;;1205     /* Clear the flag by writing 0 */
;;;1206     if (flagindex == 1)
000006  2901              CMP      r1,#1
000008  d102              BNE      |L32.16|
;;;1207     {
;;;1208       /* Clear the selected I2C flag */
;;;1209       I2Cx->SR1 = (u16)~flagpos;
00000a  43d1              MVNS     r1,r2
00000c  8281              STRH     r1,[r0,#0x14]
;;;1210     }
;;;1211     /* Flags that need a read of the SR1 register to be cleared */
;;;1212     else if (flagindex == 2)
;;;1213     {
;;;1214       /* Read the SR1 register */
;;;1215       (void)I2Cx->SR1;
;;;1216     }
;;;1217     /* Flags that need a read of SR1 and a write on CR1 registers to be cleared */
;;;1218     else if (flagindex == 6)
;;;1219     {
;;;1220       /* Read the SR1 register */
;;;1221       (void)I2Cx->SR1;
;;;1222   
;;;1223       /* Write on the CR1 register */
;;;1224       I2Cx->CR1 |= CR1_PE_Set;
;;;1225     }
;;;1226     /* Flags that need a read of SR1 and SR2 registers to be cleared */
;;;1227     else /*flagindex == 0xA*/
;;;1228     {
;;;1229       /* Read the SR1 register */
;;;1230       (void)I2Cx->SR1;
;;;1231   
;;;1232       /* Read the SR2 register */
;;;1233       (void)I2Cx->SR2;
;;;1234     }
;;;1235   }
00000e  4770              BX       lr
                  |L32.16|
000010  2902              CMP      r1,#2                 ;1212
000012  d101              BNE      |L32.24|
000014  8a80              LDRH     r0,[r0,#0x14]         ;1215
000016  4770              BX       lr
                  |L32.24|
000018  2906              CMP      r1,#6                 ;1218
00001a  8a81              LDRH     r1,[r0,#0x14]         ;1221
00001c  d104              BNE      |L32.40|
00001e  8801              LDRH     r1,[r0,#0]            ;1224
000020  f041f041          ORR      r1,r1,#1              ;1224
000024  8001              STRH     r1,[r0,#0]            ;1224
000026  4770              BX       lr
                  |L32.40|
000028  8b00              LDRH     r0,[r0,#0x18]         ;1233
00002a  4770              BX       lr
;;;1236   
                          ENDP

⌨️ 快捷键说明

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