📄 stm8_tsl_services.ls
字号:
1249 0339 a607 ld a,#7
1250 033b 42 mul x,a
1251 033c 72bb0000 addw x,_pMCKeyStruct
1252 0340 7b0a ld a,(OFST-1,sp)
1253 0342 e70b ld (11,x),a
1254 ; 435 for (ChannelIndex = 0; ChannelIndex < CHANNEL_PER_MCKEY; ChannelIndex++)
1256 0344 3c00 inc _ChannelIndex
1259 0346 b600 ld a,_ChannelIndex
1260 0348 a105 cp a,#5
1261 034a 2403 jruge L25
1262 034c cc02bc jp L563
1263 034f L25:
1264 034f L363:
1265 ; 430 for (KeyIndex = 0; KeyIndex < NUMBER_OF_MULTI_CHANNEL_KEYS; KeyIndex++)
1267 034f 3c00 inc _KeyIndex
1270 0351 3d00 tnz _KeyIndex
1271 0353 2603 jrne L45
1272 0355 cc02ad jp L553
1273 0358 L45:
1274 0358 L522:
1275 ; 307 while (Local_TickECS10ms--)
1277 0358 b600 ld a,_Local_TickECS10ms
1278 035a 3a00 dec _Local_TickECS10ms
1279 035c 4d tnz a
1280 035d 2703 jreq L65
1281 035f cc011f jp L322
1282 0362 L65:
1283 ; 449 }
1286 0362 5b0b addw sp,#11
1287 0364 81 ret
1334 ; 464 void TSL_SCKey_DxS(void)
1334 ; 465 {
1335 switch .text
1336 0365 _TSL_SCKey_DxS:
1338 0365 89 pushw x
1339 00000002 OFST: set 2
1342 ; 468 if (pKeyStruct->Setting.b.LOCKED)
1344 0366 be00 ldw x,_pKeyStruct
1345 0368 e602 ld a,(2,x)
1346 036a a580 bcp a,#128
1347 036c 264c jrne L26
1348 ; 469 return;
1350 ; 471 DxSGroupMask = pKeyStruct->DxSGroup;
1352 036e be00 ldw x,_pKeyStruct
1353 0370 e604 ld a,(4,x)
1354 0372 6b01 ld (OFST-1,sp),a
1355 ; 473 for (KeyToCheck = 0; KeyToCheck < NUMBER_OF_SINGLE_CHANNEL_KEYS; KeyToCheck++)
1357 0374 0f02 clr (OFST+0,sp)
1358 0376 L124:
1359 ; 475 if (KeyToCheck != KeyIndex)
1361 0376 7b02 ld a,(OFST+0,sp)
1362 0378 b100 cp a,_KeyIndex
1363 037a 2718 jreq L724
1364 ; 478 if (sSCKeyInfo[KeyToCheck].DxSGroup & DxSGroupMask)
1366 037c 7b02 ld a,(OFST+0,sp)
1367 037e 97 ld xl,a
1368 037f a60f ld a,#15
1369 0381 42 mul x,a
1370 0382 e604 ld a,(_sSCKeyInfo+4,x)
1371 0384 1501 bcp a,(OFST-1,sp)
1372 0386 270c jreq L724
1373 ; 480 if (sSCKeyInfo[KeyToCheck].Setting.b.LOCKED)
1375 0388 7b02 ld a,(OFST+0,sp)
1376 038a 97 ld xl,a
1377 038b a60f ld a,#15
1378 038d 42 mul x,a
1379 038e e602 ld a,(_sSCKeyInfo+2,x)
1380 0390 a580 bcp a,#128
1381 0392 2622 jrne L373
1382 ; 482 goto ExitToIdle;
1384 0394 L724:
1385 ; 473 for (KeyToCheck = 0; KeyToCheck < NUMBER_OF_SINGLE_CHANNEL_KEYS; KeyToCheck++)
1387 0394 0c02 inc (OFST+0,sp)
1390 0396 7b02 ld a,(OFST+0,sp)
1391 0398 a102 cp a,#2
1392 039a 25da jrult L124
1393 ; 489 for (KeyToCheck = 0; KeyToCheck < NUMBER_OF_MULTI_CHANNEL_KEYS; KeyToCheck++)
1395 039c 0f02 clr (OFST+0,sp)
1396 039e L534:
1397 ; 492 if (sMCKeyInfo[KeyToCheck].DxSGroup & DxSGroupMask)
1399 039e 7b02 ld a,(OFST+0,sp)
1400 03a0 97 ld xl,a
1401 03a1 a630 ld a,#48
1402 03a3 42 mul x,a
1403 03a4 e604 ld a,(_sMCKeyInfo+4,x)
1404 03a6 1501 bcp a,(OFST-1,sp)
1405 03a8 2712 jreq L344
1406 ; 494 if (sMCKeyInfo[KeyToCheck].Setting.b.LOCKED)
1408 03aa 7b02 ld a,(OFST+0,sp)
1409 03ac 97 ld xl,a
1410 03ad a630 ld a,#48
1411 03af 42 mul x,a
1412 03b0 e602 ld a,(_sMCKeyInfo+2,x)
1413 03b2 a580 bcp a,#128
1414 03b4 2706 jreq L344
1415 ; 496 goto ExitToIdle;
1416 03b6 L373:
1417 ; 505 ExitToIdle: // The DxS is verified at PRE DETECT state only !
1417 ; 506 pKeyStruct->Channel.IntegratorCounter++; // Increment integrator to never allow DETECT state
1419 03b6 be00 ldw x,_pKeyStruct
1420 03b8 6c0a inc (10,x)
1421 ; 507 return;
1422 03ba L26:
1425 03ba 85 popw x
1426 03bb 81 ret
1427 03bc L344:
1428 ; 489 for (KeyToCheck = 0; KeyToCheck < NUMBER_OF_MULTI_CHANNEL_KEYS; KeyToCheck++)
1430 03bc 0c02 inc (OFST+0,sp)
1433 03be 0d02 tnz (OFST+0,sp)
1434 03c0 27dc jreq L534
1435 ; 502 pKeyStruct->Setting.b.LOCKED = 1;
1437 03c2 be00 ldw x,_pKeyStruct
1438 03c4 e602 ld a,(2,x)
1439 03c6 aa80 or a,#128
1440 03c8 e702 ld (2,x),a
1441 ; 503 return;
1443 03ca 20ee jra L26
1471 ; 521 void TSL_SCKey_DetectionTimeout(void)
1471 ; 522 {
1472 switch .text
1473 03cc _TSL_SCKey_DetectionTimeout:
1477 ; 523 if (Local_TickFlag.b.DTO_1sec)
1479 03cc b600 ld a,_Local_TickFlag
1480 03ce a501 bcp a,#1
1481 03d0 2711 jreq L754
1482 ; 525 if (DetectionTimeout)
1484 03d2 3d00 tnz _DetectionTimeout
1485 03d4 270d jreq L754
1486 ; 527 pKeyStruct->Counter--;
1488 03d6 be00 ldw x,_pKeyStruct
1489 03d8 6a03 dec (3,x)
1490 ; 528 if (!pKeyStruct->Counter)
1492 03da be00 ldw x,_pKeyStruct
1493 03dc 6d03 tnz (3,x)
1494 03de 2603 jrne L754
1495 ; 530 TSL_SCKey_SetCalibrationState();
1497 03e0 cd0094 call _TSL_SCKey_SetCalibrationState
1499 03e3 L754:
1500 ; 534 }
1503 03e3 81 ret
1506 .const: section .text
1507 0000 _MCKEY1_DELTA_COEFF:
1508 0000 0100 dc.w 256
1509 0002 0100 dc.w 256
1510 0004 0100 dc.w 256
1511 0006 0100 dc.w 256
1512 0008 0100 dc.w 256
1558 ; 666 u8 TSL_MCKey_InitAcq(u8 channel)
1558 ; 667 {
1559 switch .text
1560 03e4 _TSL_MCKey_InitAcq:
1562 03e4 88 push a
1563 03e5 88 push a
1564 00000001 OFST: set 1
1567 ; 668 u8 mask = 0;
1569 03e6 0f01 clr (OFST+0,sp)
1570 ; 670 for (KeyIndex = 0; KeyIndex < NUMBER_OF_MULTI_CHANNEL_KEYS;KeyIndex++)
1572 03e8 3f00 clr _KeyIndex
1573 03ea L705:
1574 ; 672 if ((sMCKeyInfo[KeyIndex].State.whole & (DISABLED_STATE | ERROR_STATE)) == 0)
1576 03ea b600 ld a,_KeyIndex
1577 03ec 97 ld xl,a
1578 03ed a630 ld a,#48
1579 03ef 42 mul x,a
1580 03f0 e600 ld a,(_sMCKeyInfo,x)
1581 03f2 a588 bcp a,#136
1582 03f4 262e jrne L515
1583 ; 674 for (ChannelIndex = 0; ChannelIndex < CHANNEL_PER_MCKEY * NUMBER_OF_MULTI_CHANNEL_KEYS; ChannelIndex++)
1585 03f6 3f00 clr _ChannelIndex
1586 03f8 L715:
1587 ; 676 if (Table_MCKEY_PORTS[ChannelIndex] == channel)
1589 03f8 b600 ld a,_ChannelIndex
1590 03fa 5f clrw x
1591 03fb 97 ld xl,a
1592 03fc 58 sllw x
1593 03fd 7b02 ld a,(OFST+1,sp)
1594 03ff 905f clrw y
1595 0401 9097 ld yl,a
1596 0403 90bf00 ldw c_y,y
1597 0406 9093 ldw y,x
1598 0408 90de0000 ldw y,(_Table_MCKEY_PORTS,y)
1599 040c 90b300 cpw y,c_y
1600 040f 260b jrne L525
1601 ; 678 mask |= Table_MCKEY_BITS[ChannelIndex];
1603 0411 b600 ld a,_ChannelIndex
1604 0413 5f clrw x
1605 0414 97 ld xl,a
1606 0415 7b01 ld a,(OFST+0,sp)
1607 0417 da0000 or a,(_Table_MCKEY_BITS,x)
1608 041a 6b01 ld (OFST+0,sp),a
1609 041c L525:
1610 ; 674 for (ChannelIndex = 0; ChannelIndex < CHANNEL_PER_MCKEY * NUMBER_OF_MULTI_CHANNEL_KEYS; ChannelIndex++)
1612 041c 3c00 inc _ChannelIndex
1615 041e b600 ld a,_ChannelIndex
1616 0420 a105 cp a,#5
1617 0422 25d4 jrult L715
1618 0424 L515:
1619 ; 670 for (KeyIndex = 0; KeyIndex < NUMBER_OF_MULTI_CHANNEL_KEYS;KeyIndex++)
1621 0424 3c00 inc _KeyIndex
1624 0426 3d00 tnz _KeyIndex
1625 0428 27c0 jreq L705
1626 ; 684 return (mask);
1628 042a 7b01 ld a,(OFST+0,sp)
1631 042c 85 popw x
1632 042d 81 ret
1659 ; 697 void TSL_MCKey_SetStructPointer(void)
1659 ; 698 {
1660 switch .text
1661 042e _TSL_MCKey_SetStructPointer:
1665 ; 699 pMCKeyStruct = &sMCKeyInfo[KeyIndex];
1667 042e b600 ld a,_KeyIndex
1668 0430 97 ld xl,a
1669 0431 a630 ld a,#48
1670 0433 42 mul x,a
1671 0434 01 rrwa x,a
1672 0435 ab00 add a,#_sMCKeyInfo
1673 0437 2401 jrnc L27
1674 0439 5c incw x
1675 043a L27:
1676 043a 5f clrw x
1677 043b 97 ld xl,a
1678 043c bf00 ldw _pMCKeyStruct,x
1679 ; 700 }
1682 043e 81 ret
1719 ; 712 void TSL_MCKey_DeltaCalculation(u8 ChIdx)
1719 ; 713 {
1720 switch .text
1721 043f _TSL_MCKey_DeltaCalculation:
1723 043f 88 push a
1724 0440 89 pushw x
1725 00000002 OFST: set 2
1728 ; 726 Delta = (s16)(pMCKeyStruct->Channel[ChIdx].LastMeas - pMCKeyStruct->Channel[ChIdx].Reference);
1730 0441 97 ld xl,a
1731 0442 a607 ld a,#7
1732 0444 42 mul x,a
1733 0445 72bb0000 addw x,_pMCKeyStruct
1734 0449 ee08 ldw x,(8,x)
1735 044b 1f01 ldw (OFST-1,sp),x
1736 044d 7b03 ld a,(OFST+1,sp)
1737 044f 97 ld xl,a
1738 0450 a607 ld a,#7
1739 0452 42 mul x,a
1740 0453 72bb0000 addw x,_pMCKeyStruct
1741 0457 ee05 ldw x,(5,x)
1742 0459 72f001 subw x,(OFST-1,sp)
1743 045c bf00 ldw _Delta,x
1744 ; 728 }
1747 045e 5b03 addw sp,#3
1748 0460 81 ret
1774 ; 741 void TSL_MCKey_SetIdleState(void)
1774 ; 742 {
1775 switch .text
1776 0461 _TSL_MCKey_SetIdleState:
1780 ; 743 pMCKeyStruct->Setting.b.CHANGED = 1;
1782 0461 be00 ldw x,_pMCKeyStruct
1783 0463 e602 ld a,(2,x)
1784 0465 aa08 or a,#8
1785 0467 e702 ld (2,x),a
1786 ; 744 TSL_MCKey_BackToIdleState();
1788 0469 ad01 call _TSL_MCKey_BackToIdleState
1790 ; 745 }
1793 046b 81 ret
1818 ; 758 void TSL_MCKey_BackToIdleState(void)
1818 ; 759 {
1819 switch .text
1820 046c _TSL_MCKey_BackToIdleState:
1824 ; 760 pMCKeyStruct->State.whole = IDLE_STATE;
1826 046c a602 ld a,#2
1827 046e 92c700 ld [_pMCKeyStruct.w],a
1828 ; 761 pMCKeyStruct->Setting.b.DETECTED = 0;
1830 0471 be00 ldw x,_pMCKeyStruct
1831 0473 e602 ld a,(2,x)
1832 0475 a4fb and a,#251
1833 0477 e702 ld (2,x),a
1834 ; 762 pMCKeyStruct->Setting.b.LOCKED = 0;
1836 0479 be00 ldw x,_pMCKeyStruct
1837 047b e602 ld a,(2,x)
1838 047d a47f and a,#127
1839 047f e702 ld (2,x),a
1840 ; 763 }
1843 0481 81 ret
1869 ; 776 void TSL_MCKey_SetPreDetectState(void)
1869 ; 777 {
1870 switch .text
1871 0482 _TSL_MCKey_SetPreDetectState:
1875 ; 778 pMCKeyStruct->State.whole = PRE_DETECTED_STATE;
1877 0482 a614 ld a,#20
1878 0484 92c700 ld [_pMCKeyStruct.w],a
1879 ; 779 pMCKeyStruct->Channel[0].IntegratorCounter = DetectionIntegrator;
1881 0487 be00 ldw x,_pMCKeyStruct
1882 0489 b600 ld a,_DetectionIntegrator
1883 048b e70a ld (10,x),a
1884 ; 780 }
1887 048d 81 ret
1913 ; 793 void TSL_MCKey_SetDetectedState(void)
1913 ; 794 {
1914 switch .text
1915 048e _TSL_MCKey_SetDetectedState:
1919 ; 795 pMCKeyStruct->State.whole = DETECTED_STATE;
1921 048e a604 ld a,#4
1922 0490 92c700 ld [_pMCKeyStruct.w],a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -