📄 stm32f10x_i2c.txt
字号:
;;;805 I2Cx->CR1 &= CR1_ENARP_Reset;
;;;806 }
;;;807 }
00028c 4770 BX lr
|L1.654|
00028e 8801 LDRH r1,[r0,#0]
000290 f021f021 BIC r1,r1,#0x10
000294 8001 STRH r1,[r0,#0]
000296 4770 BX lr
;;;808
ENDP
I2C_StretchClockCmd PROC
;;;822
;;;823 if (NewState == DISABLE)
000298 b921 CBNZ r1,|L1.676|
;;;824 {
;;;825 /* Enable the selected I2C Clock stretching */
;;;826 I2Cx->CR1 |= CR1_NOSTRETCH_Set;
00029a 8801 LDRH r1,[r0,#0]
00029c f041f041 ORR r1,r1,#0x80
0002a0 8001 STRH r1,[r0,#0]
;;;827 }
;;;828 else
;;;829 {
;;;830 /* Disable the selected I2C Clock stretching */
;;;831 I2Cx->CR1 &= CR1_NOSTRETCH_Reset;
;;;832 }
;;;833 }
0002a2 4770 BX lr
|L1.676|
0002a4 8801 LDRH r1,[r0,#0]
0002a6 f021f021 BIC r1,r1,#0x80
0002aa 8001 STRH r1,[r0,#0]
0002ac 4770 BX lr
;;;834
ENDP
I2C_FastModeDutyCycleConfig PROC
;;;850
;;;851 if (I2C_DutyCycle != I2C_DutyCycle_16_9)
0002ae f5b1f5b1 CMP r1,#0x4000
0002b2 d004 BEQ |L1.702|
;;;852 {
;;;853 /* I2C fast mode Tlow/Thigh=2 */
;;;854 I2Cx->CCR &= I2C_DutyCycle_2;
0002b4 8b81 LDRH r1,[r0,#0x1c]
0002b6 f421f421 BIC r1,r1,#0x4000
0002ba 8381 STRH r1,[r0,#0x1c]
;;;855 }
;;;856 else
;;;857 {
;;;858 /* I2C fast mode Tlow/Thigh=16/9 */
;;;859 I2Cx->CCR |= I2C_DutyCycle_16_9;
;;;860 }
;;;861 }
0002bc 4770 BX lr
|L1.702|
0002be 8b81 LDRH r1,[r0,#0x1c]
0002c0 f441f441 ORR r1,r1,#0x4000
0002c4 8381 STRH r1,[r0,#0x1c]
0002c6 4770 BX lr
;;;862
ENDP
I2C_GetLastEvent PROC
;;;874
;;;875 Flag1 = I2Cx->SR1;
0002c8 8a81 LDRH r1,[r0,#0x14]
;;;876 Flag2 = I2Cx->SR2;
0002ca 8b00 LDRH r0,[r0,#0x18]
;;;877 Flag2 = Flag2 << 16;
0002cc 0400 LSLS r0,r0,#16
;;;878
;;;879 /* Get the last event value from I2C status register */
;;;880 LastEvent = (Flag1 | Flag2) & I2C_FLAG_Mask;
0002ce 4308 ORRS r0,r0,r1
0002d0 f020f020 BIC r0,r0,#0xff000000
;;;881
;;;882 /* Return status */
;;;883 return LastEvent;
;;;884 }
0002d4 4770 BX lr
;;;885
ENDP
I2C_CheckEvent PROC
;;;911 u32 Flag1 = 0, Flag2 = 0;
;;;912 ErrorStatus status = ERROR;
0002d6 2200 MOVS r2,#0
;;;913
;;;914 /* Check the parameters */
;;;915 assert(IS_I2C_EVENT(I2C_EVENT));
;;;916
;;;917 Flag1 = I2Cx->SR1;
0002d8 8a83 LDRH r3,[r0,#0x14]
;;;918 Flag2 = I2Cx->SR2;
0002da 8b00 LDRH r0,[r0,#0x18]
;;;919 Flag2 = Flag2 << 16;
0002dc 0400 LSLS r0,r0,#16
;;;920
;;;921 /* Get the last event value from I2C status register */
;;;922 LastEvent = (Flag1 | Flag2) & I2C_FLAG_Mask;
0002de 4318 ORRS r0,r0,r3
0002e0 f020f020 BIC r0,r0,#0xff000000
;;;923
;;;924 /* Check whether the last event is equal to I2C_EVENT */
;;;925 if (LastEvent == I2C_EVENT )
0002e4 4288 CMP r0,r1
0002e6 d100 BNE |L1.746|
;;;926 {
;;;927 /* SUCCESS: last event is equal to I2C_EVENT */
;;;928 status = SUCCESS;
0002e8 2201 MOVS r2,#1
|L1.746|
;;;929 }
;;;930 else
;;;931 {
;;;932 /* ERROR: last event is different from I2C_EVENT */
;;;933 status = ERROR;
;;;934 }
;;;935
;;;936 /* Return status */
;;;937 return status;
0002ea 4610 MOV r0,r2
;;;938 }
0002ec 4770 BX lr
;;;939
ENDP
I2C_GetFlagStatus PROC
;;;972 {
;;;973 FlagStatus bitstatus = RESET;
0002ee 2200 MOVS r2,#0
;;;974 u32 i2cstatus = 0;
;;;975 u32 Flag1 = 0, Flag2 = 0;
;;;976
;;;977 /* Check the parameters */
;;;978 assert(IS_I2C_GET_FLAG(I2C_FLAG));
;;;979
;;;980 /* Read the I2Cx status register */
;;;981 Flag1 = I2Cx->SR1;
0002f0 8a83 LDRH r3,[r0,#0x14]
;;;982 Flag2 = I2Cx->SR2;
0002f2 8b00 LDRH r0,[r0,#0x18]
;;;983 Flag2 = (Flag2 & I2C_FLAG_Mask) << 16;
0002f4 0400 LSLS r0,r0,#16
;;;984
;;;985 /* Get the I2C status value */
;;;986 i2cstatus = Flag1 | Flag2;
0002f6 4318 ORRS r0,r0,r3
;;;987
;;;988 /* Get bit[27:0] of the flag */
;;;989 I2C_FLAG &= I2C_FLAG_Mask;
0002f8 f021f021 BIC r1,r1,#0xff000000
;;;990
;;;991 /* Check the status of the specified I2C flag */
;;;992 if ((i2cstatus & I2C_FLAG) != (u32)RESET)
0002fc 4208 TST r0,r1
0002fe d000 BEQ |L1.770|
;;;993 {
;;;994 /* I2C_FLAG is set */
;;;995 bitstatus = SET;
000300 2201 MOVS r2,#1
|L1.770|
;;;996 }
;;;997 else
;;;998 {
;;;999 /* I2C_FLAG is reset */
;;;1000 bitstatus = RESET;
;;;1001 }
;;;1002 /* Return the I2C_FLAG status */
;;;1003 return bitstatus;
000302 4610 MOV r0,r2
;;;1004 }
000304 4770 BX lr
;;;1005
ENDP
I2C_ClearFlag PROC
;;;1036 /* Get the I2C flag position */
;;;1037 flagpos = I2C_FLAG & I2C_FLAG_Mask;
000306 f021f021 BIC r2,r1,#0xff000000
;;;1038
;;;1039 /* Get the I2C flag index */
;;;1040 flagindex = I2C_FLAG >> 28;
00030a 0f09 LSRS r1,r1,#28
;;;1041
;;;1042 /* Clear the flag by writing 0 */
;;;1043 if (flagindex == 1)
00030c 2901 CMP r1,#1
00030e d103 BNE |L1.792|
;;;1044 {
;;;1045 /* Clear the selected I2C flag */
;;;1046 I2Cx->SR1 &= ~flagpos;
000310 8a81 LDRH r1,[r0,#0x14]
000312 4391 BICS r1,r1,r2
000314 8281 STRH r1,[r0,#0x14]
;;;1047 }
;;;1048 /* Flags that need a read of the SR1 register to be cleared */
;;;1049 else if (flagindex == 2)
;;;1050 {
;;;1051 /* Read the SR1 register */
;;;1052 (void)I2Cx->SR1;
;;;1053 }
;;;1054 /* Flags that need a read of SR1 and a write on CR2 registers to be cleared */
;;;1055 else if (flagindex == 6)
;;;1056 {
;;;1057 /* Read the SR1 register */
;;;1058 (void)I2Cx->SR1;
;;;1059
;;;1060 /* Write on the CR1 register */
;;;1061 I2Cx->CR1 |= CR1_PE_Set;
;;;1062 }
;;;1063 /* Flags that need a read of SR1 and a write on CR2 registers to be cleared */
;;;1064 else /*flagindex == 0xA*/
;;;1065 {
;;;1066 /* Read the SR1 register */
;;;1067 (void)I2Cx->SR1;
;;;1068
;;;1069 /* Read the SR2 register */
;;;1070 (void)I2Cx->SR2;
;;;1071 }
;;;1072 }
000316 4770 BX lr
|L1.792|
000318 2902 CMP r1,#2
00031a d101 BNE |L1.800|
00031c 8a80 LDRH r0,[r0,#0x14]
00031e 4770 BX lr
|L1.800|
000320 2906 CMP r1,#6
000322 d105 BNE |L1.816|
000324 8a81 LDRH r1,[r0,#0x14]
000326 8801 LDRH r1,[r0,#0]
000328 f041f041 ORR r1,r1,#1
00032c 8001 STRH r1,[r0,#0]
00032e 4770 BX lr
|L1.816|
000330 8a81 LDRH r1,[r0,#0x14]
000332 8b00 LDRH r0,[r0,#0x18]
000334 4770 BX lr
;;;1073
ENDP
I2C_GetITStatus PROC
;;;1099 {
;;;1100 ITStatus bitstatus = RESET;
000336 2200 MOVS r2,#0
;;;1101 u32 i2cstatus = 0;
;;;1102 u32 Flag1 = 0, Flag2 = 0;
;;;1103
;;;1104 /* Check the parameters */
;;;1105 assert(IS_I2C_GET_IT(I2C_IT));
;;;1106
;;;1107 /* Read the I2Cx status register */
;;;1108 Flag1 = I2Cx->SR1;
000338 8a83 LDRH r3,[r0,#0x14]
;;;1109 Flag2 = I2Cx->SR2;
00033a 8b00 LDRH r0,[r0,#0x18]
;;;1110 Flag2 = (Flag2 & I2C_FLAG_Mask) << 16;
00033c 0400 LSLS r0,r0,#16
;;;1111
;;;1112 /* Get the I2C status value */
;;;1113 i2cstatus = Flag1 | Flag2;
00033e 4318 ORRS r0,r0,r3
;;;1114
;;;1115 /* Get bit[27:0] of the flag */
;;;1116 I2C_IT &= I2C_FLAG_Mask;
000340 f021f021 BIC r1,r1,#0xff000000
;;;1117
;;;1118 /* Check the status of the specified I2C flag */
;;;1119 if ((i2cstatus & I2C_IT) != (u32)RESET)
000344 4208 TST r0,r1
000346 d000 BEQ |L1.842|
;;;1120 {
;;;1121 /* I2C_IT is set */
;;;1122 bitstatus = SET;
000348 2201 MOVS r2,#1
|L1.842|
;;;1123 }
;;;1124 else
;;;1125 {
;;;1126 /* I2C_IT is reset */
;;;1127 bitstatus = RESET;
;;;1128 }
;;;1129 /* Return the I2C_IT status */
;;;1130 return bitstatus;
00034a 4610 MOV r0,r2
;;;1131 }
00034c 4770 BX lr
;;;1132
ENDP
I2C_ClearITPendingBit PROC
;;;1163 /* Get the I2C flag position */
;;;1164 flagpos = I2C_IT & I2C_FLAG_Mask;
00034e f021f021 BIC r2,r1,#0xff000000
;;;1165
;;;1166 /* Get the I2C flag index */
;;;1167 flagindex = I2C_IT >> 28;
000352 0f09 LSRS r1,r1,#28
;;;1168
;;;1169 /* Clear the flag by writing 0 */
;;;1170 if (flagindex == 1)
000354 2901 CMP r1,#1
000356 d103 BNE |L1.864|
;;;1171 {
;;;1172 /* Clear the selected I2C flag */
;;;1173 I2Cx->SR1 &= ~flagpos;
000358 8a81 LDRH r1,[r0,#0x14]
00035a 4391 BICS r1,r1,r2
00035c 8281 STRH r1,[r0,#0x14]
;;;1174 }
;;;1175 /* Flags that need a read of the SR1 register to be cleared */
;;;1176 else if (flagindex == 2)
;;;1177 {
;;;1178 /* Read the SR1 register */
;;;1179 (void)I2Cx->SR1;
;;;1180 }
;;;1181 /* Flags that need a read of SR1 and a write on CR2 registers to be cleared */
;;;1182 else if (flagindex == 6)
;;;1183 {
;;;1184 /* Read the SR1 register */
;;;1185 (void)I2Cx->SR1;
;;;1186
;;;1187 /* Write on the CR1 register */
;;;1188 I2Cx->CR1 |= CR1_PE_Set;
;;;1189 }
;;;1190 /* Flags that need a read of SR1 and a write on CR2 registers to be cleared */
;;;1191 else /*flagindex == 0xA*/
;;;1192 {
;;;1193 /* Read the SR1 register */
;;;1194 (void)I2Cx->SR1;
;;;1195
;;;1196 /* Read the SR2 register */
;;;1197 (void)I2Cx->SR2;
;;;1198 }
;;;1199 }
00035e 4770 BX lr
|L1.864|
000360 2902 CMP r1,#2
000362 d101 BNE |L1.872|
000364 8a80 LDRH r0,[r0,#0x14]
000366 4770 BX lr
|L1.872|
000368 2906 CMP r1,#6
00036a d105 BNE |L1.888|
00036c 8a81 LDRH r1,[r0,#0x14]
00036e 8801 LDRH r1,[r0,#0]
000370 f041f041 ORR r1,r1,#1
000374 8001 STRH r1,[r0,#0]
000376 4770 BX lr
|L1.888|
000378 8a81 LDRH r1,[r0,#0x14]
00037a 8b00 LDRH r0,[r0,#0x18]
00037c 4770 BX lr
;;;1200
ENDP
00037e 0000 DCW 0x0000
|L1.896|
000380 000f4240 DCD 0x000f4240
|L1.900|
000384 000186a0 DCD 0x000186a0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -