stm32f10x_i2c.txt

来自「stm32 ucos 精简移殖版本 不需作任何修改直接便可运行。包含串口 定时器」· 文本 代码 · 共 1,113 行 · 第 1/3 页

TXT
1,113
字号
00027e  4770              BX       lr
                  |L1.640|
000280  8801              LDRH     r1,[r0,#0]            ;831
000282  f021f021          BIC      r1,r1,#0x10           ;831
000286  8001              STRH     r1,[r0,#0]            ;831
000288  4770              BX       lr
;;;834    
                          ENDP

                  I2C_StretchClockCmd PROC
;;;849    
;;;850      if (NewState == DISABLE)
00028a  b921              CBNZ     r1,|L1.662|
;;;851      {
;;;852        /* Enable the selected I2C Clock stretching */
;;;853        I2Cx->CR1 |= CR1_NOSTRETCH_Set;
00028c  8801              LDRH     r1,[r0,#0]
00028e  f041f041          ORR      r1,r1,#0x80
000292  8001              STRH     r1,[r0,#0]
;;;854      }
;;;855      else
;;;856      {
;;;857        /* Disable the selected I2C Clock stretching */
;;;858        I2Cx->CR1 &= CR1_NOSTRETCH_Reset;
;;;859      }
;;;860    }
000294  4770              BX       lr
                  |L1.662|
000296  8801              LDRH     r1,[r0,#0]            ;858
000298  f021f021          BIC      r1,r1,#0x80           ;858
00029c  8001              STRH     r1,[r0,#0]            ;858
00029e  4770              BX       lr
;;;861    
                          ENDP

                  I2C_FastModeDutyCycleConfig PROC
;;;878    
;;;879      if (I2C_DutyCycle != I2C_DutyCycle_16_9)
0002a0  f5b1f5b1          CMP      r1,#0x4000
0002a4  d004              BEQ      |L1.688|
;;;880      {
;;;881        /* I2C fast mode Tlow/Thigh=2 */
;;;882        I2Cx->CCR &= I2C_DutyCycle_2;
0002a6  8b81              LDRH     r1,[r0,#0x1c]
0002a8  f421f421          BIC      r1,r1,#0x4000
0002ac  8381              STRH     r1,[r0,#0x1c]
;;;883      }
;;;884      else
;;;885      {
;;;886        /* I2C fast mode Tlow/Thigh=16/9 */
;;;887        I2Cx->CCR |= I2C_DutyCycle_16_9;
;;;888      }
;;;889    }
0002ae  4770              BX       lr
                  |L1.688|
0002b0  8b81              LDRH     r1,[r0,#0x1c]         ;887
0002b2  f441f441          ORR      r1,r1,#0x4000         ;887
0002b6  8381              STRH     r1,[r0,#0x1c]         ;887
0002b8  4770              BX       lr
;;;890    
                          ENDP

                  I2C_GetLastEvent PROC
;;;906      /* Read the I2Cx status register */
;;;907      flag1 = I2Cx->SR1;
0002ba  8a81              LDRH     r1,[r0,#0x14]
;;;908      flag2 = I2Cx->SR2;
0002bc  8b00              LDRH     r0,[r0,#0x18]
;;;909      flag2 = flag2 << 16;
0002be  0400              LSLS     r0,r0,#16
;;;910    
;;;911      /* Get the last event value from I2C status register */
;;;912      lastevent = (flag1 | flag2) & FLAG_Mask;
0002c0  4301              ORRS     r1,r1,r0
0002c2  f021f021          BIC      r0,r1,#0xff000000
;;;913    
;;;914      /* Return status */
;;;915      return lastevent;
;;;916    }
0002c6  4770              BX       lr
;;;917    
                          ENDP

                  I2C_CheckEvent PROC
;;;940    ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, u32 I2C_EVENT)
;;;941    {
0002c8  4602              MOV      r2,r0
;;;942      u32 lastevent = 0;
;;;943      u32 flag1 = 0, flag2 = 0;
;;;944      ErrorStatus status = ERROR;
0002ca  2000              MOVS     r0,#0
;;;945    
;;;946      /* Check the parameters */
;;;947      assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;948      assert_param(IS_I2C_EVENT(I2C_EVENT));
;;;949    
;;;950      /* Read the I2Cx status register */
;;;951      flag1 = I2Cx->SR1;
0002cc  8a93              LDRH     r3,[r2,#0x14]
;;;952      flag2 = I2Cx->SR2;
0002ce  8b12              LDRH     r2,[r2,#0x18]
;;;953      flag2 = flag2 << 16;
0002d0  0412              LSLS     r2,r2,#16
;;;954    
;;;955      /* Get the last event value from I2C status register */
;;;956      lastevent = (flag1 | flag2) & FLAG_Mask;
0002d2  4313              ORRS     r3,r3,r2
0002d4  f023f023          BIC      r2,r3,#0xff000000
;;;957    
;;;958      /* Check whether the last event is equal to I2C_EVENT */
;;;959      if (lastevent == I2C_EVENT )
0002d8  428a              CMP      r2,r1
0002da  d100              BNE      |L1.734|
;;;960      {
;;;961        /* SUCCESS: last event is equal to I2C_EVENT */
;;;962        status = SUCCESS;
0002dc  2001              MOVS     r0,#1
                  |L1.734|
;;;963      }
;;;964      else
;;;965      {
;;;966        /* ERROR: last event is different from I2C_EVENT */
;;;967        status = ERROR;
;;;968      }
;;;969    
;;;970      /* Return status */
;;;971      return status;
;;;972    }
0002de  4770              BX       lr
;;;973    
                          ENDP

                  I2C_GetFlagStatus PROC
;;;1005   FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, u32 I2C_FLAG)
;;;1006   {
0002e0  4602              MOV      r2,r0
;;;1007     FlagStatus bitstatus = RESET;
0002e2  2000              MOVS     r0,#0
;;;1008     u32 i2cstatus = 0;
;;;1009     u32 flag1 = 0, flag2 = 0;
;;;1010   
;;;1011     /* Check the parameters */
;;;1012     assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;1013     assert_param(IS_I2C_GET_FLAG(I2C_FLAG));
;;;1014   
;;;1015     /* Read the I2Cx status register */
;;;1016     flag1 = I2Cx->SR1;
0002e4  8a93              LDRH     r3,[r2,#0x14]
;;;1017     flag2 = I2Cx->SR2;
0002e6  8b12              LDRH     r2,[r2,#0x18]
;;;1018     flag2 = (flag2 & FLAG_Mask) << 16;
0002e8  0412              LSLS     r2,r2,#16
;;;1019   
;;;1020     /* Get the I2C status value */
;;;1021     i2cstatus = flag1 | flag2;
0002ea  4313              ORRS     r3,r3,r2
;;;1022   
;;;1023     /* Get bit[23:0] of the flag */
;;;1024     I2C_FLAG &= FLAG_Mask;
0002ec  f021f021          BIC      r1,r1,#0xff000000
;;;1025   
;;;1026     /* Check the status of the specified I2C flag */
;;;1027     if ((i2cstatus & I2C_FLAG) != (u32)RESET)
0002f0  420b              TST      r3,r1
0002f2  d000              BEQ      |L1.758|
;;;1028     {
;;;1029       /* I2C_FLAG is set */
;;;1030       bitstatus = SET;
0002f4  2001              MOVS     r0,#1
                  |L1.758|
;;;1031     }
;;;1032     else
;;;1033     {
;;;1034       /* I2C_FLAG is reset */
;;;1035       bitstatus = RESET;
;;;1036     }
;;;1037     /* Return the I2C_FLAG status */
;;;1038     return  bitstatus;
;;;1039   }
0002f6  4770              BX       lr
;;;1040   
                          ENDP

                  I2C_ClearFlag PROC
;;;1072     /* Get the I2C flag position */
;;;1073     flagpos = I2C_FLAG & FLAG_Mask;
0002f8  f021f021          BIC      r2,r1,#0xff000000
;;;1074   
;;;1075     /* Get the I2C flag index */
;;;1076     flagindex = I2C_FLAG >> 28;
0002fc  0f09              LSRS     r1,r1,#28
;;;1077   
;;;1078     /* Clear the flag by writing 0 */
;;;1079     if (flagindex == 1)
0002fe  2901              CMP      r1,#1
000300  d102              BNE      |L1.776|
;;;1080     {
;;;1081       /* Clear the selected I2C flag */
;;;1082       I2Cx->SR1 = (u16)~flagpos;
000302  43d1              MVNS     r1,r2
000304  8281              STRH     r1,[r0,#0x14]
;;;1083     }
;;;1084     /* Flags that need a read of the SR1 register to be cleared */
;;;1085     else if (flagindex == 2)
;;;1086     {
;;;1087       /* Read the SR1 register */
;;;1088       (void)I2Cx->SR1;
;;;1089     }
;;;1090     /* Flags that need a read of SR1 and a write on CR1 registers to be cleared */
;;;1091     else if (flagindex == 6)
;;;1092     {
;;;1093       /* Read the SR1 register */
;;;1094       (void)I2Cx->SR1;
;;;1095   
;;;1096       /* Write on the CR1 register */
;;;1097       I2Cx->CR1 |= CR1_PE_Set;
;;;1098     }
;;;1099     /* Flags that need a read of SR1 and SR2 registers to be cleared */
;;;1100     else /*flagindex == 0xA*/
;;;1101     {
;;;1102       /* Read the SR1 register */
;;;1103       (void)I2Cx->SR1;
;;;1104   
;;;1105       /* Read the SR2 register */
;;;1106       (void)I2Cx->SR2;
;;;1107     }
;;;1108   }
000306  4770              BX       lr
                  |L1.776|
000308  2902              CMP      r1,#2                 ;1085
00030a  d101              BNE      |L1.784|
00030c  8a80              LDRH     r0,[r0,#0x14]         ;1088
00030e  4770              BX       lr
                  |L1.784|
000310  2906              CMP      r1,#6                 ;1091
000312  d105              BNE      |L1.800|
000314  8a81              LDRH     r1,[r0,#0x14]         ;1094
000316  8801              LDRH     r1,[r0,#0]            ;1097
000318  f041f041          ORR      r1,r1,#1              ;1097
00031c  8001              STRH     r1,[r0,#0]            ;1097
00031e  4770              BX       lr
                  |L1.800|
000320  8a81              LDRH     r1,[r0,#0x14]         ;1103
000322  8b00              LDRH     r0,[r0,#0x18]         ;1106
000324  4770              BX       lr
;;;1109   
                          ENDP

                  I2C_GetITStatus PROC
;;;1134   ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, u32 I2C_IT)
;;;1135   {
000326  4602              MOV      r2,r0
;;;1136     ITStatus bitstatus = RESET;
000328  2000              MOVS     r0,#0
;;;1137     u32 i2cstatus = 0;
;;;1138     u32 flag1 = 0, flag2 = 0;
;;;1139   
;;;1140     /* Check the parameters */
;;;1141     assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;1142     assert_param(IS_I2C_GET_IT(I2C_IT));
;;;1143   
;;;1144     /* Read the I2Cx status register */
;;;1145     flag1 = I2Cx->SR1;
00032a  8a93              LDRH     r3,[r2,#0x14]
;;;1146     flag2 = I2Cx->SR2;
00032c  8b12              LDRH     r2,[r2,#0x18]
;;;1147     flag2 = (flag2 & FLAG_Mask) << 16;
00032e  0412              LSLS     r2,r2,#16
;;;1148   
;;;1149     /* Get the I2C status value */
;;;1150     i2cstatus = flag1 | flag2;
000330  4313              ORRS     r3,r3,r2
;;;1151   
;;;1152     /* Get bit[23:0] of the flag */
;;;1153     I2C_IT &= FLAG_Mask;
000332  f021f021          BIC      r1,r1,#0xff000000
;;;1154   
;;;1155     /* Check the status of the specified I2C flag */
;;;1156     if ((i2cstatus & I2C_IT) != (u32)RESET)
000336  420b              TST      r3,r1
000338  d000              BEQ      |L1.828|
;;;1157     {
;;;1158       /* I2C_IT is set */
;;;1159       bitstatus = SET;
00033a  2001              MOVS     r0,#1
                  |L1.828|
;;;1160     }
;;;1161     else
;;;1162     {
;;;1163       /* I2C_IT is reset */
;;;1164       bitstatus = RESET;
;;;1165     }
;;;1166     /* Return the I2C_IT status */
;;;1167     return  bitstatus;
;;;1168   }
00033c  4770              BX       lr
;;;1169   
                          ENDP

                  I2C_ClearITPendingBit PROC
;;;1201     /* Get the I2C flag position */
;;;1202     flagpos = I2C_IT & FLAG_Mask;
00033e  f021f021          BIC      r2,r1,#0xff000000
;;;1203   
;;;1204     /* Get the I2C flag index */
;;;1205     flagindex = I2C_IT >> 28;
000342  0f09              LSRS     r1,r1,#28
;;;1206   
;;;1207     /* Clear the flag by writing 0 */
;;;1208     if (flagindex == 1)
000344  2901              CMP      r1,#1
000346  d102              BNE      |L1.846|
;;;1209     {
;;;1210       /* Clear the selected I2C flag */
;;;1211       I2Cx->SR1 = (u16)~flagpos;
000348  43d1              MVNS     r1,r2
00034a  8281              STRH     r1,[r0,#0x14]
;;;1212     }
;;;1213     /* Flags that need a read of the SR1 register to be cleared */
;;;1214     else if (flagindex == 2)
;;;1215     {
;;;1216       /* Read the SR1 register */
;;;1217       (void)I2Cx->SR1;
;;;1218     }
;;;1219     /* Flags that need a read of SR1 and a write on CR1 registers to be cleared */
;;;1220     else if (flagindex == 6)
;;;1221     {
;;;1222       /* Read the SR1 register */
;;;1223       (void)I2Cx->SR1;
;;;1224   
;;;1225       /* Write on the CR1 register */
;;;1226       I2Cx->CR1 |= CR1_PE_Set;
;;;1227     }
;;;1228     /* Flags that need a read of SR1 and SR2 registers to be cleared */
;;;1229     else /*flagindex == 0xA*/
;;;1230     {
;;;1231       /* Read the SR1 register */
;;;1232       (void)I2Cx->SR1;
;;;1233   
;;;1234       /* Read the SR2 register */
;;;1235       (void)I2Cx->SR2;
;;;1236     }
;;;1237   }
00034c  4770              BX       lr
                  |L1.846|
00034e  2902              CMP      r1,#2                 ;1214
000350  d101              BNE      |L1.854|
000352  8a80              LDRH     r0,[r0,#0x14]         ;1217
000354  4770              BX       lr
                  |L1.854|
000356  2906              CMP      r1,#6                 ;1220
000358  d105              BNE      |L1.870|
00035a  8a81              LDRH     r1,[r0,#0x14]         ;1223
00035c  8801              LDRH     r1,[r0,#0]            ;1226
00035e  f041f041          ORR      r1,r1,#1              ;1226
000362  8001              STRH     r1,[r0,#0]            ;1226
000364  4770              BX       lr
                  |L1.870|
000366  8a81              LDRH     r1,[r0,#0x14]         ;1232
000368  8b00              LDRH     r0,[r0,#0x18]         ;1235
00036a  4770              BX       lr
;;;1238   
                          ENDP

                  |L1.876|
00036c  bfffac00          DCD      0xbfffac00
                  |L1.880|
000370  000f4240          DCD      0x000f4240
                  |L1.884|
000374  000186a0          DCD      0x000186a0

⌨️ 快捷键说明

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