浏览代码

AGC 동작 중 Table 값 설정 함수 안에 Table Length 설정 할 수있도록 변경 / EEPROM Data Length Ref LENGTH 가 사용자 값이랑 틀릴 때 EEPROM Data 재설정 하도록 수정 /

PYJ 5 年之前
父节点
当前提交
9fe2a792f8
共有 4 个文件被更改,包括 172 次插入76 次删除
  1. 122 50
      Bluecell_Src/Bluecell_operate.c
  2. 48 24
      Bluecell_Src/eeprom.c
  3. 1 1
      Bluecell_Src/uart.c
  4. 1 1
      STM32F103ZE_FLASH.ld

+ 122 - 50
Bluecell_Src/Bluecell_operate.c

@@ -9,6 +9,21 @@
9 9
 #include "eeprom.h"
10 10
 
11 11
 
12
+
13
+
14
+#define CPU_VERSION0 0
15
+#define CPU_VERSION1 0
16
+#define CPU_VERSION2 3
17
+#define ANSI_COLOR_RED     "\x1b[31m"
18
+#define ANSI_COLOR_GREEN   "\x1b[32m"
19
+#define ANSI_COLOR_YELLOW  "\x1b[33m"
20
+#define ANSI_COLOR_BLUE    "\x1b[34m"
21
+#define ANSI_COLOR_MAGENTA "\x1b[35m"
22
+#define ANSI_COLOR_CYAN    "\x1b[36m"
23
+#define ANSI_COLOR_RESET   "\x1b[0m"
24
+
25
+
26
+
12 27
 /***************************************************************************************/
13 28
 /*                                  Extern Function                                    */
14 29
 /***************************************************************************************/
@@ -2270,10 +2285,11 @@ bool Bluecell_Operate(uint8_t* data){
2270 2285
         break;
2271 2286
     case Bluecell_DLI_AGC_ON_OFF:                             
2272 2287
         bluecell_Currdatastatus.DLI_AGC_ON_OFF = data[BLUECELL_DATA + i];
2273
-//        printf("AGC ON OFF SET : %d \r\n",bluecell_Currdatastatus.DLI_AGC_ON_OFF);
2288
+        printf("AGC ON OFF SET : %d \r\n",bluecell_Currdatastatus.DLI_AGC_ON_OFF);
2274 2289
         break;
2275 2290
     case Bluecell_ULO_ALC_ON_OFF:                             
2276 2291
         bluecell_Currdatastatus.ULO_ALC_ON_OFF = data[BLUECELL_DATA + i];
2292
+        printf("ALC ON OFF SET : %d \r\n",bluecell_Currdatastatus.DLI_AGC_ON_OFF);
2277 2293
         break;
2278 2294
     case Bluecell_DLI_AGC_Threshold:                          
2279 2295
         bluecell_Currdatastatus.DLI_AGC_Threshold_H = data[BLUECELL_DATA + i++];
@@ -2420,7 +2436,7 @@ bool Bluecell_Operate(uint8_t* data){
2420 2436
         break;
2421 2437
     case Bluecell_ULO_Shutdown_ON_OFF                     :   
2422 2438
         bluecell_Currdatastatus.ULO_Shutdown_ON_OFF = data[BLUECELL_DATA + i++];
2423
-         printf("%s : %d \r\n",__func__,__LINE__);
2439
+         printf("%s Bluecell_ULO_Shutdown_ON_OFF : %d \r\n",__func__,bluecell_Currdatastatus.ULO_Shutdown_ON_OFF );
2424 2440
 
2425 2441
         break;
2426 2442
     case Bluecell_ULO_Shutdown_Threshold                  :   
@@ -2517,6 +2533,10 @@ typedef enum{
2517 2533
     MBIC Request List 
2518 2534
     Turn off all paths at boot
2519 2535
  */
2536
+   bluecell_Currdatastatus.CPUVERSION1 = CPU_VERSION0;
2537
+   bluecell_Currdatastatus.CPUVERSION2 = CPU_VERSION1;
2538
+   bluecell_Currdatastatus.CPUVERSION3 = CPU_VERSION2;
2539
+   
2520 2540
    bluecell_Currdatastatus.Type =  HAL_GPIO_ReadPin(UNIT_ID0_GPIO_Port,UNIT_ID0_Pin);
2521 2541
    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID1_GPIO_Port,UNIT_ID1_Pin) << 1;
2522 2542
    bluecell_Currdatastatus.Type +=  HAL_GPIO_ReadPin(UNIT_ID2_GPIO_Port,UNIT_ID2_Pin) << 2;
@@ -2679,9 +2699,9 @@ uint32_t MBIC_DataSend(uint8_t* data){
2679 2699
     data[MBIC_PAYLOADSTART + i++] = CPU_Version;
2680 2700
     Length += 3;
2681 2701
     data[MBIC_PAYLOADSTART + i++] = 3; // LENGTH
2682
-    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION1 = 0x00;
2683
-    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION2 = 0x00;
2684
-    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION3 = 0x01;
2702
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION1 = CPU_VERSION0;
2703
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION2 = CPU_VERSION1;
2704
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.CPUVERSION3 = CPU_VERSION2;
2685 2705
     
2686 2706
 
2687 2707
 
@@ -3659,7 +3679,6 @@ bool MBIC_Operate(uint8_t* data){
3659 3679
                     HAL_GPIO_WritePin(PATH_EN_UL1_GPIO_Port,PATH_EN_UL1_Pin,GPIO_PIN_SET);//CLOCK
3660 3680
                 }
3661 3681
                 CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
3662
-
3663 3682
                 break;
3664 3683
             case  ULO_RF_Path2_ON_OFF                    :
3665 3684
                 bluecell_Currdatastatus.ATT_UL2_PATH = data[MBIC_PAYLOADSTART + 3]; 
@@ -4116,16 +4135,25 @@ void DET_LevelAlarmCheck(){
4116 4135
     /*
4117 4136
         DL Level Alarm Check Part
4118 4137
     */
4138
+//    printf("======================================================\r\n");
4119 4139
     for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
4120
-        if(LimitData_DL_High < Res_DL_dBm[DET_Alarm_DL1_Index + i]){
4140
+        if(LimitData_DL_High <= Res_DL_dBm[DET_Alarm_DL1_Index + i]){
4121 4141
             ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = true;
4122 4142
 //            printf("ADC_Alarm_DL_High_Set %d ,Value : %d\r\n",DET_Alarm_UL1_Index + i,ADC_Alarm_DL_High_Set[DET_Alarm_UL1_Index + i]);            
4123 4143
         }
4124 4144
         else{
4125
-            ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = false;
4145
+            if(LimitData_DL_High - 2 >= Res_DL_dBm[DET_Alarm_DL1_Index + i])
4146
+                ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = false;
4126 4147
 //            printf("ADC_Alarm_DL_High_Set %d ,Value : %d\r\n",DET_Alarm_UL1_Index + i,ADC_Alarm_DL_High_Set[DET_Alarm_UL1_Index + i]);            
4127 4148
         }
4128
-//        printf("LimitData_DL_High: %d Res_DL_dBm [%d] : %d ,Value : %d\r\n",
4149
+#if 0 // PYJ.2020.06.22_BEGIN -- 
4150
+        printf("LimitData_DL_High: %d Res_DL_dBm [%d] : %d ,Value : %d\r\n",
4151
+        LimitData_DL_High,
4152
+        DET_Alarm_UL1_Index + i,
4153
+        Res_DL_dBm[DET_Alarm_DL1_Index + i],
4154
+        ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i]);            
4155
+#endif // PYJ.2020.06.22_END -- 
4156
+
4129 4157
 //        LimitData_DL_Low,
4130 4158
 //        DET_Alarm_UL1_Index + i,
4131 4159
 //        Res_DL_dBm[DET_Alarm_DL1_Index + i],
@@ -4153,19 +4181,28 @@ void DET_LevelAlarmCheck(){
4153 4181
             ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
4154 4182
         }
4155 4183
         else{
4156
-            ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
4184
+             if(LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
4185
+                ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
4157 4186
         }
4158 4187
     }
4159
-
4188
+//    printf("======================================================\r\n");
4160 4189
     for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
4161 4190
         if(LimitData_DL_Low >= Res_DL_dBm[DET_Alarm_DL1_Index + i]){
4162 4191
             ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
4163 4192
         }
4164 4193
         else{
4165
-            ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
4194
+            if(LimitData_DL_Low + 2 <= Res_DL_dBm[DET_Alarm_DL1_Index + i])
4195
+                ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
4166 4196
 
4167 4197
         }
4168
-//        printf("LimitData_DL_Low: %d Res_DL_dBm [%d] : %d ,Value : %d\r\n",LimitData_DL_Low,DET_Alarm_UL1_Index + i,Res_DL_dBm[DET_Alarm_DL1_Index + i],ADC_Alarm_DL_Low_Set[LimitData_DL_High + i]);            
4198
+        
4199
+#if 0 // PYJ.2020.06.22_BEGIN -- 
4200
+        printf("LimitData_DL_Low: %d Res_DL_dBm [%d] : %d ,Value : %d\r\n",
4201
+        LimitData_DL_Low,
4202
+        DET_Alarm_UL1_Index + i,
4203
+        Res_DL_dBm[DET_Alarm_DL1_Index + i],
4204
+        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i]);            
4205
+#endif // PYJ.2020.06.22_END -- 
4169 4206
     }       
4170 4207
     
4171 4208
     /*
@@ -4194,24 +4231,39 @@ void DET_LevelAlarmCheck(){
4194 4231
 //            printf("Shutdown threas hold : %d | Curr Meas : %d Shutdown UL %d | Alarm ON Count : %d\r\n",LimitData_UL_Shutdown,Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
4195 4232
         }
4196 4233
         else{
4197
-            ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
4234
+            if(LimitData_UL_Shutdown - 2 >= Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i])
4235
+                ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
4198 4236
 //            printf("Shutdown threas hold : %d | Curr Meas : %d Shutdown UL %d | Alarm OFF Count : %d\r\n",LimitData_UL_Shutdown,Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
4199 4237
         }
4200 4238
     }
4201 4239
     /*
4202 4240
         UL Level Alarm Check Part
4203 4241
     */
4242
+    uint8_t* UL_Alarm_Timer_Status = &bluecell_Currdatastatus.ULO_Level_High_Alarm1;
4243
+    uint8_t* UL_ADC = &bluecell_Currdatastatus.ULO_P1_Level1_H;
4204 4244
 //    LimitData_UL_High = -27;
4205
-    printf("==========================================================\r\n");
4245
+//    printf("==========================================================\r\n");
4206 4246
     for(int i = 0 ; i < DET_Alarm_UL_Index_MAX; i++){
4207 4247
         if(LimitData_UL_High <= Res_UL_dBm[DET_Alarm_UL1_Index + i]){
4208 4248
             ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] = true;
4209
-            printf("ON _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);
4249
+//            printf("ON _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);
4210 4250
         }
4211 4251
         else{
4212
-            ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] = false;
4213
-            printf("OFF _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);            
4252
+            if(LimitData_UL_High - 2 >= Res_UL_dBm[DET_Alarm_UL1_Index + i])
4253
+                ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] = false;
4254
+//            printf("OFF _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);            
4214 4255
         }
4256
+#if 1 // PYJ.2020.06.22_BEGIN -- 
4257
+#if 0 // PYJ.2020.06.22_BEGIN --
4258
+                printf("ADC : %f LimitData_UL_High: %d Res_UL_dBm [%d] : %d ,Value : %d\r\n",
4259
+                (UL_ADC[i * 2] << 8 | UL_ADC[i * 2 + 1]) * 0.001,
4260
+                LimitData_UL_High,
4261
+                DET_Alarm_UL1_Index + i,
4262
+                Res_UL_dBm[DET_Alarm_UL1_Index + i],
4263
+                ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);            
4264
+#endif // PYJ.2020.06.22_END -- 
4265
+#endif // PYJ.2020.06.22_END -- 
4266
+        
4215 4267
     }    
4216 4268
 
4217 4269
 }
@@ -4613,7 +4665,7 @@ double AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t siz
4613 4665
     TableAdc += CompareAdc[1];
4614 4666
     TableAdc /= 1000;    
4615 4667
     if(CurrentAdc < TableAdc){
4616
-//        for(int i = 0; i < sizeof(ALC_dBm_t); i++)
4668
+        for(int i = 0; i < sizeof(ALC_dBm_t); i++)
4617 4669
 //            printf("ref Tabe: %d \r\n",RefTable_Data[i]);
4618 4670
 //        printf("LastIndex : %d  / dot : %d  TableAdc : %f \r\n",LastIndex,dot,(RefTable_Data[LastIndex] - (dot * 0.1)));
4619 4671
         return (RefTable_Data[LastIndex] - (dot * 0.1));
@@ -4640,7 +4692,7 @@ double AGC_AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t
4640 4692
         NextTableAdc += CompareAdc[i * 2 + 3];
4641 4693
         NextTableAdc /= 1000;        
4642 4694
 //        printf("TableAdc[%d] : %f \r\n",i,TableAdc);
4643
-//        CurrRet = TableAdc - CurrentAdc;
4695
+        CurrRet = TableAdc - CurrentAdc;
4644 4696
 
4645 4697
         step = (TableAdc - NextTableAdc) / 10;
4646 4698
         for(int a = 0; a < 10; a++){
@@ -4663,7 +4715,7 @@ double AGC_AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t
4663 4715
     TableAdc += CompareAdc[1];
4664 4716
     TableAdc /= 1000;    
4665 4717
     if(CurrentAdc < TableAdc){
4666
-//        printf("LastIndex : %d  / dot : %d  TableAdc : %f \r\n",LastIndex,dot,(AutoControl_Save[LastIndex] - (dot * 0.1)));
4718
+//        printf("LastIndex : %d  / dot : %d  TableAdc : %f \r\n",LastIndex,dot,(RefTable_Data[LastIndex] - (dot * 0.1)));
4667 4719
         return (RefTable_Data[LastIndex] - (dot * 0.1));
4668 4720
     }
4669 4721
     else{
@@ -4849,8 +4901,8 @@ void ALC_Function(){ //DL
4849 4901
             
4850 4902
             CurrentATTENVALUE = PE43711_Double(bluecell_Currdatastatus.ATT_UL1_H,bluecell_Currdatastatus.ATT_UL1_L);
4851 4903
 
4852
-bluecell_Currdatastatus.ULO_Level1_H = ((int16_t)ResultData & 0xFF00) >> 8;
4853
-bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
4904
+            bluecell_Currdatastatus.ULO_Level1_H = ((int16_t)ResultData & 0xFF00) >> 8;
4905
+            bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
4854 4906
 
4855 4907
 
4856 4908
             
@@ -4970,8 +5022,8 @@ bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
4970 5022
             Limitdata = (( bluecell_Currdatastatus.ULO_ALC_Threshold_H << 8) & 0xFF00) ;
4971 5023
             Limitdata +=  bluecell_Currdatastatus.ULO_ALC_Threshold_L ;
4972 5024
             Limitdata /= 10;
4973
-               bluecell_Currdatastatus.ULO_Level3_H = ((int16_t)ResdBm & 0xFF00) >> 8;
4974
-            bluecell_Currdatastatus.ULO_Level3_L = ((int16_t)ResdBm & 0x00FF);         
5025
+//            bluecell_Currdatastatus.ULO_Level3_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5026
+//            bluecell_Currdatastatus.ULO_Level3_L = ((int16_t)ResdBm & 0x00FF);         
4975 5027
 //                              printf("==================START================\r\n");          
4976 5028
             ResdBm = AutoControl_ADC_Compare(ret,&Det_UL3.Table_Det_15_dBm_H,Det_UL3.Table_Length* 2,ALC_Table);
4977 5029
             ResultData = ResdBm;
@@ -5062,6 +5114,7 @@ bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
5062 5114
 
5063 5115
 #endif // PYJ.2020.06.21_END -- 
5064 5116
 
5117
+#if 1 // PYJ.2020.06.22_BEGIN -- 
5065 5118
             ret  = bluecell_Currdatastatus.ULO_P2_Level2_H << 8;
5066 5119
             ret += bluecell_Currdatastatus.ULO_P2_Level2_L;   
5067 5120
             ret *= 0.001;
@@ -5079,6 +5132,7 @@ bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
5079 5132
 //            printf("CurrentATTENVALUE : %f I WILL GIVE ATTEN  : %d \r\n",CurrentATTENVALUE,IwillGiveAtten);  
5080 5133
             bluecell_Currdatastatus.ULO_Level2_H = ((int16_t)ResultData & 0xFF00) >> 8;
5081 5134
             bluecell_Currdatastatus.ULO_Level2_L = ((int16_t)ResultData & 0x00FF);
5135
+#endif // PYJ.2020.06.22_END -- 
5082 5136
 
5083 5137
 #if 0 // PYJ.2020.06.21_BEGIN -- 
5084 5138
                         printf("=========ALC_OFF=========START================\r\n");
@@ -5099,9 +5153,17 @@ bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
5099 5153
 
5100 5154
             
5101 5155
             ResdBm = AutoControl_ADC_Compare(ret,&Det_UL3.Table_Det_15_dBm_H,Det_UL3.Table_Length* 2,ALC_Table);
5102
-            ResultData = ResdBm;; 
5103
-            bluecell_Currdatastatus.MBIC_ULO_ALC_Atten3_H = ((int16_t)ResultData & 0xFF00) >> 8;
5104
-            bluecell_Currdatastatus.MBIC_ULO_ALC_Atten3_L = ((int16_t)ResultData & 0x00FF);
5156
+            ResultData = ResdBm;
5157
+            bluecell_Currdatastatus.ULO_Level3_H = ((int16_t)ResultData & 0xFF00) >> 8;
5158
+            bluecell_Currdatastatus.ULO_Level3_L = ((int16_t)ResultData & 0x00FF);
5159
+#if 0 // PYJ.2020.06.21_BEGIN -- 
5160
+                        printf("=========ALC_OFF=========START================\r\n");
5161
+                        printf("Current UL ADC VALUE : %f \r\n",ret);
5162
+                        printf("ResdBm : UL3 : %f \r\n",ResdBm);
5163
+                        printf("ResdBm  : %x /////  bluecell_Currdatastatus.ULO_Level3_H : %x \r\n",ResultData,bluecell_Currdatastatus.ULO_Level3_H);
5164
+                        printf("ResdBm  : %x /////  bluecell_Currdatastatus.ULO_Level3_L : %x \r\n",ResultData,bluecell_Currdatastatus.ULO_Level3_L);            
5165
+                        printf("==================END================\r\n");
5166
+#endif // PYJ.2020.06.21_END --             
5105 5167
 #if 0 // PYJ.2020.06.21_BEGIN -- 
5106 5168
             printf("=========ALC_OFF=========START================\r\n");
5107 5169
             printf("Current UL ADC VALUE : %f \r\n",ret);
@@ -5111,6 +5173,7 @@ bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
5111 5173
             printf("==================END================\r\n");
5112 5174
 #endif // PYJ.2020.06.21_END -- 
5113 5175
 
5176
+#if 1 // PYJ.2020.06.22_BEGIN -- 
5114 5177
             ALC_Table = &ALC_Table_ref[ALC_Table_UL4_Ref_Index].DET_UL_0;
5115 5178
 
5116 5179
             ret  = bluecell_Currdatastatus.ULO_P4_Level4_H << 8;
@@ -5120,8 +5183,9 @@ bluecell_Currdatastatus.ULO_Level1_L = ((int16_t)ResultData & 0x00FF);
5120 5183
             
5121 5184
             ResdBm = AutoControl_ADC_Compare(ret,&Det_UL4.Table_Det_15_dBm_H,Det_UL4.Table_Length* 2,ALC_Table);
5122 5185
             ResultData = ResdBm;; 
5123
-            bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_H = ((int16_t)ResultData & 0xFF00) >> 8;
5124
-            bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_L = ((int16_t)ResultData & 0x00FF);            
5186
+            bluecell_Currdatastatus.ULO_Level4_H = ((int16_t)ResultData & 0xFF00) >> 8;
5187
+            bluecell_Currdatastatus.ULO_Level4_L = ((int16_t)ResultData & 0x00FF);            
5188
+#endif // PYJ.2020.06.22_END -- 
5125 5189
 #endif // PYJ.2020.06.21_END -- 
5126 5190
 #endif // PYJ.2020.06.20_END -- 
5127 5191
 
@@ -5187,7 +5251,7 @@ void AGC_Function(){//DL
5187 5251
     int16_t Levelret = 0;
5188 5252
     int i = 0;
5189 5253
     int16_t Limitdata = 0;
5190
-    uint16_t IwillgiveAtten = 0;
5254
+    int16_t IwillgiveAtten = 0;
5191 5255
     int16_t ResultData = 0;
5192 5256
     static int8_t* AGC_Table;// = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
5193 5257
 
@@ -5204,7 +5268,7 @@ void AGC_Function(){//DL
5204 5268
             ret += bluecell_Currdatastatus.DLI_P1_Level1_L;   
5205 5269
             ret *= 0.001;
5206 5270
             
5207
-            ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st),AGC_Table));
5271
+            ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL1.Table_Length * 2,AGC_Table));
5208 5272
              bluecell_Currdatastatus.DLI_Level1_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5209 5273
              bluecell_Currdatastatus.DLI_Level1_L = ((int16_t)ResdBm & 0x00FF);
5210 5274
 
@@ -5219,15 +5283,19 @@ void AGC_Function(){//DL
5219 5283
             Limitdata +=  bluecell_Currdatastatus.DLI_AGC_Threshold_L ;
5220 5284
             Limitdata /= 10;
5221 5285
 
5222
-//            printf("==================================\r\n");
5223
-//            printf("Current DL1 ADC VALUE : %f \r\n",ret);
5224
-//            printf("ResdBm : DL1 : %d \r\n",ResdBm);
5225
-//            printf("AGC_Table[%d] : %d\r\n",i,AGC_Table[i]);
5226
-//            printf("I WILL GIVE YOU ATTEN  : %d\r\n",AGC_Calc(Limitdata,ResdBm));            
5227
-//            printf("AGC  : %d\r\n",Limitdata);            
5286
+#if 0 // PYJ.2020.06.22_BEGIN -- 
5287
+            printf(ANSI_COLOR_YELLOW     "=================AGC ON =================\r\n"ANSI_COLOR_RESET "\n");
5288
+            printf(ANSI_COLOR_YELLOW     "Current DL1 ADC VALUE : %f \r\n"ANSI_COLOR_RESET "\n",ret);
5289
+            printf(ANSI_COLOR_YELLOW     "ResdBm : DL1 : %d \r\n"ANSI_COLOR_RESET "\n",ResdBm);
5290
+            printf(ANSI_COLOR_YELLOW     "AGC_Table[%d] : %d\r\n"ANSI_COLOR_RESET "\n",i,AGC_Table[i]);
5291
+            printf(ANSI_COLOR_YELLOW     "I WILL GIVE YOU ATTEN  : %d\r\n"ANSI_COLOR_RESET "\n",AGC_Calc(Limitdata,ResdBm));            
5292
+            printf(ANSI_COLOR_YELLOW     "AGC  : %d\r\n"ANSI_COLOR_RESET "\n",Limitdata);            
5293
+#endif // PYJ.2020.06.22_END -- 
5228 5294
 //            HAL_Delay(1000);
5229 5295
 
5230 5296
             IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5297
+            IwillgiveAtten *= -1; 
5298
+
5231 5299
             AGC_Alarm_Check(AGC_Alarm_DL1_Index,ret,&Det_DL1.Table_Det5_dBm_H,IwillgiveAtten);
5232 5300
             bluecell_Currdatastatus.ATT_DL1_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5233 5301
             bluecell_Currdatastatus.ATT_DL1_L = (((IwillgiveAtten * 10) & 0x00FF));     
@@ -5236,6 +5304,7 @@ void AGC_Function(){//DL
5236 5304
 
5237 5305
 
5238 5306
 
5307
+#if 1// PYJ.2020.06.22_BEGIN -- 
5239 5308
         AGC_Table = &AGC_Table_ref[MBIC_Table_DL2_INDEX].DET_DL_0;
5240 5309
 
5241 5310
 
@@ -5243,7 +5312,7 @@ void AGC_Function(){//DL
5243 5312
        ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
5244 5313
        ret *= 0.001;
5245 5314
       
5246
-       ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL2.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st),AGC_Table));
5315
+       ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL2.Table_Det5_dBm_H,Det_DL2.Table_Length * 2,AGC_Table));
5247 5316
         bluecell_Currdatastatus.DLI_Level2_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5248 5317
         bluecell_Currdatastatus.DLI_Level2_L = ((int16_t)ResdBm & 0x00FF);
5249 5318
        for(i = 0; i < sizeof(AGC_dBm_t); i++){
@@ -5279,7 +5348,7 @@ void AGC_Function(){//DL
5279 5348
         ret += bluecell_Currdatastatus.DLI_P3_Level3_L;   
5280 5349
         ret *= 0.001;
5281 5350
         
5282
-        ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL3.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st),AGC_Table));
5351
+        ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL3.Table_Det5_dBm_H,Det_DL3.Table_Length * 2,AGC_Table));
5283 5352
         bluecell_Currdatastatus.DLI_Level3_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5284 5353
         bluecell_Currdatastatus.DLI_Level3_L = ((int16_t)ResdBm & 0x00FF);
5285 5354
         for(i = 0; i < sizeof(AGC_dBm_t); i++){
@@ -5307,13 +5376,13 @@ void AGC_Function(){//DL
5307 5376
 
5308 5377
 
5309 5378
 
5310
-#endif // PYJ.2020.05.25_END -- 
5379
+
5311 5380
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL4_INDEX].DET_DL_0;
5312 5381
 
5313 5382
             ret  = bluecell_Currdatastatus.DLI_P4_Level4_H << 8;
5314 5383
             ret += bluecell_Currdatastatus.DLI_P4_Level4_L;   
5315 5384
             ret *= 0.001;
5316
-            ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL4.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st),AGC_Table));
5385
+            ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL4.Table_Det5_dBm_H,Det_DL4.Table_Length * 2,AGC_Table));
5317 5386
             bluecell_Currdatastatus.DLI_Level4_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5318 5387
             bluecell_Currdatastatus.DLI_Level4_L = ((int16_t)ResdBm & 0x00FF);            
5319 5388
             for(i = 0; i < sizeof(AGC_dBm_t); i++){
@@ -5337,6 +5406,8 @@ void AGC_Function(){//DL
5337 5406
             bluecell_Currdatastatus.ATT_DL4_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5338 5407
             bluecell_Currdatastatus.ATT_DL4_L = (((IwillgiveAtten * 10) & 0x00FF));     
5339 5408
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5409
+#endif // PYJ.2020.05.25_END --             
5410
+#endif // PYJ.2020.06.22_END -- 
5340 5411
         }else{
5341 5412
 
5342 5413
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
@@ -5344,15 +5415,16 @@ void AGC_Function(){//DL
5344 5415
             ret += bluecell_Currdatastatus.DLI_P1_Level1_L;   
5345 5416
             ret *= 0.001;
5346 5417
             
5347
-            Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st),AGC_Table));
5418
+            Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL2.Table_Length * 2,AGC_Table));
5348 5419
             bluecell_Currdatastatus.DLI_Level1_H = (Levelret & 0xFF00) >> 8;
5349 5420
             bluecell_Currdatastatus.DLI_Level1_L = (Levelret & 0x00FF);
5350 5421
 #if 0 // PYJ.2020.06.20_BEGIN -- 
5351 5422
             printf("========AGC OFF==========START================\r\n");
5352
-            printf("Current DL ADC VALUE : %f \r\n",ret);
5353
-            printf("Levelret : DL1 : %f \r\n",Levelret);
5423
+            printf("Current DL1 ADC VALUE : %f \r\n",ret);
5424
+            printf("AGC_Table[%d] : %d\r\n",i,AGC_Table[i]);
5425
+            printf("Levelret : DL1 : %d \r\n",Levelret);
5354 5426
             printf("Levelret  : %x /////  bluecell_Currdatastatus.DLI_Level1_H : %x \r\n",Levelret,bluecell_Currdatastatus.DLI_Level1_H);
5355
-            printf("Levelret  : %x /////  bluecell_Currdatastatus.ULO_Level1_L : %x \r\n",Levelret,bluecell_Currdatastatus.DLI_Level1_L);            
5427
+            printf("Levelret  : %x /////  bluecell_Currdatastatus.DLI_Level1_L : %x \r\n",Levelret,bluecell_Currdatastatus.DLI_Level1_L);            
5356 5428
             printf("==================END================\r\n");        
5357 5429
 #endif // PYJ.2020.06.20_END -- 
5358 5430
 
@@ -5366,7 +5438,7 @@ void AGC_Function(){//DL
5366 5438
             ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
5367 5439
             ret *= 0.001;
5368 5440
             
5369
-            Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL2.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st),AGC_Table));
5441
+            Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL2.Table_Det5_dBm_H,Det_DL1.Table_Length * 2,AGC_Table));
5370 5442
             bluecell_Currdatastatus.DLI_Level2_H = (Levelret & 0xFF00) >> 8;
5371 5443
             bluecell_Currdatastatus.DLI_Level2_L = (Levelret & 0x00FF);
5372 5444
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL3_INDEX].DET_DL_0;
@@ -5376,7 +5448,7 @@ void AGC_Function(){//DL
5376 5448
             
5377 5449
             
5378 5450
             
5379
-            Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL3.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st),AGC_Table));
5451
+            Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL3.Table_Det5_dBm_H,Det_DL3.Table_Length * 2,AGC_Table));
5380 5452
             bluecell_Currdatastatus.DLI_Level3_H = (Levelret & 0xFF00) >> 8;
5381 5453
             bluecell_Currdatastatus.DLI_Level3_L = (Levelret & 0x00FF);
5382 5454
             
@@ -5386,7 +5458,7 @@ void AGC_Function(){//DL
5386 5458
             
5387 5459
             
5388 5460
             
5389
-            Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL4.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st),AGC_Table));
5461
+            Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL4.Table_Det5_dBm_H,Det_DL4.Table_Length * 2,AGC_Table));
5390 5462
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL4_INDEX].DET_DL_0;
5391 5463
             bluecell_Currdatastatus.DLI_Level4_H = (Levelret & 0xFF00) >> 8;
5392 5464
             bluecell_Currdatastatus.DLI_Level4_L = (Levelret & 0x00FF);
@@ -6442,7 +6514,7 @@ void Temp_HighAlarmCheck(){
6442 6514
             if(bluecell_Currdatastatus.Temp_High_Threshold - 2 >= (bluecell_Currdatastatus.DET_TEMP )){
6443 6515
                 bluecell_Currdatastatus.Temp_High_Alarm = false;        
6444 6516
                 if( Alarm_Temp_TimerOffCnt > MBIC_OFF_MAINTAIN_SEC){
6445
-//                    printf("1 Alarm TEMP ON Curr : %d  Limit : %d \r\n",(bluecell_Currdatastatus.DET_TEMP ),bluecell_Currdatastatus.Temp_High_Threshold);
6517
+                    printf("1 Alarm TEMP OFF Curr : %d  Limit : %d \r\n",(bluecell_Currdatastatus.DET_TEMP ),bluecell_Currdatastatus.Temp_High_Threshold);
6446 6518
                     bluecell_Currdatastatus.ALARM_TEMP_HIGH &= ~ENVIRONMENT_TEMPHIGH;
6447 6519
                 }
6448 6520
             }

+ 48 - 24
Bluecell_Src/eeprom.c

@@ -79,30 +79,54 @@ void EEPROM_M24C08_Init(void){
79 79
         }
80 80
 #if 1 // PYJ.2020.06.19_BEGIN --
81 81
     if(
82
-	Att_DL1.Table_Length    == 0||
83
-	Att_DL2.Table_Length    == 0||
84
-	Att_DL3.Table_Length    == 0||
85
-	Att_DL4.Table_Length    == 0||
86
-	Att_UL1.Table_Length    == 0||
87
-	Att_UL2.Table_Length    == 0||
88
-	Att_UL3.Table_Length    == 0||
89
-	Att_UL4.Table_Length    == 0||
90
-	Det_DL1.Table_Length    == 0||
91
-	Det_DL2.Table_Length    == 0||
92
-	Det_DL3.Table_Length    == 0||
93
-	Det_DL4.Table_Length    == 0||
94
-	Det_UL1.Table_Length    == 0||
95
-	Det_UL2.Table_Length    == 0||
96
-	Det_UL3.Table_Length    == 0||
97
-	Det_UL4.Table_Length    == 0||
98
-	Temp_DL1.Table_Length   == 0||
99
-	Temp_DL2.Table_Length   == 0||
100
-	Temp_DL3.Table_Length   == 0||
101
-	Temp_DL4.Table_Length   == 0||
102
-	Temp_UL1.Table_Length   == 0||
103
-	Temp_UL2.Table_Length   == 0||
104
-	Temp_UL3.Table_Length   == 0||
105
-	Temp_UL4.Table_Length   == 0
82
+    Att_DL1.Table_Length    == 0||
83
+    Att_DL2.Table_Length    == 0||
84
+    Att_DL3.Table_Length    == 0||
85
+    Att_DL4.Table_Length    == 0||
86
+    Att_UL1.Table_Length    == 0||
87
+    Att_UL2.Table_Length    == 0||
88
+    Att_UL3.Table_Length    == 0||
89
+    Att_UL4.Table_Length    == 0||
90
+    Det_DL1.Table_Length    == 0||
91
+    Det_DL2.Table_Length    == 0||
92
+    Det_DL3.Table_Length    == 0||
93
+    Det_DL4.Table_Length    == 0||
94
+    Det_UL1.Table_Length    == 0||
95
+    Det_UL2.Table_Length    == 0||
96
+    Det_UL3.Table_Length    == 0||
97
+    Det_UL4.Table_Length    == 0||
98
+    Temp_DL1.Table_Length   == 0||
99
+    Temp_DL2.Table_Length   == 0||
100
+    Temp_DL3.Table_Length   == 0||
101
+    Temp_DL4.Table_Length   == 0||
102
+    Temp_UL1.Table_Length   == 0||
103
+    Temp_UL2.Table_Length   == 0||
104
+    Temp_UL3.Table_Length   == 0||
105
+    Temp_UL4.Table_Length   == 0||
106
+     Att_DL1.Table_Ref  != ATTENTABLEDL_REF||
107
+      Att_DL2.Table_Ref != ATTENTABLEDL_REF||
108
+      Att_DL3.Table_Ref != ATTENTABLEDL_REF||
109
+      Att_DL4.Table_Ref != ATTENTABLEDL_REF||
110
+      Att_UL1.Table_Ref != ATTENTABLEUL_REF||
111
+      Att_UL2.Table_Ref != ATTENTABLEUL_REF||
112
+      Att_UL3.Table_Ref != ATTENTABLEUL_REF||
113
+      Att_UL4.Table_Ref != ATTENTABLEUL_REF||
114
+      Det_DL1.Table_Ref != ATTENTABLEDET_DL_REF||
115
+      Det_DL2.Table_Ref != ATTENTABLEDET_DL_REF||
116
+      Det_DL3.Table_Ref != ATTENTABLEDET_DL_REF||
117
+      Det_DL4.Table_Ref != ATTENTABLEDET_DL_REF||
118
+      Det_UL1.Table_Ref != ATTENTABLEDET_UL_REF||
119
+      Det_UL2.Table_Ref != ATTENTABLEDET_UL_REF||
120
+      Det_UL3.Table_Ref != ATTENTABLEDET_UL_REF||
121
+      Det_UL4.Table_Ref != ATTENTABLEDET_UL_REF||
122
+      Temp_DL1.Table_Ref!= ATTENTABLE_TEMP_REF||
123
+      Temp_DL2.Table_Ref!= ATTENTABLE_TEMP_REF||
124
+      Temp_DL3.Table_Ref!= ATTENTABLE_TEMP_REF||
125
+      Temp_DL4.Table_Ref!= ATTENTABLE_TEMP_REF||
126
+      Temp_UL1.Table_Ref!= ATTENTABLE_TEMP_REF||
127
+      Temp_UL2.Table_Ref!= ATTENTABLE_TEMP_REF||
128
+      Temp_UL3.Table_Ref!= ATTENTABLE_TEMP_REF||
129
+      Temp_UL4.Table_Ref!= ATTENTABLE_TEMP_REF
106 130
     ){
107 131
       Att_DL1.Table_Length  = ATTENTABLEDLUL_LENGTH;
108 132
       Att_DL2.Table_Length  = ATTENTABLEDLUL_LENGTH;

+ 1 - 1
Bluecell_Src/uart.c

@@ -54,7 +54,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
54 54
     if (pQueue->data >= QUEUE_BUFFER_LENGTH)
55 55
         GetDataFromUartQueue(huart);
56 56
     HAL_UART_Receive_DMA(&hTerminal, pQueue->Buffer + pQueue->head, 1);
57
-  //  HAL_UART_Receive_DMA(&hTest, pQueue->Buffer + pQueue->head, 1);
57
+    HAL_UART_Receive_DMA(&hTest, pQueue->Buffer + pQueue->head, 1);
58 58
    // Set_UartRcv(true);
59 59
 }
60 60
 

+ 1 - 1
STM32F103ZE_FLASH.ld

@@ -62,7 +62,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
62 62
 MEMORY
63 63
 {
64 64
 RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 64K
65
-FLASH (rx)      : ORIGIN = 0x8005000, LENGTH = 512K
65
+FLASH (rx)      : ORIGIN = 0x8005000, LENGTH = 64K
66 66
 }
67 67
 
68 68
 /* Define output sections */