bmt_main.c
54.8 KB
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
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* BMT_main.c
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This Module defines main function of the BMT task.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#include "drv_comm.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "task_config.h" /* Task creation */
#include "stack_ltlcom.h" /* msg_send_ext_queue.....definitions */
#include "bmt.h"
#include "bmt_trc.h"
#include "drvsignals.h"
// For RHR ADD Usage
#include "stack_config.h"
#include "kal_trace.h"
#include "task_main_func.h"
#include "bmt_sw.h"
#include "dcl.h"
#include "kal_general_types.h"
#include "kal_public_api.h"
#include "hisr_config.h"
#include "kal_public_defs.h"
#ifdef __DRV_BMT_SW_POLLING_CHARGER_OV__
extern kal_timerid bmt_sw_polling_timerId;
#endif //#ifdef __DRV_BMT_SW_POLLING_CHARGER_OV__
extern const kal_uint8 gCHRDET_EINT_NO;
#if defined(DRV_GPT_GPT3)
#if (defined(__CS_SERVICE__) && defined(__PS_SERVICE__))
#define PERIOD_RST_TO_DRVINT 1000
#else // #if (defined(__CS_SERVICE__) && defined(__PS_SERVICE__))
#define PERIOD_RST_TO_DRVINT 100
#endif // #if (defined(__CS_SERVICE__) && defined(__PS_SERVICE__))
#endif // #if defined(DRV_GPT_GPT3)
extern void bmt_adc_init(void);
extern void bmt_charge_start(void);
extern void bmt_charge_end(void);
extern void BMT_CHARSTOP(void);
extern void USB_PowerControl(kal_bool enable);
extern Customer_Period_Period(void);
extern BMTStruct BMT;
extern stack_timer_struct *timer_adcsche; /*Normal Measure, only monitor VBAT*/
extern stack_timer_struct *timer_stopcharge;
extern event_scheduler *adc_sche_event_scheduler_ptr;
extern const kal_uint8 adc_timer_index;
stack_timer_struct aux_timer; //for detect earphone plug in before booting.
kal_uint32 VBAT_OFF = 3900000;
double ADCBAT_OFF = 0;
//extern ADC_CALIDATA adc_cali_param;
extern stack_timer_struct ChargeTimeout_timer;
//#ifdef PMIC_PRESENT
#if defined(PMIC_PRESENT)
static Charger_Status previous_chr_status=bmt_chr_uninit;
#endif // #if defined(PMIC_PRESENT)
static Charger_Status chr_status;
static kal_uint8 chr_read_flag;
#if defined(__USB_ENABLE__)
static bmt_usb_state_enum bmt_usb_state = USB_INIT_STATE;
PMU_CHR_CURRENT_ENUM bmt_usb_chr_current=PMU_CHARGE_CURRENT_0_00_MA;
#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
extern void BMT_VbatInHISR_Init(void);
#endif //#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
#endif // #if defined(__USB_ENABLE__)
#if (( defined(__USB_ENABLE__) && defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__) && !defined(DRV_USB_IP_V3)) || defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__) )
volatile kal_uint8 bmt_event_sche_active = 0;
#endif // #if !defined(DRV_USB_IP_V3)
#ifdef __BACKUP_DOWNLOAD_RESTORE_WITHOUT_BATTERY__
DCL_HANDLE bmt_without_battery_handle = 0x7F;
void bmt_without_battery_callback(void *parameter)
{
DCL_HANDLE pmu_handle;
pmu_handle = DclPMU_Open(DCL_PMU, FLAGS_NONE);
DclPMU_Control(pmu_handle, CHR_SET_WDT_CLEAR, NULL);
DclPMU_Close(pmu_handle);
{
SGPT_CTRL_START_T start;
start.u2Tick=200; // 2 secs
start.pfCallback=bmt_without_battery_callback;
start.vPara=NULL;
DclSGPT_Control(bmt_without_battery_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
}
}
#endif //#ifdef __BACKUP_DOWNLOAD_RESTORE_WITHOUT_BATTERY__
#if defined(__DRV_BATTERY_EXIST_DETECTION__)
stack_timer_struct timer_batt_det;
static kal_bool batt_exist_flag = KAL_TRUE; // Assume batt is mounted at init state
#endif // #if defined(__DRV_BATTERY_EXIST_DETECTION__)
#ifdef __BMT_CHARGE_GUARD_TIME__
extern stack_timer_struct *timer_guardcharge;
#endif // #if defined(__BMT_CHARGE_GUARD_TIME__)
#if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)
extern stack_timer_struct *timer_estimative;
#endif // #if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)
//#define BOOTING_DELAY 20 //need longer than first plugin debounce.
#if defined(DRV_BMT_BOOTING_DELAY_EXTEND)
kal_uint32 BOOTING_DELAY = 100; //need longer than first plugin debounce.
#else
kal_uint32 BOOTING_DELAY = 40; //need longer than first plugin debounce.
#endif
kal_bool aux_first_booting = KAL_TRUE; // for inform MMI already finish booting AUX detection
DCL_HANDLE bmt_PmuHandler;
extern kal_bool BMT_Current_Voltage(DCL_ADC_CHANNEL_TYPE_ENUM ch, kal_uint32 *voltage, double *adc_value);
// default adc scheduler complete call back
void adc_sche_task_complete_callback(DCL_INT32 handle, DCL_INT32 volt_result, DCL_DOUBLE adc_result)
{
#ifndef L4_NOT_PRESENT
ilm_struct *BMT_ilm;
bmt_adc_measure_done_conf_struct *BMT_Prim;
ADC_CTRL_GET_PHYSICAL_CHANNEL_T adc_ch;
ADC_CTRL_GET_SCHEDULER_PARAMETER_T SchedulerPara;
adc_ch.u2AdcName = DCL_VBAT_ADC_CHANNEL;
DclSADC_Control(handle, ADC_CMD_GET_CHANNEL, (DCL_CTRL_DATA_T *)&adc_ch);
SchedulerPara.u4Handle = handle;
DclSADC_Control(handle, ADC_CMD_GET_SCHEDULER_PARAMETER, (DCL_CTRL_DATA_T *)&SchedulerPara);
if (SchedulerPara.pPara.bSend_primitive)
{
BMT_Prim = (bmt_adc_measure_done_conf_struct*)
construct_local_para(sizeof(bmt_adc_measure_done_conf_struct), TD_CTRL);
BMT_Prim->adc_handle = handle;
if ((SchedulerPara.pPara.u1Adc_phy_id == adc_ch.u1AdcPhyCh) &&
(SchedulerPara.pPara.u4Ownerid == MOD_UEM) )
{
switch(BMT.VBAT_UEM)
{
case VBAT_UEM_CHR_OUT:
BMT_Prim->volt= volt_result;
BMT_Prim->adc_value = adc_result;
break;
case VBAT_UEM_CHR_IN:
BMT_Prim->volt= (kal_int32)VBAT_OFF;
BMT_Prim->adc_value = ADCBAT_OFF;
break;
case VBAT_UEM_CHR_IN_FISRT:
BMT_Prim->volt= volt_result;
BMT_Prim->adc_value = adc_result;
BMT.VBAT_UEM = VBAT_UEM_CHR_IN;
break;
case VBAT_UEM_CHR_OUT_FIRST:
BMT_Prim->volt= (kal_int32)VBAT_OFF;
BMT_Prim->adc_value = ADCBAT_OFF;
BMT.VBAT_UEM = VBAT_UEM_CHR_OUT;
break;
}
}
else
{
BMT_Prim->volt= volt_result;
BMT_Prim->adc_value = adc_result;
}
if (SchedulerPara.pPara.u4Ownerid == MOD_L1)
{
DRV_SendPrimitive(BMT_ilm,
MOD_BMT,
(module_type)SchedulerPara.pPara.u4Ownerid,
MSG_ID_BMT_ADC_MEASURE_DONE_CONF,
BMT_Prim,
DRIVER_L1_SAP); // DCL can use SchedulerPara.pPara.u4Sapid
msg_send_ext_queue(BMT_ilm);
}
else
{
DRV_BuildPrimitive(BMT_ilm,
MOD_BMT,
(module_type)SchedulerPara.pPara.u4Ownerid,
MSG_ID_BMT_ADC_MEASURE_DONE_CONF,
BMT_Prim);
msg_send_ext_queue(BMT_ilm);
}
}
#endif // #ifndef L4_NOT_PRESENT
}
/*
* FUNCTION
* BMT_sendMes
*
* DESCRIPTION
* This function is used to send message to BMT task
*
* CALLS
*
* PARAMETERS
* queue: BMT_QUEUE
* message_id: the message id
*
* RETURNS
* None
*
* GLOBALS AFFECTED
* None
*/
/*send to BMT task*/
void BMT_sendMes(module_type srcid, msg_type msgid)
{
ilm_struct *BMT_ilm;
DRV_BuildPrimitive(BMT_ilm,
srcid,
MOD_BMT,
msgid,
NULL);
msg_send_ext_queue(BMT_ilm);
}
void BMT_sendMes2UEM(BMT_CHR_STAT status)
{
#ifndef L4_NOT_PRESENT
ilm_struct *BMT_ilm;
#if (defined(__UART1_WITH_CHARGER__) || defined(__UART2_WITH_CHARGER__) || defined(__UART3_WITH_CHARGER__))
#if defined(__TST_MODULE__)
ilm_struct *TST_ilm;
drvuem_pmic_ind_struct *TST_Prim;
#endif
#endif
drvuem_pmic_ind_struct *BMT_Prim;
module_type src_mod;
if(kal_if_hisr() == KAL_TRUE)
src_mod = MOD_DRV_HISR;
else
src_mod = MOD_BMT;
BMT_Prim = (drvuem_pmic_ind_struct*)
construct_local_para(sizeof(drvuem_pmic_ind_struct), TD_CTRL);
BMT_Prim->status= status;
DRV_BuildPrimitive(BMT_ilm,
src_mod,
MOD_UEM,
MSG_ID_DRVUEM_PMIC_IND,
BMT_Prim);
msg_send_ext_queue(BMT_ilm);
#if (defined(__UART1_WITH_CHARGER__) || defined(__UART2_WITH_CHARGER__) || defined(__UART3_WITH_CHARGER__))
#if defined(__TST_MODULE__)
TST_Prim = (drvuem_pmic_ind_struct*)
construct_local_para(sizeof(drvuem_pmic_ind_struct), TD_CTRL);
// If add any plug-in/out status in drvsignals.h, need to add the new status here!!
if( (status == BMT_CHARGER_IN) ||
(status == BMT_INVALID_CHARGER))
{
TST_Prim->status= BMT_CHARGER_IN;
}
DRV_BuildPrimitive(TST_ilm,
src_mod,
MOD_TST_READER,
MSG_ID_DRVUEM_PMIC_IND,
TST_Prim);
msg_send_ext_queue(TST_ilm);
#endif //#if defined(__TST_MODULE__)
#endif //__UART1_WITH_CHARGER__
#endif // #ifndef L4_NOT_PRESENT
}
void bmt_set_chr_status(Charger_Status status)
{
chr_status = status;
#if defined(DRV_BMT_HW_PRECC_WORKAROUND)
HW_Plug_Status = status; // To save current H/W plug status
#endif
if (chr_read_flag == 0)
{
chr_read_flag = 1;
BMT_sendMes(MOD_EINT_HISR/*MOD_BMT*/,MSG_ID_BMT_CHARGER_IND);
}
}
Charger_Status bmt_read_chr_status(void)
{
chr_read_flag = 0;
return chr_status;
}
void bmt_adc_sche_add_item(local_para_struct *buf)
{
DCL_STATUS adc_status;
ADC_CTRL_REGISTER_COMPLETE_CB_T registerCB;
bmt_adc_add_item_req_struct *ptr=(bmt_adc_add_item_req_struct *)buf;
registerCB.pfComplete_cb = (PFN_DCLSADC_COMPLETE_CALLBACK)adc_sche_task_complete_callback;
adc_status = DclSADC_Control(ptr->adc_handle, ADC_CMD_REGISTER_COMPLETE_CB, (DCL_CTRL_DATA_T *)®isterCB);
if(adc_status != STATUS_OK)
{
ASSERT(0);
}
adc_status = DclSADC_Control(ptr->adc_handle, ADC_CMD_START_MEASURE, NULL);
if(adc_status != STATUS_OK)
{
ASSERT(0);
}
}
void bmt_adc_sche_remove_item(local_para_struct *buf)
{
DCL_STATUS adc_status;
bmt_adc_remove_item_req_struct *ptr=(bmt_adc_remove_item_req_struct *)buf;
adc_status = DclSADC_Control(ptr->adc_handle, ADC_CMD_STOP_MEASURE, NULL);
if(adc_status != STATUS_OK)
{
ASSERT(0);
}
}
void bmt_adc_sche_modify_parameters(local_para_struct *buf)
{
DCL_STATUS adc_status;
ADC_CTRL_MODIFY_PARAM_T adc_para;
bmt_adc_modify_parameters_req_struct *ptr=(bmt_adc_modify_parameters_req_struct *)buf;
adc_para.u4Period = ptr->period;
adc_para.u1EvaluateCount = ptr->evaluate_count;
adc_status = DclSADC_Control(ptr->adc_handle, ADC_CMD_MODIFY_PARAM, (DCL_CTRL_DATA_T *)&adc_para);
if(adc_status != STATUS_OK)
{
ASSERT(0);
}
}
/*
* FUNCTION
* bmt_check_poweron
*
* DESCRIPTION
* This function is to check if AC/USB exists at CHRPWRON/USBPWRON
*
* CALLS
*
* PARAMETERS
*
*
* RETURNS
* Receive primitive from the specified queue.
*
* GLOBALS AFFECTED
* None
*/
void bmt_check_poweron(kal_uint8 power_on)
{
kal_bool state=KAL_FALSE;
DCL_HANDLE dcl_wdt_handle;
DCL_HANDLE pw_handle;
#if !defined(__DRV_EXT_CHARGER_DETECTION__)
PMU_CTRL_CHR_GET_CHR_DET_STATUS chr_det_status;
#endif
dcl_wdt_handle = DclWDT_Open(DCL_WDT, FLAGS_NONE);
pw_handle = DclPW_Open(DCL_PW, FLAGS_NONE);
#if defined(__DRV_EXT_CHARGER_DETECTION__)
if (ext_charger_det->det_charger_present() != NO_PRESENT)
{
state = KAL_TRUE;
}
if (ext_charger_det->support_usb_det() != KAL_TRUE)
{
ASSERT(0); // Need to find a way to detect USB
}
state = KAL_FALSE;
#else
DclPMU_Control(bmt_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chr_det_status);
state = (kal_bool)chr_det_status.enable;
#endif // #if defined(__DRV_EXT_CHARGER_DETECTION__)
#if !defined(__USB_ENABLE__)
if (power_on==(kal_uint8)CHRPWRON||power_on==(kal_uint8)PRECHRPWRON)
#else // #if !defined(__USB_ENABLE__)
if(power_on==(kal_uint8)CHRPWRON||power_on==(kal_uint8)PRECHRPWRON||
power_on==(kal_uint8)USBPWRON||power_on==(kal_uint8)USBPWRON_WDT)
#endif // #if !defined(__USB_ENABLE__)
{
if(state==KAL_FALSE)
{
while(1)
{
kal_uint32 delay=0;
DclPW_Control(pw_handle,PW_CMD_POWEROFF,NULL);
DclPW_Close(pw_handle);
for(delay=0;delay<5000;delay++){};
DclWDT_Control(dcl_wdt_handle,WDT_CMD_DRV_RESET,0);
}
}
}
}
// first_time_det: Means whether it is first time to perform battery detection
// If first time, then need to send the battery status to UEM
void bmt_batt_exist_detection(kal_bool first_time_det)
{
#if defined(__DRV_BATTERY_EXIST_DETECTION__)
kal_bool batt_exist_state;
#ifdef __CS_FAC_DET__
{
cs_fac_boot_mode_enum fac_boot_mode;
fac_boot_mode = cs_fac_det->factory_det_get_boot_mode();
switch (fac_boot_mode)
{
case CS_FAC_BOOT_IDLE:
; // We boot into IDLE on purpose, skip battery check
return;
break;
case CS_FAC_BOOT_CHARGING:
;
break;
case CS_FAC_BOOT_USB_CHARGING:
;
break;
default:
break;
}
}
#endif // #ifdef __CS_FAC_DET__
batt_exist_state = bmt_is_bat_on();
drv_trace1(TRACE_GROUP_10, BMT_MSG_BATT_ON_DET, batt_exist_state);
if ( (batt_exist_flag != batt_exist_state) || (first_time_det) )
{
if (batt_exist_state == KAL_FALSE)
{
// A temp workaround
// It seems UEM expect to receive charger in message first in charger boot mode,
// then be able to process other messages from BMT
if (first_time_det)
{
if (BMT_AC_IN == bmt_IsUSBorCharger())
{
// Send charger in to UEM
BMT_sendMes2UEM(BMT_USB_NO_CHARGING_IN);
}
}
// Batt removal
BMT_sendMes2UEM(BMT_BATT_OUT);
}
else
{
// Batt attached
BMT_sendMes2UEM(BMT_BATT_IN);
// When program run to here, it means we are CHARGER or USB boot mode
// Manually trigger cable plug-in HISR to perform charging procedure
//pmic_adpt_sw_trigger_chr_usb_intr
if ( (!first_time_det) && (batt_exist_flag != batt_exist_state) )
{
BMT_sendMes(MOD_EINT_HISR/*MOD_BMT*/,MSG_ID_BMT_CHARGER_IND);
}
}
batt_exist_flag = batt_exist_state;
}
#endif // #if defined(__DRV_BATTERY_EXIST_DETECTION__)
}
kal_bool bmt_is_bat_on_pw()
{
kal_uint32 voltage=0;
double adc_value=0;
BMT_Current_Voltage(DCL_VBATTMP_ADC_CHANNEL, &voltage, &adc_value);
if(voltage < bmt_charging_para->BATT_EXIST_ADC_THRESHOLD)
return KAL_TRUE;
else
return KAL_FALSE;
}
kal_bool bmt_is_bat_on()
{
if(bmt_charging_para->bmt_check_battery)
{
return bmt_is_bat_on_pw();
}
else
{
return bmt_check_if_bat_on();
}
}
/*
* FUNCTION
* BMT_Task
*
* DESCRIPTION
* This function is used to send message to BMT task.
* This Module defines main function of the BMT task.
*
* CALLS
*
* PARAMETERS
*
*
* RETURNS
* Receive primitive from the specified queue.
*
* GLOBALS AFFECTED
* None
*/
void bmt_task_main(task_entry_struct *task_entry_ptr)
{
#if defined (WISDOM35B_DEMO_BB)
extern const char gpio_ext_chr_ctrl_pin; //for power consumption
DCL_HANDLE gpio_handle;
#endif
aux_id_struct *aux_id_data;
ilm_struct *aux_ilm;
ilm_struct current_ilm;
ilm_struct *BMT_ilm;
drvuem_power_on_ind_struct *power_on_ind;
kal_uint16 UEM_RECEIVE_PWR_IND=2012;
DCL_HANDLE dcl_adc_handle;
DCL_HANDLE pmu_handle;
#if defined(__UMTS_RAT__)
/* under construction !*/
#endif /* __UMTS_RAT__ */
#ifdef BMT_ACTIVE_TO_READ_NVRAM_DATA
nvram_read_req_struct* nvram_read_req;
#endif /*BMT_ACTIVE_TO_READ_NVRAM_DATA*/
#if defined(DRV_GPT_GPT3)
DCL_HANDLE gpt_handle;
FGPT_CTRL_RETURN_COUNT_T current_count;
#endif
drv_trace0(TRACE_GROUP_10, BMT_TASK_MAIN_TRC);
#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
drv_trace0(TRACE_GROUP_10, BMT_HIGH_VCHG_ENABLED_TRC);
#endif //#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
bmt_PmuHandler=DclPMU_Open(DCL_PMU, FLAGS_NONE);
#ifdef __DRV_BMT_SW_POLLING_CHARGER_OV__
bmt_sw_polling_timerId=kal_create_timer("BMT OV SW Timer");
#endif //#ifdef __DRV_BMT_SW_POLLING_CHARGER_OV__
#if ( (!defined(__MAUI_BASIC__)) && (!defined(L4_NOT_PRESENT)) )
// If not Basic load, then we init the timer
// In Basic load, L1S load, there is no L4, send message to UEM module(L4 module) will make ASSERT
stack_init_timer(&aux_timer, "AUX timeout timer", MOD_BMT);
stack_start_timer(&aux_timer, 0, BOOTING_DELAY);
#endif // #if ( (!defined(__MAUI_BASIC__)) && (!defined(L4_NOT_PRESENT)) )
#if defined(__UMTS_RAT__)
/* under construction !*/
#endif /* __UMTS_RAT__ */
#ifdef PMIC_PRESENT
#if defined(__UMTS_RAT__)
/* under construction !*/
/* under construction !*/
#endif // #if defined(__UMTS_RAT__)
pmu_handle = Dcl_Chr_Det_Open(DCL_CHR_USB_DET, FLAGS_NONE);
Dcl_Chr_Det_Control(pmu_handle, CHR_DET_CMD_REGISTER_CHR_USB, NULL);
Dcl_Chr_Det_Close(pmu_handle);
#if defined(__UMTS_RAT__)
/* under construction !*/
#endif // #if defined(__UMTS_RAT__)
#endif /*PMIC_PRESENT*/
#if ( (!defined(L4_NOT_PRESENT)) && (!defined(DUMMY_PROTOCOL)) && (!defined(PMIC_PRESENT)))
//if( INT_USBBoot() == KAL_FALSE )
#if defined(__UMTS_RAT__)
/* under construction !*/
#endif /* __UMTS_RAT__ */
{
#if defined(DRV_GPT_GPT3)
gpt_handle=DclFGPT_Open(DCL_GPT_FreeRUN3,0);
DclFGPT_Control(gpt_handle,FGPT_CMD_RETURN_COUNT,(DCL_CTRL_DATA_T*)¤t_count);
UEM_RECEIVE_PWR_IND = current_count+PERIOD_RST_TO_DRVINT;
DclFGPT_Control(gpt_handle,FGPT_CMD_STOP,0);
DclFGPT_Close(gpt_handle);
#endif // #if defined(DRV_GPT_GPT3)
power_on_ind = (drvuem_power_on_ind_struct *) construct_local_para(sizeof(drvuem_power_on_ind_struct),TD_UL);
power_on_ind->power_on = bmt_Get_PowerOn_Type();
if (UEM_RECEIVE_PWR_IND>Customer_Period_Period())
{
power_on_ind->poweron_time_left=0;
}
else
{
power_on_ind->poweron_time_left=Customer_Period_Period()-UEM_RECEIVE_PWR_IND;
}
DRV_BuildPrimitive(BMT_ilm,
MOD_BMT,
MOD_UEM,
MSG_ID_DRVUEM_POWER_ON_IND,
power_on_ind);
msg_send_ext_queue(BMT_ilm);
}
#endif // #if ( (!defined(L4_NOT_PRESENT)) && (!defined(DUMMY_PROTOCOL)) && (!defined(PMIC_PRESENT)))
#if ( (!defined(L4_NOT_PRESENT)) && (!defined(DUMMY_PROTOCOL)) && (defined(PMIC_PRESENT)) )
#if defined(__UMTS_RAT__)
/* under construction !*/
#endif /* __UMTS_RAT__ */
{
#if defined(__MTK_INTERNAL__)
/* under construction !*/
#endif // #if defined(__MTK_INTERNAL__)
#if defined(DRV_GPT_GPT3)
gpt_handle=DclFGPT_Open(DCL_GPT_FreeRUN3,0);
DclFGPT_Control(gpt_handle,FGPT_CMD_RETURN_COUNT,(DCL_CTRL_DATA_T*)¤t_count);
UEM_RECEIVE_PWR_IND = current_count+PERIOD_RST_TO_DRVINT;
DclFGPT_Control(gpt_handle,FGPT_CMD_STOP,0);
DclFGPT_Close(gpt_handle);
#endif // #if defined(DRV_GPT_GPT3)
bmt_check_poweron(bmt_Get_PowerOn_Type());
power_on_ind = (drvuem_power_on_ind_struct *) construct_local_para(sizeof(drvuem_power_on_ind_struct),TD_UL);
power_on_ind->power_on = (PW_CTRL_POWER_ON_REASON)bmt_Get_PowerOn_Type();
// Alarm wakeup, we set poweron_time_left as PWRKEY power on
// To avoid earphone plug-in message late than power on time
// If earphone plug-in message ia later than power on time, MMI will choose general profile
//if(BMT.PWRon == (kal_uint8)PWRKEYPWRON)
if ( (bmt_Get_PowerOn_Type() == (kal_uint8)PWRKEYPWRON) || (bmt_Get_PowerOn_Type() == (kal_uint8)RTCPWRON) )
{
if (UEM_RECEIVE_PWR_IND>Customer_Period_Period())
{
power_on_ind->poweron_time_left=0;
}
else
{
power_on_ind->poweron_time_left=Customer_Period_Period()-UEM_RECEIVE_PWR_IND;
}
}
else
{
power_on_ind->poweron_time_left = 0;
}
DRV_BuildPrimitive(BMT_ilm,
MOD_BMT,
MOD_UEM,
MSG_ID_DRVUEM_POWER_ON_IND,
power_on_ind);
msg_send_ext_queue(BMT_ilm);
#ifdef BMT_ACTIVE_TO_READ_NVRAM_DATA
/*send to read the ADC calibration data req.*/
nvram_read_req = (nvram_read_req_struct*)construct_local_para(
sizeof(nvram_read_req_struct),
TD_CTRL);
nvram_read_req->file_idx = NVRAM_EF_ADC_LID;
nvram_read_req->para = 1;
nvram_read_req->access_id = 0;
DRV_BuildPrimitive(BMT_ilm,
MOD_BMT,
MOD_NVRAM,
MSG_ID_NVRAM_READ_REQ,
nvram_read_req);
msg_send_ext_queue(BMT_ilm);
#endif // #ifdef BMT_ACTIVE_TO_READ_NVRAM_DATA
} /* if (boot_mode != FACTORY_BOOT) */
#endif // #if ( (!defined(L4_NOT_PRESENT)) && (!defined(DUMMY_PROTOCOL)) && (defined(PMIC_PRESENT)) )
#ifdef PMIC_PRESENT
#if defined(__UMTS_RAT__)
/* under construction !*/
/* under construction !*/
#endif /* __UMTS_RAT__ */
/*Charging algorithm initial*/
bmt_adc_init();
#if defined(__UMTS_RAT__)
/* under construction !*/
#endif /* __UMTS_RAT__ */
#endif /*PMIC_PRESENT*/
#if defined(__UMTS_RAT__)
/* under construction !*/
/* under construction !*/
#endif /* __UMTS_RAT__ */
drv_trace1(TRACE_GROUP_10, BMT_PWRON_TRC, bmt_Get_PowerOn_Type());
dcl_adc_handle = DclSADC_Open(DCL_ADC, FLAGS_NONE);
DclSADC_Control(dcl_adc_handle, ADC_CMD_READ_CALIBRATION_INFORM_IN_USBBOOT, NULL);
DclSADC_Close(dcl_adc_handle);
stack_init_timer(&ChargeTimeout_timer, "chr timeout timer", MOD_BMT);
#if defined(__UMTS_RAT__)
/* under construction !*/
#endif /* __UMTS_RAT__ */
#if defined(__DRV_BATTERY_EXIST_DETECTION__)
stack_init_timer(&timer_batt_det, "Batt det Timer", MOD_BMT);
stack_start_timer(&timer_batt_det, 0, bmt_get_batt_exist_det_period());
bmt_batt_exist_detection(KAL_TRUE); // First time perform battery detection
#endif // #if defined(__DRV_BATTERY_EXIST_DETECTION__)
while(1)
{
receive_msg_ext_q_for_stack(task_info_g[task_entry_ptr->task_indx].task_ext_qid, ¤t_ilm);
switch(current_ilm.msg_id)
{
kal_uint32 savedMask1;
kal_uint32 timer_index;
case MSG_ID_TIMER_EXPIRY:
// Need to check Aux detection status no matter PMIC_PRESENT or NOT
// This is no notify UEM that aux detection is done
timer_index = evshed_get_index(¤t_ilm);
if (((kal_uint32)current_ilm.local_para_ptr) == ((kal_uint32)&aux_timer))
{
savedMask1 = SaveAndSetIRQMask();
if(aux_first_booting)
{
aux_first_booting = KAL_FALSE;
RestoreIRQMask(savedMask1);
aux_id_data = (aux_id_struct*)construct_local_para(sizeof(aux_id_struct), TD_CTRL);
aux_id_data->aux_id = AUX_ID_DETECTION_DONE;
DRV_BuildPrimitive(aux_ilm,
MOD_BMT,
MOD_UEM,
MSG_ID_AUX_ID,
aux_id_data);
msg_send_ext_queue(aux_ilm);
}
else
{
RestoreIRQMask(savedMask1);
}
}
#if !defined(PMIC_PRESENT)
// If PMIC NOT PRESENT, we DO NOT need to handle the following
// messages
break;
#endif // #if !defined(PMIC_PRESENT)
#ifdef PMIC_PRESENT
// if (((kal_uint32)current_ilm.local_para_ptr) == ((kal_uint32)timer_adcsche))
if (timer_index == adc_timer_index)
{
#if (( defined(__USB_ENABLE__) && defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__) && !defined(DRV_USB_IP_V3)) || defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__) )
{
// Add to avoid race condition
// stack timer APIs can NOT suffer race condition between Task and HISR
// We may call event scheduler APIs in HISR for USB/Charger detection
kal_uint32 savedMask;
savedMask = SaveAndSetIRQMask();
bmt_event_sche_active = 1;
RestoreIRQMask(savedMask);
}
#endif // #if defined(__USB_ENABLE__)
/* Check if the base timer is stopped or not */
/* Execute event's timeout handler */
evshed_timer_handler(adc_sche_event_scheduler_ptr);
/* Shoulbe be paired with stack_is_time_out_valid() */
#if (( defined(__USB_ENABLE__) && defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__) && !defined(DRV_USB_IP_V3)) || defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__) )
{
kal_uint32 savedMask;
savedMask = SaveAndSetIRQMask();
bmt_event_sche_active = 0;
RestoreIRQMask(savedMask);
}
#endif // #if defined(__USB_ENABLE__)
}
if (((kal_uint32)current_ilm.local_para_ptr) == ((kal_uint32)timer_stopcharge))
{
if (stack_is_time_out_valid(timer_stopcharge))
{
drv_trace0(TRACE_GROUP_10, BMT_STOP_TIMER_EXPIRE_TRC);
BMT_CHARSTOP();
#ifdef __BMT_CHARGE_GUARD_TIME__
bmt_stop_guardtimer(); //Here to stop guard timer
#endif
#if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)
bmt_stop_estimativetimer(); //Here to stop guard timer
#endif //#if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)
}
stack_process_time_out(timer_stopcharge);
}
#ifdef __BMT_CHARGE_GUARD_TIME__
if (((kal_uint32)current_ilm.local_para_ptr) == ((kal_uint32)timer_guardcharge))
{
if (stack_is_time_out_valid(timer_guardcharge))
{
drv_trace1(TRACE_GROUP_10, BMT_CHARGE_GUARD_TIMER_EXPIRE_TRC, BMT_CHARGE_GUARD_TIME_PERIOD);
BMT_CHARSTOP();
bmt_stop_stoptimer(); //Here to stop 30min timer
bmt_stop_estimativetimer();
#ifdef __DRV_BMT_CHARGING_COMPLETE_MSG__
if(BMT_VBatVoltageIsFull(VBAT_OFF))
#endif //__DRV_BMT_CHARGING_COMPLETE_MSG__
BMT_sendMes2UEM(BMT_CHARGE_COMPLETE);
}
stack_process_time_out(timer_guardcharge);
}
#endif
#if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)
if (((kal_uint32)current_ilm.local_para_ptr) == ((kal_uint32)timer_estimative))
{
if (stack_is_time_out_valid(timer_estimative))
{
drv_trace1(TRACE_GROUP_10, BMT_CHARGE_GUARD_TIMER_EXPIRE_TRC, BMT_CHARGE_GUARD_TIME_PERIOD);
BMT_CHARSTOP();
bmt_stop_stoptimer(); //Here to stop 30min timer
#ifdef __DRV_BMT_CHARGING_COMPLETE_MSG__
if(BMT_VBatVoltageIsFull(VBAT_OFF))
#endif //__DRV_BMT_CHARGING_COMPLETE_MSG__
BMT_sendMes2UEM(BMT_CHARGE_COMPLETE);
}
stack_process_time_out(timer_estimative);
}
#endif
if (((kal_uint32)current_ilm.local_para_ptr) == ((kal_uint32)&ChargeTimeout_timer))
{
if (stack_is_time_out_valid(&ChargeTimeout_timer))
{
#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
drv_trace1(TRACE_GROUP_10, BMT_SAFETY_TIMER_EXPIRE_TRC, bmt_total_charge_time);
#else
drv_trace1(TRACE_GROUP_10, BMT_SAFETY_TIMER_EXPIRE_TRC, BMT_TOTAL_CHARGE_TIME);
#endif
#ifndef __BMT_CHARGE_GUARD_TIME__
//When BMT has guard time, it won't need safty time
BMT_sendMes2UEM(BMT_CHARGE_TIMEOUT);
bmt_charge_end();
#endif
}
stack_process_time_out(&ChargeTimeout_timer);
}
#if defined(__DRV_BATTERY_EXIST_DETECTION__)
if (((kal_uint32)current_ilm.local_para_ptr) == ((kal_uint32)&timer_batt_det))
{
bmt_batt_exist_detection(KAL_FALSE);
stack_process_time_out(&timer_batt_det);
// Re-start timer
stack_start_timer(&timer_batt_det, 0, bmt_get_batt_exist_det_period());
}
#endif // #if defined(__DRV_BATTERY_EXIST_DETECTION__)
break;
case MSG_ID_BMT_CHARGER_IND:
drv_trace0(TRACE_GROUP_10, BMT_MSG_CHARGER_TRC);
// If battery is NOT attached, we just skip the message
if (!bmt_is_bat_on())
{
drv_trace0(TRACE_GROUP_10, BMT_MSG_BATT_OFF_BLOCK);
break;
}
if (bmt_read_chr_status() == bmt_chr_in)
{
drv_trace0(TRACE_GROUP_10, BMT_CHR_STATUS_CHARGE_IN_TRC);
#if defined (WISDOM35B_DEMO_BB)
gpio_handle=DclGPIO_Open(DCL_GPIO, gpio_ext_chr_ctrl_pin);
DclGPIO_Control(handle,GPIO_CMD_SET_DIR_OUT,0);
DclGPIO_Close(handle);
#endif
//dbg_print("bmt_chr_in \r\n");
if ( (previous_chr_status == bmt_chr_uninit) || (previous_chr_status != bmt_chr_in) )
{
previous_chr_status = bmt_chr_in;
#if defined(__USB_ENABLE__)
/*06102004 TY*/
#if defined(PMIC_DET_USB_CHR)
#if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
if(bmt_is_chr_det(PMIC_AC_CHR))/*AC exists*/
#else // #if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
if(bmt_IsUSBorCharger() != BMT_USB_IN)
#endif // #if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
{
if(bmt_is_chr_valid())/*check if it's a valid charger*/
{
drv_trace0(TRACE_GROUP_10, BMT_AC_IN_TRC);
//pmic_charging_currnet_ctrl(CHR_CURRENT_650);
BMT_sendMes2UEM(BMT_CHARGER_IN);
bmt_charge_start();
drv_trace0(TRACE_GROUP_10, BMT_AC_IN_AND_START_CHARGE_TRC);
}
else
{
drv_trace0(TRACE_GROUP_10, BMT_INV_AC_IN_TRC);
bmt_charge_end();
BMT_sendMes2UEM(BMT_INVALID_CHARGER);
drv_trace0(TRACE_GROUP_10, BMT_INV_AC_IN_AND_START_CHARGE_TRC);
}
}
#else // #if defined(PMIC_DET_USB_CHR)
// check USB or AC
if(bmt_IsUSBorCharger() == BMT_USB_IN)
{
drv_trace0(TRACE_GROUP_10, BMT_USB_IN_TRC);
//dbg_print("BMT_USB_IN \r\n");
// a USB cable is plugged in
bmt_usb_state = USB_IN_STATE;
}
else
{
drv_trace0(TRACE_GROUP_10, BMT_AC_IN_TRC);
//dbg_print("AC_IN_STATE and bmt_charge_start \r\n");
bmt_usb_state = AC_IN_STATE;
// a AC charger is plugged in
BMT_sendMes2UEM(BMT_CHARGER_IN);
bmt_charge_start();
drv_trace0(TRACE_GROUP_10, BMT_AC_IN_AND_START_CHARGE_TRC);
}
#endif // #if defined(PMIC_DET_USB_CHR)
#else // #if defined(__USB_ENABLE__)
/*06102004 TY*/
#if defined(PMIC_DET_USB_CHR)
if(bmt_is_chr_det(PMIC_AC_CHR))/*AC exists*/
{
if(bmt_is_chr_valid())/*check if it's a valid charger*/
{
drv_trace0(TRACE_GROUP_10, BMT_AC_IN_TRC);
//pmic_charging_currnet_ctrl(CHR_CURRENT_650);
BMT_sendMes2UEM(BMT_CHARGER_IN);
bmt_charge_start();
drv_trace0(TRACE_GROUP_10, BMT_AC_IN_AND_START_CHARGE_TRC);
}
else
{
drv_trace0(TRACE_GROUP_10, BMT_INV_AC_IN_TRC);
bmt_charge_end();
BMT_sendMes2UEM(BMT_INVALID_CHARGER);
drv_trace0(TRACE_GROUP_10, BMT_INV_AC_IN_AND_START_CHARGE_TRC);
}
}
#else // #if defined(PMIC_DET_USB_CHR)
drv_trace0(TRACE_GROUP_10, BMT_AC_IN_TRC);
BMT_sendMes2UEM(BMT_CHARGER_IN);
bmt_charge_start();
drv_trace0(TRACE_GROUP_10, BMT_AC_IN_AND_START_CHARGE_TRC);
#endif // #if defined(PMIC_DET_USB_CHR)
#endif // #if defined(__USB_ENABLE__)
}
}
else if(bmt_read_chr_status() == bmt_chr_out)
{
#if defined(DRV_BMT_HW_PRECC_WORKAROUND)
drv_trace0(TRACE_GROUP_10, BMT_CHR_STATUS_CHARGE_OUT_TRC);
#if defined(__USB_ENABLE__)
if((SW_Workaround_Flag == KAL_TRUE) && (bmt_usb_state == AC_IN_STATE))
#else
if(SW_Workaround_Flag == KAL_TRUE)
#endif
{
drv_trace0(TRACE_GROUP_10, BMT_HW_PLUG_OUT_INSIDE_SW_WORKAROUND_RANGE_TRC);
break;
}
#endif // End of #if defined(DRV_BMT_HW_PRECC_WORKAROUND)
#if defined (WISDOM35B_DEMO_BB)
gpio_handle=DclGPIO_Open(DCL_GPIO, gpio_ext_chr_ctrl_pin);
DclGPIO_Control(handle,GPIO_CMD_SET_DIR_OUT,0);
DclGPIO_Close(handle);
#endif
//dbg_print("bmt_chr_out \r\n");
if ( (previous_chr_status == bmt_chr_uninit) || (previous_chr_status != bmt_chr_out) )
{
previous_chr_status = bmt_chr_out;
#if defined(__USB_ENABLE__)
#if defined(PMIC_DET_USB_CHR)
ASSERT(0);
#else // #if defined(PMIC_DET_USB_CHR)
drv_trace1(TRACE_GROUP_10, BMT_USB_STATE_TRC, bmt_usb_state);
// current sate != previous state
switch(bmt_usb_state)
{
case AC_IN_STATE:
//dbg_print("AC_CHARGER_OUT \r\n");
bmt_usb_state = AC_OUT_STATE;
BMT_sendMes2UEM(BMT_CHARGER_OUT);
bmt_charge_end();
drv_trace0(TRACE_GROUP_10, BMT_AC_OUT_AND_STOP_CHARGE_TRC);
break;
case USB500_STATE:
//dbg_print("USB_OUT_STATE \r\n");
drv_trace0(TRACE_GROUP_10, BMT_USB_OUT_TRC);
{
bmt_usb_state = USB_OUT_STATE;
BMT_sendMes2UEM(BMT_USB_CHARGER_OUT);
bmt_charge_end();
drv_trace0(TRACE_GROUP_10, BMT_USB_500_OUT_AND_STOP_CHARGE_TRC);
}
break;
case USB_IN_STATE:
case USB100_STATE:
drv_trace0(TRACE_GROUP_10, BMT_USB_OUT_TRC);
//dbg_print("USB_OUT_STATE \r\n");
{
bmt_usb_state = USB_OUT_STATE;
BMT_sendMes2UEM(BMT_USB_NO_CHARGING_OUT);
drv_trace0(TRACE_GROUP_10, BMT_USB_100_OUT_TRC);
}
break;
default:
break;
}
#endif // // #if defined(PMIC_DET_USB_CHR)
#else // #if defined(__USB_ENABLE__)
drv_trace0(TRACE_GROUP_10, BMT_AC_OUT_TRC);
BMT_sendMes2UEM(BMT_CHARGER_OUT);
bmt_charge_end();
drv_trace0(TRACE_GROUP_10, BMT_AC_OUT_AND_STOP_CHARGE_TRC);
#endif // #if defined(__USB_ENABLE__)
}
}
else
{
ASSERT(0);
}
break;
#if defined (__USB_ENABLE__)
case MSG_ID_BMT_USB_IND:
drv_trace0(TRACE_GROUP_10, BMT_MSG_USB);
//dbg_print("receive MSG_ID_BMT_USB_IND \r\n");
// If battery is NOT attached, we just skip the message
if (!bmt_is_bat_on())
{
drv_trace0(TRACE_GROUP_10, BMT_MSG_BATT_OFF_BLOCK);
break;
}
{
//EXT_ASSERT((bmt_usb_state == USB_IN_STATE),bmt_usb_state,0,0);
bmt_usb_ind_struct *ind = (bmt_usb_ind_struct*)current_ilm.local_para_ptr;
/* This message may send again, so we have to deal with this case. */
if((bmt_usb_state == USB_IN_STATE) || (bmt_usb_state == USB500_STATE) || (bmt_usb_state == USB100_STATE))
{
/* Set the allowed current index for USB. */
bmt_usb_chr_current=ind->usb_ind;
if((ind->usb_ind) == PMU_CHARGE_CURRENT_0_00_MA)
{
drv_trace0(TRACE_GROUP_10, BMT_USB_100_TRC);
//dbg_print("receive MSG_ID_BMT_USB_IND with BMT_USB_100 \r\n");
/* If state is from USB_IN_STATE or USB500_STATE to USB100_STATE. */
if (bmt_usb_state != USB100_STATE)
{
/* If state is from USB500_STATE(usb charging), charging should stop. */
if(bmt_usb_state == USB500_STATE)
{
bmt_charge_end();
drv_trace0(TRACE_GROUP_10, BMT_CHARGING_CURRENT_NOT_SUPPORTED_STOP_CHARGING_TRC);
}
else
{
bmt_chr_force_enable(KAL_FALSE);
}
bmt_usb_state = USB100_STATE;
BMT_sendMes2UEM(BMT_USB_NO_CHARGING_IN);
}
}
else if((ind->usb_ind) <= PMU_CHARGE_CURRENT_500_00_MA)
{
drv_trace0(TRACE_GROUP_10, BMT_USB_500_TRC);
/* If state is from USB_IN_STATE or USB100_STATE to USB500_STATE. */
if (bmt_usb_state != USB500_STATE)
{
drv_trace0(TRACE_GROUP_10, BMT_USB_500_AND_START_CHARGE_TRC);
bmt_usb_state = USB500_STATE;
// modify for test
BMT_sendMes2UEM(BMT_USB_CHARGER_IN);
bmt_charge_start();
}
}
else
{
ASSERT(0);// usb should not send current > 500
}
#ifdef PMU_REFERENCE_WY
#ifdef __USB_MULTI_CHARGE_CURRENT__
/* If chargin current is allowed. */
if((ind->usb_ind) <= PMU_CHARGE_CURRENT_500_00_MA)
#else // #ifdef __USB_MULTI_CHARGE_CURRENT__
if(ind->usb_ind == BMT_USB_500)
#endif // #ifdef __USB_MULTI_CHARGE_CURRENT__
{
drv_trace0(TRACE_GROUP_10, BMT_USB_500_TRC);
/*06102004 TY*/
#if defined(PMIC_WAIT_USB_FOR_CHARGING)//defined(MT6318)
/* If state is from USB_IN_STATE or USB100_STATE to USB500_STATE. */
if (bmt_usb_state != USB500_STATE)
{
bmt_usb_state = USB500_STATE;
BMT_sendMes2UEM(BMT_USB_CHARGER_IN);
#if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
if(bmt_is_chr_det(PMIC_AC_CHR))/*check if AC exists*/
#else // #if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
if(bmt_IsUSBorCharger() != BMT_USB_IN)
#endif // #if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
{
drv_trace0(TRACE_GROUP_10, BMT_USB_500_AC_ALREAY_IN_TRC);
/*change state but not charge*/
}
else
{
drv_trace0(TRACE_GROUP_10, BMT_USB_500_AND_START_CHARGE_TRC);
bmt_charge_start();
}
}
#ifdef __USB_MULTI_CHARGE_CURRENT__
/* Set the allowed current index for USB. */
bmt_find_and_set_the_nearest_current(ind->usb_ind);
#endif // #ifdef __USB_MULTI_CHARGE_CURRENT__
#else // #if defined(PMIC_WAIT_USB_FOR_CHARGING)//defined(MT6318)
//dbg_print("receive MSG_ID_BMT_USB_IND with BMT_USB_500 \r\n");
/* If state is from USB_IN_STATE or USB100_STATE to USB500_STATE. */
if (bmt_usb_state != USB500_STATE)
{
drv_trace0(TRACE_GROUP_10, BMT_USB_500_AND_START_CHARGE_TRC);
bmt_usb_state = USB500_STATE;
// modify for test
BMT_sendMes2UEM(BMT_USB_CHARGER_IN);
bmt_charge_start();
}
#ifdef __USB_MULTI_CHARGE_CURRENT__
/* Set the allowed current index for USB. */
bmt_find_and_set_the_nearest_current(ind->usb_ind);
#endif // #ifdef __USB_MULTI_CHARGE_CURRENT__
#endif // // #if defined(PMIC_WAIT_USB_FOR_CHARGING)//defined(MT6318)
}
else
{
drv_trace0(TRACE_GROUP_10, BMT_USB_100_TRC);
//dbg_print("receive MSG_ID_BMT_USB_IND with BMT_USB_100 \r\n");
/* If state is from USB_IN_STATE or USB500_STATE to USB100_STATE. */
if (bmt_usb_state != USB100_STATE)
{
#if defined(PMIC_WAIT_USB_FOR_CHARGING)//defined(MT6318)
/* If state is from USB500_STATE and there's no AC, charging should stop. */
if((KAL_FALSE==bmt_is_chr_det(PMIC_AC_CHR)) && (bmt_usb_state == USB500_STATE))
#else // #if defined(PMIC_WAIT_USB_FOR_CHARGING)//defined(MT6318)
/* If state is from USB500_STATE(usb charging), charging should stop. */
if(bmt_usb_state == USB500_STATE)
#endif // #if defined(PMIC_WAIT_USB_FOR_CHARGING)//defined(MT6318)
{
bmt_charge_end();
drv_trace0(TRACE_GROUP_10, BMT_CHARGING_CURRENT_NOT_SUPPORTED_STOP_CHARGING_TRC);
}
bmt_usb_state = USB100_STATE;
BMT_sendMes2UEM(BMT_USB_NO_CHARGING_IN);
}
}
#endif
}
}
break;
#endif // // #if defined (__USB_ENABLE__)
/***********ADC scheduler***********/
case MSG_ID_BMT_ADC_ADD_ITEM_REQ:
drv_trace0(TRACE_GROUP_10, BMT_MSG_ADC_ADD);
bmt_adc_sche_add_item(current_ilm.local_para_ptr);
break;
case MSG_ID_BMT_ADC_REMOVE_ITEM_REQ:
drv_trace0(TRACE_GROUP_10, BMT_MSG_ADC_REMOVE);
bmt_adc_sche_remove_item(current_ilm.local_para_ptr);
break;
case MSG_ID_BMT_ADC_MODIFY_PARAMETERS_REQ:
drv_trace0(TRACE_GROUP_10, BMT_MSG_ADC_PARAM);
bmt_adc_sche_modify_parameters(current_ilm.local_para_ptr);
break;
#endif // #ifdef PMIC_PRESENT
#if ( (!defined(L4_NOT_PRESENT)) && (!defined(DUMMY_PROTOCOL)) )
case MSG_ID_NVRAM_READ_CNF:
{
DCL_HANDLE dcl_handle;
ADC_CTRL_SET_CALIBRATION_DATA_T prSetCalibrationData;
#if defined(__DRV_BMT_REPORT_VBAT_IN_BOOTING__)
ilm_struct *BMT_ilm2;
bmt_adc_measure_done_conf_struct *BMT_Prim;
#endif //#if defined(DRV_BMT_REPORT_VBAT_IN_BOOTING)
drv_trace0(TRACE_GROUP_10, BMT_MSG_ADC_NVRAM_READ_CNF);
prSetCalibrationData.ilm_ptr = (void *)¤t_ilm;
dcl_handle = DclSADC_Open(DCL_ADC, FLAGS_NONE);
DclSADC_Control(dcl_handle, ADC_CMD_SET_CALIBRATION_DATA, (DCL_CTRL_DATA_T *)&prSetCalibrationData);
DclSADC_Close(dcl_handle);
#if defined(__DRV_BMT_REPORT_VBAT_IN_BOOTING__)
BMT_Prim = (bmt_adc_measure_done_conf_struct*)
construct_local_para(sizeof(bmt_adc_measure_done_conf_struct), TD_CTRL);
BMT_Current_Voltage(DCL_VBAT_ADC_CHANNEL, &VBAT_OFF, &ADCBAT_OFF);
BMT_Prim->volt= VBAT_OFF;
DRV_BuildPrimitive(BMT_ilm2,
MOD_BMT,
MOD_UEM,
MSG_ID_BMT_ADC_MEASURE_DONE_CONF,
BMT_Prim);
msg_send_ext_queue(BMT_ilm2);
#endif //#if defined(DRV_BMT_REPORT_VBAT_IN_BOOTING)
break;
}
#endif /*(!defined(L4_NOT_PRESENT)) && (!defined(DUMMY_PROTOCOL))*/
default:
break;
}
free_ilm(¤t_ilm);
}
}