1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
|
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
File: oct6100_interrupts.c
Copyright (c) 2001-2007 Octasic Inc.
Description:
This file contains the API's interrupt service routine and all of its
sub-functions.
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is
free software; you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
The OCT6100 GPL API is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with the OCT6100 GPL API; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
$Octasic_Release: OCT612xAPI-01.00-PR49 $
$Octasic_Revision: 81 $
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
/***************************** INCLUDE FILES *******************************/
#include "octdef.h"
#include "oct6100api/oct6100_defines.h"
#include "oct6100api/oct6100_errors.h"
#include "oct6100api/oct6100_apiud.h"
#include "oct6100api/oct6100_tlv_inst.h"
#include "oct6100api/oct6100_chip_open_inst.h"
#include "oct6100api/oct6100_chip_stats_inst.h"
#include "oct6100api/oct6100_interrupts_inst.h"
#include "oct6100api/oct6100_remote_debug_inst.h"
#include "oct6100api/oct6100_debug_inst.h"
#include "oct6100api/oct6100_api_inst.h"
#include "oct6100api/oct6100_interrupts_pub.h"
#include "oct6100api/oct6100_chip_open_pub.h"
#include "oct6100api/oct6100_events_pub.h"
#include "oct6100api/oct6100_channel_pub.h"
#include "oct6100api/oct6100_interrupts_pub.h"
#include "oct6100api/oct6100_channel_inst.h"
#include "oct6100_chip_open_priv.h"
#include "oct6100_miscellaneous_priv.h"
#include "oct6100_events_priv.h"
#include "oct6100_interrupts_priv.h"
/**************************** PUBLIC FUNCTIONS *****************************/
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100InterruptConfigure
Description: Configure the operation of all possible interrupt sources.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntrptConfig Pointer to interrupt configuration structure.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100InterruptConfigureDef
UINT32 Oct6100InterruptConfigureDef(
tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
{
f_pIntrptConfig->ulFatalGeneralConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
f_pIntrptConfig->ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
f_pIntrptConfig->ulErrorMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
f_pIntrptConfig->ulErrorOverflowToneEventsConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
f_pIntrptConfig->ulErrorH100Config = cOCT6100_INTERRUPT_NO_TIMEOUT;
f_pIntrptConfig->ulFatalMemoryTimeout = 100;
f_pIntrptConfig->ulErrorMemoryTimeout = 100;
f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = 100;
f_pIntrptConfig->ulErrorH100Timeout = 100;
return cOCT6100_ERR_OK;
}
#endif
#if !SKIP_Oct6100InterruptConfigure
UINT32 Oct6100InterruptConfigure(
tPOCT6100_INSTANCE_API f_pApiInstance,
tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
{
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
UINT32 ulResult;
UINT32 ulFncRes;
/* Set the process context of the serialize structure.*/
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
/* Create serialization object for ISR. */
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Call serialized sub-function. */
ulFncRes = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
/* Release serialization object. */
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check if an error occured in sub-function. */
if ( ulFncRes != cOCT6100_ERR_OK )
return ulFncRes;
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100InterruptServiceRoutine
Description: The API's interrupt service routine. This function clears all
register ROLs which have generated an interrupt and report the
events in the user supplied structure. Also, the tone event
and/or playout event buffer will be emptied if valid events
are present.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntFlags Pointer to structure containing event flags returned
to user.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100InterruptServiceRoutineDef
UINT32 Oct6100InterruptServiceRoutineDef(
tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
{
f_pIntFlags->fFatalGeneral = FALSE;
f_pIntFlags->ulFatalGeneralFlags = 0x0;
f_pIntFlags->fFatalReadTimeout = FALSE;
f_pIntFlags->fErrorRefreshTooLate = FALSE;
f_pIntFlags->fErrorPllJitter = FALSE;
f_pIntFlags->fErrorOverflowToneEvents = FALSE;
f_pIntFlags->fErrorH100OutOfSync = FALSE;
f_pIntFlags->fErrorH100ClkA = FALSE;
f_pIntFlags->fErrorH100ClkB = FALSE;
f_pIntFlags->fErrorH100FrameA = FALSE;
f_pIntFlags->fToneEventsPending = FALSE;
f_pIntFlags->fBufferPlayoutEventsPending = FALSE;
f_pIntFlags->fApiSynch = FALSE;
return cOCT6100_ERR_OK;
}
#endif
#if !SKIP_Oct6100InterruptServiceRoutine
UINT32 Oct6100InterruptServiceRoutine(
tPOCT6100_INSTANCE_API f_pApiInstance,
tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
{
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
UINT32 ulResult;
UINT32 ulFncRes;
/* Set the process context of the serialize structure. */
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
/* Seize the serialization object for the ISR. */
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
if ( ulResult == cOCT6100_ERR_OK )
{
/* Call the serialized sub-function. */
ulFncRes = Oct6100InterruptServiceRoutineSer( f_pApiInstance, f_pIntFlags );
}
else
{
return ulResult;
}
/* Release the serialization object. */
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check for an error in the sub-function. */
if ( ulFncRes != cOCT6100_ERR_OK )
return ulFncRes;
return cOCT6100_ERR_OK;
}
#endif
/**************************** PRIVATE FUNCTIONS ****************************/
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiIsrSwInit
Description: Initializes portions of API instance associated to the API's
interrupt service routine.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiIsrSwInit
UINT32 Oct6100ApiIsrSwInit(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
{
tPOCT6100_SHARED_INFO pSharedInfo;
/* Get local pointer to shared portion of instance. */
pSharedInfo = f_pApiInstance->pSharedInfo;
/* Set the state of each interrupt group to disabled. The state will */
/* be updated to the true configuration once the configure interrupts function is called. */
pSharedInfo->IntrptManage.byFatalGeneralState = cOCT6100_INTRPT_DISABLED;
pSharedInfo->IntrptManage.byFatalMemoryState = cOCT6100_INTRPT_DISABLED;
pSharedInfo->IntrptManage.byErrorMemoryState = cOCT6100_INTRPT_DISABLED;
pSharedInfo->IntrptManage.byErrorH100State = cOCT6100_INTRPT_DISABLED;
pSharedInfo->IntrptManage.byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED;
/* Indicate that the mclk interrupt is not active at the moment. */
pSharedInfo->IntrptManage.fMclkIntrptActive = FALSE;
/* Indicate that no buffer playout events are pending for the moment. */
pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE;
/* Indicate that no tone events are pending for the moment. */
pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
/* The ISR has never been called. */
pSharedInfo->IntrptManage.fIsrCalled = FALSE;
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiIsrHwInit
Description: Initializes the chip's interrupt registers.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntrptConfig Pointer to structure defining how the interrupts
should be configured.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiIsrHwInit
UINT32 Oct6100ApiIsrHwInit(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
{
tOCT6100_WRITE_PARAMS WriteParams;
UINT32 ulResult;
/* Set some parameters of write struct. */
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
/*==================================================================================*/
/* Enable all the interrupts */
WriteParams.ulWriteAddress = 0x104;
WriteParams.usWriteData = 0x0001;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
WriteParams.ulWriteAddress = 0x204;
WriteParams.usWriteData = 0x1C05;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
WriteParams.ulWriteAddress = 0x304;
WriteParams.usWriteData = 0xFFFF;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
WriteParams.ulWriteAddress = 0x504;
WriteParams.usWriteData = 0x0002;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
WriteParams.ulWriteAddress = 0x704;
WriteParams.usWriteData = 0x0007;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/*==================================================================================*/
/* Calculate the number of mclk cycles in 1 ms. */
f_pApiInstance->pSharedInfo->IntrptManage.ulNumMclkCyclesIn1Ms = f_pApiInstance->pSharedInfo->MiscVars.ulMclkFreq / 1000;
/* Configure the interrupt registers as requested by the user. */
ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100InterruptConfigureSer
Description: Configure the operation of interrupt groups.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntrptConfig Pointer to interrupt configuration structure.
f_fCheckParams Check parameter enable flag.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100InterruptConfigureSer
UINT32 Oct6100InterruptConfigureSer(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig,
IN BOOL f_fCheckParams )
{
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
UINT32 ulResult;
/* Check for errors. */
if ( f_fCheckParams == TRUE )
{
if ( f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE &&
f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
return cOCT6100_ERR_INTRPTS_FATAL_GENERAL_CONFIG;
if ( f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_CONFIG;
if ( f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_CONFIG;
if ( f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE &&
f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_TIMEOUT &&
f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_CONFIG;
if ( f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_DISABLE &&
f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_TIMEOUT &&
f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_NO_TIMEOUT )
return cOCT6100_ERR_INTRPTS_H100_ERROR_CONFIG;
if ( f_pIntrptConfig->ulFatalMemoryTimeout < 10 ||
f_pIntrptConfig->ulFatalMemoryTimeout > 10000 )
return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_TIMEOUT;
if ( f_pIntrptConfig->ulErrorMemoryTimeout < 10 ||
f_pIntrptConfig->ulErrorMemoryTimeout > 10000 )
return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_TIMEOUT;
if ( f_pIntrptConfig->ulErrorOverflowToneEventsTimeout < 10 ||
f_pIntrptConfig->ulErrorOverflowToneEventsTimeout > 10000 )
return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_TIMEOUT;
if ( f_pIntrptConfig->ulErrorH100Timeout < 10 ||
f_pIntrptConfig->ulErrorH100Timeout > 10000 )
return cOCT6100_ERR_INTRPTS_H100_ERROR_TIMEOUT;
}
/* Copy the configuration to the API instance. */
pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
pIntrptConfig->byFatalGeneralConfig = (UINT8)( f_pIntrptConfig->ulFatalGeneralConfig & 0xFF );
pIntrptConfig->byFatalMemoryConfig = (UINT8)( f_pIntrptConfig->ulFatalMemoryConfig & 0xFF );
pIntrptConfig->byErrorMemoryConfig = (UINT8)( f_pIntrptConfig->ulErrorMemoryConfig & 0xFF );
pIntrptConfig->byErrorOverflowToneEventsConfig = (UINT8)( f_pIntrptConfig->ulErrorOverflowToneEventsConfig & 0xFF );
pIntrptConfig->byErrorH100Config = (UINT8)( f_pIntrptConfig->ulErrorH100Config & 0xFF );
f_pIntrptConfig->ulFatalMemoryTimeout = ((f_pIntrptConfig->ulFatalMemoryTimeout + 9) / 10) * 10;
pIntrptConfig->ulFatalMemoryTimeoutMclk = f_pIntrptConfig->ulFatalMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
f_pIntrptConfig->ulErrorMemoryTimeout = ((f_pIntrptConfig->ulErrorMemoryTimeout + 9) / 10) * 10;
pIntrptConfig->ulErrorMemoryTimeoutMclk = f_pIntrptConfig->ulErrorMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = ((f_pIntrptConfig->ulErrorOverflowToneEventsTimeout + 9) / 10) * 10;
pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk = f_pIntrptConfig->ulErrorOverflowToneEventsTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
f_pIntrptConfig->ulErrorH100Timeout = ((f_pIntrptConfig->ulErrorH100Timeout + 9) / 10) * 10;
pIntrptConfig->ulErrorH100TimeoutMclk = f_pIntrptConfig->ulErrorH100Timeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
/*Clear all interrupts that were already enabled*/
ulResult = Oct6100ApiClearEnabledInterrupts( f_pApiInstance );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Before writing the new configuration to the chip's registers, make sure that any */
/* interrupts which are either disabled or have no timeout period are not on the */
/* disabled interrupt list. */
/*==================================================================================*/
if ( pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_DISABLE )
pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_DISABLED;
else /* pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_NO_TIMEOUT */
pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_ACTIVE;
/*==================================================================================*/
if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_DISABLE )
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_DISABLED;
else if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
else /* ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
{
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_DISABLED )
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
}
/*==================================================================================*/
if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_DISABLE )
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_DISABLED;
else if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
else /* (pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
{
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_DISABLED )
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
}
/*==================================================================================*/
if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_DISABLE )
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED;
else if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
else /* (pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
{
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_DISABLED )
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
}
/*==================================================================================*/
if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_DISABLE )
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_DISABLED;
else if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_NO_TIMEOUT )
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
else /* (pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT ) */
{
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_DISABLED )
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
}
/* Write to the interrupt registers to update the state of each interrupt group. */
ulResult = Oct6100ApiWriteIeRegs( f_pApiInstance );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiClearEnabledInterrupts
Description: Disabled interruption are not reported but still available. This
function will clear the interrupts that were disabled and wish
to enable now.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntrptConfig Pointer to interrupt configuration structure.
f_pIntrptManage Pointer to interrupt manager structure.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiClearEnabledInterrupts
UINT32 Oct6100ApiClearEnabledInterrupts(
IN tPOCT6100_INSTANCE_API f_pApiInstance )
{
tPOCT6100_SHARED_INFO pSharedInfo;
tOCT6100_WRITE_PARAMS WriteParams;
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
UINT32 ulResult;
/* Get local pointer to shared portion of instance. */
pSharedInfo = f_pApiInstance->pSharedInfo;
/* Set the process context and user chip ID parameters once and for all. */
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
/* Copy the configuration to the API instance. */
pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
if ( pIntrptConfig->byFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE &&
pIntrptManage->byFatalGeneralState != cOCT6100_INTRPT_DISABLED )
{
WriteParams.ulWriteAddress = 0x102;
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_102H;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
WriteParams.ulWriteAddress = 0x202;
WriteParams.usWriteData = 0x1800;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
WriteParams.ulWriteAddress = 0x502;
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_502H;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
if ( pIntrptConfig->byErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
{
WriteParams.ulWriteAddress = 0x202;
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_202H;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
if ( pIntrptConfig->byErrorH100Config != cOCT6100_INTERRUPT_DISABLE &&
pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
{
WriteParams.ulWriteAddress = 0x302;
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_302H;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
if ( pIntrptConfig->byErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE &&
pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
{
WriteParams.ulWriteAddress = 0x702;
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_702H;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100InterruptServiceRoutineSer
Description: Serialized sub-function of API's interrupt service routine.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntFlags Pointer to structure containing event flags returned
to user.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100InterruptServiceRoutineSer
UINT32 Oct6100InterruptServiceRoutineSer(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
{
tPOCT6100_SHARED_INFO pSharedInfo;
tOCT6100_READ_PARAMS ReadParams;
tOCT6100_WRITE_PARAMS WriteParams;
UINT32 ulRegister210h;
UINT32 ulResult;
UINT16 usReadData;
/* Get local pointer(s). */
pSharedInfo = f_pApiInstance->pSharedInfo;
/* Must update the statistics. Set parameters in read and write structs. */
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
ReadParams.pusReadData = &usReadData;
/* Set all the flags to default values to make sure the variables are initialized. */
f_pIntFlags->fFatalGeneral = FALSE;
f_pIntFlags->ulFatalGeneralFlags = 0x0;
f_pIntFlags->fFatalReadTimeout = FALSE;
f_pIntFlags->fErrorRefreshTooLate = FALSE;
f_pIntFlags->fErrorPllJitter = FALSE;
f_pIntFlags->fErrorH100OutOfSync = FALSE;
f_pIntFlags->fErrorH100ClkA = FALSE;
f_pIntFlags->fErrorH100ClkB = FALSE;
f_pIntFlags->fErrorH100FrameA = FALSE;
f_pIntFlags->fApiSynch = FALSE;
f_pIntFlags->fErrorOverflowToneEvents = FALSE;
/* Start by reading registers 210h to determine if any modules have flagged an interrupt. */
ReadParams.ulReadAddress = 0x210;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
ulRegister210h = usReadData;
/* Update the extended mclk counter. */
ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* If the mclk interrupt is active then check which interrupt timeout periods have expired. */
ReadParams.ulReadAddress = 0x302;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
if ( (usReadData & 0x1) != 0 && pSharedInfo->IntrptManage.fMclkIntrptActive == TRUE )
{
/* Update timeout periods. */
ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
f_pIntFlags->fApiSynch = TRUE;
/* Read registers 210h and 212h again to determine if any modules have flagged an interrupt. */
ReadParams.ulReadAddress = 0x210;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
ulRegister210h = usReadData;
}
/* Read the interrupt registers to determine what interrupt conditions have occured. */
ulResult = Oct6100ApiReadIntrptRegs( f_pApiInstance, f_pIntFlags, ulRegister210h );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Empty the tone buffer if any events are pending. */
ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, FALSE );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Set the tone events pending flag. */
f_pIntFlags->fToneEventsPending = pSharedInfo->IntrptManage.fToneEventsPending;
/* Check for buffer playout events and insert in the software queue -- if activated. */
if ( pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize != 0 )
{
ulResult = Oct6100BufferPlayoutTransferEvents( f_pApiInstance, FALSE );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Set the buffer playout events pending flag. */
f_pIntFlags->fBufferPlayoutEventsPending = pSharedInfo->IntrptManage.fBufferPlayoutEventsPending;
}
else
{
f_pIntFlags->fBufferPlayoutEventsPending = FALSE;
}
/* Update the states of each interrupt group. */
ulResult = Oct6100ApiUpdateIntrptStates( f_pApiInstance, f_pIntFlags );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check the state of the NLP timestamp if required.*/
ulResult = Oct6100ApiCheckProcessorState( f_pApiInstance, f_pIntFlags );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Write to the necessary IE registers. */
ulResult = Oct6100ApiWriteIntrptRegs( f_pApiInstance );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Schedule the next mclk interrupt, if one is needed. */
ulResult = Oct6100ApiScheduleNextMclkIntrptSer( f_pApiInstance );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */
WriteParams.ulWriteAddress = 0x214;
WriteParams.usWriteData = 0x0000;
if ( pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY )
WriteParams.usWriteData |= 0x4000;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Indicate that the interrupt ROLs have been treated. */
WriteParams.ulWriteAddress = 0x212;
WriteParams.usWriteData = 0x8000;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiReadIntrptRegs
Description: Reads the interrupt registers of all modules currently
indicating an interrupt condition.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntFlags Pointer to an interrupt flag structure.
f_ulRegister210h Value of register 0x210.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiReadIntrptRegs
UINT32 Oct6100ApiReadIntrptRegs(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags,
IN UINT32 f_ulRegister210h )
{
tPOCT6100_SHARED_INFO pSharedInfo;
tPOCT6100_API_CHIP_ERROR_STATS pErrorStats;
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
tOCT6100_READ_PARAMS ReadParams;
tOCT6100_WRITE_PARAMS WriteParams;
UINT32 ulResult;
UINT16 usReadData;
UINT32 ulFeatureBytesOffset;
UINT32 ulFeatureBitOffset;
UINT32 ulFeatureFieldLength;
UINT32 ulTempData;
UINT32 ulCounterValue;
UINT32 ulMask;
/* Get local pointer(s). */
pSharedInfo = f_pApiInstance->pSharedInfo;
pErrorStats = &pSharedInfo->ErrorStats;
pIntrptManage = &pSharedInfo->IntrptManage;
/* Set some parameters of read struct. */
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
ReadParams.pusReadData = &usReadData;
/* Set some parameters of write struct. */
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
/* CPU registers. */
if ( (f_ulRegister210h & 0x00001) != 0 )
{
/*=======================================================================*/
/* Read registers of this module. */
ReadParams.ulReadAddress = 0x102;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check which interrupt(s) were set. */
if ( (usReadData & 0x0001) != 0 )
{
f_pIntFlags->fFatalReadTimeout = TRUE;
pErrorStats->ulInternalReadTimeoutCnt++;
}
pIntrptManage->usRegister102h = usReadData;
/*=======================================================================*/
}
else
{
pIntrptManage->usRegister102h = 0x0;
}
/* MAIN registers. */
if ( (f_ulRegister210h & 0x00002) != 0 )
{
/*=======================================================================*/
/* Read registers of this module. */
ReadParams.ulReadAddress = 0x202;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Save current value in instance. */
pIntrptManage->usRegister202h = usReadData;
/* Check which interrupts were set. */
if ( (usReadData & 0x0001) != 0 )
{
f_pIntFlags->fErrorRefreshTooLate = TRUE;
pErrorStats->ulSdramRefreshTooLateCnt++;
}
if ( (usReadData & 0x0800) != 0 )
{
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_1;
f_pIntFlags->fFatalGeneral = TRUE;
pErrorStats->fFatalChipError = TRUE;
}
if ( (usReadData & 0x1000) != 0 )
{
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_2;
f_pIntFlags->fFatalGeneral = TRUE;
pErrorStats->fFatalChipError = TRUE;
}
if ( (usReadData & 0x0400) != 0 )
{
f_pIntFlags->fErrorPllJitter = TRUE;
pErrorStats->ulPllJitterErrorCnt++;
/* Update the PLL jitter error count here. */
if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
{
ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
ulResult = Oct6100ApiReadDword( f_pApiInstance,
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
&ulTempData );
/* Read previous value set in the feature field. */
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
/* Update counter. */
ulCounterValue = ulTempData & ulMask;
ulCounterValue = ulCounterValue >> ulFeatureBitOffset;
ulCounterValue ++;
/* Handle wrap around case. */
ulCounterValue &= ( 1 << ulFeatureFieldLength ) - 1;
/* Clear old counter value. */
ulTempData &= (~ulMask);
ulTempData |= ulCounterValue << ulFeatureBitOffset;
/* Write the DWORD where the field is located.*/
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
ulTempData );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
}
/*=======================================================================*/
}
else
{
pIntrptManage->usRegister202h = 0x0;
}
/* H.100 registers. */
if ( (f_ulRegister210h & 0x00004) != 0 )
{
/*=======================================================================*/
/* Read registers of this module. */
ReadParams.ulReadAddress = 0x302;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check which interrupts were set. */
if ( (usReadData & 0x0100) != 0 )
{
f_pIntFlags->fErrorH100OutOfSync = TRUE;
pErrorStats->ulH100OutOfSyncCnt++;
}
if ( (usReadData & 0x1000) != 0 )
{
f_pIntFlags->fErrorH100FrameA = TRUE;
pErrorStats->ulH100FrameABadCnt++;
}
if ( (usReadData & 0x4000) != 0 )
{
f_pIntFlags->fErrorH100ClkA = TRUE;
pErrorStats->ulH100ClkABadCnt++;
}
if ( (usReadData & 0x8000) != 0 )
{
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
{
f_pIntFlags->fErrorH100ClkB = TRUE;
pErrorStats->ulH100ClkBBadCnt++;
}
}
pIntrptManage->usRegister302h = usReadData;
/*=======================================================================*/
}
else
{
pIntrptManage->usRegister302h = 0x0;
}
/* TDMIE registers. */
if ( (f_ulRegister210h & 0x00010) != 0 )
{
/*=======================================================================*/
/* Read register. */
ReadParams.ulReadAddress = 0x502;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check which interrupts were set. */
if ( (usReadData & 0x0002) != 0 )
{
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_3;
f_pIntFlags->fFatalGeneral = TRUE;
pErrorStats->fFatalChipError = TRUE;
}
pIntrptManage->usRegister502h = usReadData;
/*=======================================================================*/
}
else
{
pIntrptManage->usRegister502h = 0x0;
}
/* PGSP registers. */
if ( (f_ulRegister210h & 0x00080) != 0 )
{
/*=======================================================================*/
/* Read register. */
ReadParams.ulReadAddress = 0x702;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check which interrupts were set. */
if ( (usReadData & 0x0002) != 0 )
{
f_pIntFlags->fErrorOverflowToneEvents = TRUE;
pErrorStats->ulOverflowToneEventsCnt++;
}
pIntrptManage->usRegister702h = usReadData;
/*=======================================================================*/
}
else
{
pIntrptManage->usRegister702h = 0x0;
}
/* If this is the first time the ISR is called, clear the ISR is not called bit */
/* in external memory to signal the remote client that we are called. */
if ( pSharedInfo->IntrptManage.fIsrCalled == FALSE )
{
/* Remember that we are being called. */
pSharedInfo->IntrptManage.fIsrCalled = TRUE;
if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
{
ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
ulResult = Oct6100ApiReadDword( f_pApiInstance,
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
&ulTempData );
/* Read previous value set in the feature field. */
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
/* Clear the field. */
ulTempData &= (~ulMask);
/* Write the DWORD where the field is located.*/
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
ulTempData );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
}
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiUpdateIntrptStates
Description: Updates the state of all interrupt register groups.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntFlags Interrupt flags.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiUpdateIntrptStates
UINT32 Oct6100ApiUpdateIntrptStates(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
{
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
/*-----------------------------------------------------------------------*/
if ( ( f_pIntFlags->fFatalReadTimeout == TRUE) &&
pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
{
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
pIntrptManage->ulFatalMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
pIntrptManage->ulFatalMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
}
/*-----------------------------------------------------------------------*/
if ( (f_pIntFlags->fErrorRefreshTooLate == TRUE ||
f_pIntFlags->fErrorPllJitter == TRUE ) &&
pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
{
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
pIntrptManage->ulErrorMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
pIntrptManage->ulErrorMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
}
/*-----------------------------------------------------------------------*/
if ( (f_pIntFlags->fErrorOverflowToneEvents == TRUE) &&
pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT &&
pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
{
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_WILL_TIMEOUT;
pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
}
/*-----------------------------------------------------------------------*/
if ( (f_pIntFlags->fErrorH100OutOfSync == TRUE ||
f_pIntFlags->fErrorH100ClkA == TRUE ||
f_pIntFlags->fErrorH100ClkB == TRUE ||
f_pIntFlags->fErrorH100FrameA == TRUE ) &&
pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT &&
pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
{
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_WILL_TIMEOUT;
pIntrptManage->ulErrorH100DisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
pIntrptManage->ulErrorH100DisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
}
/*-----------------------------------------------------------------------*/
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiWriteIntrptRegs
Description: Writes to interrupt registers to clear interrupt condition, and
writes to an interrupt's IE register if interrupt is to time
out.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiWriteIntrptRegs
UINT32 Oct6100ApiWriteIntrptRegs(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
{
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
tOCT6100_WRITE_PARAMS WriteParams;
UINT32 ulResult;
/* Get some local pointers. */
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
/* Set some parameters of write struct. */
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
/*===========================================================================*/
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
{
WriteParams.ulWriteAddress = 0x104;
WriteParams.usWriteData = 0x0000;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
if ( (pIntrptManage->usRegister102h & cOCT6100_INTRPT_MASK_REG_102H) != 0 )
{
WriteParams.ulWriteAddress = 0x102;
WriteParams.usWriteData = pIntrptManage->usRegister102h;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*===========================================================================*/
/*===========================================================================*/
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT ||
pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
{
WriteParams.ulWriteAddress = 0x204;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x1800;
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x0401;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
if ( (pIntrptManage->usRegister202h & cOCT6100_INTRPT_MASK_REG_202H) != 0 )
{
WriteParams.ulWriteAddress = 0x202;
WriteParams.usWriteData = pIntrptManage->usRegister202h;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*===========================================================================*/
/*===========================================================================*/
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_WILL_TIMEOUT )
{
WriteParams.ulWriteAddress = 0x304;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->fMclkIntrptActive == TRUE )
WriteParams.usWriteData |= 0x0001;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
if ( (pIntrptManage->usRegister302h & cOCT6100_INTRPT_MASK_REG_302H) != 0 )
{
WriteParams.ulWriteAddress = 0x302;
WriteParams.usWriteData = pIntrptManage->usRegister302h;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*===========================================================================*/
/*===========================================================================*/
if ( (pIntrptManage->usRegister502h & cOCT6100_INTRPT_MASK_REG_502H) != 0 )
{
WriteParams.ulWriteAddress = 0x502;
WriteParams.usWriteData = pIntrptManage->usRegister502h;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*===========================================================================*/
/*===========================================================================*/
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_WILL_TIMEOUT )
{
WriteParams.ulWriteAddress = 0x704;
WriteParams.usWriteData = 0x0000;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
if ( (pIntrptManage->usRegister702h & cOCT6100_INTRPT_MASK_REG_702H) != 0 )
{
WriteParams.ulWriteAddress = 0x702;
WriteParams.usWriteData = pIntrptManage->usRegister702h;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*===========================================================================*/
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiWriteIeRegs
Description: Writes the IE field of each interrupt register.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiWriteIeRegs
UINT32 Oct6100ApiWriteIeRegs(
tPOCT6100_INSTANCE_API f_pApiInstance )
{
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
tOCT6100_WRITE_PARAMS WriteParams;
tOCT6100_READ_PARAMS ReadParams;
UINT32 ulResult;
/* Get some local pointers. */
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
/* Set some parameters of write struct. */
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
/* Set some parameters of read struct. */
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
/*==================================================================================*/
WriteParams.ulWriteAddress = 0x104;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x0001;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/*==================================================================================*/
/*==================================================================================*/
WriteParams.ulWriteAddress = 0x204;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x1800;
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x0401;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/*==================================================================================*/
/*==================================================================================*/
WriteParams.ulWriteAddress = 0x304;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->fMclkIntrptActive == TRUE )
WriteParams.usWriteData |= 0x0001;
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
{
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
WriteParams.usWriteData |= 0xD100;
else
WriteParams.usWriteData |= 0x5100;
}
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/*==================================================================================*/
/*==================================================================================*/
WriteParams.ulWriteAddress = 0x504;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byFatalGeneralState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x0002;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/*==================================================================================*/
/*==================================================================================*/
WriteParams.ulWriteAddress = 0x704;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x0002;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/*==================================================================================*/
/*==================================================================================*/
/* Enable the GLOBAL IEs for the interrupt pin. */
WriteParams.ulWriteAddress = 0x218;
WriteParams.usWriteData = 0x00D7;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/*==================================================================================*/
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiReadChipMclkTime
Description: Reads the chip's mclk cycle count to construct a chip time.
The time is used to manage interrupts.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiReadChipMclkTime
UINT32 Oct6100ApiReadChipMclkTime(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
{
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
tPOCT6100_SHARED_INFO pSharedInfo;
tOCT6100_READ_PARAMS ReadParams;
UINT32 ulCheckData;
UINT32 ulResult;
UINT32 i;
UINT16 usReadData;
/* Get local pointer(s). */
pSharedInfo = f_pApiInstance->pSharedInfo;
pIntrptManage = &pSharedInfo->IntrptManage;
/* Assign memory for read data. */
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
ReadParams.pusReadData = &usReadData;
/* Perform reads. */
for ( i = 0; i < 100; i++ )
{
ReadParams.ulReadAddress = 0x306;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
pIntrptManage->ulRegMclkTimeHigh = usReadData & 0xFF;
ulCheckData = usReadData;
ReadParams.ulReadAddress = 0x308;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
pIntrptManage->ulRegMclkTimeLow = (usReadData & 0xFFFF) << 16;
ReadParams.ulReadAddress = 0x306;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
if ( ulCheckData == usReadData )
break;
}
if ( i == 100 )
return cOCT6100_ERR_FATAL_2F;
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiUpdateIntrptTimeouts
Description: Checks which interrupt groups have finished their timeout
period.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiUpdateIntrptTimeouts
UINT32 Oct6100ApiUpdateIntrptTimeouts(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
{
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
tOCT6100_WRITE_PARAMS WriteParams;
UINT32 ulRegMclkTimePlus5MsHigh;
UINT32 ulRegMclkTimePlus5MsLow;
UINT32 ulResult;
BOOL fFatalMemoryChange = FALSE;
BOOL fDataErrMemoryChange = FALSE;
BOOL fErrorOverflowToneEventsChange = FALSE;
BOOL fH100ErrorChange = FALSE;
/* Get local pointer to interrupt management structure. */
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
/* Calculate mclk time + 5 ms. */
ulRegMclkTimePlus5MsLow = pIntrptManage->ulRegMclkTimeLow + (5 * pIntrptManage->ulNumMclkCyclesIn1Ms);
if ( ulRegMclkTimePlus5MsLow < pIntrptManage->ulRegMclkTimeLow )
ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh + 1;
else /* ( ulRegMclkTimePlus5MsLow >= pIntrptManage->ulRegMclkTimeLow ) */
ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh;
/* Check which interrupts are timed out and need to be reenabled now. */
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
{
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulFatalMemoryDisableMclkHigh, pIntrptManage->ulFatalMemoryDisableMclkLow, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptManage->byFatalMemoryState, fFatalMemoryChange )
}
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
{
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorMemoryDisableMclkHigh, pIntrptManage->ulErrorMemoryDisableMclkLow, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptManage->byErrorMemoryState, fDataErrMemoryChange )
}
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_IN_TIMEOUT )
{
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptManage->byErrorOverflowToneEventsState, fErrorOverflowToneEventsChange )
}
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_IN_TIMEOUT )
{
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorH100DisableMclkHigh, pIntrptManage->ulErrorH100DisableMclkLow, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptManage->byErrorH100State, fH100ErrorChange )
}
/* Set some parameters of write struct. */
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
/* Write to the IE registers which have changed. */
/*==================================================================================*/
if ( fFatalMemoryChange == TRUE )
{
WriteParams.ulWriteAddress = 0x104;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x0001;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*==================================================================================*/
/*==================================================================================*/
if ( fFatalMemoryChange == TRUE ||
fDataErrMemoryChange == TRUE )
{
WriteParams.ulWriteAddress = 0x204;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x1800;
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x0401;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*==================================================================================*/
/*==================================================================================*/
if ( pIntrptManage->fMclkIntrptActive == TRUE ||
fH100ErrorChange == TRUE )
{
WriteParams.ulWriteAddress = 0x304;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->fMclkIntrptActive == TRUE )
WriteParams.usWriteData |= 0x0001;
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
{
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
WriteParams.usWriteData |= 0xD100;
else
WriteParams.usWriteData |= 0x5100;
}
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*==================================================================================*/
/*==================================================================================*/
if ( fErrorOverflowToneEventsChange == TRUE )
{
WriteParams.ulWriteAddress = 0x704;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
WriteParams.usWriteData |= 0x0002;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
/*==================================================================================*/
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiScheduleNextMclkIntrptSer
Description: Serialized sub-function of Oct6100ApiScheduleNextMclkIntrpt.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiScheduleNextMclkIntrptSer
UINT32 Oct6100ApiScheduleNextMclkIntrptSer(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
{
tPOCT6100_SHARED_INFO pSharedInfo;
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
tOCT6100_WRITE_PARAMS WriteParams;
UINT32 ulTimeDiff;
UINT32 ulRegMclkTimeHigh;
UINT32 ulRegMclkTimeLow;
UINT32 ulResult;
BOOL fConditionFlag = TRUE;
/* Get local pointer(s). */
pSharedInfo = f_pApiInstance->pSharedInfo;
/* Obtain temporary pointers to reduce indirection, thus speeding up processing. */
pIntrptConfig = &pSharedInfo->IntrptConfig;
pIntrptManage = &pSharedInfo->IntrptManage;
ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
/* First, check if any interrupts have just been disabled. If there are any, */
/* determine the time at which they should be reenabled. */
pIntrptManage->ulNextMclkIntrptTimeHigh = cOCT6100_INVALID_VALUE;
pIntrptManage->ulNextMclkIntrptTimeLow = cOCT6100_INVALID_VALUE;
while ( fConditionFlag )
{
/* Indicate that no mclk interrupt is needed, yet. */
ulTimeDiff = cOCT6100_INVALID_VALUE;
/* Check each interrupt category to see if an mclk interrupt is needed to */
/* reenable an interrupt at a later time. */
if ( pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_ACTIVE &&
pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_DISABLED )
{
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byFatalMemoryState, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptConfig->ulFatalMemoryTimeoutMclk, ulTimeDiff )
}
if ( pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_ACTIVE &&
pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
{
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorMemoryState, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptConfig->ulErrorMemoryTimeoutMclk, ulTimeDiff )
}
if ( pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_ACTIVE &&
pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
{
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorOverflowToneEventsState, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk, ulTimeDiff )
}
if ( pIntrptManage->byErrorH100State != cOCT6100_INTRPT_ACTIVE &&
pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
{
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorH100State, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptConfig->ulErrorH100TimeoutMclk, ulTimeDiff )
}
/* Set some parameters of write struct. */
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
/* Schedule next mclk interrupt, if any is needed. */
if ( ulTimeDiff != cOCT6100_INVALID_VALUE )
{
UINT32 ulMclkTimeTest;
UINT32 ulAlarmTimeTest;
UINT32 ulTimeDiffTest;
BOOL fAlarmTimePassed;
/* Indicate that an mclk interrupt is scheduled.*/
pIntrptManage->fMclkIntrptActive = TRUE;
pIntrptManage->ulNextMclkIntrptTimeLow = ulRegMclkTimeLow + ulTimeDiff;
if ( pIntrptManage->ulNextMclkIntrptTimeLow < ulRegMclkTimeLow )
pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh + 1;
else /* ( pIntrptManage->ulNextMclkIntrptTimeLow >= ulRegMclkTimeLow ) */
pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh;
WriteParams.ulWriteAddress = 0x30C;
WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 24) & 0xFF );
WriteParams.usWriteData |= (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeHigh & 0xFF) << 8 );
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
WriteParams.ulWriteAddress = 0x30E;
WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 8) & 0xFFFF );
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
WriteParams.ulWriteAddress = 0x304;
WriteParams.usWriteData = 0;
if ( pIntrptManage->fMclkIntrptActive == TRUE )
WriteParams.usWriteData = 0x0001;
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
{
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
WriteParams.usWriteData |= 0xD100;
else
WriteParams.usWriteData |= 0x5100;
}
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Disable the ROL if previously set. */
WriteParams.ulWriteAddress = 0x302;
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check if already passed the next interrupt time. */
ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
ulMclkTimeTest = (pIntrptManage->ulRegMclkTimeLow >> 16) & 0xFFFF;
ulAlarmTimeTest = (pIntrptManage->ulNextMclkIntrptTimeLow >> 16) & 0xFFFF;
/* Update the local Mlck timer values.*/
ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
fAlarmTimePassed = FALSE;
if ( ulMclkTimeTest > ulAlarmTimeTest )
{
ulTimeDiffTest = ulMclkTimeTest - ulAlarmTimeTest;
if ( ulTimeDiffTest <= 0x8000 )
fAlarmTimePassed = TRUE;
}
else /* ( ulMclkTimeTest <= ulAlarmTimeTest ) */
{
ulTimeDiffTest = ulAlarmTimeTest - ulMclkTimeTest;
if ( ulTimeDiffTest > 0x8000 )
fAlarmTimePassed = TRUE;
}
if ( fAlarmTimePassed == TRUE )
{
/* Passed the interrupt time. Schedule next interrupt (if needed). */
ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
continue;
}
else
{
fConditionFlag = FALSE;
}
}
else
{
/* Indicate that no mclk interrupt is scheduled. */
pIntrptManage->fMclkIntrptActive = FALSE;
/* Insure that the mclk interrupt is not enabled. */
WriteParams.ulWriteAddress = 0x304;
WriteParams.usWriteData = 0x0000;
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
{
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
WriteParams.usWriteData |= 0xD100;
else
WriteParams.usWriteData |= 0x5100;
}
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
fConditionFlag = FALSE;
}
}
return cOCT6100_ERR_OK;
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: Oct6100ApiCheckProcessorState
Description: This function verifies if the NLP and AF processors are operating
correctly.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
f_pApiInstance Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
f_pIntFlags Pointer to a tOCT6100_INTERRUPT_FLAGS structure.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if !SKIP_Oct6100ApiCheckProcessorState
UINT32 Oct6100ApiCheckProcessorState(
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
IN OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
{
tPOCT6100_SHARED_INFO pSharedInfo;
tOCT6100_READ_PARAMS ReadParams;
tOCT6100_READ_BURST_PARAMS ReadBurstParams;
UINT32 ulNlpTimestamp;
UINT32 ulAfTimestamp;
UINT32 ulTimestampDiff;
UINT32 ulResult;
UINT32 i;
UINT16 usReadData;
UINT16 ausReadData[ 2 ];
UINT32 aulWaitTime[ 2 ];
/* Get local pointer(s). */
pSharedInfo = f_pApiInstance->pSharedInfo;
/* Set some parameters of write struct. */
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
ReadParams.pusReadData = &usReadData;
/* Set some parameters of write struct. */
ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
ReadBurstParams.pusReadData = ausReadData;
/*-----------------------------------------------------------------------*/
/* Check if chip is in reset. */
/* Read the main control register. */
ReadParams.ulReadAddress = 0x100;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
if ( usReadData == 0x0000 )
{
/* Chip was resetted. */
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_4;
f_pIntFlags->fFatalGeneral = TRUE;
pSharedInfo->ErrorStats.fFatalChipError = TRUE;
}
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* Reading the AF timestamp.*/
for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
{
/* Read the timestamp.*/
ReadBurstParams.ulReadAddress = 0x082E0008;
ReadBurstParams.ulReadLength = 2;
mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Read the high part again to make sure it didn't wrap. */
ReadParams.ulReadAddress = 0x082E0008;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check if the low part wrapped. */
if ( ausReadData[ 0 ] == usReadData )
break;
}
if ( i == cOCT6100_MAX_LOOP )
return cOCT6100_ERR_INTRPTS_AF_TIMESTAMP_READ_TIMEOUT;
/* Save the AF timestamp. */
ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* Reading the NLP timestamp. */
for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
{
/* Read the timestamp. */
ReadBurstParams.ulReadAddress = 0x08000008;
ReadBurstParams.ulReadLength = 2;
mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Read the high part again to make sure it didn't wrap. */
ReadParams.ulReadAddress = 0x08000008;
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Check if the low part wrapped. */
if ( ausReadData[ 0 ] == usReadData )
break;
}
if ( i == cOCT6100_MAX_LOOP )
return cOCT6100_ERR_INTRPTS_NLP_TIMESTAMP_READ_TIMEOUT;
/* Save the NLP timestamp. */
ulNlpTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* Check the validity of the timestamp. */
if ( ulAfTimestamp > ulNlpTimestamp )
{
/* The NLP timestamp wrapped. */
ulTimestampDiff = 0xFFFFFFFF - ulAfTimestamp + 1;
ulTimestampDiff += ulNlpTimestamp;
}
else
ulTimestampDiff = ulNlpTimestamp - ulAfTimestamp;
if ( ulTimestampDiff > 0x2000 )
{
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_5;
f_pIntFlags->fFatalGeneral = TRUE;
pSharedInfo->ErrorStats.fFatalChipError = TRUE;
}
/*Check if AF and NLP are both stuck*/
if ( f_pIntFlags->fErrorH100ClkA == FALSE &&
f_pIntFlags->fErrorH100ClkB == FALSE &&
f_pIntFlags->fErrorH100FrameA == FALSE &&
f_pIntFlags->fErrorH100OutOfSync == FALSE )
{
if ( ulAfTimestamp == 0 && ulNlpTimestamp == 0 )
{
/*Give some time to the counters*/
aulWaitTime[ 0 ] = 250;
aulWaitTime[ 1 ] = 0;
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/*Let's read again the AF timestamp to be sure. Maybe they were at 0 at the same time*/
ReadBurstParams.ulReadAddress = 0x082E0008;
ReadBurstParams.ulReadLength = 2;
mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
if ( ulAfTimestamp == 0 )
{
/*TDM Clocks are ok but NLP and AF timestamps are both at 0*/
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_9;
f_pIntFlags->fFatalGeneral = TRUE;
pSharedInfo->ErrorStats.fFatalChipError = TRUE;
}
}
}
/*-----------------------------------------------------------------------*/
return cOCT6100_ERR_OK;
}
#endif
|