📄 stm8s_i2c.ls
字号:
628 ; 251 if (NewState != DISABLE)
630 0151 4d tnz a
631 0152 2705 jreq L512
632 ; 254 I2C->CR1 |= I2C_CR1_ENGC;
634 0154 721c5210 bset 21008,#6
637 0158 81 ret
638 0159 L512:
639 ; 259 I2C->CR1 &= (u8)(~I2C_CR1_ENGC);
641 0159 721d5210 bres 21008,#6
642 ; 261 }
645 015d 81 ret
680 ; 278 void I2C_GenerateSTART(FunctionalState NewState)
680 ; 279 {
681 switch .text
682 015e _I2C_GenerateSTART:
686 ; 282 assert_param(IS_FUNCTIONALSTATE_OK(NewState));
688 ; 284 if (NewState != DISABLE)
690 015e 4d tnz a
691 015f 2705 jreq L732
692 ; 287 I2C->CR2 |= I2C_CR2_START;
694 0161 72105211 bset 21009,#0
697 0165 81 ret
698 0166 L732:
699 ; 292 I2C->CR2 &= (u8)(~I2C_CR2_START);
701 0166 72115211 bres 21009,#0
702 ; 295 }
705 016a 81 ret
740 ; 312 void I2C_GenerateSTOP(FunctionalState NewState)
740 ; 313 {
741 switch .text
742 016b _I2C_GenerateSTOP:
746 ; 316 assert_param(IS_FUNCTIONALSTATE_OK(NewState));
748 ; 318 if (NewState != DISABLE)
750 016b 4d tnz a
751 016c 2705 jreq L162
752 ; 321 I2C->CR2 |= I2C_CR2_STOP;
754 016e 72125211 bset 21009,#1
757 0172 81 ret
758 0173 L162:
759 ; 326 I2C->CR2 &= (u8)(~I2C_CR2_STOP);
761 0173 72135211 bres 21009,#1
762 ; 329 }
765 0177 81 ret
801 ; 346 void I2C_SoftwareResetCmd(FunctionalState NewState)
801 ; 347 {
802 switch .text
803 0178 _I2C_SoftwareResetCmd:
807 ; 349 assert_param(IS_FUNCTIONALSTATE_OK(NewState));
809 ; 351 if (NewState != DISABLE)
811 0178 4d tnz a
812 0179 2705 jreq L303
813 ; 354 I2C->CR2 |= I2C_CR2_SWRST;
815 017b 721e5211 bset 21009,#7
818 017f 81 ret
819 0180 L303:
820 ; 359 I2C->CR2 &= (u8)(~I2C_CR2_SWRST);
822 0180 721f5211 bres 21009,#7
823 ; 361 }
826 0184 81 ret
862 ; 379 void I2C_StretchClockCmd(FunctionalState NewState)
862 ; 380 {
863 switch .text
864 0185 _I2C_StretchClockCmd:
868 ; 382 assert_param(IS_FUNCTIONALSTATE_OK(NewState));
870 ; 384 if (NewState != DISABLE)
872 0185 4d tnz a
873 0186 2705 jreq L523
874 ; 387 I2C->CR1 &= (u8)(~I2C_CR1_NOSTRETCH);
876 0188 721f5210 bres 21008,#7
879 018c 81 ret
880 018d L523:
881 ; 393 I2C->CR1 |= I2C_CR1_NOSTRETCH;
883 018d 721e5210 bset 21008,#7
884 ; 395 }
887 0191 81 ret
923 ; 412 void I2C_AcknowledgeConfig(I2C_Ack_TypeDef Ack)
923 ; 413 {
924 switch .text
925 0192 _I2C_AcknowledgeConfig:
927 0192 88 push a
928 00000000 OFST: set 0
931 ; 416 assert_param(IS_I2C_ACK_OK(Ack));
933 ; 418 if (Ack == I2C_ACK_NONE)
935 0193 4d tnz a
936 0194 2606 jrne L743
937 ; 421 I2C->CR2 &= (u8)(~I2C_CR2_ACK);
939 0196 72155211 bres 21009,#2
941 019a 2013 jra L153
942 019c L743:
943 ; 426 I2C->CR2 |= I2C_CR2_ACK;
945 019c 72145211 bset 21009,#2
946 ; 428 if (Ack == I2C_ACK_CURR)
948 01a0 7b01 ld a,(OFST+1,sp)
949 01a2 4a dec a
950 01a3 2606 jrne L353
951 ; 431 I2C->CR2 &= (u8)(~I2C_CR2_POS);
953 01a5 72175211 bres 21009,#3
955 01a9 2004 jra L153
956 01ab L353:
957 ; 436 I2C->CR2 |= I2C_CR2_POS;
959 01ab 72165211 bset 21009,#3
960 01af L153:
961 ; 440 }
964 01af 84 pop a
965 01b0 81 ret
1037 ; 459 void I2C_ITConfig(I2C_IT_TypeDef ITName, FunctionalState NewState)
1037 ; 460 {
1038 switch .text
1039 01b1 _I2C_ITConfig:
1041 01b1 89 pushw x
1042 00000000 OFST: set 0
1045 ; 463 assert_param(IS_I2C_INTERRUPT_OK(ITName));
1047 ; 464 assert_param(IS_FUNCTIONALSTATE_OK(NewState));
1049 ; 466 if (NewState != DISABLE)
1051 01b2 9f ld a,xl
1052 01b3 4d tnz a
1053 01b4 2706 jreq L314
1054 ; 469 I2C->ITR |= (u8)ITName;
1056 01b6 9e ld a,xh
1057 01b7 ca521a or a,21018
1059 01ba 2006 jra L514
1060 01bc L314:
1061 ; 474 I2C->ITR &= (u8)(~(u8)ITName);
1063 01bc 7b01 ld a,(OFST+1,sp)
1064 01be 43 cpl a
1065 01bf c4521a and a,21018
1066 01c2 L514:
1067 01c2 c7521a ld 21018,a
1068 ; 476 }
1071 01c5 85 popw x
1072 01c6 81 ret
1108 ; 493 void I2C_FastModeDutyCycleConfig(I2C_DutyCycle_TypeDef DutyCycle)
1108 ; 494 {
1109 switch .text
1110 01c7 _I2C_FastModeDutyCycleConfig:
1114 ; 497 assert_param(IS_I2C_DUTYCYCLE_OK(DutyCycle));
1116 ; 499 if (DutyCycle == I2C_DUTYCYCLE_16_9)
1118 01c7 a140 cp a,#64
1119 01c9 2605 jrne L534
1120 ; 502 I2C->CCRH |= I2C_CCRH_DUTY;
1122 01cb 721c521c bset 21020,#6
1125 01cf 81 ret
1126 01d0 L534:
1127 ; 507 I2C->CCRH &= (u8)(~I2C_CCRH_DUTY);
1129 01d0 721d521c bres 21020,#6
1130 ; 510 }
1133 01d4 81 ret
1311 ; 531 ErrorStatus I2C_CheckEvent(I2C_Event_TypeDef I2C_Event)
1311 ; 532 {
1312 switch .text
1313 01d5 _I2C_CheckEvent:
1315 01d5 89 pushw x
1316 01d6 89 pushw x
1317 00000002 OFST: set 2
1320 ; 534 u8 flag1 = 0;
1322 ; 535 u8 flag2 = 0;
1324 ; 536 ErrorStatus status = ERROR;
1326 ; 539 assert_param(IS_I2C_EVENT_OK(I2C_Event));
1328 ; 541 flag1 = I2C->SR1;
1330 01d7 c65217 ld a,21015
1331 01da 6b01 ld (OFST-1,sp),a
1332 ; 542 flag2 = I2C->SR2;
1334 01dc c65218 ld a,21016
1335 01df 6b02 ld (OFST+0,sp),a
1336 ; 545 if (((u16)I2C_Event & (u16)0x0F00) == 0x0700)
1338 01e1 01 rrwa x,a
1339 01e2 9f ld a,xl
1340 01e3 a40f and a,#15
1341 01e5 97 ld xl,a
1342 01e6 4f clr a
1343 01e7 02 rlwa x,a
1344 01e8 a30700 cpw x,#1792
1345 01eb 2608 jrne L535
1346 ; 548 if (flag1 & (u8)I2C_Event)
1348 01ed 7b04 ld a,(OFST+2,sp)
1349 01ef 1501 bcp a,(OFST-1,sp)
1350 01f1 270c jreq L545
1351 ; 551 status = SUCCESS;
1353 01f3 2006 jp LC002
1354 ; 556 status = ERROR;
1355 01f5 L535:
1356 ; 561 if (flag2 & (u8)I2C_Event)
1358 01f5 7b04 ld a,(OFST+2,sp)
1359 01f7 1502 bcp a,(OFST+0,sp)
1360 01f9 2704 jreq L545
1361 ; 564 status = SUCCESS;
1363 01fb LC002:
1365 01fb a601 ld a,#1
1367 01fd 2001 jra L345
1368 01ff L545:
1369 ; 569 status = ERROR;
1372 01ff 4f clr a
1373 0200 L345:
1374 ; 574 return status;
1378 0200 5b04 addw sp,#4
1379 0202 81 ret
1402 ; 594 u8 I2C_ReceiveData(void)
1402 ; 595 {
1403 switch .text
1404 0203 _I2C_ReceiveData:
1408 ; 597 return ((u8)I2C->DR);
1410 0203 c65216 ld a,21014
1413 0206 81 ret
1478 ; 616 void I2C_Send7bitAddress(u8 Address, I2C_Direction_TypeDef Direction)
1478 ; 617 {
1479 switch .text
1480 0207 _I2C_Send7bitAddress:
1482 0207 89 pushw x
1483 00000000 OFST: set 0
1486 ; 619 assert_param(IS_I2C_ADDRESS_OK(Address));
1488 ; 620 assert_param(IS_I2C_DIRECTION_OK(Direction));
1490 ; 623 Address &= (u8)0xFE;
1492 0208 7b01 ld a,(OFST+1,sp)
1493 020a a4fe and a,#254
1494 020c 6b01 ld (OFST+1,sp),a
1495 ; 626 I2C->DR = (u8)(Address | (u8)Direction);
1497 020e 1a02 or a,(OFST+2,sp)
1498 0210 c75216 ld 21014,a
1499 ; 627 }
1502 0213 85 popw x
1503 0214 81 ret
1537 ; 643 void I2C_SendData(u8 Data)
1537 ; 644 {
1538 switch .text
1539 0215 _I2C_SendData:
1543 ; 646 I2C->DR = Data;
1545 0215 c75216 ld 21014,a
1546 ; 647 }
1549 0218 81 ret
1746 ; 666 FlagStatus I2C_GetFlagStatus(I2C_Flag_TypeDef Flag)
1746 ; 667 {
1747 switch .text
1748 0219 _I2C_GetFlagStatus:
1750 0219 89 pushw x
1751 021a 88 push a
1752 00000001 OFST: set 1
1755 ; 669 FlagStatus bitstatus = RESET;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -