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
#include "System_Monitor.h"
#include <stdio.h>
typedef struct
{
monitorlib_uint8_t SumCnt;
monitorlib_uint16_t DebounceTimer;
monitorlib_uint32_t ActVoltage;
monitorlib_uint8_t FinalSts;
monitorlib_uint8_t ActSts;
} MonitorStruct;
MonitorStruct SysFun_KL30Monitor;
MonitorStruct SysFun_KL15Monitor;
MonitorStruct SysNM_KL30Monitor;
MonitorStruct SysNM_KL15Monitor;
#define Base_Vol 0u
#define ENTER_LOW_N_RANGE 6500U
#define EXIT_LOW_N_RANGE 7000U
#define ENTER_LOW_Y_RANGE 9000U
#define EXIT_LOW_Y_RANGE 9500U
#define EXIT_HIGH_Y_RANGE 16000U
#define ENTER_HIGH_Y_RANGE 16500U
#define EXIT_HIGH_N_RANGE 18500U
#define ENTER_HIGH_N_RANGE 19000U
#define Top_Vol 0xffffu
static monitorlib_uint8_t System_Calc_NMRange(monitorlib_uint16_t u16Vol);
static monitorlib_uint8_t System_Calc_FunRange(monitorlib_uint16_t u16Vol);
static void System_Fast_WakeUp(void);
static void System_Fun_Process(void);
static void System_NM_Process(void);
MonitorExt_st pfunction;
monitorlib_uint8_t SysWakeUpMode = 0u;
monitorlib_uint8_t SetVolFlag = 0u;
monitorlib_uint16_t FUNSysVol_Range [ 10u ] = {
Base_Vol,
ENTER_LOW_N_RANGE,
EXIT_LOW_N_RANGE,
ENTER_LOW_Y_RANGE,
EXIT_LOW_Y_RANGE,
EXIT_HIGH_Y_RANGE,
ENTER_HIGH_Y_RANGE,
EXIT_HIGH_N_RANGE,
ENTER_HIGH_N_RANGE,
Top_Vol,
};
monitorlib_uint16_t NMSysVol_Range [ 10u ] = {
Base_Vol,
ENTER_LOW_N_RANGE,
EXIT_LOW_N_RANGE,
ENTER_LOW_Y_RANGE,
EXIT_LOW_Y_RANGE,
EXIT_HIGH_Y_RANGE,
ENTER_HIGH_Y_RANGE,
EXIT_HIGH_N_RANGE,
ENTER_HIGH_N_RANGE,
Top_Vol,
};
monitorlib_uint16_t t_FUN_KL30_Debounce;
monitorlib_uint16_t t_FUN_KL15_Debounce;
monitorlib_uint16_t t_NM_KL30_Debounce;
monitorlib_uint16_t t_NM_KL15_Debounce;
monitorlib_uint16_t t_NM_KL30_Debounce_Cancel;
monitorlib_uint16_t t_NM_KL15_Debounce_Cancel;
monitorlib_uint16_t t_FUN_KL30_Debounce_Cancel;
monitorlib_uint16_t t_FUN_KL15_Debounce_Cancel;
monitorlib_uint16_t t_NM_KL30_timer;
monitorlib_uint16_t t_FUN_KL30_timer;
monitorlib_uint8_t Read_KL30_ConvertFinish(void)
{
return SysWakeUpMode;
}
static monitorlib_uint8_t System_Calc_FunRange(monitorlib_uint16_t u16Vol)
{
monitorlib_uint8_t i;
for ( i = 0u; i < (sizeof(FUNSysVol_Range) / sizeof(FUNSysVol_Range [ 0 ])); i++ )
{
if ( u16Vol < FUNSysVol_Range [ i ] )
{
break;
}
}
return i;
}
static monitorlib_uint8_t System_Calc_NMRange(monitorlib_uint16_t u16Vol)
{
monitorlib_uint8_t i;
for ( i = 0u; i < (sizeof(NMSysVol_Range) / sizeof(NMSysVol_Range [ 0 ])); i++ )
{
if ( u16Vol < NMSysVol_Range [ i ] )
{
break;
}
}
return i;
}
void Sys_Set_Pata(const monitorlib_uint16_t FUN_Vol [], MonitorExt_st *pfunc)
{
FUNSysVol_Range [ 0 ] = FUN_Vol [ 0 ];
FUNSysVol_Range [ 1 ] = FUN_Vol [ 1 ];
FUNSysVol_Range [ 2 ] = FUN_Vol [ 2 ];
FUNSysVol_Range [ 3 ] = FUN_Vol [ 3 ];
FUNSysVol_Range [ 4 ] = FUN_Vol [ 4 ];
FUNSysVol_Range [ 5 ] = FUN_Vol [ 5 ];
FUNSysVol_Range [ 6 ] = FUN_Vol [ 6 ];
FUNSysVol_Range [ 7 ] = FUN_Vol [ 7 ];
FUNSysVol_Range [ 8 ] = FUN_Vol [ 8 ];
FUNSysVol_Range [ 9 ] = FUN_Vol [ 9 ];
t_FUN_KL30_Debounce = FUN_Vol [ 10 ];
t_FUN_KL15_Debounce = FUN_Vol [ 11 ];
NMSysVol_Range [ 0 ] = FUN_Vol [ 12 ];
NMSysVol_Range [ 1 ] = FUN_Vol [ 13 ];
NMSysVol_Range [ 2 ] = FUN_Vol [ 14 ];
NMSysVol_Range [ 3 ] = FUN_Vol [ 15 ];
NMSysVol_Range [ 4 ] = FUN_Vol [ 16 ];
NMSysVol_Range [ 5 ] = FUN_Vol [ 17 ];
NMSysVol_Range [ 6 ] = FUN_Vol [ 18 ];
NMSysVol_Range [ 7 ] = FUN_Vol [ 19 ];
NMSysVol_Range [ 8 ] = FUN_Vol [ 20 ];
NMSysVol_Range [ 9 ] = FUN_Vol [ 21 ];
t_NM_KL30_Debounce = FUN_Vol [ 22 ];
t_NM_KL15_Debounce = FUN_Vol [ 23 ];
t_NM_KL30_Debounce_Cancel = FUN_Vol [ 24 ];
t_FUN_KL30_Debounce_Cancel = FUN_Vol [ 25 ];
pfunction.SysGet_KL30_Valid = pfunc->SysGet_KL30_Valid;
pfunction.SysGet_KL15_Valid = pfunc->SysGet_KL15_Valid;
pfunction.SysGet_KL30_value_Force = pfunc->SysGet_KL30_value_Force;
pfunction.SysGet_KL15_value_Force = pfunc->SysGet_KL15_value_Force;
pfunction.SysGet_KL30_value = pfunc->SysGet_KL30_value;
pfunction.SysGet_KL15_value = pfunc->SysGet_KL15_value;
pfunction.SysGet_KL15Line = pfunc->SysGet_KL15Line;
pfunction.COM_Delay = pfunc->COM_Delay;
pfunction.SysMonitorLogic = pfunc->SysMonitorLogic;
SetVolFlag = 0x55u;
}
void System_Monitor_KL30Init(void)
{
SysWakeUpMode = 0u;
SysFun_KL30Monitor.SumCnt = 0u;
SysFun_KL30Monitor.DebounceTimer = 0u;
SysFun_KL30Monitor.ActVoltage = 0u;
SysFun_KL30Monitor.FinalSts = 0u;
SysFun_KL30Monitor.ActSts = 0u;
SysFun_KL15Monitor.SumCnt = 0u;
SysFun_KL15Monitor.DebounceTimer = 0u;
SysFun_KL15Monitor.ActVoltage = 0u;
SysFun_KL15Monitor.FinalSts = 0u;
SysFun_KL15Monitor.ActSts = 0u;
SysNM_KL30Monitor.SumCnt = 0u;
SysNM_KL30Monitor.DebounceTimer = 0u;
SysNM_KL30Monitor.ActVoltage = 0u;
SysNM_KL30Monitor.FinalSts = 0u;
SysNM_KL30Monitor.ActSts = 0u;
SysNM_KL15Monitor.SumCnt = 0u;
SysNM_KL15Monitor.DebounceTimer = 0u;
SysNM_KL15Monitor.ActVoltage = 0u;
SysNM_KL15Monitor.FinalSts = 0u;
SysNM_KL15Monitor.ActSts = 0u;
if ( SetVolFlag != 0x55u )
{
t_NM_KL30_Debounce = 1000u;
t_NM_KL15_Debounce = 2u;
t_FUN_KL30_Debounce = 1000u;
t_FUN_KL15_Debounce = 2u;
t_NM_KL30_Debounce_Cancel = 1000U;
t_NM_KL15_Debounce_Cancel = 2U;
t_FUN_KL30_Debounce_Cancel = 1000U;
t_FUN_KL15_Debounce_Cancel = 2U;
FUNSysVol_Range [ 0 ] = Base_Vol;
FUNSysVol_Range [ 1 ] = ENTER_LOW_N_RANGE;
FUNSysVol_Range [ 2 ] = EXIT_LOW_N_RANGE;
FUNSysVol_Range [ 3 ] = ENTER_LOW_Y_RANGE;
FUNSysVol_Range [ 4 ] = EXIT_LOW_Y_RANGE;
FUNSysVol_Range [ 5 ] = EXIT_HIGH_Y_RANGE;
FUNSysVol_Range [ 6 ] = ENTER_HIGH_Y_RANGE;
FUNSysVol_Range [ 7 ] = EXIT_HIGH_N_RANGE;
FUNSysVol_Range [ 8 ] = ENTER_HIGH_N_RANGE;
FUNSysVol_Range [ 9 ] = Top_Vol;
NMSysVol_Range [ 0 ] = Base_Vol;
NMSysVol_Range [ 1 ] = ENTER_LOW_N_RANGE;
NMSysVol_Range [ 2 ] = EXIT_LOW_N_RANGE;
NMSysVol_Range [ 3 ] = ENTER_LOW_Y_RANGE;
NMSysVol_Range [ 4 ] = EXIT_LOW_Y_RANGE;
NMSysVol_Range [ 5 ] = EXIT_HIGH_Y_RANGE;
NMSysVol_Range [ 6 ] = ENTER_HIGH_Y_RANGE;
NMSysVol_Range [ 7 ] = EXIT_HIGH_N_RANGE;
NMSysVol_Range [ 8 ] = ENTER_HIGH_N_RANGE;
NMSysVol_Range [ 9 ] = Top_Vol;
SetVolFlag = 0x55u;
}
if ( pfunction.COM_Delay != (( void * )0) )
{
pfunction.COM_Delay(260U);
}
System_Fast_WakeUp( );
}
void System_Monitor_WakeupInit(void)
{
SysWakeUpMode = 0u;
SysFun_KL30Monitor.SumCnt = 0u;
SysFun_KL30Monitor.DebounceTimer = 0u;
SysFun_KL30Monitor.ActVoltage = 0u;
SysFun_KL30Monitor.FinalSts = 0u;
SysFun_KL30Monitor.ActSts = 0u;
SysFun_KL15Monitor.SumCnt = 0u;
SysFun_KL15Monitor.DebounceTimer = 0u;
SysFun_KL15Monitor.ActVoltage = 0u;
SysFun_KL15Monitor.FinalSts = 0u;
SysFun_KL15Monitor.ActSts = 0u;
SysNM_KL30Monitor.SumCnt = 0u;
SysNM_KL30Monitor.DebounceTimer = 0u;
SysNM_KL30Monitor.ActVoltage = 0u;
SysNM_KL30Monitor.FinalSts = 0u;
SysNM_KL30Monitor.ActSts = 0u;
SysNM_KL15Monitor.SumCnt = 0u;
SysNM_KL15Monitor.DebounceTimer = 0u;
SysNM_KL15Monitor.ActVoltage = 0u;
SysNM_KL15Monitor.FinalSts = 0u;
SysNM_KL15Monitor.ActSts = 0u;
if ( SetVolFlag != 0x55u )
{
t_NM_KL30_Debounce = 1000u;
t_NM_KL15_Debounce = 2u;
t_FUN_KL30_Debounce = 1000u;
t_FUN_KL15_Debounce = 2u;
t_NM_KL30_Debounce_Cancel = 1000U;
t_NM_KL15_Debounce_Cancel = 2U;
t_FUN_KL30_Debounce_Cancel = 1000U;
t_FUN_KL15_Debounce_Cancel = 2U;
FUNSysVol_Range [ 0 ] = Base_Vol;
FUNSysVol_Range [ 1 ] = ENTER_LOW_N_RANGE;
FUNSysVol_Range [ 2 ] = EXIT_LOW_N_RANGE;
FUNSysVol_Range [ 3 ] = ENTER_LOW_Y_RANGE;
FUNSysVol_Range [ 4 ] = EXIT_LOW_Y_RANGE;
FUNSysVol_Range [ 5 ] = EXIT_HIGH_Y_RANGE;
FUNSysVol_Range [ 6 ] = ENTER_HIGH_Y_RANGE;
FUNSysVol_Range [ 7 ] = EXIT_HIGH_N_RANGE;
FUNSysVol_Range [ 8 ] = ENTER_HIGH_N_RANGE;
FUNSysVol_Range [ 9 ] = Top_Vol;
NMSysVol_Range [ 0 ] = Base_Vol;
NMSysVol_Range [ 1 ] = ENTER_LOW_N_RANGE;
NMSysVol_Range [ 2 ] = EXIT_LOW_N_RANGE;
NMSysVol_Range [ 3 ] = ENTER_LOW_Y_RANGE;
NMSysVol_Range [ 4 ] = EXIT_LOW_Y_RANGE;
NMSysVol_Range [ 5 ] = EXIT_HIGH_Y_RANGE;
NMSysVol_Range [ 6 ] = ENTER_HIGH_Y_RANGE;
NMSysVol_Range [ 7 ] = EXIT_HIGH_N_RANGE;
NMSysVol_Range [ 8 ] = ENTER_HIGH_N_RANGE;
NMSysVol_Range [ 9 ] = Top_Vol;
SetVolFlag = 0x55u;
}
System_Fast_WakeUp( );
}
void Sys_Status_Update_Service(void)
{
System_Fun_Process( );
System_NM_Process( );
if ( pfunction.SysMonitorLogic != (( void * )0) )
{
pfunction.SysMonitorLogic( );
}
}
static void System_Fast_WakeUp(void)
{
monitorlib_uint16_t KL30_Voltage;
monitorlib_uint16_t KL15_Voltage;
monitorlib_uint16_t Voltage;
monitorlib_uint8_t NormalKL30Cnt = 0U;
monitorlib_uint8_t abnormalKL30Cnt = 0U;
monitorlib_uint8_t AttemptCnt = 0U;
AttemptCnt = 0u;
while ( SysNM_KL30Monitor.FinalSts == 0u )
{
if ( pfunction.COM_Delay != (( void * )0) )
{
pfunction.COM_Delay(2U);
}
/*KL30 KL15 voltage */
if ( pfunction.SysGet_KL30_value_Force != ( void * )0 )
{
KL30_Voltage = pfunction.SysGet_KL30_value_Force( );
}
else
{
KL30_Voltage = 0u;
}
if ( pfunction.SysGet_KL15_value_Force != ( void * )0 )
{
KL15_Voltage = pfunction.SysGet_KL15_value_Force( );
}
else
{
KL15_Voltage = 0u;
}
if ( KL30_Voltage > KL15_Voltage )
{
Voltage = KL30_Voltage;
}
else
{
Voltage = KL15_Voltage;
}
if ( (Voltage <= NMSysVol_Range [ 2 ]) || (Voltage >= NMSysVol_Range [ 7 ]) )
{
NormalKL30Cnt = 0U;
abnormalKL30Cnt++;
}
else
{
NormalKL30Cnt++;
abnormalKL30Cnt = 0U;
}
AttemptCnt++;
if ( AttemptCnt >= 10u )
{
break;
}
if ( NormalKL30Cnt >= 5U )
{
SysNM_KL30Monitor.FinalSts = 5u;
}
if ( abnormalKL30Cnt >= 5U )
{
SysNM_KL30Monitor.FinalSts = 9u;
}
}
if ( (SysNM_KL30Monitor.FinalSts != 0u) )
{
SysWakeUpMode = 0x55U;
if ( pfunction.SysGet_KL15Line != (( void * )0) )
{
SysNM_KL15Monitor.FinalSts = pfunction.SysGet_KL15Line( );
SysNM_KL15Monitor.ActSts = pfunction.SysGet_KL15Line( );
}
else
{
SysNM_KL15Monitor.FinalSts = 0u;
SysNM_KL15Monitor.ActSts = 0u;
}
if ( pfunction.SysMonitorLogic != ( void * )0 )
{
pfunction.SysMonitorLogic( );
}
}
}
static void System_NM_Process(void)
{
monitorlib_uint8_t m8;
static monitorlib_uint16_t DebpounceTimer;
monitorlib_uint16_t Voltage;
monitorlib_uint8_t VoltageKL30Valid;
monitorlib_uint8_t VoltageKL15Valid;
monitorlib_uint16_t Voltage_KL15;
monitorlib_uint16_t Voltage_KL30;
if ( pfunction.SysGet_KL15Line != (( void * )0) )
{
if ( SysNM_KL15Monitor.ActSts == pfunction.SysGet_KL15Line( ) )
{
if ( SysNM_KL15Monitor.DebounceTimer < t_NM_KL15_Debounce )
{
SysNM_KL15Monitor.DebounceTimer++;
}
else
{
SysNM_KL15Monitor.FinalSts = SysNM_KL15Monitor.ActSts;
}
}
else
{
SysNM_KL15Monitor.DebounceTimer = 0u;
SysNM_KL15Monitor.ActSts = pfunction.SysGet_KL15Line( );
}
}
else
{
SysNM_KL15Monitor.FinalSts = 0u;
SysNM_KL15Monitor.ActSts = 0u;
SysNM_KL15Monitor.DebounceTimer = 0u;
}
if ( pfunction.SysGet_KL30_Valid != ( void * )0 )
{
VoltageKL30Valid = pfunction.SysGet_KL30_Valid( );
}
else
{
VoltageKL30Valid = 0u;
}
if ( pfunction.SysGet_KL15_Valid != ( void * )0 )
{
VoltageKL15Valid = pfunction.SysGet_KL15_Valid( );
}
else
{
VoltageKL15Valid = 0u;
}
if ( (VoltageKL30Valid == 1U) && (VoltageKL15Valid == 1U) )
{
if ( pfunction.SysGet_KL15_value != (( void * )0) )
{
Voltage_KL15 = pfunction.SysGet_KL15_value( );
}
else
{
Voltage_KL15 = 0u;
}
if ( pfunction.SysGet_KL15_value != (( void * )0) )
{
Voltage_KL30 = pfunction.SysGet_KL30_value( );
}
else
{
Voltage_KL30 = 0u;
}
if ( Voltage_KL30 > Voltage_KL15 )
{
Voltage = Voltage_KL30;
}
else
{
Voltage = Voltage_KL15;
}
if ( SysNM_KL30Monitor.SumCnt < 50u )
{
SysNM_KL30Monitor.ActVoltage += Voltage;
SysNM_KL30Monitor.SumCnt += 1u;
Voltage = ( monitorlib_uint16_t )(SysNM_KL30Monitor.ActVoltage / SysNM_KL30Monitor.SumCnt);
}
else
{
SysNM_KL30Monitor.SumCnt = 0u;
SysNM_KL30Monitor.ActVoltage = 0u;
SysNM_KL30Monitor.ActVoltage += Voltage;
SysNM_KL30Monitor.SumCnt += 1u;
Voltage = ( monitorlib_uint16_t )(SysNM_KL30Monitor.ActVoltage / SysNM_KL30Monitor.SumCnt);
}
m8 = System_Calc_NMRange(Voltage);
if ( SysNM_KL30Monitor.ActSts == m8 )
{
switch ( SysNM_KL30Monitor.FinalSts )
{
case 0:
case 1:
case 9:
t_NM_KL30_timer = t_NM_KL30_Debounce_Cancel;
break;
default:
t_NM_KL30_timer = t_NM_KL30_Debounce;
break;
}
if ( SysNM_KL30Monitor.DebounceTimer < t_NM_KL30_timer ) /*40202-8*/
{
SysNM_KL30Monitor.DebounceTimer++;
}
else
{
DebpounceTimer = 0u;
if ( SysNM_KL30Monitor.FinalSts == 9u ) /* 高压 */
{
if ( (m8 == 9u) || (m8 == 8u) )
{
SysNM_KL30Monitor.FinalSts = 9u; /** 维持不变 **/
}
else
{
SysNM_KL30Monitor.FinalSts = m8; /**退�?*/
}
}
if ( SysNM_KL30Monitor.FinalSts == 1u ) /* 低压 */
{
if ( (m8 == 1u) || (m8 == 2u) )
{
SysNM_KL30Monitor.FinalSts = 1u; /** 维持不变 */
}
else
{
SysNM_KL30Monitor.FinalSts = m8; /**退�?*/
}
}
/* 非高低压 */
if ( (SysNM_KL30Monitor.FinalSts != 1u) && (SysNM_KL30Monitor.FinalSts != 9u) )
{
SysNM_KL30Monitor.FinalSts = m8; /** 进入*/
}
}
}
else
{
/* 计时时间清除 */
SysNM_KL30Monitor.DebounceTimer = 0U;
DebpounceTimer++;
if ( DebpounceTimer >= 5u )
{
DebpounceTimer = 0u;
SysNM_KL30Monitor.ActSts = m8;
}
}
}
}
static void System_Fun_Process(void)
{
monitorlib_uint8_t m8;
monitorlib_uint8_t VoltageKL30Valid;
monitorlib_uint8_t VoltageKL15Valid;
monitorlib_uint16_t Voltage;
monitorlib_uint16_t Voltage_KL15;
monitorlib_uint16_t Voltage_KL30;
static monitorlib_uint16_t DebpounceTimer;
if ( pfunction.SysGet_KL15Line != (( void * )0) )
{
if ( SysFun_KL15Monitor.ActSts == pfunction.SysGet_KL15Line( ) )
{
if ( SysFun_KL15Monitor.DebounceTimer < t_FUN_KL15_Debounce )
{
SysFun_KL15Monitor.DebounceTimer++;
}
else
{
SysFun_KL15Monitor.FinalSts = SysFun_KL15Monitor.ActSts;
}
if(SysFun_KL15Monitor.ActSts)
{
SysFun_KL15Monitor.FinalSts = SysFun_KL15Monitor.ActSts;
}
}
else
{
SysFun_KL15Monitor.DebounceTimer = 0u;
SysFun_KL15Monitor.ActSts = pfunction.SysGet_KL15Line( );
}
}
else
{
SysFun_KL15Monitor.DebounceTimer = 0u;
SysFun_KL15Monitor.FinalSts = 0u;
SysFun_KL15Monitor.ActSts = 0u;
}
if ( pfunction.SysGet_KL30_Valid != (( void * )0) )
{
VoltageKL30Valid = pfunction.SysGet_KL30_Valid( );
}else
{
VoltageKL30Valid = 0u;
}
if ( pfunction.SysGet_KL15_Valid != (( void * )0) )
{
VoltageKL15Valid = pfunction.SysGet_KL15_Valid( );
}else
{
VoltageKL15Valid = 0u;
}
if ( (VoltageKL30Valid == 1U) && (VoltageKL15Valid == 1U) )
{
if ( pfunction.SysGet_KL15_value != (( void * )0) )
{
Voltage_KL15 = pfunction.SysGet_KL15_value( );
}
else
{
Voltage_KL15 = 0u;
}
if ( pfunction.SysGet_KL30_value != (( void * )0) )
{
Voltage_KL30 = pfunction.SysGet_KL30_value( );
}
else
{
Voltage_KL30 = 0u;
}
if ( Voltage_KL30 > Voltage_KL15 )
{
Voltage = Voltage_KL30;
}
else
{
Voltage = Voltage_KL15;
}
if ( SysFun_KL30Monitor.SumCnt < 50u )
{
SysFun_KL30Monitor.ActVoltage += Voltage;
SysFun_KL30Monitor.SumCnt += 1u;
Voltage = ( monitorlib_uint16_t )(SysFun_KL30Monitor.ActVoltage / SysFun_KL30Monitor.SumCnt);
}
else
{
SysFun_KL30Monitor.SumCnt = 0u;
SysFun_KL30Monitor.ActVoltage = 0u;
SysFun_KL30Monitor.ActVoltage += Voltage;
SysFun_KL30Monitor.SumCnt += 1u;
Voltage = ( monitorlib_uint16_t )(SysFun_KL30Monitor.ActVoltage / SysFun_KL30Monitor.SumCnt);
}
m8 = System_Calc_FunRange(Voltage);
// //printf("1 is %d, 2 is %d\r\n", m8, SysFun_KL30Monitor.FinalSts);
if ( SysFun_KL30Monitor.ActSts == m8 )
{
DebpounceTimer = 0u;
switch ( SysFun_KL30Monitor.FinalSts )
{
case 0:
case 1:
case 9:
t_FUN_KL30_timer = t_FUN_KL30_Debounce_Cancel;
break;
default:
t_FUN_KL30_timer = t_FUN_KL30_Debounce;
break;
}
/* 计时�?计时�?1000*2ms */
if ( SysFun_KL30Monitor.DebounceTimer < t_FUN_KL30_timer ) /*40202-8*/
{
SysFun_KL30Monitor.DebounceTimer++;
}
else
{
if ( SysFun_KL30Monitor.FinalSts > 7u ) /* 高压 */
{
if ( (m8 == 9u) || (m8 == 8u) || (m8 == 7u) )
{
SysFun_KL30Monitor.FinalSts = 9u;
SysFun_KL15Monitor.FinalSts = 0u;
}
else
{
SysFun_KL30Monitor.FinalSts = m8;
}
}
if ( SysFun_KL30Monitor.FinalSts == 1u ) /* 低压 */
{
if ( (m8 == 1u) || (m8 == 2u) )
{
SysFun_KL30Monitor.FinalSts = 1u;
SysFun_KL15Monitor.FinalSts = 0u;
}
else
{
SysFun_KL30Monitor.FinalSts = m8;
}
}
/* 非高低压 */
if ( (SysFun_KL30Monitor.FinalSts != 1u) && (SysFun_KL30Monitor.FinalSts <= 7u) )
{
SysFun_KL30Monitor.FinalSts = m8;
}
}
}
else
{
/* 计时时间清除 */
SysFun_KL30Monitor.DebounceTimer = 0U;
DebpounceTimer++;
if ( DebpounceTimer >= 5u )
{
DebpounceTimer = 0u;
SysFun_KL30Monitor.ActSts = m8;
}
}
}
/*
else
{
SysFun_KL30Monitor.FinalSts = 1u;
SysFun_KL15Monitor.FinalSts = 0u;
}*/
}
monitorlib_uint8_t System_NM_KL30_Status_Get(void)
{
return SysNM_KL30Monitor.FinalSts;
}
monitorlib_uint8_t System_NM_KL15_Status_Get(void)
{
return SysNM_KL15Monitor.FinalSts;
}
monitorlib_uint8_t System_FUN_KL30_Status_Get(void)
{
return SysFun_KL30Monitor.FinalSts;
}
monitorlib_uint8_t System_FUN_KL15_Status_Get(void)
{
return SysFun_KL15Monitor.FinalSts;
}
monitorlib_uint16_t Get_Sysmonitor_Version(void)
{
return 0x0002u;
}