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

📄 stm8s_i2c.ls

📁 STM8-触摸例程
💻 LS
📖 第 1 页 / 共 3 页
字号:
 615                     ; 251   if (NewState != DISABLE)
 617  0153 4d            	tnz	a
 618  0154 2705          	jreq	L512
 619                     ; 254     I2C->CR1 |= I2C_CR1_ENGC;
 621  0156 721c5210      	bset	21008,#6
 624  015a 81            	ret	
 625  015b               L512:
 626                     ; 259     I2C->CR1 &= (u8)(~I2C_CR1_ENGC);
 628  015b 721d5210      	bres	21008,#6
 629                     ; 261 }
 632  015f 81            	ret	
 667                     ; 278 void I2C_GenerateSTART(FunctionalState NewState)
 667                     ; 279 {
 668                     	switch	.text
 669  0160               _I2C_GenerateSTART:
 673                     ; 282   assert_param(IS_FUNCTIONALSTATE_OK(NewState));
 675                     ; 284   if (NewState != DISABLE)
 677  0160 4d            	tnz	a
 678  0161 2705          	jreq	L732
 679                     ; 287     I2C->CR2 |= I2C_CR2_START;
 681  0163 72105211      	bset	21009,#0
 684  0167 81            	ret	
 685  0168               L732:
 686                     ; 292     I2C->CR2 &= (u8)(~I2C_CR2_START);
 688  0168 72115211      	bres	21009,#0
 689                     ; 295 }
 692  016c 81            	ret	
 727                     ; 312 void I2C_GenerateSTOP(FunctionalState NewState)
 727                     ; 313 {
 728                     	switch	.text
 729  016d               _I2C_GenerateSTOP:
 733                     ; 316   assert_param(IS_FUNCTIONALSTATE_OK(NewState));
 735                     ; 318   if (NewState != DISABLE)
 737  016d 4d            	tnz	a
 738  016e 2705          	jreq	L162
 739                     ; 321     I2C->CR2 |= I2C_CR2_STOP;
 741  0170 72125211      	bset	21009,#1
 744  0174 81            	ret	
 745  0175               L162:
 746                     ; 326     I2C->CR2 &= (u8)(~I2C_CR2_STOP);
 748  0175 72135211      	bres	21009,#1
 749                     ; 329 }
 752  0179 81            	ret	
 788                     ; 346 void I2C_SoftwareResetCmd(FunctionalState NewState)
 788                     ; 347 {
 789                     	switch	.text
 790  017a               _I2C_SoftwareResetCmd:
 794                     ; 349   assert_param(IS_FUNCTIONALSTATE_OK(NewState));
 796                     ; 351   if (NewState != DISABLE)
 798  017a 4d            	tnz	a
 799  017b 2705          	jreq	L303
 800                     ; 354     I2C->CR2 |= I2C_CR2_SWRST;
 802  017d 721e5211      	bset	21009,#7
 805  0181 81            	ret	
 806  0182               L303:
 807                     ; 359     I2C->CR2 &= (u8)(~I2C_CR2_SWRST);
 809  0182 721f5211      	bres	21009,#7
 810                     ; 361 }
 813  0186 81            	ret	
 849                     ; 379 void I2C_StretchClockCmd(FunctionalState NewState)
 849                     ; 380 {
 850                     	switch	.text
 851  0187               _I2C_StretchClockCmd:
 855                     ; 382   assert_param(IS_FUNCTIONALSTATE_OK(NewState));
 857                     ; 384   if (NewState != DISABLE)
 859  0187 4d            	tnz	a
 860  0188 2705          	jreq	L523
 861                     ; 387     I2C->CR1 &= (u8)(~I2C_CR1_NOSTRETCH);
 863  018a 721f5210      	bres	21008,#7
 866  018e 81            	ret	
 867  018f               L523:
 868                     ; 393     I2C->CR1 |= I2C_CR1_NOSTRETCH;
 870  018f 721e5210      	bset	21008,#7
 871                     ; 395 }
 874  0193 81            	ret	
 910                     ; 412 void I2C_AcknowledgeConfig(I2C_Ack_TypeDef Ack)
 910                     ; 413 {
 911                     	switch	.text
 912  0194               _I2C_AcknowledgeConfig:
 914  0194 88            	push	a
 915       00000000      OFST:	set	0
 918                     ; 416   assert_param(IS_I2C_ACK_OK(Ack));
 920                     ; 418   if (Ack == I2C_ACK_NONE)
 922  0195 4d            	tnz	a
 923  0196 2606          	jrne	L743
 924                     ; 421     I2C->CR2 &= (u8)(~I2C_CR2_ACK);
 926  0198 72155211      	bres	21009,#2
 928  019c 2013          	jra	L153
 929  019e               L743:
 930                     ; 426     I2C->CR2 |= I2C_CR2_ACK;
 932  019e 72145211      	bset	21009,#2
 933                     ; 428     if (Ack == I2C_ACK_CURR)
 935  01a2 7b01          	ld	a,(OFST+1,sp)
 936  01a4 4a            	dec	a
 937  01a5 2606          	jrne	L353
 938                     ; 431       I2C->CR2 &= (u8)(~I2C_CR2_POS);
 940  01a7 72175211      	bres	21009,#3
 942  01ab 2004          	jra	L153
 943  01ad               L353:
 944                     ; 436       I2C->CR2 |= I2C_CR2_POS;
 946  01ad 72165211      	bset	21009,#3
 947  01b1               L153:
 948                     ; 440 }
 951  01b1 84            	pop	a
 952  01b2 81            	ret	
1024                     ; 459 void I2C_ITConfig(I2C_IT_TypeDef ITName, FunctionalState NewState)
1024                     ; 460 {
1025                     	switch	.text
1026  01b3               _I2C_ITConfig:
1028  01b3 89            	pushw	x
1029       00000000      OFST:	set	0
1032                     ; 463   assert_param(IS_I2C_INTERRUPT_OK(ITName));
1034                     ; 464   assert_param(IS_FUNCTIONALSTATE_OK(NewState));
1036                     ; 466   if (NewState != DISABLE)
1038  01b4 9f            	ld	a,xl
1039  01b5 4d            	tnz	a
1040  01b6 2706          	jreq	L314
1041                     ; 469     I2C->ITR |= (u8)ITName;
1043  01b8 9e            	ld	a,xh
1044  01b9 ca521a        	or	a,21018
1046  01bc 2006          	jra	L514
1047  01be               L314:
1048                     ; 474     I2C->ITR &= (u8)(~(u8)ITName);
1050  01be 7b01          	ld	a,(OFST+1,sp)
1051  01c0 43            	cpl	a
1052  01c1 c4521a        	and	a,21018
1053  01c4               L514:
1054  01c4 c7521a        	ld	21018,a
1055                     ; 476 }
1058  01c7 85            	popw	x
1059  01c8 81            	ret	
1095                     ; 493 void I2C_FastModeDutyCycleConfig(I2C_DutyCycle_TypeDef DutyCycle)
1095                     ; 494 {
1096                     	switch	.text
1097  01c9               _I2C_FastModeDutyCycleConfig:
1101                     ; 497   assert_param(IS_I2C_DUTYCYCLE_OK(DutyCycle));
1103                     ; 499   if (DutyCycle == I2C_DUTYCYCLE_16_9)
1105  01c9 a140          	cp	a,#64
1106  01cb 2605          	jrne	L534
1107                     ; 502     I2C->CCRH |= I2C_CCRH_DUTY;
1109  01cd 721c521c      	bset	21020,#6
1112  01d1 81            	ret	
1113  01d2               L534:
1114                     ; 507     I2C->CCRH &= (u8)(~I2C_CCRH_DUTY);
1116  01d2 721d521c      	bres	21020,#6
1117                     ; 510 }
1120  01d6 81            	ret	
1298                     ; 531 ErrorStatus I2C_CheckEvent(I2C_Event_TypeDef I2C_Event)
1298                     ; 532 {
1299                     	switch	.text
1300  01d7               _I2C_CheckEvent:
1302  01d7 89            	pushw	x
1303  01d8 89            	pushw	x
1304       00000002      OFST:	set	2
1307                     ; 534   u8 flag1 = 0;
1309                     ; 535   u8 flag2 = 0;
1311                     ; 536   ErrorStatus status = ERROR;
1313                     ; 539   assert_param(IS_I2C_EVENT_OK(I2C_Event));
1315                     ; 541   flag1 = I2C->SR1;
1317  01d9 c65217        	ld	a,21015
1318  01dc 6b01          	ld	(OFST-1,sp),a
1319                     ; 542   flag2 = I2C->SR2;
1321  01de c65218        	ld	a,21016
1322  01e1 6b02          	ld	(OFST+0,sp),a
1323                     ; 545   if (((u16)I2C_Event & (u16)0x0F00) == 0x0700)
1325  01e3 7b03          	ld	a,(OFST+1,sp)
1326  01e5 a40f          	and	a,#15
1327  01e7 97            	ld	xl,a
1328  01e8 4f            	clr	a
1329  01e9 02            	rlwa	x,a
1330  01ea a30700        	cpw	x,#1792
1331  01ed 2608          	jrne	L535
1332                     ; 548     if (flag1 & (u8)I2C_Event)
1334  01ef 7b04          	ld	a,(OFST+2,sp)
1335  01f1 1501          	bcp	a,(OFST-1,sp)
1336  01f3 270c          	jreq	L545
1337                     ; 551       status = SUCCESS;
1339  01f5 2006          	jp	LC002
1340                     ; 556       status = ERROR;
1341  01f7               L535:
1342                     ; 561     if (flag2 & (u8)I2C_Event)
1344  01f7 7b04          	ld	a,(OFST+2,sp)
1345  01f9 1502          	bcp	a,(OFST+0,sp)
1346  01fb 2704          	jreq	L545
1347                     ; 564       status = SUCCESS;
1349  01fd               LC002:
1351  01fd a601          	ld	a,#1
1353  01ff 2001          	jra	L345
1354  0201               L545:
1355                     ; 569       status = ERROR;
1358  0201 4f            	clr	a
1359  0202               L345:
1360                     ; 574   return status;
1364  0202 5b04          	addw	sp,#4
1365  0204 81            	ret	
1388                     ; 594 u8 I2C_ReceiveData(void)
1388                     ; 595 {
1389                     	switch	.text
1390  0205               _I2C_ReceiveData:
1394                     ; 597   return ((u8)I2C->DR);
1396  0205 c65216        	ld	a,21014
1399  0208 81            	ret	
1464                     ; 616 void I2C_Send7bitAddress(u8 Address, I2C_Direction_TypeDef Direction)
1464                     ; 617 {
1465                     	switch	.text
1466  0209               _I2C_Send7bitAddress:
1468  0209 89            	pushw	x
1469       00000000      OFST:	set	0
1472                     ; 619   assert_param(IS_I2C_ADDRESS_OK(Address));
1474                     ; 620   assert_param(IS_I2C_DIRECTION_OK(Direction));
1476                     ; 623   Address &= (u8)0xFE;
1478  020a 7b01          	ld	a,(OFST+1,sp)
1479  020c a4fe          	and	a,#254
1480  020e 6b01          	ld	(OFST+1,sp),a
1481                     ; 626   I2C->DR = (u8)(Address | (u8)Direction);
1483  0210 1a02          	or	a,(OFST+2,sp)
1484  0212 c75216        	ld	21014,a
1485                     ; 627 }
1488  0215 85            	popw	x
1489  0216 81            	ret	
1523                     ; 643 void I2C_SendData(u8 Data)
1523                     ; 644 {
1524                     	switch	.text
1525  0217               _I2C_SendData:
1529                     ; 646   I2C->DR = Data;
1531  0217 c75216        	ld	21014,a
1532                     ; 647 }
1535  021a 81            	ret	
1732                     ; 666 FlagStatus I2C_GetFlagStatus(I2C_Flag_TypeDef Flag)
1732                     ; 667 {
1733                     	switch	.text
1734  021b               _I2C_GetFlagStatus:
1736  021b 89            	pushw	x
1737  021c 88            	push	a
1738       00000001      OFST:	set	1
1741                     ; 669   FlagStatus bitstatus = RESET;
1743  021d 0f01          	clr	(OFST+0,sp)

⌨️ 快捷键说明

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