浏览代码

IPC Fail 수정 / Shutdown Timing 조정 / ALC AGC 조정

1. Usart DMA -> IT 방식으로 변경
2. 15초 -> 5초로 변경 30초에서 25초로 변경
3. ALC/AGC 범위 초과 미만으로 변경
PYJ 4 年之前
父节点
当前提交
908f49ae0b
共有 8 个文件被更改,包括 145 次插入129 次删除
  1. 112 47
      Bluecell_Src/Bluecell_operate.c
  2. 3 3
      Bluecell_Src/uart.c
  3. 2 2
      Inc/main.h
  4. 0 1
      Inc/stm32f1xx_it.h
  5. 21 32
      STM32F103ZET_JDASMBIC.ioc
  6. 7 10
      Src/main.c
  7. 0 19
      Src/stm32f1xx_hal_msp.c
  8. 0 15
      Src/stm32f1xx_it.c

+ 112 - 47
Bluecell_Src/Bluecell_operate.c

@@ -113,7 +113,7 @@ double TableAtteGuarantee(uint8_t* Table,double AttenValue);
113 113
 double PE43711_Double(uint8_t high_bit,uint8_t low_bit);
114 114
 double Bluecell_TestPro(double value );
115 115
 double AGC_AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t size,int8_t* RefTable_Data);
116
-void ALC_Alarm_TimerSet(uint8_t num,int16_t threshold,int16_t CurrDet,int16_t CurrAtten,int16_t MainAtten);
116
+void ALC_Alarm_TimerSet(uint8_t num,int16_t threshold,double CurrDet,int16_t CurrAtten,int16_t MainAtten);
117 117
 void Carrier_ONOFF(uint8_t val);
118 118
 void DL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,uint8_t* retrycnt,uint8_t* PrevRetryCnt);
119 119
 void Factory_Set();
@@ -3093,27 +3093,29 @@ void DataStatusSet(void){
3093 3093
 }
3094 3094
 
3095 3095
 void HFR_TypeInit(){
3096
-    bluecell_Currdatastatus.Type =   HAL_GPIO_ReadPin(UNIT_ID0_GPIO_Port,UNIT_ID0_Pin);
3097
-    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID1_GPIO_Port,UNIT_ID1_Pin) << 1;
3098
-    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID2_GPIO_Port,UNIT_ID2_Pin) << 2;
3099
-    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID3_GPIO_Port,UNIT_ID3_Pin) << 3;
3096
+    uint8_t type = 0;
3097
+    type =   HAL_GPIO_ReadPin(UNIT_ID0_GPIO_Port,UNIT_ID0_Pin);
3098
+    type +=  HAL_GPIO_ReadPin(UNIT_ID1_GPIO_Port,UNIT_ID1_Pin) << 1;
3099
+    type +=  HAL_GPIO_ReadPin(UNIT_ID2_GPIO_Port,UNIT_ID2_Pin) << 2;
3100
+    type +=  HAL_GPIO_ReadPin(UNIT_ID3_GPIO_Port,UNIT_ID3_Pin) << 3;
3100 3101
 //    printf("0: %d \r\n",HAL_GPIO_ReadPin(UNIT_ID0_GPIO_Port,UNIT_ID0_Pin));
3101 3102
 //    printf("1: %d \r\n",HAL_GPIO_ReadPin(UNIT_ID1_GPIO_Port,UNIT_ID1_Pin));
3102 3103
 //    printf("2: %d \r\n",HAL_GPIO_ReadPin(UNIT_ID2_GPIO_Port,UNIT_ID2_Pin));
3103 3104
 //    printf("3: %d \r\n",HAL_GPIO_ReadPin(UNIT_ID3_GPIO_Port,UNIT_ID3_Pin));   
3104
-    switch(bluecell_Currdatastatus.Type){
3105
-        case BLUECELL_3_7G: bluecell_Currdatastatus.Type = 0x80;bluecell_Currdatastatus.Carrier_ID = 0x01 ;break;//printf("Type BLUECELL_3_7G  Ready....\r\n"); break;
3106
-        case BLUECELL_3_8G: bluecell_Currdatastatus.Type = 0x81;bluecell_Currdatastatus.Carrier_ID = 0x02;break;// printf("Type BLUECELL_3_8G  Ready....\r\n");break;
3105
+//    printf("ret : %x \r\n",type);
3106
+    switch(type){
3107
+        case BLUECELL_3_7G: bluecell_Currdatastatus.Type = 0x80;bluecell_Currdatastatus.Carrier_ID = 0x01;break;//printf("Type BLUECELL_3_7G  Ready....\r\n"); break;
3108
+        case BLUECELL_3_8G: bluecell_Currdatastatus.Type = 0x81;bluecell_Currdatastatus.Carrier_ID = 0x02;break; //printf("Type BLUECELL_3_8G  Ready....\r\n");break;
3107 3109
         case BLUECELL_3_9G: bluecell_Currdatastatus.Type = 0x82;bluecell_Currdatastatus.Carrier_ID = 0x04;break;//printf("Type BLUECELL_3_9G  Ready....\r\n"); break;
3108 3110
         case BLUECELL_4_0G: bluecell_Currdatastatus.Type = 0x83;bluecell_Currdatastatus.Carrier_ID = 0x03;break;// printf("Type BLUECELL_4_0G  Ready....\r\n");break;
3109
-        case BLUECELL_4_1G: bluecell_Currdatastatus.Type = 0x84;bluecell_Currdatastatus.Carrier_ID = 0x02;break; //printf("Type BLUECELL_4_1G  Ready....\r\n");break;
3111
+        case BLUECELL_4_1G: bluecell_Currdatastatus.Type = 0x84;bluecell_Currdatastatus.Carrier_ID = 0x02;break;//printf("Type BLUECELL_4_1G  Ready....\r\n");break;
3110 3112
         case BLUECELL_4_6G: bluecell_Currdatastatus.Type = 0x85;bluecell_Currdatastatus.Carrier_ID = 0x01;break;// printf("Type BLUECELL_4_6G  Ready....\r\n");break;
3111 3113
         case BLUECELL_4_7G: bluecell_Currdatastatus.Type = 0x86;bluecell_Currdatastatus.Carrier_ID = 0x00;break;// printf("Type BLUECELL_4_7G  Ready....\r\n");break;
3112 3114
         case BLUECELL_4_8G: bluecell_Currdatastatus.Type = 0x87;bluecell_Currdatastatus.Carrier_ID = 0x00;break;// printf("Type BLUECELL_4_8G  Ready....\r\n");break;
3113 3115
         case BLUECELL_4_9G: bluecell_Currdatastatus.Type = 0x88;bluecell_Currdatastatus.Carrier_ID = 0x00;break;// printf("Type BLUECELL_4_9G  Ready....\r\n");break;
3114 3116
         case BLUECELL_5_0G: bluecell_Currdatastatus.Type = 0x89;bluecell_Currdatastatus.Carrier_ID = 0x00;break;// printf("Type BLUECELL_5_0G  Ready....\r\n");break;
3115 3117
         case BLUECELL_DCM : bluecell_Currdatastatus.Type = 0x8A;bluecell_Currdatastatus.Carrier_ID = 0x01;break;//printf("Type BLUECELL_DCM  Ready....\r\n"); break;
3116
-        case BLUECELL_SBM : bluecell_Currdatastatus.Type = 0x8B;bluecell_Currdatastatus.Carrier_ID = 0x03;break;// printf("Type BLUECELL_SBM  Ready....\r\n");break;
3118
+        case BLUECELL_SBM : bluecell_Currdatastatus.Type = 0x8B;bluecell_Currdatastatus.Carrier_ID = 0x03;break; //printf("Type BLUECELL_SBM  Ready....\r\n");break;
3117 3119
         case BLUECELL_KDDI: bluecell_Currdatastatus.Type = 0x8C;bluecell_Currdatastatus.Carrier_ID = 0x02;break;//printf("Type BLUECELL_KDDI  Ready....\r\n"); break;
3118 3120
 //        default : printf("Type %x  Ready....\r\n",bluecell_Currdatastatus.Type);break;
3119 3121
     }
@@ -3136,7 +3138,7 @@ void HFR_TypeInit(){
3136 3138
         PrevMBIC_DL_ShutdownCount[i] = 0xFF;        
3137 3139
     }
3138 3140
 #if 1 // PYJ.2020.06.17_BEGIN -- 
3139
-    printf("bluecell_Currdatastatus.Path_TempSave_Bit : %x \r\n",bluecell_Currdatastatus.Path_TempSave_Bit);
3141
+//    printf("bluecell_Currdatastatus.Path_TempSave_Bit : %x \r\n",bluecell_Currdatastatus.Path_TempSave_Bit);
3140 3142
     if(bluecell_Currdatastatus.Path_TempSave_Bit & 0x80)
3141 3143
         bluecell_Currdatastatus.ATT_DL1_PATH = true;
3142 3144
     else
@@ -8208,10 +8210,11 @@ int16_t ALC_Calc(uint8_t num,double CurrAtten ,int8_t threshold,double CurrDet){
8208 8210
     return result * 10;
8209 8211
 }
8210 8212
 #define UL_DL_DATASEND_MULTIPLE 10
8211
-void ALC_Alarm_TimerSet(uint8_t num,int16_t threshold,int16_t CurrDet,int16_t Atten,int16_t MainAtten){
8213
+void ALC_Alarm_TimerSet(uint8_t num,int16_t threshold,double CurrDet,int16_t Atten,int16_t MainAtten){
8212 8214
     int16_t ret =0;
8213 8215
     int16_t CurrAtten = 0; 
8214 8216
     int16_t M_Atten = 0;
8217
+    uint8_t* AlarmStatus = &bluecell_Currdatastatus.ULO_ALC_Alarm1;
8215 8218
     M_Atten = (MainAtten * 0.1);
8216 8219
 //    printf("MainAtten : %d \r\n",MainAtten);
8217 8220
     CurrAtten = Atten * 0.1; // ALC ATTEN
@@ -8220,23 +8223,28 @@ void ALC_Alarm_TimerSet(uint8_t num,int16_t threshold,int16_t CurrDet,int16_t At
8220 8223
 //            printf("Alarm 3 \r\n");                
8221 8224
     }    
8222 8225
     else if(threshold <= CurrDet){
8223
-        ret = CurrDet - threshold ;
8226
+        ret = (int)CurrDet - threshold ;
8224 8227
         ret = Bluecell_TestPro(ret +( CurrAtten * 0.1 * -1));
8225 8228
         ret *= -1;  
8226
-//            printf("CurrDet : %d CurrAtten : %d   M_Atten : %d \r\n",CurrDet,CurrAtten,M_Atten);
8229
+//            printf("CurrDet : %f CurrAtten : %d   M_Atten : %d \r\n",CurrDet,CurrAtten,M_Atten);
8230
+        
8227 8231
         if(CurrAtten + M_Atten <= -20){
8228
-            if(threshold + 0.5 <= CurrDet){
8229
-                ALC_AlarmSet[num] = true;
8230
-//                printf("Alarm 1 ON   \r\n");
8231
-            }else{
8232
-                ALC_AlarmSet[num] = false;
8233
-//               printf("Alarm 1 OFF   \r\n");
8234
-
8232
+            if(AlarmStatus[num] == false){
8233
+                if(threshold + 0.1 <= CurrDet){
8234
+                    ALC_AlarmSet[num] = true;
8235
+//                    printf("Alarm 1 ON   \r\n");
8236
+                }else{
8237
+                    ALC_AlarmSet[num] = false;
8238
+//                   printf("Alarm 1 OFF   \r\n");
8239
+                }
8235 8240
             }
8236
-        }else{
8237
-            ALC_AlarmSet[num] = false;
8241
+        }
8242
+#if 0 // PYJ.2020.10.19_BEGIN -- 
8243
+        else{
8244
+//            ALC_AlarmSet[num] = false;
8238 8245
 //            printf("Alarm 1 OFF\r\n");
8239 8246
         }
8247
+#endif // PYJ.2020.10.19_END -- 
8240 8248
     }
8241 8249
     else if(threshold -2 > CurrDet){
8242 8250
         if(CurrAtten < 0){
@@ -8265,7 +8273,7 @@ double HFR_CntUpCalc(double ret){
8265 8273
 //    printf("2. ret : %f \r\n",ret);
8266 8274
     
8267 8275
     
8268
-    if(calctmp >= 5){
8276
+    if(calctmp >= 6){
8269 8277
 //        printf("minus return \r\n");
8270 8278
         origin = (origin -1) + (calctmp  * 0.1);
8271 8279
     }else{
@@ -8290,6 +8298,7 @@ void ALC_Package_Operate(uint8_t*ULO_ADC_Level,uint8_t* ULO_Level,DET_TABLEUL_st
8290 8298
     double CurrentATTENVALUE = 0;
8291 8299
     int16_t Limitdata = 0;
8292 8300
     double ResdBm = 0;
8301
+    double Temp_ResdBm = 0;
8293 8302
     int16_t ResultData = 0;
8294 8303
     int16_t IwillGiveAtten = 0;
8295 8304
     int16_t UL_Atten = 0;
@@ -8321,32 +8330,50 @@ void ALC_Package_Operate(uint8_t*ULO_ADC_Level,uint8_t* ULO_Level,DET_TABLEUL_st
8321 8330
 
8322 8331
     CurrentATTENVALUE = PE43711_Double(ALC_Atten[ULO_ALC_H],ALC_Atten[ULO_ALC_L]);
8323 8332
 
8324
-//    printf("=============ALC ON =====START================\r\n");
8325
-//    printf("Current UL ADC VALUE : %f \r\n",ret);
8326
-//    printf("ResdBm : UL%d : %f \r\n",TableIndex + 1,ResdBm);    
8327
-//    printf("ORIGIN ResdBm : %f  %d\r\n",ResdBm,Main_Atten);
8328
-//    printf("After ResdBm : %f \r\n",ResdBm);
8333
+#if 0 // PYJ.2020.10.19_BEGIN -- 
8334
+    printf("=============ALC ON =====START================\r\n");
8335
+    printf("Current UL ADC VALUE : %f \r\n",ret);
8336
+    printf("ResdBm : UL%d : %f \r\n",TableIndex + 1,ResdBm);    
8337
+    printf("ORIGIN ResdBm : %f  %d\r\n",ResdBm,Main_Atten);
8338
+    printf("After ResdBm : %f \r\n",ResdBm);
8339
+#endif // PYJ.2020.10.19_END -- 
8340
+    
8341
+    ResultData = HFR_CntUpCalc(ResdBm); 
8342
+    int HFR_Dot5 = ((int)(ResdBm * 10) % 10);
8329 8343
 
8330
-    ResdBm = HFR_CntUpCalc(ResdBm); 
8331
-    ResultData = ResdBm;
8344
+    
8345
+    Temp_ResdBm = ResultData;
8332 8346
 //    printf("HFR CALC RET : %d \r\n",ResultData);
8333 8347
     ULO_Level[ULO_ALC_H] = (ResultData & 0xFF00) >> 8;
8334 8348
     ULO_Level[ULO_ALC_L] = (ResultData & 0x00FF);    
8335 8349
     Limitdata += (Main_Atten * 0.1);
8350
+    if(Limitdata < ResultData){
8351
+        if(HFR_Dot5 == -5){
8352
+            ResultData--;
8353
+            Temp_ResdBm--;
8354
+        }
8355
+    }
8336 8356
 //    printf("Limitdata : %d | ResultData : %d \r\n",Limitdata,ResultData);
8337
-    ALC_Alarm_TimerSet(TableIndex,Limitdata,ResultData,UL_Atten,Main_Atten);
8338
-    IwillGiveAtten = ALC_Calc(TableIndex,CurrentATTENVALUE,Limitdata,ResdBm);
8357
+    ALC_Alarm_TimerSet(TableIndex,Limitdata,ResdBm,UL_Atten,Main_Atten);
8358
+    IwillGiveAtten = ALC_Calc(TableIndex,CurrentATTENVALUE,Limitdata,Temp_ResdBm);
8359
+
8360
+    
8339 8361
 //    printf("STEP 1 : I WILL GIVE ATTEN  %d \r\n",IwillGiveAtten);
8340 8362
     IwillGiveAtten += UL_Atten;
8341 8363
 //    printf("STEP 2 : I WILL GIVE ATTEN PLUS  ALC ATTEN  %d \r\n",IwillGiveAtten);    
8342
-    if(ResdBm <= (Limitdata - 1)){
8364
+//    printf("STEP 3 :ResdBm : %f (Limitdata - 1) : %d   HFR_Dot5  %d \r\n",ResdBm,(Limitdata - 1),HFR_Dot5);    
8365
+    
8366
+    if((ResultData <= (Limitdata - 1)) ) {
8343 8367
         if(IwillGiveAtten <= -10){
8344 8368
             IwillGiveAtten += 10;
8345 8369
         }
8370
+//        printf("1 I WILL GIVE ATTEN  : %d \r\n", IwillGiveAtten);  
8346 8371
     }
8347 8372
     GiveAttenPlusULAtten = IwillGiveAtten + (Main_Atten );
8348
-    if(GiveAttenPlusULAtten <= - 200){
8373
+//    printf("1 I WILL GIVE ATTEN  : %d \r\n", IwillGiveAtten);  
8374
+    if(GiveAttenPlusULAtten <= - 200 ){
8349 8375
         IwillGiveAtten = -200 + ((Main_Atten * -1));
8376
+//         printf("3 I WILL GIVE ATTEN  : %d \r\n", IwillGiveAtten);  
8350 8377
     }
8351 8378
     if(IwillGiveAtten <= -200){
8352 8379
         IwillGiveAtten = -200;
@@ -8354,9 +8381,11 @@ void ALC_Package_Operate(uint8_t*ULO_ADC_Level,uint8_t* ULO_Level,DET_TABLEUL_st
8354 8381
     if(IwillGiveAtten >= 0){
8355 8382
         IwillGiveAtten = 0;
8356 8383
     }       
8357
-//    printf(" UL_Atten: %d I WILL GIVE ATTEN  : %d \r\n", UL_Atten,IwillGiveAtten);  
8358
-//    printf("ADC : %f CURR ATT : %f  Threas : %d : I WILL GIVE ATTEN  : %d \r\n",ret,ResdBm , Limitdata,IwillGiveAtten);  
8359
-//    printf("==================END================\r\n");          
8384
+#if 0 // PYJ.2020.10.19_BEGIN -- 
8385
+    printf(" UL_Atten: %d I WILL GIVE ATTEN  : %d \r\n", UL_Atten,IwillGiveAtten);  
8386
+    printf("ADC : %f CURR ATT : %f  Threas : %d : I WILL GIVE ATTEN  : %d \r\n",ret,ResdBm , Limitdata,IwillGiveAtten);  
8387
+    printf("==================END================\r\n");          
8388
+#endif // PYJ.2020.10.19_END -- 
8360 8389
     
8361 8390
 //    if( (IwillGiveAtten > 0) || (CurrentATTENVALUE >= (IwillGiveAtten))){
8362 8391
 //    IwillGiveAtten *= 10;
@@ -8461,7 +8490,7 @@ void ALC_Function(){ //DL
8461 8490
                             &bluecell_Currdatastatus.ATT_UL1_H,
8462 8491
                             &bluecell_Currdatastatus.bluecell_User_UL1_H,
8463 8492
                             &bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1);
8464
-#if 0 // PYJ.2020.07.16_BEGIN -- 
8493
+#if 1 // PYJ.2020.07.16_BEGIN -- 
8465 8494
         ALC_Package_Operate(&bluecell_Currdatastatus.ULO_P2_Level2_H,
8466 8495
                             &bluecell_Currdatastatus.ULO_Level2_H,
8467 8496
                             &Det_UL2.Table_Det_15_dBm_H,
@@ -8593,7 +8622,7 @@ void AGC_Alarm_Check(uint8_t Path_Index,double AGC_Det,uint8_t* AGC_Table,uint16
8593 8622
 void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tableindex,uint8_t* DLI_ADC_Level,uint8_t* DLI_Level,DET_TABLEDL_st* DL_Table,uint8_t* FRBT){
8594 8623
         double ret = 0;
8595 8624
         int16_t ResdBm = 0;
8596
-        
8625
+        double Temp_ResdBm = 0;
8597 8626
         int16_t CurrAtten = 0;
8598 8627
         int16_t Levelret = 0;
8599 8628
         int i = 0;
@@ -8620,7 +8649,9 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8620 8649
         CurrAtten = (int16_t)(DL_MainAtten[DLI_AGC_H] << 8 |  DL_MainAtten[DLI_AGC_L]);
8621 8650
         CurrAtten *= 0.1;
8622 8651
         ResdBm = (int16_t)(DLI_Level[DLI_AGC_H] << 8 |  DLI_Level[DLI_AGC_L]) * 10;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&DL_Table->Table_Det5_dBm_H,DL_Table->Table_Length,AGC_Table));
8623
-        ResdBm = (int16_t)Bluecell_TestPro( ResdBm / 10);
8652
+        Temp_ResdBm = ResdBm *0.01 ;
8653
+//        printf("ResdBm %d \r\n",ResdBm);
8654
+        ResdBm = (int16_t)Bluecell_TestPro(ResdBm/10);
8624 8655
 //        DLI_Level[DLI_AGC_H] = ((int16_t)ResdBm & 0xFF00) >> 8;
8625 8656
 //        DLI_Level[DLI_AGC_L] = ((int16_t)ResdBm & 0x00FF);
8626 8657
         for(i = 0; i < sizeof(AGC_dBm_t); i++){
@@ -8633,7 +8664,16 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8633 8664
 
8634 8665
 
8635 8666
         }
8667
+      
8636 8668
         if(bluecell_Currdatastatus.DLI_FRBT_Status == FRBT_IDEL){
8669
+           if(Limitdata < ResdBm){
8670
+                int HFR_Dot5 = ((int)(Temp_ResdBm * 10) % 10);
8671
+                if(HFR_Dot5 == -5){
8672
+                    ResdBm = Limitdata + (CurrAtten * -1);
8673
+                }
8674
+            }           
8675
+//            printf("3ResdBm : DL%d : %d \r\n",Tableindex+1,ResdBm);
8676
+
8637 8677
             IwillgiveAtten = New_AGC_Calc(Limitdata,ResdBm);
8638 8678
             if(Limitdata == ResdBm){
8639 8679
                 IwillgiveAtten = CurrAtten;
@@ -8645,13 +8685,15 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8645 8685
         
8646 8686
         IwillgiveAtten *= -1;
8647 8687
 #if 0// PYJ.2020.09.14_BEGIN -- 
8648
-        printf("==================================\r\n");
8688
+        printf("==================================\r\n");         
8649 8689
         printf("Curr ATTEN %d \r\n",CurrAtten );
8650 8690
         printf("Current DL% ADC VALUE : %f \r\n",Tableindex+1,ret);
8651
-        printf("ResdBm : DL%d : %d \r\n",Tableindex+1,ResdBm);
8691
+        printf("Temp_ResdBm : DL%d : %f \r\n",Tableindex+1,Temp_ResdBm);
8652 8692
         printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);
8653 8693
         printf("AGC  : %d\r\n",Limitdata);
8654 8694
 #endif // PYJ.2020.09.14_END -- 
8695
+
8696
+
8655 8697
         if(bluecell_Currdatastatus.DLI_FRBT_Status != FRBT_IDEL && (CurrAtten) < IwillgiveAtten){
8656 8698
             IwillgiveAtten = (CurrAtten );
8657 8699
 
@@ -8662,6 +8704,7 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8662 8704
             
8663 8705
         if(bluecell_Currdatastatus.DLI_FRBT_Status == FRBT_IDEL){
8664 8706
              if(Limitdata != ResdBm){
8707
+         
8665 8708
                 if(CurrAtten + ResdBm <= Limitdata - 1)
8666 8709
                     IwillgiveAtten = ((CurrAtten) + 1);
8667 8710
                 if(CurrAtten == 0)
@@ -8672,7 +8715,7 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8672 8715
                 DL_PrevIwillgiveAtten[Tableindex] = IwillgiveAtten;
8673 8716
                 DL_MainAtten[DLI_AGC_H] = ((((IwillgiveAtten)  * 10) & 0xFF00) >> 8) ;
8674 8717
                 DL_MainAtten[DLI_AGC_L] = ((((IwillgiveAtten) * 10) & 0x00FF));  
8675
-//                printf("Apply 2 Curr ATTEN %d \r\n", (int16_t)(DL_MainAtten[DLI_AGC_H] << 8 |  DL_MainAtten[DLI_AGC_L]));
8718
+                printf("Apply 2 Curr ATTEN %d \r\n", (int16_t)(DL_MainAtten[DLI_AGC_H] << 8 |  DL_MainAtten[DLI_AGC_L]));
8676 8719
                 CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);            
8677 8720
             }else{
8678 8721
                 if(Limitdata == ResdBm){
@@ -8791,6 +8834,7 @@ void AGC_Function(){//DL
8791 8834
     static int8_t* AGC_Table;// = &DL_DET_Table_ref[MBIC_Table_DL1_INDEX][TABLE_MAX_VALUE];*/
8792 8835
 
8793 8836
     int16_t Limitdata = 0;
8837
+    uint8_t* AGC_AlarmStatus = &bluecell_Currdatastatus.DLI_AGC_Alarm1;
8794 8838
     int16_t DL_Curr_Atten[AGC_Alarm_DL_Index_MAX] = {
8795 8839
         bluecell_Currdatastatus.ATT_DL1_H  << 8 | bluecell_Currdatastatus.ATT_DL1_L,
8796 8840
         bluecell_Currdatastatus.ATT_DL2_H  << 8 | bluecell_Currdatastatus.ATT_DL2_L,
@@ -8812,16 +8856,37 @@ void AGC_Function(){//DL
8812 8856
             bluecell_Currdatastatus.ATT_DL3_H  << 8 | bluecell_Currdatastatus.ATT_DL3_L;        
8813 8857
         DL_Curr_Atten[AGC_Alarm_DL4_Index] = 
8814 8858
             bluecell_Currdatastatus.ATT_DL4_H  << 8 | bluecell_Currdatastatus.ATT_DL4_L; 
8859
+
8860
+        uint8_t* DLI_Level = &bluecell_Currdatastatus.DLI_Level1_H;
8861
+        int16_t ResdBm = 0;
8862
+
8863
+            
8815 8864
         for(int k = 0; k < AGC_Alarm_DL_Index_MAX; k++){
8865
+//            if(k != 0) continue;
8866
+            ResdBm = (int16_t)(DLI_Level[DLI_AGC_H + (k * 2)] << 8 |  DLI_Level[DLI_AGC_L + ((k * 2))]) * 10;
8867
+        
8868
+//            printf("Limitdata : %d   ResdBm : %d \r\n",Limitdata * 100,ResdBm);
8816 8869
             if(DL_Curr_Atten[AGC_Alarm_DL1_Index+k] <= -150)
8817 8870
                 DL_Curr_Atten[AGC_Alarm_DL1_Index+k] = -150;
8818 8871
 //            printf("DL_Curr_Atten%d : %d \r\n",k+1,DL_Curr_Atten[AGC_Alarm_DL1_Index+k] * 0.1);
8819
-            if((DL_Curr_Atten[AGC_Alarm_DL1_Index+k] * 0.1) <= -15   ){
8872
+            if(((DL_Curr_Atten[AGC_Alarm_DL1_Index+k] * 0.1) <= -15) && ((Limitdata * 100) < ResdBm - 1500)   ){
8820 8873
 //                printf("DL_Curr_Atten%d : %d Alarm TRue\r\n",k+1,DL_Curr_Atten[AGC_Alarm_DL1_Index+k]);
8821 8874
                 AGC_AlarmSet[AGC_Alarm_DL1_Index+k] = true;
8822 8875
             }else{
8823
-                AGC_AlarmSet[AGC_Alarm_DL1_Index+k] = false;
8876
+                if(AGC_AlarmStatus[AGC_Alarm_DL1_Index+k] == true){
8877
+                    if((DL_Curr_Atten[AGC_Alarm_DL1_Index+k] * 0.1) >= -13   ){
8878
+                        AGC_AlarmSet[AGC_Alarm_DL1_Index+k] = false;
8879
+//                        printf("AGC FALSE 1 DL_Curr_Atten  %f \r\n",(DL_Curr_Atten[AGC_Alarm_DL1_Index+k] * 0.1));
8880
+                    }else{
8881
+                        AGC_AlarmSet[AGC_Alarm_DL1_Index+k] = true;
8882
+//                        printf("AGC TRUE 2\r\n");                        
8883
+                    }
8884
+                }else{
8885
+                    AGC_AlarmSet[AGC_Alarm_DL1_Index+k] = false;
8886
+//                    printf("AGC FALSE 3\r\n");                    
8887
+                }
8824 8888
             }
8889
+//            printf("AGC_AlarmSet : %d \r\n",AGC_AlarmSet[AGC_Alarm_DL1_Index+k]);
8825 8890
         }
8826 8891
         AGC_Package_Operate(&bluecell_Currdatastatus.DLI_AGC_Threshold_H,
8827 8892
                             &bluecell_Currdatastatus.ATT_DL1_H,
@@ -9676,7 +9741,7 @@ void LED_Alarm_Check(){
9676 9741
     if(bluecell_Currdatastatus.ALARM_TESTMODE == false){
9677 9742
           if(bluecell_Currdatastatus.SelfTest == true){
9678 9743
               Alarm_LED_OnSet = false;
9679
-              printf("%d\r\n",__LINE__);
9744
+//              printf("%d\r\n",__LINE__);
9680 9745
           }
9681 9746
 #if 0 // PYJ.2020.09.23_BEGIN -- 
9682 9747
           else if( 

+ 3 - 3
Bluecell_Src/uart.c

@@ -30,7 +30,7 @@ void InitUartQueue(pUARTQUEUE pQueue)
30 30
 
31 31
 
32 32
 
33
-  if (HAL_UART_Receive_DMA(&hTerminal, TerminalQueue.Buffer, 1) != HAL_OK)
33
+  if (HAL_UART_Receive_IT(&hTerminal, TerminalQueue.Buffer, 1) != HAL_OK)
34 34
   //if (HAL_UART_Receive_IT(&hTerminal, TerminalQueue.Buffer, 1) != HAL_OK)
35 35
   {
36 36
 //    _Error_Handler(__FILE__, __LINE__);
@@ -102,7 +102,7 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
102 102
 //        printf("data cnt zero !!!  \r\n");
103 103
         //RF_Ctrl_Main(&uart_buf[Header]);
104 104
 //        HAL_UART_Transmit(dst, &temp_buf[BLUECELL_HEADER00], 11, 3000);
105
-#if 0// PYJ.2019.07.15_BEGIN --
105
+#if 1// PYJ.2019.07.15_BEGIN --
106 106
             printf("\r\n[RX]");
107 107
             for(int i = 0; i < cnt; i++){
108 108
                 printf("%02x ",uart_buf[i]);
@@ -155,7 +155,7 @@ void Uart1_Data_Send(uint8_t* data,uint16_t size){
155 155
   //HAL_UART_Transmit_IT(&hTerminal, &data[0],size);
156 156
 //    printf("data[278] : %x \r\n",data[278]);
157 157
 ////    HAL_Delay(1);   
158
-#if 0 // PYJ.2020.07.19_BEGIN -- 
158
+#if 1 // PYJ.2020.07.19_BEGIN -- 
159 159
     printf("\r\n [TX] : ");
160 160
     for(int i = 0; i< size; i++)
161 161
         printf("%02x ",data[i]);

+ 2 - 2
Inc/main.h

@@ -183,8 +183,8 @@ extern I2C_HandleTypeDef hi2c2;
183 183
 #define ATT_EN_DL1_GPIO_Port GPIOB
184 184
 /* USER CODE BEGIN Private defines */
185 185
 #define MBIC_ON_MAINTAIN_SEC 3000
186
-#define MBIC_ON_SHUTDOWN_MAINTAIN_SEC 15000//5
187
-#define MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC 30000//30
186
+#define MBIC_ON_SHUTDOWN_MAINTAIN_SEC 5000//5
187
+#define MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC 25000//30
188 188
 #define MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC 52000 * 5 //5min
189 189
 #define MBIC_RECOVERY_SELFTEST_TIMER_SEC 1800000 //30min
190 190
 

+ 0 - 1
Inc/stm32f1xx_it.h

@@ -58,7 +58,6 @@ void PendSV_Handler(void);
58 58
 void SysTick_Handler(void);
59 59
 void DMA1_Channel1_IRQHandler(void);
60 60
 void DMA1_Channel4_IRQHandler(void);
61
-void DMA1_Channel5_IRQHandler(void);
62 61
 void DMA1_Channel7_IRQHandler(void);
63 62
 void ADC1_2_IRQHandler(void);
64 63
 void TIM2_IRQHandler(void);

+ 21 - 32
STM32F103ZET_JDASMBIC.ioc

@@ -57,27 +57,17 @@ Dma.ADC3.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlign
57 57
 Dma.Request0=ADC1
58 58
 Dma.Request1=ADC3
59 59
 Dma.Request2=USART2_TX
60
-Dma.Request3=USART1_RX
61
-Dma.Request4=USART1_TX
62
-Dma.RequestsNb=5
63
-Dma.USART1_RX.3.Direction=DMA_PERIPH_TO_MEMORY
64
-Dma.USART1_RX.3.Instance=DMA1_Channel5
65
-Dma.USART1_RX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE
66
-Dma.USART1_RX.3.MemInc=DMA_MINC_ENABLE
67
-Dma.USART1_RX.3.Mode=DMA_NORMAL
68
-Dma.USART1_RX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
69
-Dma.USART1_RX.3.PeriphInc=DMA_PINC_DISABLE
70
-Dma.USART1_RX.3.Priority=DMA_PRIORITY_LOW
71
-Dma.USART1_RX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
72
-Dma.USART1_TX.4.Direction=DMA_MEMORY_TO_PERIPH
73
-Dma.USART1_TX.4.Instance=DMA1_Channel4
74
-Dma.USART1_TX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE
75
-Dma.USART1_TX.4.MemInc=DMA_MINC_ENABLE
76
-Dma.USART1_TX.4.Mode=DMA_NORMAL
77
-Dma.USART1_TX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
78
-Dma.USART1_TX.4.PeriphInc=DMA_PINC_DISABLE
79
-Dma.USART1_TX.4.Priority=DMA_PRIORITY_LOW
80
-Dma.USART1_TX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
60
+Dma.Request3=USART1_TX
61
+Dma.RequestsNb=4
62
+Dma.USART1_TX.3.Direction=DMA_MEMORY_TO_PERIPH
63
+Dma.USART1_TX.3.Instance=DMA1_Channel4
64
+Dma.USART1_TX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE
65
+Dma.USART1_TX.3.MemInc=DMA_MINC_ENABLE
66
+Dma.USART1_TX.3.Mode=DMA_NORMAL
67
+Dma.USART1_TX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
68
+Dma.USART1_TX.3.PeriphInc=DMA_PINC_DISABLE
69
+Dma.USART1_TX.3.Priority=DMA_PRIORITY_LOW
70
+Dma.USART1_TX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
81 71
 Dma.USART2_TX.2.Direction=DMA_MEMORY_TO_PERIPH
82 72
 Dma.USART2_TX.2.Instance=DMA1_Channel7
83 73
 Dma.USART2_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE
@@ -177,14 +167,13 @@ Mcu.UserConstants=
177 167
 Mcu.UserName=STM32F103ZETx
178 168
 MxCube.Version=5.6.1
179 169
 MxDb.Version=DB.5.0.60
180
-NVIC.ADC1_2_IRQn=true\:0\:0\:false\:true\:true\:11\:true\:true
181
-NVIC.ADC3_IRQn=true\:0\:0\:false\:true\:true\:6\:true\:true
170
+NVIC.ADC1_2_IRQn=true\:0\:0\:false\:true\:true\:8\:true\:true
171
+NVIC.ADC3_IRQn=true\:0\:0\:false\:true\:true\:5\:true\:true
182 172
 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
183
-NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:true\:true\:1\:false\:true
184
-NVIC.DMA1_Channel4_IRQn=true\:0\:0\:false\:true\:true\:8\:false\:true
185
-NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:true\:true\:9\:false\:true
186
-NVIC.DMA1_Channel7_IRQn=true\:0\:0\:false\:true\:true\:7\:false\:true
187
-NVIC.DMA2_Channel4_5_IRQn=true\:0\:0\:false\:true\:true\:4\:false\:true
173
+NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:true\:true\:2\:false\:true
174
+NVIC.DMA1_Channel4_IRQn=true\:0\:0\:false\:true\:true\:7\:false\:true
175
+NVIC.DMA1_Channel7_IRQn=true\:0\:0\:false\:true\:true\:6\:false\:true
176
+NVIC.DMA2_Channel4_5_IRQn=true\:0\:0\:false\:true\:true\:3\:false\:true
188 177
 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
189 178
 NVIC.ForceEnableDMAVector=true
190 179
 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
@@ -195,11 +184,11 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
195 184
 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
196 185
 NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
197 186
 NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:false\:true
198
-NVIC.TIM6_IRQn=true\:0\:0\:false\:true\:true\:5\:true\:true
187
+NVIC.TIM6_IRQn=true\:0\:0\:false\:true\:true\:4\:true\:true
199 188
 NVIC.TimeBase=TIM2_IRQn
200 189
 NVIC.TimeBaseIP=TIM2
201
-NVIC.USART1_IRQn=true\:0\:0\:false\:true\:true\:2\:true\:true
202
-NVIC.USART2_IRQn=true\:0\:0\:false\:true\:true\:3\:true\:true
190
+NVIC.USART1_IRQn=true\:0\:0\:false\:true\:true\:1\:true\:true
191
+NVIC.USART2_IRQn=true\:0\:0\:false\:true\:true\:9\:true\:true
203 192
 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
204 193
 PA10.GPIOParameters=GPIO_Label
205 194
 PA10.GPIO_Label=MBIC_DOWN
@@ -449,7 +438,7 @@ ProjectManager.FreePins=false
449 438
 ProjectManager.HalAssertFull=false
450 439
 ProjectManager.HeapSize=0x200
451 440
 ProjectManager.KeepUserCode=true
452
-ProjectManager.LastFirmware=true
441
+ProjectManager.LastFirmware=false
453 442
 ProjectManager.LibraryCopy=1
454 443
 ProjectManager.MainLocation=Src
455 444
 ProjectManager.NoMain=false

+ 7 - 10
Src/main.c

@@ -59,7 +59,6 @@ TIM_HandleTypeDef htim6;
59 59
 
60 60
 UART_HandleTypeDef huart1;
61 61
 UART_HandleTypeDef huart2;
62
-DMA_HandleTypeDef hdma_usart1_rx;
63 62
 DMA_HandleTypeDef hdma_usart1_tx;
64 63
 DMA_HandleTypeDef hdma_usart2_tx;
65 64
 
@@ -328,6 +327,7 @@ int main(void)
328 327
   EEPROM_M24C08_Init();
329 328
   Flash_InitRead();
330 329
   Booting_LedInit();
330
+  HFR_TypeInit();
331 331
   InitUartQueue(&TerminalQueue);
332 332
   bluecell_Currdatastatus.LED_TEST = true;
333 333
   Led_ToggleCntSet = 6; // Booting Led 3Cnt  ,Led Test 10Cnt
@@ -434,15 +434,12 @@ void SystemClock_Config(void)
434 434
   */
435 435
 static void MX_NVIC_Init(void)
436 436
 {
437
-  /* DMA1_Channel1_IRQn interrupt configuration */
438
-  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
439
-  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
440 437
   /* USART1_IRQn interrupt configuration */
441 438
   HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
442 439
   HAL_NVIC_EnableIRQ(USART1_IRQn);
443
-  /* USART2_IRQn interrupt configuration */
444
-  HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
445
-  HAL_NVIC_EnableIRQ(USART2_IRQn);
440
+  /* DMA1_Channel1_IRQn interrupt configuration */
441
+  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
442
+  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
446 443
   /* DMA2_Channel4_5_IRQn interrupt configuration */
447 444
   HAL_NVIC_SetPriority(DMA2_Channel4_5_IRQn, 0, 0);
448 445
   HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn);
@@ -458,12 +455,12 @@ static void MX_NVIC_Init(void)
458 455
   /* DMA1_Channel4_IRQn interrupt configuration */
459 456
   HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 0, 0);
460 457
   HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn);
461
-  /* DMA1_Channel5_IRQn interrupt configuration */
462
-  HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
463
-  HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
464 458
   /* ADC1_2_IRQn interrupt configuration */
465 459
   HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
466 460
   HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
461
+  /* USART2_IRQn interrupt configuration */
462
+  HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
463
+  HAL_NVIC_EnableIRQ(USART2_IRQn);
467 464
 }
468 465
 
469 466
 /**

+ 0 - 19
Src/stm32f1xx_hal_msp.c

@@ -28,8 +28,6 @@ extern DMA_HandleTypeDef hdma_adc1;
28 28
 
29 29
 extern DMA_HandleTypeDef hdma_adc3;
30 30
 
31
-extern DMA_HandleTypeDef hdma_usart1_rx;
32
-
33 31
 extern DMA_HandleTypeDef hdma_usart1_tx;
34 32
 
35 33
 extern DMA_HandleTypeDef hdma_usart2_tx;
@@ -397,22 +395,6 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
397 395
     HAL_GPIO_Init(MBIC_DOWN_GPIO_Port, &GPIO_InitStruct);
398 396
 
399 397
     /* USART1 DMA Init */
400
-    /* USART1_RX Init */
401
-    hdma_usart1_rx.Instance = DMA1_Channel5;
402
-    hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
403
-    hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
404
-    hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
405
-    hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
406
-    hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
407
-    hdma_usart1_rx.Init.Mode = DMA_NORMAL;
408
-    hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW;
409
-    if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK)
410
-    {
411
-      Error_Handler();
412
-    }
413
-
414
-    __HAL_LINKDMA(huart,hdmarx,hdma_usart1_rx);
415
-
416 398
     /* USART1_TX Init */
417 399
     hdma_usart1_tx.Instance = DMA1_Channel4;
418 400
     hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
@@ -503,7 +485,6 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
503 485
     HAL_GPIO_DeInit(GPIOA, MBIC_UP_Pin|MBIC_DOWN_Pin);
504 486
 
505 487
     /* USART1 DMA DeInit */
506
-    HAL_DMA_DeInit(huart->hdmarx);
507 488
     HAL_DMA_DeInit(huart->hdmatx);
508 489
 
509 490
     /* USART1 interrupt DeInit */

+ 0 - 15
Src/stm32f1xx_it.c

@@ -61,7 +61,6 @@ extern DMA_HandleTypeDef hdma_adc3;
61 61
 extern ADC_HandleTypeDef hadc1;
62 62
 extern ADC_HandleTypeDef hadc3;
63 63
 extern TIM_HandleTypeDef htim6;
64
-extern DMA_HandleTypeDef hdma_usart1_rx;
65 64
 extern DMA_HandleTypeDef hdma_usart1_tx;
66 65
 extern DMA_HandleTypeDef hdma_usart2_tx;
67 66
 extern UART_HandleTypeDef huart1;
@@ -236,20 +235,6 @@ void DMA1_Channel4_IRQHandler(void)
236 235
   /* USER CODE END DMA1_Channel4_IRQn 1 */
237 236
 }
238 237
 
239
-/**
240
-  * @brief This function handles DMA1 channel5 global interrupt.
241
-  */
242
-void DMA1_Channel5_IRQHandler(void)
243
-{
244
-  /* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
245
-
246
-  /* USER CODE END DMA1_Channel5_IRQn 0 */
247
-  HAL_DMA_IRQHandler(&hdma_usart1_rx);
248
-  /* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
249
-
250
-  /* USER CODE END DMA1_Channel5_IRQn 1 */
251
-}
252
-
253 238
 /**
254 239
   * @brief This function handles DMA1 channel7 global interrupt.
255 240
   */