Sfoglia il codice sorgente

EEPROM AT24C32 / AGC Level Test

PYJ 5 anni fa
parent
commit
c0f1cc78dc
2 ha cambiato i file con 59 aggiunte e 22 eliminazioni
  1. 42 22
      Bluecell_Src/Bluecell_operate.c
  2. 17 0
      Bluecell_Src/eeprom.c

+ 42 - 22
Bluecell_Src/Bluecell_operate.c

@@ -399,24 +399,23 @@ double TableAtteGuarantee(uint8_t* Table,double AttenValue){
399 399
 
400 400
 #if 1 // PYJ.2020.05.25_BEGIN -- 
401 401
 AGC_dBm_t AGC_Table_ref[AGC_Table_DL_Ref_Index_MAX] = {
402
-   {  5  ,} , {   4  ,} ,  { 3   ,}, {  2 ,} ,
403
-   {  1  ,} , {   0  ,} ,  { -1  ,}, {  -2,} ,
404
-   { -3  ,},  {  -4  ,},   {-5  , }, { -6 ,},
405
-   { -7  ,},  {  -8  ,},   {-9  , }, { -10,},
406
-   { -11 ,},  {  -12 ,},   {-13 , }, { -14,},
407
-   { -15 ,},  {  -16 ,},   {-17 , }, { -18,},
408
-   { -19 ,},  {  -20 ,},   {-21 , }, { -22,},
409
-   { -23 ,},  {  -24 ,},   {-25 , }
410
-
402
+     7,6,5,4,3,
403
+     2,1,0,-1,-2,
404
+     -3,-4,-5,-6,
405
+     -7,-8,-9,-10,
406
+     -11,-12,-13,-14,
407
+     -15,-16,-17,-18,
408
+     -19,-20,-21,-22,
409
+     -23,-24,-25
411 410
 }; 
412 411
 ALC_dBm_t ALC_Table_ref[ALC_Table_UL_Ref_Index_MAX] = {
413
-    {15,} ,   { -16,} ,   { -17 ,},    {-18,} , { -19,} ,
414
-    {20,} ,   { -21,} ,   { -22 ,},    {-23,} , { -24,} ,   { -25,} ,   { -26,} ,   { -27,} ,
415
-    {28,} ,   { -29,} ,   { -30 ,},    {-31,} , { -32,} ,   { -33,} ,   { -34,} ,   { -35,} ,
416
-    {36,} ,   { -37,} ,   { -38 ,},    {-39,} , { -40,} ,   { -41,} ,   { -42,} ,   { -43,} ,
417
-    {44,} ,   { -45,} ,   { -46 ,},    {-47,} , { -48,} ,   { -49,} ,   { -50,} ,   { -51,} ,
418
-    {52,} ,   { -53,} ,   { -54 ,},    {-55,} , { -56,} ,   { -57,} ,   { -58,} ,   { -59,} ,
419
-    {60,} 
412
+    -15,    -16,    -17 ,    -18 ,  -19 ,
413
+    -20,    -21,    -22 ,    -23 ,  -24 ,    -25 ,    -26 ,    -27 ,
414
+    -28,    -29,    -30 ,    -31 ,  -32 ,    -33 ,    -34 ,    -35 ,
415
+    -36,    -37,    -38 ,    -39 ,  -40 ,    -41 ,    -42 ,    -43 ,
416
+    -44,    -45,    -46 ,    -47 ,  -48 ,    -49 ,    -50 ,    -51 ,
417
+    -52,    -53,    -54 ,    -55 ,  -56 ,    -57 ,    -58 ,    -59 ,
418
+    -60, 
420 419
 
421 420
 };
422 421
 #if 0 // PYJ.2020.06.29_BEGIN -- 
@@ -2564,6 +2563,7 @@ bool Bluecell_Operate(uint8_t* data){
2564 2563
         }
2565 2564
         printf("\r\n");
2566 2565
 #endif // PYJ.2020.04.22_END --   
2566
+#if 0 // PYJ.2020.07.01_BEGIN -- 
2567 2567
         printf("===================START=======================\r\n");
2568 2568
         printf("ALC ON %d  \r\n",bluecell_Currdatastatus.ULO_ALC_ON_OFF);
2569 2569
         printf("AGC ON %d  \r\n",bluecell_Currdatastatus.DLI_AGC_ON_OFF);
@@ -2634,6 +2634,7 @@ bool Bluecell_Operate(uint8_t* data){
2634 2634
             bluecell_Currdatastatus.ALARM_ULO_Level & ALARM_ULO_P4_LEVEL_HIGH
2635 2635
         );        
2636 2636
         printf("===================END=======================\r\n");
2637
+#endif // PYJ.2020.07.01_END -- 
2637 2638
 
2638 2639
 //        printf("Level DL Alarm %d \r\n");
2639 2640
 //        printf("Level DL Alarm %d \r\n");
@@ -5512,18 +5513,18 @@ double AGC_AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t
5512 5513
         
5513 5514
     }
5514 5515
     if(Lastdata > CurrentAdc){
5515
-//        printf("RefTable_Data[(size / 2) - 1] : %d \r\n",RefTable_Data[(size / 2) - 1]);
5516
+        printf("RefTable_Data[(size / 2) - 1] : %d \r\n",RefTable_Data[(size / 2) - 1]);
5516 5517
         return RefTable_Data[(size / 2) - 1];
5517 5518
     }
5518
-//        printf("CurrentAdc : %f     TableAdc : %f \r\n",CurrentAdc,TableAdc);
5519
+        printf("CurrentAdc : %f     TableAdc : %f \r\n",CurrentAdc,TableAdc);
5519 5520
 //        for(int a = 0; a < sizeof(AGC_dBm_t); a++)
5520 5521
 //            printf("AutoControl_Save[%d] : %d \r\n",a,AutoControl_Save[a]);
5521 5522
     if(first_data < CurrentAdc){
5522
-//        printf("(RefTable_Data[0]) : %d \r\n",(RefTable_Data[0]));
5523
+        printf("(RefTable_Data[0]) : %d \r\n",(RefTable_Data[0]));
5523 5524
         return (RefTable_Data[0]);
5524 5525
     }else{
5525
-//        printf("Nomal _Table Data %f",(RefTable_Data[LastIndex] - (dot * 0.1)));
5526
-//        printf("LastIndex : %d  / dot : %d  TableAdc : %f \r\n",LastIndex,dot,(RefTable_Data[LastIndex] - (dot * 0.1)));
5526
+        printf("Nomal _Table Data %f",(RefTable_Data[LastIndex] - (dot * 0.1)));
5527
+        printf("LastIndex : %d  / dot : %d  TableAdc : %f \r\n",LastIndex,dot,(RefTable_Data[LastIndex] - (dot * 0.1)));
5527 5528
         return (RefTable_Data[LastIndex] - (dot * 0.1));
5528 5529
     }
5529 5530
 }
@@ -6498,7 +6499,21 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
6498 6499
 
6499 6500
 }
6500 6501
 #endif // PYJ.2020.06.27_END -- 
6501
-
6502
+typedef enum{
6503
+    DL_Level_H,
6504
+    DL_Level_L,        
6505
+};
6506
+void DL_Det_Function(uint8_t Table_Num,uint8_t* CurrADC_Level,uint8_t* Det_Val,uint8_t* Level){
6507
+    double ret = 0;//  
6508
+    uint8_t* AGC_Table;
6509
+    int16_t Levelret = 0;    
6510
+    AGC_Table = &AGC_Table_ref[Table_Num].DET_DL_0;
6511
+    ret = (((CurrADC_Level[DL_Level_H] << 8) | CurrADC_Level[DL_Level_L]) * 0.001);
6512
+                
6513
+    Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_Val,33,AGC_Table));
6514
+    Level[DL_Level_H] = (Levelret & 0xFF00) >> 8;
6515
+    Level[DL_Level_L] = (Levelret & 0x00FF);
6516
+}
6502 6517
 void AGC_Function(){//DL
6503 6518
     double ret = 0;
6504 6519
     int8_t ResdBm = 0;
@@ -6786,6 +6801,7 @@ void AGC_Function(){//DL
6786 6801
 #endif // PYJ.2020.06.22_END -- 
6787 6802
         }else{
6788 6803
 
6804
+#if 0 // PYJ.2020.07.01_BEGIN -- 
6789 6805
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
6790 6806
             ret  = bluecell_Currdatastatus.DLI_P1_Level1_H << 8;
6791 6807
             ret += bluecell_Currdatastatus.DLI_P1_Level1_L;   
@@ -6794,6 +6810,10 @@ void AGC_Function(){//DL
6794 6810
             Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL2.Table_Length * 2,AGC_Table));
6795 6811
             bluecell_Currdatastatus.DLI_Level1_H = (Levelret & 0xFF00) >> 8;
6796 6812
             bluecell_Currdatastatus.DLI_Level1_L = (Levelret & 0x00FF);
6813
+#else
6814
+            DL_Det_Function(MBIC_Table_DL1_INDEX,&bluecell_Currdatastatus.DLI_P1_Level1_H,&Det_DL1.Table_Det5_dBm_H,&bluecell_Currdatastatus.DLI_Level1_H);
6815
+
6816
+#endif // PYJ.2020.07.01_END -- 
6797 6817
 #if 0 // PYJ.2020.06.20_BEGIN -- 
6798 6818
             printf("========AGC OFF==========START================\r\n");
6799 6819
             printf(ANSI_COLOR_YELLOW"Current DL1 ADC VALUE : %f \r\n"ANSI_COLOR_RESET,ret);

+ 17 - 0
Bluecell_Src/eeprom.c

@@ -410,6 +410,23 @@ HAL_StatusTypeDef EEPROM_M24C08_Zerowrite(uint8_t devid,uint16_t Address){
410 410
 
411 411
     return ret;
412 412
 }
413
+#define EEPROM_IM24CM01P_ID               0x00A0
414
+#define EEPROM_ATTEN_CURR_ST_LEN          4
415
+
416
+
417
+HAL_StatusTypeDef EEPROM_IM24CM01P_write(uint16_t devid,uint16_t Address,uint8_t* data,uint8_t size){
418
+    HAL_StatusTypeDef ret = HAL_ERROR;
419
+    ret = HAL_I2C_Mem_Write(&hi2c2, devid, Address,  I2C_MEMADD_SIZE_16BIT, data, size, 10);
420
+    HAL_Delay(5);
421
+    return ret;
422
+}
423
+
424
+HAL_StatusTypeDef EEPROM_IM24CM01P_Read(uint16_t devid,uint16_t Address,uint8_t* data,uint8_t size){
425
+   HAL_StatusTypeDef ret = HAL_ERROR;
426
+   ret = HAL_I2C_Mem_Read(&hi2c2, devid, Address, I2C_MEMADD_SIZE_16BIT, data, size, 10);
427
+   HAL_Delay(5);
428
+    return ret;   
429
+}
413 430
 
414 431
 
415 432