Explorar o código

HFR 검수
1. 부팅시 죽는 문제 수정 CrcLength 오버 플로우 로인한 죽음 수정
2.SelfTest On off 시 Atten 0 과 이전값을 기억 수정 완료
3.Carrier OFF 시 path 제어 안되 도록 수정

PYJ %!s(int64=5) %!d(string=hai) anos
pai
achega
d8ea6c936b
Modificáronse 3 ficheiros con 176 adicións e 14 borrados
  1. 151 11
      Bluecell_Src/Bluecell_operate.c
  2. 21 2
      Bluecell_Src/flash.c
  3. 4 1
      Src/main.c

+ 151 - 11
Bluecell_Src/Bluecell_operate.c

@@ -80,6 +80,9 @@ extern volatile uint32_t Alarm_UL_Level_TimerOnCnt ;
80 80
 
81 81
 extern volatile uint32_t SelfTestLifeCnt[4];
82 82
 
83
+uint8_t Selftest_DL_PrevAttenSave[8] = {0,};
84
+uint8_t Selftest_UL_PrevAttenSave[8] = {0,};
85
+
83 86
 
84 87
 /***************************************************************************************/
85 88
 /*                                  Function                                           */
@@ -180,6 +183,12 @@ typedef enum{
180 183
     Atten_L,        
181 184
 };
182 185
    
186
+typedef enum{
187
+    SelfTest1 = 0,
188
+    SelfTest2,
189
+    SelfTest3,
190
+    SelfTest4,    
191
+};
183 192
 
184 193
 
185 194
 #if 0 // PYJ.2020.05.21_BEGIN -- 
@@ -764,6 +773,11 @@ void DL_AttenOperate(uint8_t* Atten,uint8_t* PrevAtten,uint8_t* UserAtten,uint8_
764 773
 
765 774
 
766 775
 }
776
+typedef enum{
777
+    UserAtten_H = 0,
778
+    UserAtten_L,        
779
+};
780
+
767 781
 void CompareAttenData(BLUESTATUS_st Curr,BLUESTATUS_st Prev){
768 782
      uint8_t val = 0;
769 783
      uint16_t MBIC_Val = 0;
@@ -2506,6 +2520,8 @@ bool Bluecell_Operate(uint8_t* data){
2506 2520
 //        printf("Function : %s Line %d \r\n",__func__,__LINE__);
2507 2521
 		break;
2508 2522
 	case ATT_SelfTest1		 :
2523
+#if 0 // PYJ.2020.07.05_BEGIN -- 
2524
+        
2509 2525
         if(data[BLUECELL_DATA]==0){
2510 2526
             HAL_GPIO_WritePin(_PATH_SW1_GPIO_Port,_PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
2511 2527
             HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_SET);//CLOCK
@@ -2516,6 +2532,28 @@ bool Bluecell_Operate(uint8_t* data){
2516 2532
         }
2517 2533
         bluecell_Currdatastatus.Selftest1 = data[BLUECELL_DATA];
2518 2534
 //		printf("Function : %s Line %d \r\n",__func__,__LINE__);
2535
+#else
2536
+#if 0 // PYJ.2020.07.05_BEGIN -- 
2537
+        if(data[BLUECELL_DATA] == 0){
2538
+            bluecell_Currdatastatus.ATT_DL1_H = Selftest_DL_PrevAttenSave[0]; 
2539
+            bluecell_Currdatastatus.ATT_DL1_L = Selftest_DL_PrevAttenSave[1];  
2540
+            bluecell_Currdatastatus.ATT_UL1_H = Selftest_UL_PrevAttenSave[0]; 
2541
+            bluecell_Currdatastatus.ATT_UL1_L = Selftest_UL_PrevAttenSave[1];
2542
+        }else{
2543
+            Selftest_DL_PrevAttenSave[0] = bluecell_Currdatastatus.ATT_DL1_H;
2544
+            Selftest_DL_PrevAttenSave[1] = bluecell_Currdatastatus.ATT_DL1_L;            
2545
+            Selftest_UL_PrevAttenSave[0] = bluecell_Currdatastatus.ATT_UL1_H;
2546
+            Selftest_UL_PrevAttenSave[1] = bluecell_Currdatastatus.ATT_UL1_L;            
2547
+            bluecell_Currdatastatus.ATT_DL1_H = 0;
2548
+            bluecell_Currdatastatus.ATT_DL1_L = 0;        
2549
+            bluecell_Currdatastatus.ATT_UL1_H = 0;
2550
+            bluecell_Currdatastatus.ATT_UL1_L = 0;              
2551
+        }
2552
+        CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
2553
+#endif // PYJ.2020.07.05_END -- 
2554
+        SelfTest_Ctrl(SelfTest1,data[BLUECELL_DATA],&bluecell_Currdatastatus.Selftest1,&bluecell_Currdatastatus.ATT_DL1_H,&bluecell_Currdatastatus.ATT_UL1_H);
2555
+
2556
+#endif // PYJ.2020.07.05_END -- 
2519 2557
 		break;
2520 2558
 	case ATT_DL2_PATH		 :
2521 2559
 #if 0 // PYJ.2020.07.03_BEGIN -- 
@@ -2572,6 +2610,7 @@ bool Bluecell_Operate(uint8_t* data){
2572 2610
 #endif // PYJ.2020.07.03_END -- 
2573 2611
 		break;
2574 2612
 	case ATT_SelfTest2		 :
2613
+#if 0 // PYJ.2020.07.05_BEGIN -- 
2575 2614
         if(data[BLUECELL_DATA]==0){
2576 2615
             HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
2577 2616
             HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
@@ -2580,6 +2619,10 @@ bool Bluecell_Operate(uint8_t* data){
2580 2619
             HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
2581 2620
         }
2582 2621
         bluecell_Currdatastatus.Selftest2 = data[BLUECELL_DATA];
2622
+#else
2623
+        SelfTest_Ctrl(SelfTest2,data[BLUECELL_DATA],&bluecell_Currdatastatus.Selftest2,&bluecell_Currdatastatus.ATT_DL2_H,&bluecell_Currdatastatus.ATT_UL2_H);
2624
+
2625
+#endif // PYJ.2020.07.05_END -- 
2583 2626
 //		printf("Function : %s Line %d \r\n",__func__,__LINE__);
2584 2627
 		break;
2585 2628
 	case ATT_DL3_PATH :
@@ -2633,6 +2676,7 @@ bool Bluecell_Operate(uint8_t* data){
2633 2676
 #endif // PYJ.2020.07.03_END -- 
2634 2677
 		break;
2635 2678
 	case ATT_SelfTest3 :
2679
+#if 0 // PYJ.2020.07.05_BEGIN -- 
2636 2680
         if(data[BLUECELL_DATA]==0){
2637 2681
             HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
2638 2682
             HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
@@ -2642,6 +2686,10 @@ bool Bluecell_Operate(uint8_t* data){
2642 2686
             HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
2643 2687
         }
2644 2688
         bluecell_Currdatastatus.Selftest3 = data[BLUECELL_DATA];
2689
+#else
2690
+        SelfTest_Ctrl(SelfTest3,data[BLUECELL_DATA],&bluecell_Currdatastatus.Selftest3,&bluecell_Currdatastatus.ATT_DL3_H,&bluecell_Currdatastatus.ATT_UL3_H);
2691
+
2692
+#endif // PYJ.2020.07.05_END -- 
2645 2693
 //		printf("Function : %s Line %d \r\n",__func__,__LINE__);
2646 2694
 		break;
2647 2695
 	case ATT_DL4_PATH :
@@ -2698,6 +2746,7 @@ bool Bluecell_Operate(uint8_t* data){
2698 2746
 //		printf("Function : %s Line %d \r\n",__func__,__LINE__);
2699 2747
 		break;
2700 2748
 	case ATT_SelfTest4 :
2749
+#if 0 // PYJ.2020.07.05_BEGIN -- 
2701 2750
 	  if(data[BLUECELL_DATA]==0){
2702 2751
 	    HAL_GPIO_WritePin(_PATH_SW4_GPIO_Port,_PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
2703 2752
 	    HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_SET);//CLOCK
@@ -2706,6 +2755,10 @@ bool Bluecell_Operate(uint8_t* data){
2706 2755
 	    HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
2707 2756
 	  }
2708 2757
       bluecell_Currdatastatus.Selftest4 = data[BLUECELL_DATA];
2758
+#else
2759
+        SelfTest_Ctrl(SelfTest4,data[BLUECELL_DATA],&bluecell_Currdatastatus.Selftest4,&bluecell_Currdatastatus.ATT_DL4_H,&bluecell_Currdatastatus.ATT_UL4_H);
2760
+
2761
+#endif // PYJ.2020.07.05_END -- 
2709 2762
 //		printf("Function : %s Line %d \r\n",__func__,__LINE__);
2710 2763
 		break;
2711 2764
     case ATT_TableSet:
@@ -2860,7 +2913,7 @@ bool Bluecell_Operate(uint8_t* data){
2860 2913
 
2861 2914
 
2862 2915
         
2863
-        printf("Temp Alarm %d \r\n");
2916
+        printf("Temp Alarm %d \r\n",bluecell_Currdatastatus.ALARM_TEMP_HIGH);
2864 2917
         printf("ALC  Alarm 1: %d 2:  %d 3: %d 4: %d\r\n",
2865 2918
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm & ALARM_ALC_P1,
2866 2919
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm & ALARM_ALC_P2,
@@ -3379,10 +3432,14 @@ typedef enum{
3379 3432
     Turn off all paths at boot
3380 3433
  */
3381 3434
    
3382
-   bluecell_Currdatastatus.Type =  HAL_GPIO_ReadPin(UNIT_ID0_GPIO_Port,UNIT_ID0_Pin);
3435
+   bluecell_Currdatastatus.Type =   HAL_GPIO_ReadPin(UNIT_ID0_GPIO_Port,UNIT_ID0_Pin);
3383 3436
    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID1_GPIO_Port,UNIT_ID1_Pin) << 1;
3384 3437
    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID2_GPIO_Port,UNIT_ID2_Pin) << 2;
3385 3438
    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID3_GPIO_Port,UNIT_ID3_Pin) << 3;
3439
+   printf("0: %d \r\n",HAL_GPIO_ReadPin(UNIT_ID0_GPIO_Port,UNIT_ID0_Pin));
3440
+   printf("1: %d \r\n",HAL_GPIO_ReadPin(UNIT_ID1_GPIO_Port,UNIT_ID1_Pin));
3441
+   printf("2: %d \r\n",HAL_GPIO_ReadPin(UNIT_ID2_GPIO_Port,UNIT_ID2_Pin));
3442
+   printf("3: %d \r\n",HAL_GPIO_ReadPin(UNIT_ID3_GPIO_Port,UNIT_ID3_Pin));   
3386 3443
     switch(bluecell_Currdatastatus.Type){
3387 3444
      case BLUECELL_3_7G: bluecell_Currdatastatus.Type = 0x80;bluecell_Currdatastatus.Carrier_ID = 0x01 ;printf("Type BLUECELL_3_7G  Ready....\r\n"); break;
3388 3445
      case BLUECELL_3_8G: bluecell_Currdatastatus.Type = 0x81;bluecell_Currdatastatus.Carrier_ID = 0x02; printf("Type BLUECELL_3_8G  Ready....\r\n");break;
@@ -3391,7 +3448,7 @@ typedef enum{
3391 3448
      case BLUECELL_4_1G: bluecell_Currdatastatus.Type = 0x84;bluecell_Currdatastatus.Carrier_ID = 0x02; printf("Type BLUECELL_4_1G  Ready....\r\n");break;
3392 3449
      case BLUECELL_4_6G: bluecell_Currdatastatus.Type = 0x85;bluecell_Currdatastatus.Carrier_ID = 0x01; printf("Type BLUECELL_4_6G  Ready....\r\n");break;
3393 3450
      case BLUECELL_4_7G: bluecell_Currdatastatus.Type = 0x86;bluecell_Currdatastatus.Carrier_ID = 0x00; printf("Type BLUECELL_4_7G  Ready....\r\n");break;
3394
-     case BLUECELL_4_8G: bluecell_Currdatastatus.Type = 0x87;bluecell_Currdatastatus.Carrier_ID = 0x00; printf("Type BLUECELL_3_7G  Ready....\r\n");break;
3451
+     case BLUECELL_4_8G: bluecell_Currdatastatus.Type = 0x87;bluecell_Currdatastatus.Carrier_ID = 0x00; printf("Type BLUECELL_4_8G  Ready....\r\n");break;
3395 3452
      case BLUECELL_4_9G: bluecell_Currdatastatus.Type = 0x88;bluecell_Currdatastatus.Carrier_ID = 0x00; printf("Type BLUECELL_4_9G  Ready....\r\n");break;
3396 3453
      case BLUECELL_5_0G: bluecell_Currdatastatus.Type = 0x89;bluecell_Currdatastatus.Carrier_ID = 0x00; printf("Type BLUECELL_5_0G  Ready....\r\n");break;
3397 3454
      case BLUECELL_DCM : bluecell_Currdatastatus.Type = 0x8A;bluecell_Currdatastatus.Carrier_ID = 0x01;printf("Type BLUECELL_DCM  Ready....\r\n"); break;
@@ -4533,6 +4590,9 @@ void Factory_Set(){
4533 4590
 void DL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,uint8_t* retrycnt,uint8_t* PrevRetryCnt){
4534 4591
     GPIO_TypeDef *Port = 0;
4535 4592
     uint16_t Pin = 0;    
4593
+    if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
4594
+        return;
4595
+        
4536 4596
     switch(Index){
4537 4597
         case Path1_OnOff:
4538 4598
         Port = PATH_EN_DL1_GPIO_Port;
@@ -4570,6 +4630,8 @@ void DL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,
4570 4630
 void UL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,uint8_t* retrycnt,uint8_t* PrevRetryCnt){
4571 4631
     GPIO_TypeDef *Port = 0;
4572 4632
     uint16_t Pin = 0;    
4633
+     if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
4634
+            return;    
4573 4635
     switch(Index){
4574 4636
         case Path1_OnOff:
4575 4637
         Port = PATH_EN_UL1_GPIO_Port;
@@ -5427,6 +5489,7 @@ bool MBIC_Operate(uint8_t* data){
5427 5489
 //                bluecell_Currdatastatus.ULO_Level_High_Threshold_default = data[MBIC_PAYLOADSTART + 3]; 
5428 5490
                 break;
5429 5491
             case ULO_SelfTest1:
5492
+#if 0 // PYJ.2020.07.05_BEGIN -- 
5430 5493
                 if(data[MBIC_PAYLOADSTART + 3]==0){
5431 5494
                     HAL_GPIO_WritePin(_PATH_SW1_GPIO_Port,_PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
5432 5495
                     HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_SET);//CLOCK
@@ -5436,8 +5499,13 @@ bool MBIC_Operate(uint8_t* data){
5436 5499
                     HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
5437 5500
                 }
5438 5501
                 bluecell_Currdatastatus.Selftest1 = data[MBIC_PAYLOADSTART + 3];                
5502
+#else
5503
+                SelfTest_Ctrl(SelfTest1,data[MBIC_PAYLOADSTART + 3],&bluecell_Currdatastatus.Selftest1,&bluecell_Currdatastatus.ATT_DL1_H,&bluecell_Currdatastatus.ATT_UL1_H);
5504
+
5505
+#endif // PYJ.2020.07.05_END -- 
5439 5506
                 break;
5440 5507
             case ULO_SelfTest2:
5508
+#if 0 // PYJ.2020.07.05_BEGIN -- 
5441 5509
                 if(data[MBIC_PAYLOADSTART + 3]==0){
5442 5510
                     HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
5443 5511
                     HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
@@ -5447,8 +5515,13 @@ bool MBIC_Operate(uint8_t* data){
5447 5515
                     HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
5448 5516
                 }
5449 5517
                 bluecell_Currdatastatus.Selftest2 = data[MBIC_PAYLOADSTART + 3];                
5518
+#else
5519
+                SelfTest_Ctrl(SelfTest2,data[MBIC_PAYLOADSTART + 3],&bluecell_Currdatastatus.Selftest2,&bluecell_Currdatastatus.ATT_DL2_H,&bluecell_Currdatastatus.ATT_UL2_H);
5520
+
5521
+#endif // PYJ.2020.07.05_END -- 
5450 5522
                 break;
5451 5523
             case ULO_SelfTest3:
5524
+#if 0 // PYJ.2020.07.05_BEGIN -- 
5452 5525
                 if(data[MBIC_PAYLOADSTART + 3]==0){
5453 5526
                     HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
5454 5527
                     HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
@@ -5458,8 +5531,13 @@ bool MBIC_Operate(uint8_t* data){
5458 5531
                     HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
5459 5532
                 }
5460 5533
                 bluecell_Currdatastatus.Selftest3 = data[MBIC_PAYLOADSTART + 3];                
5534
+#else         
5535
+                SelfTest_Ctrl(SelfTest3,data[MBIC_PAYLOADSTART + 3],&bluecell_Currdatastatus.Selftest3,&bluecell_Currdatastatus.ATT_DL3_H,&bluecell_Currdatastatus.ATT_UL3_H);
5536
+
5537
+#endif // PYJ.2020.07.05_END -- 
5461 5538
                 break;
5462 5539
             case ULO_SelfTest4:
5540
+#if 0 // PYJ.2020.07.05_BEGIN -- 
5463 5541
                 if(data[MBIC_PAYLOADSTART + 3]==0){
5464 5542
                     HAL_GPIO_WritePin(_PATH_SW4_GPIO_Port,_PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
5465 5543
                     HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_SET);//CLOCK
@@ -5469,6 +5547,10 @@ bool MBIC_Operate(uint8_t* data){
5469 5547
                     HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
5470 5548
                 }
5471 5549
                 bluecell_Currdatastatus.Selftest4 = data[MBIC_PAYLOADSTART + 3];                
5550
+#else
5551
+                SelfTest_Ctrl(SelfTest4,data[MBIC_PAYLOADSTART + 3],&bluecell_Currdatastatus.Selftest4,&bluecell_Currdatastatus.ATT_DL4_H,&bluecell_Currdatastatus.ATT_UL4_H);
5552
+
5553
+#endif // PYJ.2020.07.05_END -- 
5472 5554
                 break;
5473 5555
             case  ULO_ALC_ON_OFF                   :
5474 5556
                 bluecell_Currdatastatus.ULO_ALC_ON_OFF = data[MBIC_PAYLOADSTART + 3]; 
@@ -5484,9 +5566,9 @@ bool MBIC_Operate(uint8_t* data){
5484 5566
             case  ULO_ALC_Threshold_Default               :
5485 5567
 			    tempdata = ULO_ALC_THREADHOLD_DEFAULT;
5486 5568
 			    bluecell_Currdatastatus.ULO_ALC_Threshold_H = ((tempdata & 0xFF00) >> 8);    
5487
-			    bluecell_Currdatastatus.ULO_ALC_Threshold_L = ((tempdata & 0x00FF));  				
5569
+			    bluecell_Currdatastatus.ULO_ALC_Threshold_L = ((tempdata & 0x00FF));  	
5570
+                printf("ALC DEFAULT VALUE SETTING COMPLETE \r\n");
5488 5571
 //                bluecell_Currdatastatus.ULO_ALC_Threshold_Default = data[MBIC_PAYLOADSTART + 3]; 
5489
-
5490 5572
                 break;
5491 5573
             case  ULO_Shutdown_ON_OFF                     :
5492 5574
                 bluecell_Currdatastatus.ULO_Shutdown_ON_OFF = data[MBIC_PAYLOADSTART + 3]; 
@@ -9464,12 +9546,7 @@ void FRBT_Tracking_Package(uint8_t Index, uint8_t* FRBT,uint8_t* DL_MainAtten,ui
9464 9546
     FRBT[FRBT_L] = DL_MainAtten[FRBT_L];        
9465 9547
 
9466 9548
 }
9467
-typedef enum{
9468
-    SelfTest1 = 0,
9469
-    SelfTest2,
9470
-    SelfTest3,
9471
-    SelfTest4,    
9472
-};
9549
+
9473 9550
 void SelfTest_TimerOff(uint8_t num,uint8_t* selftest){
9474 9551
     GPIO_TypeDef *Port = 0;
9475 9552
     uint16_t Pin = 0;
@@ -9513,6 +9590,69 @@ void SelfTest_TimerOff(uint8_t num,uint8_t* selftest){
9513 9590
     HAL_GPIO_WritePin(Port,Pin,GPIO_PIN_SET);//CLOCK
9514 9591
     
9515 9592
 }
9593
+
9594
+void SelfTest_Ctrl(uint8_t num,uint8_t val,uint8_t* selftest,uint8_t* DL_Atten,uint8_t* UL_Atten){
9595
+    GPIO_TypeDef *Port = 0;
9596
+    uint16_t Pin = 0;
9597
+    GPIO_TypeDef *_Port = 0;
9598
+    uint16_t _Pin = 0;   
9599
+    
9600
+    switch(num){
9601
+        case SelfTest1:
9602
+        _Port = _PATH_SW1_GPIO_Port;
9603
+        _Pin = _PATH_SW1_Pin;
9604
+        
9605
+        Port = PATH_SW1_GPIO_Port;
9606
+        Pin =  PATH_SW1_Pin;   
9607
+        break;
9608
+        case SelfTest2:
9609
+        _Port = _PATH_SW2_GPIO_Port;
9610
+        _Pin = _PATH_SW2_Pin;
9611
+        
9612
+        Port = PATH_SW2_GPIO_Port;
9613
+        Pin =  PATH_SW2_Pin;        
9614
+        break;
9615
+        case SelfTest3:
9616
+        _Port = _PATH_SW3_GPIO_Port;
9617
+        _Pin = _PATH_SW3_Pin;
9618
+        
9619
+        Port = PATH_SW3_GPIO_Port;
9620
+        Pin =  PATH_SW3_Pin;        
9621
+        break;
9622
+        case SelfTest4:
9623
+        _Port = _PATH_SW4_GPIO_Port;
9624
+        _Pin = _PATH_SW4_Pin;
9625
+        
9626
+        Port = PATH_SW4_GPIO_Port;
9627
+        Pin =  PATH_SW4_Pin;        
9628
+        break;        
9629
+    }
9630
+
9631
+        
9632
+    if(val == true){
9633
+        Selftest_DL_PrevAttenSave[num * 2]         = DL_Atten[Atten_H];
9634
+        Selftest_DL_PrevAttenSave[((num * 2) + 1)] = DL_Atten[Atten_L];
9635
+        Selftest_UL_PrevAttenSave[num * 2]         = UL_Atten[Atten_H];
9636
+        Selftest_UL_PrevAttenSave[((num * 2) + 1)] = UL_Atten[Atten_L];
9637
+        DL_Atten[Atten_H] = 0;
9638
+        DL_Atten[Atten_L] = 0;
9639
+        UL_Atten[Atten_H] = 0;
9640
+        UL_Atten[Atten_L] = 0;          
9641
+        HAL_GPIO_WritePin(_Port,_Pin,GPIO_PIN_SET);//CLOCK
9642
+        HAL_GPIO_WritePin(Port,Pin,GPIO_PIN_RESET);//CLOCK
9643
+    }else{
9644
+        DL_Atten[Atten_H] = Selftest_DL_PrevAttenSave[num * 2];
9645
+        DL_Atten[Atten_L] = Selftest_DL_PrevAttenSave[((num * 2) + 1)];    
9646
+        UL_Atten[Atten_H] = Selftest_UL_PrevAttenSave[num * 2];
9647
+        UL_Atten[Atten_L] = Selftest_UL_PrevAttenSave[((num * 2) + 1)];              
9648
+        HAL_GPIO_WritePin(_Port,_Pin,GPIO_PIN_RESET);//CLOCK
9649
+        HAL_GPIO_WritePin(Port,Pin,GPIO_PIN_SET);//CLOCK
9650
+    }
9651
+    CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);       
9652
+    *selftest = val;
9653
+    
9654
+}
9655
+
9516 9656
 void SelfTestTimer_Operate()
9517 9657
 {
9518 9658
     SelfTest_TimerOff(SelfTest1,&bluecell_Currdatastatus.Selftest1);

+ 21 - 2
Bluecell_Src/flash.c

@@ -28,6 +28,25 @@ void Jump_App(void){
28 28
     jump_to_app();
29 29
 }
30 30
 
31
+uint8_t CurrFlash_BankCheck(){
32
+    uint32_t  CurrApiAddress = 0,Bank1Address=0,Bank2Address = 0;
33
+    uint32_t i = 0;
34
+    uint8_t ret = 0;
35
+    CurrApiAddress = FLASH_MBICUSER_START_ADDR;
36
+    Bank1Address = FLASH_USER_BANK1_START_ADDR;
37
+    Bank2Address = FLASH_USER_BANK2_START_ADDR;
38
+    
39
+    uint8_t* Currdata = (uint8_t*)CurrApiAddress;
40
+    uint8_t* Bank1data = (uint8_t*)Bank1Address;
41
+    uint8_t* Bank2data = (uint8_t*)Bank2Address;
42
+
43
+    for(i = 0; i < MBIC_BOOT_DATA; i++){
44
+        if(Currdata[MBIC_BOOT_MARK + i] != Bank2data[MBIC_BOOT_MARK + i]){
45
+            return HFR_BANK1_SEL;
46
+        }
47
+    }
48
+    return HFR_BANK2_SEL;
49
+}
31 50
 
32 51
 
33 52
 void Flash_InitRead() // ?占쏙옙湲고븿?占쏙옙
@@ -177,7 +196,7 @@ void Flash_InitRead() // ?占쏙옙湲고븿?占쏙옙
177 196
     | Bank1data[MBIC_BOOT_LENGTH + 1]<<16 
178 197
     | Bank1data[MBIC_BOOT_LENGTH + 2]<<8   
179 198
     | Bank1data[MBIC_BOOT_LENGTH + 3]);
180
-    if(CrcLength > 0 )
199
+    if(CrcLength > 0 && CrcLength <= 0x1FFFF )
181 200
         crcret = crc32(&Bank1data[MBIC_BOOT_DATA], CrcLength);
182 201
     if(crcret != FileCrc){
183 202
         bluecell_Currdatastatus.CPU_Bank1_Image_Version1 = 0xFF;
@@ -254,7 +273,7 @@ void Flash_InitRead() // ?占쏙옙湲고븿?占쏙옙
254 273
     | Bank2data[MBIC_BOOT_LENGTH + 1]<<16 
255 274
     | Bank2data[MBIC_BOOT_LENGTH + 2]<<8   
256 275
     | Bank2data[MBIC_BOOT_LENGTH + 3]);       
257
-     if(CrcLength > 0 )
276
+     if(CrcLength > 0 && CrcLength <= 0x1FFFF )
258 277
         crcret = crc32(&Bank2data[MBIC_BOOT_DATA], CrcLength);
259 278
     if(crcret != FileCrc){
260 279
    

+ 4 - 1
Src/main.c

@@ -304,8 +304,10 @@ int main(void)  {
304 304
         | Bank1data[MBIC_BOOT_LENGTH + 2]<<8   
305 305
         | Bank1data[MBIC_BOOT_LENGTH + 3]);    
306 306
 
307
-        if(CrcLength > 0)
307
+        if(CrcLength > 0 && CrcLength <= 0x1FFFF ){
308
+            printf("Bank 1 Crc ret : %x  Length : %x :  %d \r\n",crcret ,CrcLength,CrcLength);
308 309
             crcret = CRC16_Generate(Bank1data, CrcLength + 128);
310
+        }
309 311
         CrcLength += 128;
310 312
         printf("Bank 1 Crc ret : %x  Length : %x :  %d \r\n",crcret ,CrcLength,CrcLength);
311 313
         
@@ -318,6 +320,7 @@ int main(void)  {
318 320
         
319 321
         printf("Bank 2 Crc ret : %x  Length : %x :  %d  \r\n", crcret,CrcLength,CrcLength );
320 322
         CrcLength += 128;
323
+        if(CrcLength > 0 && CrcLength <= 0x1FFFF )
321 324
          crcret = CRC16_Generate(Bank2data, CrcLength );
322 325
         printf("Bank 2 Crc ret : %x  Length : %x :  %d  \r\n", crcret,CrcLength,CrcLength );
323 326