#include <stdio.h>
#include <stdlib.h>
#include "main.h"
#include "stm32f2xx_hal.h"
#include <string.h>


void Atten_Operate(uint8_t* data);
void Atten_Table_Read(uint16_t Address,Atten_Table_Value_t TableName,uint8_t* data);
void Uart_Data_Send(uint8_t* data,uint8_t size);


#define DEBUG_PRINT 0

                                          


Atten_AB_Val_t Atten_Setting;

Atten_Table_Value_t ATT_A_EN_150M_Table;
Atten_Table_Value_t ATT_A_EN_WIFI1_2_4Ghz_Table;
Atten_Table_Value_t ATT_A_EN_WIFI2_2_4Ghz_Table;
Atten_Table_Value_t ATT_A_EN_WIFI3_2_4Ghz_Table;
Atten_Table_Value_t ATT_A_EN_WIFI4_2_4Ghz_Table;
Atten_Table_Value_t ATT_A_EN_WIFI1_5_8Ghz_Table;
Atten_Table_Value_t ATT_A_EN_WIFI2_5_8Ghz_Table;
Atten_Table_Value_t ATT_A_EN_WIFI3_5_8Ghz_Table;
Atten_Table_Value_t ATT_A_EN_WIFI4_5_8Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G1_28_28_5Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G2_28_28_5Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G3_28_28_5Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G1_28_5_29Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G2_28_5_29Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G3_28_5_29Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G1_29_29_5Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G2_29_29_5Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G3_29_29_5Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G1_29_5_30Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G2_29_5_30Ghz_Table;
Atten_Table_Value_t ATT_A_EN_30G3_29_5_30Ghz_Table;
Atten_Table_Value_t ATT_B_EN_150M_Table;
Atten_Table_Value_t ATT_B_EN_WIFI1_2_4Ghz_Table;
Atten_Table_Value_t ATT_B_EN_WIFI2_2_4Ghz_Table;
Atten_Table_Value_t ATT_B_EN_WIFI3_2_4Ghz_Table;
Atten_Table_Value_t ATT_B_EN_WIFI4_2_4Ghz_Table;
Atten_Table_Value_t ATT_B_EN_WIFI1_5_8Ghz_Table;
Atten_Table_Value_t ATT_B_EN_WIFI2_5_8Ghz_Table;
Atten_Table_Value_t ATT_B_EN_WIFI3_5_8Ghz_Table;
Atten_Table_Value_t ATT_B_EN_WIFI4_5_8Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G1_28_28_5Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G2_28_28_5Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G3_28_28_5Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G1_28_5_29Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G2_28_5_29Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G3_28_5_29Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G1_29_29_5Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G2_29_29_5Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G3_29_29_5Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G1_29_5_30Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G2_29_5_30Ghz_Table;
Atten_Table_Value_t ATT_B_EN_30G3_29_5_30Ghz_Table;
Atten_Curr_Val_t    ATT_Curr_Value;


#if 0 // PYJ.2019.02.15_BEGIN -- 
void gpio_output_set(uint8_t gpioPin){
	HAL_GPIO_WritePinOut(gpioPin,GPIO_PIN_SET);
	HAL_GPIO_WritePinMode(gpioPin, ITH_GPIO_MODE0);
}
void Atten_GpioInit(void){
    gpio_output_set(ITH_GPIO_PIN70);
    gpio_output_set(ITH_GPIO_PIN71);    
    gpio_output_set(ITH_GPIO_PIN72);    
    gpio_output_set(ITH_GPIO_PIN73);    
    gpio_output_set(ITH_GPIO_PIN74);    
    gpio_output_set(ITH_GPIO_PIN75);    
    gpio_output_set(ITH_GPIO_PIN76);    
    gpio_output_set(ITH_GPIO_PIN77);        
    gpio_output_set(ITH_GPIO_PIN78);    
    gpio_output_set(ITH_GPIO_PIN79);    
    gpio_output_set(ITH_GPIO_PIN80);    
    gpio_output_set(ITH_GPIO_PIN81); 

    gpio_output_set(ITH_GPIO_PIN5);    
    gpio_output_set(ITH_GPIO_PIN6);    
    gpio_output_set(ITH_GPIO_PIN7);    
    gpio_output_set(ITH_GPIO_PIN8);    
    gpio_output_set(ITH_GPIO_PIN9);   
    gpio_output_set(ITH_GPIO_PIN10);   
    gpio_output_set(ITH_GPIO_PIN11);    
    gpio_output_set(ITH_GPIO_PIN12);    
    gpio_output_set(ITH_GPIO_PIN13);    

    gpio_output_set(ITH_GPIO_PIN16);   
    gpio_output_set(ITH_GPIO_PIN17);    
    gpio_output_set(ITH_GPIO_PIN21);    
    gpio_output_set(ITH_GPIO_PIN22);   
}
#endif // PYJ.2019.02.15_END -- 


float Atten_QPC6614_TraceValue_Func(uint8_t value)
{
   uint8_t Temp_data = 0;
   float ret = ATTEN_0DB;
   if (value != 0)Temp_data = (~value)& 0x3F;
   while (1)
   {
       if ((Temp_data | QPC6614_ATTEN_0DB_Trace) == 0)
       {
           ret += ATTEN_0DB;
           break;
       }
       else if ((Temp_data & QPC6614_ATTEN_0_5DB_Trace) > 0)
       {
           Temp_data &= ~(QPC6614_ATTEN_0_5DB_Trace);
           ret += ATTEN_0_5DB;
       }
       else if ((Temp_data & QPC6614_ATTEN_1DB_Trace) > 0)
       {
           Temp_data &= (~QPC6614_ATTEN_1DB_Trace);
           ret += ATTEN_1DB;
       }
       else if ((Temp_data & QPC6614_ATTEN_2DB_Trace) > 0)
       {
           Temp_data &= (~QPC6614_ATTEN_2DB_Trace);
           ret += ATTEN_2DB;

       }
       else if ((Temp_data & QPC6614_ATTEN_4DB_Trace) > 0)
       {
           Temp_data &= (~QPC6614_ATTEN_4DB_Trace);
           ret += ATTEN_4DB;
       }
       else if ((Temp_data & QPC6614_ATTEN_8DB_Trace) > 0)
       {
           Temp_data &= (~QPC6614_ATTEN_8DB_Trace);
           ret += ATTEN_8DB;
       }
       else if ((Temp_data & QPC6614_ATTEN_16DB_Trace) > 0)
       {
           Temp_data &= (~QPC6614_ATTEN_16DB_Trace);
           ret += ATTEN_16DB;
       }
       else if ((Temp_data & QPC6614_ATTEN_31_5DB_Trace) >= 0)
       {
           Temp_data &= (~QPC6614_ATTEN_31_5DB_Trace);
           ret += ATTEN_31_5DB;
       }
   }
   return ret;
}
float Atten_ADRF5720_TraceValue_Func(uint8_t value)
{
   uint8_t Temp_data = 0;
   float ret = ATTEN_0DB;
   if (value != 0)
       Temp_data = (uint8_t)(value & 0x3F);
   while (1)
   {

       if ((Temp_data & ADRF5720_ATTEN_31_5DB_VAL) == ADRF5720_ATTEN_31_5DB_VAL)
       {
           Temp_data &= ((~ADRF5720_ATTEN_31_5DB_VAL) & 0x3F);
           ret += ATTEN_31_5DB;
       }
       else if ((Temp_data & ADRF5720_ATTEN_16DB_VAL) > 0)
       {
           Temp_data &= ((~ADRF5720_ATTEN_16DB_VAL) & 0x3F);
           ret += ATTEN_16DB;
       }
       else if ((Temp_data & ADRF5720_ATTEN_8DB_VAL) > 0)
       {
           Temp_data &= ((~ADRF5720_ATTEN_8DB_VAL) & 0x3F);
           ret += ATTEN_8DB;
       }
       else if ((Temp_data & ADRF5720_ATTEN_4DB_VAL) > 0)
       {
           Temp_data &= ((~ADRF5720_ATTEN_4DB_VAL) & 0x3F);
           ret += ATTEN_4DB;
       }
       else if ((Temp_data & ADRF5720_ATTEN_2DB_VAL) > 0)
       {
           Temp_data &= ((~ADRF5720_ATTEN_2DB_VAL) & 0x3F);
           ret += ATTEN_2DB;

       }
       else if ((Temp_data & ADRF5720_ATTEN_1DB_VAL) > 0)
       {
           Temp_data &= ((~ADRF5720_ATTEN_1DB_VAL) & 0x3F);
           ret += ATTEN_1DB;
       }
       else if ((Temp_data & ADRF5720_ATTEN_0_5DB_VAL) > 0)
       {
           Temp_data &= ((~ADRF5720_ATTEN_0_5DB_VAL) & 0x3F);
           ret += ATTEN_0_5DB;
       }
       else if ((Temp_data | ADRF5720_ATTEN_0DB_VAL) == 0)
       {
           ret += ATTEN_0DB;
           break;
       }
   }
   return ret;
}
float Atten_HMC939_TraceValue_Func(uint8_t value)
{
   uint32_t Temp_data = 0;
   float ret = ATTEN_0DB;

   Temp_data = (~value) & 0x1F;
   while (1)
   {
       if ((Temp_data | ((~HMC939_ATTEN_0DB_VAL) & 0x1F)) == 0)
       {
           ret += ATTEN_0DB;
           break;
       }
       else if ((Temp_data & ((~HMC939_ATTEN_1DB_VAL) & 0x1F)) > 0)
       {
           Temp_data &= (HMC939_ATTEN_1DB_VAL);
           ret += ATTEN_1DB;
       }
       else if ((Temp_data & ((~HMC939_ATTEN_2DB_VAL) & 0x1F)) > 0)
       {
           Temp_data &= (HMC939_ATTEN_2DB_VAL);
           ret += ATTEN_2DB;
       }
       else if ((Temp_data & ((~HMC939_ATTEN_4DB_VAL) & 0x1F)) > 0)
       {
           Temp_data &= (HMC939_ATTEN_4DB_VAL);
           ret += ATTEN_4DB;
       }
       else if ((Temp_data & ((~HMC939_ATTEN_8DB_VAL) & 0x1F)) > 0)
       {
           Temp_data &= (HMC939_ATTEN_8DB_VAL);
           ret += ATTEN_8DB;
       }
       else if ((Temp_data & ((~HMC939_ATTEN_16DB_VAL) & 0x1F)) > 0)
       {
           Temp_data &= (HMC939_ATTEN_16DB_VAL);
           ret += ATTEN_16DB;
       }
       else if ((Temp_data & ((~HMC939_ATTEN_30DB_VAL) & 0x1F)) > 0)
       {
           Temp_data &= (HMC939_ATTEN_30DB_VAL);
           ret += ATTEN_31DB;
       }
       else if ((Temp_data & ((~HMC939_ATTEN_31DB_VAL) & 0x1F)) >= 0)
       {
           Temp_data &= (HMC939_ATTEN_31DB_VAL);
           ret += ATTEN_31_5DB;
       }
   }
   return ret;
}


uint8_t QPC6614_Atten_Rx_DataCheck(float data)
{
    float Temp_Atten_Ret = data;
    uint8_t Temp_Atten_Value = QPC6614_ATTEN_0DB_VAL;
    while (1)
    {
        if (data == 0)
            break;

        if (data == ATTEN_31_5DB)
        {
            data = 0;
            Temp_Atten_Value &= QPC6614_ATTEN_31_5DB_VAL;
        }
        else if (data >= ATTEN_16DB)
        {
            data -= ATTEN_16DB;
            Temp_Atten_Value &= QPC6614_ATTEN_16DB_VAL;
        }
        else if (data >= ATTEN_8DB)
        {
            data -= ATTEN_8DB;
            Temp_Atten_Value &= QPC6614_ATTEN_8DB_VAL;
        }
        else if (data >= ATTEN_4DB)
        {
            data -= ATTEN_4DB;
            Temp_Atten_Value &= QPC6614_ATTEN_4DB_VAL;
        }
        else if (data >= ATTEN_2DB)
        {
            data -= ATTEN_2DB;
            Temp_Atten_Value &= QPC6614_ATTEN_2DB_VAL;
        }
        else if (data >= ATTEN_1DB)
        {
            data -= ATTEN_1DB;
            Temp_Atten_Value &= QPC6614_ATTEN_1DB_VAL;
        }
        else if (data >= ATTEN_0_5DB)
        {
            data = 0;
            Temp_Atten_Value &= QPC6614_ATTEN_0_5DB_VAL;
        }
        else if (data >= ATTEN_0DB)
        {
            data -= ATTEN_0DB;
            Temp_Atten_Value &= QPC6614_ATTEN_0DB_VAL;
        }
    }
    return Temp_Atten_Value;
}
uint8_t ADRF5720_Atten_Rx_DataCheck(float data)
{
   double Temp_Atten_Ret = data;
   uint8_t  Temp_Atten_Value = ADRF5720_ATTEN_0DB_VAL;
   while (1)
   {
       if (data == 0)
           break;

       if (data == ATTEN_31_5DB)
       {
           data = 0;
           Temp_Atten_Value |= ADRF5720_ATTEN_31_5DB_VAL;
       }
       else if (data >= ATTEN_16DB)
       {
           data -= ATTEN_16DB;
           Temp_Atten_Value |= ADRF5720_ATTEN_16DB_VAL;
       }
       else if (data >= ATTEN_8DB)
       {
           data -= ATTEN_8DB;
           Temp_Atten_Value |= ADRF5720_ATTEN_8DB_VAL;
       }
       else if (data >= ATTEN_4DB)
       {
           data -= ATTEN_4DB;
           Temp_Atten_Value |= ADRF5720_ATTEN_4DB_VAL;
       }
       else if (data >= ATTEN_2DB)
       {
           data -= ATTEN_2DB;
           Temp_Atten_Value |= ADRF5720_ATTEN_2DB_VAL;
       }
       else if (data >= ATTEN_1DB)
       {
           data -= ATTEN_1DB;
           Temp_Atten_Value |= ADRF5720_ATTEN_1DB_VAL;
       }
       else if (data >= ATTEN_0_5DB)
       {
           data -= ATTEN_0_5DB;
           Temp_Atten_Value |= ADRF5720_ATTEN_0_5DB_VAL;
       }
       else if (data >= ATTEN_0DB)
       {
           data -= ATTEN_0DB;
           Temp_Atten_Value |= ADRF5720_ATTEN_0DB_VAL;
       }
   }
    return Temp_Atten_Value;
}
uint8_t HMC939_Atten_Rx_DataCheck(uint8_t data)
{
   uint8_t Temp_Atten_Ret = data, Temp_Atten_Value = HMC939_ATTEN_0DB_VAL;
     while (1)
   {
       if (data == ATTEN_0DB)
       {
           data -= ATTEN_0DB;
           Temp_Atten_Value &= HMC939_ATTEN_0DB_VAL;
           break;
       }
       if (data == ATTEN_31DB)
       {
           data = 0;
           Temp_Atten_Value &= HMC939_ATTEN_31DB_VAL;
       }
       else if (data >= ATTEN_16DB)
       {
           data -= ATTEN_16DB;
           Temp_Atten_Value &= HMC939_ATTEN_16DB_VAL;
       }
       else if (data >= ATTEN_8DB)
       {
           data -= ATTEN_8DB;
           Temp_Atten_Value &= HMC939_ATTEN_8DB_VAL;
       }
       else if (data >= ATTEN_4DB)
       {
           data -= ATTEN_4DB;
           Temp_Atten_Value &= HMC939_ATTEN_4DB_VAL;
       }
       else if (data >= ATTEN_2DB)
       {
           data -= ATTEN_2DB;
           Temp_Atten_Value &= HMC939_ATTEN_2DB_VAL;
       }
       else if (data >= ATTEN_1DB)
       {
           data -= ATTEN_1DB;
           Temp_Atten_Value &= HMC939_ATTEN_1DB_VAL;
       }
   }
   return Temp_Atten_Value;
}

void Atten_150M_DataSet(float value,uint8_t type)
{
    uint8_t cnt = 0;
    uint8_t ret_buf[CHSET_UART_LENGTH] = {0,};
    
    ret_buf[cnt++]     = 0xBE;
    ret_buf[cnt++]     = type;
    ret_buf[cnt++]     = CHSET_UARTDATA_LENGTH;
    ret_buf[cnt++]     = QPC6614_Atten_Rx_DataCheck(value);
    ret_buf[cnt++]     = QPC6614_ATTEN_0DB_VAL;
    ret_buf[cnt++]     = QPC6614_ATTEN_0DB_VAL;
    ret_buf[cnt++]     = QPC6614_ATTEN_0DB_VAL;    
    ret_buf[CHSET_UART_LENGTH - 2] = STH30_CreateCrc(&ret_buf[Bluecell_Type],ret_buf[Bluecell_Length]+2);
    ret_buf[CHSET_UART_LENGTH - 1] = 0xEB; 
    memcpy(&buf[0],&ret_buf[0],CHSET_UART_LENGTH);
    ButtonDataSet(true);
}

void Atten_Wifi_DataSet(float value,uint8_t type)
{
    uint8_t cnt = 0;
    uint8_t ret_buf[CHSET_UART_LENGTH] = {0,};

    ret_buf[cnt++] = 0xBE;
    ret_buf[cnt++] = type;
    ret_buf[cnt++] = CHSET_UARTDATA_LENGTH;
    if (value > 90)
    {
        value -= 90;
       
        ret_buf[cnt++] = QPC6614_ATTEN_30DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_ATTEN_30DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_ATTEN_30DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_Atten_Rx_DataCheck(value);
    }
    else if (value > 60)
    {
        value -= 60;
        QPC6614_Atten_Rx_DataCheck(value);
        ret_buf[cnt++] = QPC6614_ATTEN_30DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_ATTEN_30DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_Atten_Rx_DataCheck(value);
        ret_buf[cnt++] = QPC6614_ATTEN_0DB_VAL;//3번째 byte Data 
    }
    else if (value > 30)
    {
        value -= 30;
        ret_buf[cnt++] = QPC6614_ATTEN_30DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_Atten_Rx_DataCheck(value);
        ret_buf[cnt++] = QPC6614_ATTEN_0DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_ATTEN_0DB_VAL;//3번째 byte Data 
        

    }
    else if (value >= 0)
    {
        ret_buf[cnt++] = QPC6614_Atten_Rx_DataCheck(value);
        ret_buf[cnt++] = QPC6614_ATTEN_0DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_ATTEN_0DB_VAL;//3번째 byte Data 
        ret_buf[cnt++] = QPC6614_ATTEN_0DB_VAL;//3번째 byte Data 
    }

    ret_buf[CHSET_UART_LENGTH - 2] = STH30_CreateCrc(&ret_buf[Bluecell_Type],ret_buf[Bluecell_Length]+2);
    ret_buf[CHSET_UART_LENGTH - 1] = 0xEB;
    memcpy(&buf[0],&ret_buf[0],CHSET_UART_LENGTH);
    ButtonDataSet(true);
}

void Atten_30G_DataSet(float value,uint8_t type)
{
    int cnt = 0;
    uint8_t ret_buf[9] = {0,};


    ret_buf[cnt++] = 0xBE;
    ret_buf[cnt++] = type;
    ret_buf[cnt++] = CHSET_UARTDATA_LENGTH;
    if (value > 60)
    {
        value -= 60;
        ret_buf[cnt++] = HMC939_ATTEN_30DB_VAL;
        ret_buf[cnt++] = HMC939_ATTEN_30DB_VAL;
        ret_buf[cnt++] = ADRF5720_Atten_Rx_DataCheck(value);;
    }
    else if (value >= 30)
    {
        value -= 30;
        

        ret_buf[cnt++] = HMC939_ATTEN_30DB_VAL;
        ret_buf[cnt++] = HMC939_Atten_Rx_DataCheck(value);
        ret_buf[cnt++] = ADRF5720_ATTEN_0DB_VAL;
    }
    else if (value >= 0)
    {
        ret_buf[cnt++] = HMC939_Atten_Rx_DataCheck(value);
        ret_buf[cnt++] = HMC939_ATTEN_0DB_VAL;
        ret_buf[cnt++] = ADRF5720_ATTEN_0DB_VAL;
    }

    ret_buf[CHSET_UART_LENGTH - 2] = STH30_CreateCrc(&ret_buf[Bluecell_Type],ret_buf[Bluecell_Length]+2);
    ret_buf[CHSET_UART_LENGTH - 1] = 0xEB;
    memcpy(&buf[0],&ret_buf[0],CHSET_UART_LENGTH);
    ButtonDataSet(true);
}

void QPC6614_Ach_atten_ctrl(uint8_t data,uint8_t Ch){
    atten_ctrl pin;
    uint8_t i = 0;
     pin.Clock_PIN = GPIO_PIN_8;
     pin.Data_PIN  = GPIO_PIN_9; 
     pin.LE_PIN    = GPIO_PIN_10;
     if(Ch == 0)       {
         pin.LE_PIN    = GPIO_PIN_10;
     }//LE}
     else if (Ch == 1) {
         pin.LE_PIN         = GPIO_PIN_11;
     }//LE}
     else if (Ch == 2) {
         pin.LE_PIN         = GPIO_PIN_12;
     }//LE}
     else if (Ch == 3) {
         pin.LE_PIN         = GPIO_PIN_13;
     }//LE}
     else if (Ch == 4) {
         pin.LE_PIN         = GPIO_PIN_14;
     }//LE}
     pin.Port               = GPIOE;

    for(i = 0; i < 6; i++){
        if(data & 0x20)
           HAL_GPIO_WritePin(pin.Port,pin.Data_PIN,GPIO_PIN_SET);//DATA
        else
           HAL_GPIO_WritePin(pin.Port,pin.Data_PIN,GPIO_PIN_RESET);//DATA
        data <<= 1;

		HAL_GPIO_WritePin(pin.Port,pin.Clock_PIN,GPIO_PIN_SET);//CLOCK
		 HAL_Delay(1);
		HAL_GPIO_WritePin(pin.Port,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK
        HAL_Delay(1);
    }
    HAL_GPIO_WritePin(pin.Port,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK
    HAL_GPIO_WritePin(pin.Port,pin.Data_PIN,GPIO_PIN_RESET);//DATA

    HAL_GPIO_WritePin(pin.Port,pin.LE_PIN,GPIO_PIN_SET);//LE
    HAL_Delay(1);
    HAL_GPIO_WritePin(pin.Port,pin.LE_PIN,GPIO_PIN_RESET);
}
void QPC6614_Bch_atten_ctrl(uint8_t data,uint8_t Ch){
    atten_ctrl pin;
    uint8_t i = 0;
     pin.Clock_PIN = GPIO_PIN_12;
     pin.Data_PIN  = GPIO_PIN_13; 
     if(Ch == 0)       {
         pin.LE_PIN    = GPIO_PIN_14;
         pin.Port      = GPIOG;
     }
     else if (Ch == 1) {
         pin.LE_PIN         = GPIO_PIN_6;
         pin.Port           = GPIOB;
     }
     else if (Ch == 2) {
         pin.LE_PIN         = GPIO_PIN_7;
         pin.Port           = GPIOB;
         
     }
     else if (Ch == 3) {
         pin.LE_PIN         = GPIO_PIN_5;
         pin.Port           = GPIOB;
     }
     else if (Ch == 4) {
         pin.LE_PIN         = GPIO_PIN_9;
         pin.Port           = GPIOB;
     }
    
    pin.Port      = GPIOG;
    for(i = 0; i < 6; i++){
        if(data & 0x20)
           HAL_GPIO_WritePin(pin.Port,pin.Data_PIN,GPIO_PIN_SET);//DATA
        else
           HAL_GPIO_WritePin(pin.Port,pin.Data_PIN,GPIO_PIN_RESET);//DATA
        data <<= 1;

		HAL_GPIO_WritePin(pin.Port,pin.Clock_PIN,GPIO_PIN_SET);//CLOCK
		 HAL_Delay(1);
		HAL_GPIO_WritePin(pin.Port,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK
        HAL_Delay(1);
    }
    HAL_GPIO_WritePin(pin.Port,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK
    if (Ch != 0) pin.Port = GPIOB;
    HAL_GPIO_WritePin(pin.Port,pin.Data_PIN,GPIO_PIN_RESET);//DATA
    HAL_GPIO_WritePin(pin.Port,pin.LE_PIN,GPIO_PIN_SET);//LE
    HAL_Delay(1);
    HAL_GPIO_WritePin(pin.Port,pin.LE_PIN,GPIO_PIN_RESET);
}


void ADRF5720_Ach_atten_ctrl(uint8_t data){
    atten_ctrl pin;
    uint8_t i = 0;

    pin.Clock_PIN = GPIO_PIN_13;
    pin.Data_PIN  = GPIO_PIN_14;
    pin.LE_PIN    = GPIO_PIN_15;

    HAL_GPIO_WritePin(GPIOF,pin.LE_PIN,GPIO_PIN_RESET);//LE
    HAL_GPIO_WritePin(GPIOF,pin.Data_PIN,GPIO_PIN_RESET);//DATA
    HAL_GPIO_WritePin(GPIOF,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK

    for(i = 0; i < 8; i++){
            if(data & 0x80)
               HAL_GPIO_WritePin(GPIOF,pin.Data_PIN,GPIO_PIN_SET);//DATA
            else
               HAL_GPIO_WritePin(GPIOF,pin.Data_PIN,GPIO_PIN_RESET);//DATA
            data <<= 1;


        HAL_GPIO_WritePin(GPIOF,pin.Clock_PIN,GPIO_PIN_SET);//CLOCK
        HAL_Delay(1);
        HAL_GPIO_WritePin(GPIOF,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK
        HAL_Delay(1);
    }
    HAL_GPIO_WritePin(GPIOF,pin.LE_PIN,GPIO_PIN_SET);//LE
    HAL_Delay(1);
    HAL_GPIO_WritePin(GPIOF,pin.LE_PIN,GPIO_PIN_RESET);//LE
    HAL_GPIO_WritePin(GPIOF,pin.Data_PIN,GPIO_PIN_RESET);//DATA
    HAL_GPIO_WritePin(GPIOF,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK
}
void ADRF5720_Bch_atten_ctrl(uint8_t data){
    atten_ctrl pin;
    uint8_t i = 0;

    pin.Clock_PIN = GPIO_PIN_6;
    pin.Data_PIN  = GPIO_PIN_7;
    pin.LE_PIN    = GPIO_PIN_9;

    HAL_GPIO_WritePin(GPIOG,pin.LE_PIN,GPIO_PIN_RESET);//LE
    HAL_GPIO_WritePin(GPIOD,pin.Data_PIN,GPIO_PIN_RESET);//DATA
    HAL_GPIO_WritePin(GPIOD,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK

    for(i = 0; i < 8; i++){
            if(data & 0x80)
               HAL_GPIO_WritePin(GPIOD,pin.Data_PIN,GPIO_PIN_SET);//DATA
            else
               HAL_GPIO_WritePin(GPIOD,pin.Data_PIN,GPIO_PIN_RESET);//DATA
            data <<= 1;


        HAL_GPIO_WritePin(GPIOD,pin.Clock_PIN,GPIO_PIN_SET);//CLOCK
        HAL_Delay(1);
        HAL_GPIO_WritePin(GPIOD,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK
        HAL_Delay(1);
    }
    HAL_GPIO_WritePin(GPIOG,pin.LE_PIN,GPIO_PIN_SET);//LE
    HAL_Delay(1);
    HAL_GPIO_WritePin(GPIOG,pin.LE_PIN,GPIO_PIN_RESET);//LE
    HAL_GPIO_WritePin(GPIOD,pin.Data_PIN,GPIO_PIN_RESET);//DATA
    HAL_GPIO_WritePin(GPIOD,pin.Clock_PIN,GPIO_PIN_RESET);//CLOCK
}

void HMC939_Ach_atten_ctrl(uint8_t data,uint8_t Ch){
    HMC939atten_ctrl pin;
    pin.ATT_P0    = GPIO_PIN_4;
    pin.ATT_P1    = GPIO_PIN_5;
    pin.ATT_P2    = GPIO_PIN_6;
    pin.ATT_P3    = GPIO_PIN_7;
    pin.ATT_P4    = GPIO_PIN_4;    
    pin.ATT_ENABLE = GPIO_PIN_7;
   
    if(data & 0x10)
        HAL_GPIO_WritePin(GPIOC,pin.ATT_P4,GPIO_PIN_SET); //data
    else
        HAL_GPIO_WritePin(GPIOC,pin.ATT_P4,GPIO_PIN_RESET); //data
    if(data & 0x08)
        HAL_GPIO_WritePin(GPIOA,pin.ATT_P3,GPIO_PIN_SET); //data
    else
        HAL_GPIO_WritePin(GPIOA,pin.ATT_P3,GPIO_PIN_RESET); //data
    if(data & 0x04)
        HAL_GPIO_WritePin(GPIOA,pin.ATT_P2,GPIO_PIN_SET); //data
    else
        HAL_GPIO_WritePin(GPIOA,pin.ATT_P2,GPIO_PIN_RESET); //data
    if(data & 0x02)
        HAL_GPIO_WritePin(GPIOA,pin.ATT_P1,GPIO_PIN_SET);    //data
    else
        HAL_GPIO_WritePin(GPIOA,pin.ATT_P1,GPIO_PIN_RESET); //data
    if(data & 0x01)
        HAL_GPIO_WritePin(GPIOA,pin.ATT_P0,GPIO_PIN_SET); //data
    else
        HAL_GPIO_WritePin(GPIOA,pin.ATT_P0,GPIO_PIN_RESET); //data

     if(Ch == 0)       {
         pin.ATT_ENABLE    = GPIO_PIN_5;//enable
         HAL_GPIO_WritePin(GPIOC,pin.ATT_ENABLE,GPIO_PIN_SET);//LE
         HAL_Delay(1);
         HAL_GPIO_WritePin(GPIOC,pin.ATT_ENABLE,GPIO_PIN_RESET);//LE
         HAL_Delay(1);
     }//LE}
     if (Ch == 1) {
         pin.ATT_ENABLE    = GPIO_PIN_0;//enable
         HAL_GPIO_WritePin(GPIOB,pin.ATT_ENABLE,GPIO_PIN_SET);//LE
         HAL_Delay(1);
         HAL_GPIO_WritePin(GPIOB,pin.ATT_ENABLE,GPIO_PIN_RESET);//LE       
         HAL_Delay(1);
     }//LE}   


}
void HMC939_Bch_atten_ctrl(uint8_t data,uint8_t Ch){
    HMC939atten_ctrl pin;
    pin.ATT_P0    = GPIO_PIN_10;
    pin.ATT_P1    = GPIO_PIN_11;
    pin.ATT_P2    = GPIO_PIN_12;
    pin.ATT_P3    = GPIO_PIN_0;
    pin.ATT_P4    = GPIO_PIN_1;    
    pin.ATT_ENABLE = GPIO_PIN_7;


    if(data & 0x10)
        HAL_GPIO_WritePin(GPIOD,pin.ATT_P4,GPIO_PIN_SET); //data
    else
        HAL_GPIO_WritePin(GPIOD,pin.ATT_P4,GPIO_PIN_RESET); //data
    if(data & 0x08)
        HAL_GPIO_WritePin(GPIOD,pin.ATT_P3,GPIO_PIN_SET); //data
    else
        HAL_GPIO_WritePin(GPIOD,pin.ATT_P3,GPIO_PIN_RESET); //data
    if(data & 0x04)
        HAL_GPIO_WritePin(GPIOC,pin.ATT_P2,GPIO_PIN_SET); //data
    else
        HAL_GPIO_WritePin(GPIOC,pin.ATT_P2,GPIO_PIN_RESET); //data
    if(data & 0x02)
        HAL_GPIO_WritePin(GPIOC,pin.ATT_P1,GPIO_PIN_SET);    //data
    else
        HAL_GPIO_WritePin(GPIOC,pin.ATT_P1,GPIO_PIN_RESET); //data
    if(data & 0x01)
        HAL_GPIO_WritePin(GPIOC,pin.ATT_P0,GPIO_PIN_SET); //data
    else
        HAL_GPIO_WritePin(GPIOC,pin.ATT_P0,GPIO_PIN_RESET); //data

    


     if(Ch == 0)       {
         pin.ATT_ENABLE    = GPIO_PIN_2;//enable
         HAL_GPIO_WritePin(GPIOD,pin.ATT_ENABLE,GPIO_PIN_SET);//LE
         HAL_Delay(1);
         HAL_GPIO_WritePin(GPIOD,pin.ATT_ENABLE,GPIO_PIN_RESET);//LE
         HAL_Delay(1);
     }//LE}
     if (Ch == 1) {
         pin.ATT_ENABLE    = GPIO_PIN_3;//enable
         HAL_GPIO_WritePin(GPIOD,pin.ATT_ENABLE,GPIO_PIN_SET);//LE
         HAL_Delay(1);
         HAL_GPIO_WritePin(GPIOD,pin.ATT_ENABLE,GPIO_PIN_RESET);//LE       
         HAL_Delay(1);
     }//LE}   
}

Atten_Alarm_t Atten_Alarm_Read(void){
    Atten_Alarm_t ret;

    ret.Atten_Ach_Alarm_30G  = HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_6);
    ret.Atten_Bch_Alarm_30G  = HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_1);

    ret.Atten_Ach_Alarm_WIFI = HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_7);
    ret.Atten_Bch_Alarm_WIFI = HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_2);

    ret.Atten_Ach_Alarm_150M = HAL_GPIO_ReadPin(GPIOF,GPIO_PIN_8);
    ret.Atten_Bch_Alarm_150M = HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_3);
    
    return ret;    
}
void Alarm_Operate(Atten_Alarm_t data){
    if(data.Atten_Ach_Alarm_30G ==  GPIO_PIN_RESET|| data.Atten_Bch_Alarm_30G == GPIO_PIN_RESET){
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_2,GPIO_PIN_RESET);        
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_3,GPIO_PIN_SET);
    }
    else{
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_2,GPIO_PIN_SET);
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_3,GPIO_PIN_RESET);        
    }
        
    if(data.Atten_Ach_Alarm_WIFI ==  GPIO_PIN_RESET|| data.Atten_Bch_Alarm_WIFI == GPIO_PIN_RESET){
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_4,GPIO_PIN_RESET);        
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_5,GPIO_PIN_SET);
    }
    else{
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_4,GPIO_PIN_SET);
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_5,GPIO_PIN_RESET);        

    }
    
    if(data.Atten_Ach_Alarm_150M ==  GPIO_PIN_RESET|| data.Atten_Bch_Alarm_150M == GPIO_PIN_RESET){
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_0,GPIO_PIN_RESET);        
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_1,GPIO_PIN_SET);
    }
    else{
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_0,GPIO_PIN_SET);
        HAL_GPIO_WritePin(GPIOE,GPIO_PIN_1,GPIO_PIN_RESET);        
    }

}
void Uart_Data_Send(uint8_t* data,uint8_t size){
    HAL_UART_Transmit(&huart3, data,size, 10); 
//    for(uint8_t i = 0; i <data[Bluecell_Length] + 5;i++ )
//        printf("%02x ",data[i]);
//    printf("\r\n");
}
#define ATT_NOT_CRC_CHECK_LEN 5
#define ATT_AB_CH_Read_Length 38 + ATT_NOT_CRC_CHECK_LEN
uint8_t printf_if = 0;
uint8_t Atten_Offset_QPC6614(Atten_Table_Value_t TableName, uint8_t data){
    uint8_t ret = 0;
    uint8_t temp_data[100] = {0,};
    memcpy(temp_data,&TableName.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));
    
    switch(data){
        case QPC6614_Atten_31_5dB_num : ret = TableName.Atten_Table_31_5dB_Value ;break;
        case QPC6614_Atten_31dB_num   : ret = TableName.Atten_Table_31dB_Value   ;break;
        case QPC6614_Atten_30_5dB_num : ret = TableName.Atten_Table_30_5dB_Value ;break;
        case QPC6614_Atten_30dB_num   : ret = TableName.Atten_Table_30dB_Value   ;break;
        case QPC6614_Atten_29_5dB_num : ret = TableName.Atten_Table_29_5dB_Value ;break;
        case QPC6614_Atten_29dB_num   : ret = TableName.Atten_Table_29dB_Value   ;break;
        case QPC6614_Atten_28_5dB_num : ret = TableName.Atten_Table_28_5dB_Value ;break;
        case QPC6614_Atten_28dB_num   : ret = TableName.Atten_Table_28dB_Value   ;break;
        case QPC6614_Atten_27_5dB_num : ret = TableName.Atten_Table_27_5dB_Value ;break;
        case QPC6614_Atten_27dB_num   : ret = TableName.Atten_Table_27dB_Value   ;break;
        case QPC6614_Atten_26_5dB_num : ret = TableName.Atten_Table_26_5dB_Value ;break;
        case QPC6614_Atten_26dB_num   : ret = TableName.Atten_Table_26dB_Value   ;break;
        case QPC6614_Atten_25_5dB_num : ret = TableName.Atten_Table_25_5dB_Value ;break;
        case QPC6614_Atten_25dB_num   : ret = TableName.Atten_Table_25dB_Value   ;break;
        case QPC6614_Atten_24_5dB_num : ret = TableName.Atten_Table_24_5dB_Value ;break;
        case QPC6614_Atten_24dB_num   : ret = TableName.Atten_Table_24dB_Value   ;break;
        case QPC6614_Atten_23_5dB_num : ret = TableName.Atten_Table_23_5dB_Value ;break;
        case QPC6614_Atten_23dB_num   : ret = TableName.Atten_Table_23dB_Value   ;break;
        case QPC6614_Atten_22_5dB_num : ret = TableName.Atten_Table_22_5dB_Value ;break;
        case QPC6614_Atten_22dB_num   : ret = TableName.Atten_Table_22dB_Value   ;break;
        case QPC6614_Atten_21_5dB_num : ret = TableName.Atten_Table_21_5dB_Value ;break;
        case QPC6614_Atten_21dB_num   : ret = TableName.Atten_Table_21dB_Value   ;break;
        case QPC6614_Atten_20_5dB_num : ret = TableName.Atten_Table_20_5dB_Value ;break;
        case QPC6614_Atten_20dB_num   : ret = TableName.Atten_Table_20dB_Value   ;break;
        case QPC6614_Atten_19_5dB_num : ret = TableName.Atten_Table_19_5dB_Value ;break;
        case QPC6614_Atten_19dB_num   : ret = TableName.Atten_Table_19dB_Value   ;break;
        case QPC6614_Atten_18_5dB_num : ret = TableName.Atten_Table_18_5dB_Value ;break;
        case QPC6614_Atten_18dB_num   : ret = TableName.Atten_Table_18dB_Value   ;break;
        case QPC6614_Atten_17_5dB_num : ret = TableName.Atten_Table_17_5dB_Value ;break;
        case QPC6614_Atten_17dB_num   : ret = TableName.Atten_Table_17dB_Value   ;break;
        case QPC6614_Atten_16_5dB_num : ret = TableName.Atten_Table_16_5dB_Value ;break;
        case QPC6614_Atten_16dB_num   : ret = TableName.Atten_Table_16dB_Value   ;break;
        case QPC6614_Atten_15_5dB_num : ret = TableName.Atten_Table_15_5dB_Value ;break;
        case QPC6614_Atten_15dB_num   : ret = TableName.Atten_Table_15dB_Value   ;break;
        case QPC6614_Atten_14_5dB_num : ret = TableName.Atten_Table_14_5dB_Value ;break;
        case QPC6614_Atten_14dB_num   : ret = TableName.Atten_Table_14dB_Value   ;break;
        case QPC6614_Atten_13_5dB_num : ret = TableName.Atten_Table_13_5dB_Value ;break;
        case QPC6614_Atten_13dB_num   : ret = TableName.Atten_Table_13dB_Value   ;break;
        case QPC6614_Atten_12_5dB_num : ret = TableName.Atten_Table_12_5dB_Value ;break;
        case QPC6614_Atten_12dB_num   : ret = TableName.Atten_Table_12dB_Value   ;break;
        case QPC6614_Atten_11_5dB_num : ret = TableName.Atten_Table_11_5dB_Value ;break;
        case QPC6614_Atten_11dB_num   : ret = TableName.Atten_Table_11dB_Value   ;break;
        case QPC6614_Atten_10_5dB_num : ret = TableName.Atten_Table_10_5dB_Value ;break;
        case QPC6614_Atten_10dB_num   : ret = TableName.Atten_Table_10dB_Value   ;break;
        case QPC6614_Atten_9_5dB_num  : ret = TableName.Atten_Table_9_5dB_Value  ;break;
        case QPC6614_Atten_9dB_num    : ret = TableName.Atten_Table_9dB_Value    ;break;
        case QPC6614_Atten_8_5dB_num  : ret = TableName.Atten_Table_8_5dB_Value  ;break;
        case QPC6614_Atten_8dB_num    : ret = TableName.Atten_Table_8dB_Value    ;break;
        case QPC6614_Atten_7_5dB_num  : ret = TableName.Atten_Table_7_5dB_Value  ;break;
        case QPC6614_Atten_7dB_num    : ret = TableName.Atten_Table_7dB_Value    ;break;
        case QPC6614_Atten_6_5dB_num  : ret = TableName.Atten_Table_6_5dB_Value  ;break;
        case QPC6614_Atten_6dB_num    : ret = TableName.Atten_Table_6dB_Value    ;break;
        case QPC6614_Atten_5_5dB_num  : ret = TableName.Atten_Table_5_5dB_Value  ;break;
        case QPC6614_Atten_5dB_num    : ret = TableName.Atten_Table_5dB_Value    ;break;
        case QPC6614_Atten_4_5dB_num  : ret = TableName.Atten_Table_4_5dB_Value  ;break;
        case QPC6614_Atten_4dB_num    : ret = TableName.Atten_Table_4dB_Value    ;break;
        case QPC6614_Atten_3_5dB_num  : ret = TableName.Atten_Table_3_5dB_Value  ;break;
        case QPC6614_Atten_3dB_num    : ret = TableName.Atten_Table_3dB_Value    ;break;
        case QPC6614_Atten_2_5dB_num  : ret = TableName.Atten_Table_2_5dB_Value  ;break;
        case QPC6614_Atten_2dB_num    : ret = TableName.Atten_Table_2dB_Value    ;break;
        case QPC6614_Atten_1_5dB_num  : ret = TableName.Atten_Table_1_5dB_Value  ;break;
        case QPC6614_Atten_1dB_num    : ret = TableName.Atten_Table_1dB_Value    ;break;
        case QPC6614_Atten_0_5dB_num  : ret = TableName.Atten_Table_0_5dB_Value  ;break;
        case QPC6614_Atten_0dB_num    : ret = TableName.Atten_Table_0dB_Value    ;break;

        default : printf("Critical Error\r\n");
    }
    return ret;

}
uint8_t Atten_Offset_ADRF5720(Atten_Table_Value_t TableName, uint8_t data){
    uint8_t ret = 0;
    switch(data){
        case ADRF5720_Atten_31_5dB_num : ret = TableName.Atten_Table_31_5dB_Value ;break;
        case ADRF5720_Atten_31dB_num   : ret = TableName.Atten_Table_31dB_Value   ;break;
        case ADRF5720_Atten_30_5dB_num : ret = TableName.Atten_Table_30_5dB_Value ;break;
        case ADRF5720_Atten_30dB_num   : ret = TableName.Atten_Table_30dB_Value   ;break;
        case ADRF5720_Atten_29_5dB_num : ret = TableName.Atten_Table_29_5dB_Value ;break;
        case ADRF5720_Atten_29dB_num   : ret = TableName.Atten_Table_29dB_Value   ;break;
        case ADRF5720_Atten_28_5dB_num : ret = TableName.Atten_Table_28_5dB_Value ;break;
        case ADRF5720_Atten_28dB_num   : ret = TableName.Atten_Table_28dB_Value   ;break;
        case ADRF5720_Atten_27_5dB_num : ret = TableName.Atten_Table_27_5dB_Value ;break;
        case ADRF5720_Atten_27dB_num   : ret = TableName.Atten_Table_27dB_Value   ;break;
        case ADRF5720_Atten_26_5dB_num : ret = TableName.Atten_Table_26_5dB_Value ;break;
        case ADRF5720_Atten_26dB_num   : ret = TableName.Atten_Table_26dB_Value   ;break;
        case ADRF5720_Atten_25_5dB_num : ret = TableName.Atten_Table_25_5dB_Value ;break;
        case ADRF5720_Atten_25dB_num   : ret = TableName.Atten_Table_25dB_Value   ;break;
        case ADRF5720_Atten_24_5dB_num : ret = TableName.Atten_Table_24_5dB_Value ;break;
        case ADRF5720_Atten_24dB_num   : ret = TableName.Atten_Table_24dB_Value   ;break;
        case ADRF5720_Atten_23_5dB_num : ret = TableName.Atten_Table_23_5dB_Value ;break;
        case ADRF5720_Atten_23dB_num   : ret = TableName.Atten_Table_23dB_Value   ;break;
        case ADRF5720_Atten_22_5dB_num : ret = TableName.Atten_Table_22_5dB_Value ;break;
        case ADRF5720_Atten_22dB_num   : ret = TableName.Atten_Table_22dB_Value   ;break;
        case ADRF5720_Atten_21_5dB_num : ret = TableName.Atten_Table_21_5dB_Value ;break;
        case ADRF5720_Atten_21dB_num   : ret = TableName.Atten_Table_21dB_Value   ;break;
        case ADRF5720_Atten_20_5dB_num : ret = TableName.Atten_Table_20_5dB_Value ;break;
        case ADRF5720_Atten_20dB_num   : ret = TableName.Atten_Table_20dB_Value   ;break;
        case ADRF5720_Atten_19_5dB_num : ret = TableName.Atten_Table_19_5dB_Value ;break;
        case ADRF5720_Atten_19dB_num   : ret = TableName.Atten_Table_19dB_Value   ;break;
        case ADRF5720_Atten_18_5dB_num : ret = TableName.Atten_Table_18_5dB_Value ;break;
        case ADRF5720_Atten_18dB_num   : ret = TableName.Atten_Table_18dB_Value   ;break;
        case ADRF5720_Atten_17_5dB_num : ret = TableName.Atten_Table_17_5dB_Value ;break;
        case ADRF5720_Atten_17dB_num   : ret = TableName.Atten_Table_17dB_Value   ;break;
        case ADRF5720_Atten_16_5dB_num : ret = TableName.Atten_Table_16_5dB_Value ;break;
        case ADRF5720_Atten_16dB_num   : ret = TableName.Atten_Table_16dB_Value   ;break;
        case ADRF5720_Atten_15_5dB_num : ret = TableName.Atten_Table_15_5dB_Value ;break;
        case ADRF5720_Atten_15dB_num   : ret = TableName.Atten_Table_15dB_Value   ;break;
        case ADRF5720_Atten_14_5dB_num : ret = TableName.Atten_Table_14_5dB_Value ;break;
        case ADRF5720_Atten_14dB_num   : ret = TableName.Atten_Table_14dB_Value   ;break;
        case ADRF5720_Atten_13_5dB_num : ret = TableName.Atten_Table_13_5dB_Value ;break;
        case ADRF5720_Atten_13dB_num   : ret = TableName.Atten_Table_13dB_Value   ;break;
        case ADRF5720_Atten_12_5dB_num : ret = TableName.Atten_Table_12_5dB_Value ;break;
        case ADRF5720_Atten_12dB_num   : ret = TableName.Atten_Table_12dB_Value   ;break;
        case ADRF5720_Atten_11_5dB_num : ret = TableName.Atten_Table_11_5dB_Value ;break;
        case ADRF5720_Atten_11dB_num   : ret = TableName.Atten_Table_11dB_Value   ;break;
        case ADRF5720_Atten_10_5dB_num : ret = TableName.Atten_Table_10_5dB_Value ;break;
        case ADRF5720_Atten_10dB_num   : ret = TableName.Atten_Table_10dB_Value   ;break;
        case ADRF5720_Atten_9_5dB_num  : ret = TableName.Atten_Table_9_5dB_Value  ;break;
        case ADRF5720_Atten_9dB_num    : ret = TableName.Atten_Table_9dB_Value    ;break;
        case ADRF5720_Atten_8_5dB_num  : ret = TableName.Atten_Table_8_5dB_Value  ;break;
        case ADRF5720_Atten_8dB_num    : ret = TableName.Atten_Table_8dB_Value    ;break;
        case ADRF5720_Atten_7_5dB_num  : ret = TableName.Atten_Table_7_5dB_Value  ;break;
        case ADRF5720_Atten_7dB_num    : ret = TableName.Atten_Table_7dB_Value    ;break;
        case ADRF5720_Atten_6_5dB_num  : ret = TableName.Atten_Table_6_5dB_Value  ;break;
        case ADRF5720_Atten_6dB_num    : ret = TableName.Atten_Table_6dB_Value    ;break;
        case ADRF5720_Atten_5_5dB_num  : ret = TableName.Atten_Table_5_5dB_Value  ;break;
        case ADRF5720_Atten_5dB_num    : ret = TableName.Atten_Table_5dB_Value    ;break;
        case ADRF5720_Atten_4_5dB_num  : ret = TableName.Atten_Table_4_5dB_Value  ;break;
        case ADRF5720_Atten_4dB_num    : ret = TableName.Atten_Table_4dB_Value    ;break;
        case ADRF5720_Atten_3_5dB_num  : ret = TableName.Atten_Table_3_5dB_Value  ;break;
        case ADRF5720_Atten_3dB_num    : ret = TableName.Atten_Table_3dB_Value    ;break;
        case ADRF5720_Atten_2_5dB_num  : ret = TableName.Atten_Table_2_5dB_Value  ;break;
        case ADRF5720_Atten_2dB_num    : ret = TableName.Atten_Table_2dB_Value    ;break;
        case ADRF5720_Atten_1_5dB_num  : ret = TableName.Atten_Table_1_5dB_Value  ;break;
        case ADRF5720_Atten_1dB_num    : ret = TableName.Atten_Table_1dB_Value    ;break;
        case ADRF5720_Atten_0_5dB_num  : ret = TableName.Atten_Table_0_5dB_Value  ;break;
        case ADRF5720_Atten_0dB_num    : ret = TableName.Atten_Table_0dB_Value    ;break;

        default : printf("Critical Error\r\n");
    }
    return ret;

}
uint8_t Atten_Offset_HMC939(Atten_Table_Value_t TableName, uint8_t data){
    uint8_t ret = 0;
    switch(data){
        case HMC939_Atten_31dB_num   : ret = TableName.Atten_Table_31dB_Value   ;break;
        case HMC939_Atten_30dB_num   : ret = TableName.Atten_Table_30dB_Value   ;break;
        case HMC939_Atten_29dB_num   : ret = TableName.Atten_Table_29dB_Value   ;break;
        case HMC939_Atten_28dB_num   : ret = TableName.Atten_Table_28dB_Value   ;break;
        case HMC939_Atten_27dB_num   : ret = TableName.Atten_Table_27dB_Value   ;break;
        case HMC939_Atten_26dB_num   : ret = TableName.Atten_Table_26dB_Value   ;break;
        case HMC939_Atten_25dB_num   : ret = TableName.Atten_Table_25dB_Value   ;break;
        case HMC939_Atten_24dB_num   : ret = TableName.Atten_Table_24dB_Value   ;break;
        case HMC939_Atten_23dB_num   : ret = TableName.Atten_Table_23dB_Value   ;break;
        case HMC939_Atten_22dB_num   : ret = TableName.Atten_Table_22dB_Value   ;break;
        case HMC939_Atten_21dB_num   : ret = TableName.Atten_Table_21dB_Value   ;break;
        case HMC939_Atten_20dB_num   : ret = TableName.Atten_Table_20dB_Value   ;break;
        case HMC939_Atten_19dB_num   : ret = TableName.Atten_Table_19dB_Value   ;break;
        case HMC939_Atten_18dB_num   : ret = TableName.Atten_Table_18dB_Value   ;break;
        case HMC939_Atten_17dB_num   : ret = TableName.Atten_Table_17dB_Value   ;break;
        case HMC939_Atten_16dB_num   : ret = TableName.Atten_Table_16dB_Value   ;break;
        case HMC939_Atten_15dB_num   : ret = TableName.Atten_Table_15dB_Value   ;break;
        case HMC939_Atten_14dB_num   : ret = TableName.Atten_Table_14dB_Value   ;break;
        case HMC939_Atten_13dB_num   : ret = TableName.Atten_Table_13dB_Value   ;break;
        case HMC939_Atten_12dB_num   : ret = TableName.Atten_Table_12dB_Value   ;break;
        case HMC939_Atten_11dB_num   : ret = TableName.Atten_Table_11dB_Value   ;break;
        case HMC939_Atten_10dB_num   : ret = TableName.Atten_Table_10dB_Value   ;break;
        case HMC939_Atten_9dB_num    : ret = TableName.Atten_Table_9dB_Value    ;break;
        case HMC939_Atten_8dB_num    : ret = TableName.Atten_Table_8dB_Value    ;break;
        case HMC939_Atten_7dB_num    : ret = TableName.Atten_Table_7dB_Value    ;break;
        case HMC939_Atten_6dB_num    : ret = TableName.Atten_Table_6dB_Value    ;break;
        case HMC939_Atten_5dB_num    : ret = TableName.Atten_Table_5dB_Value    ;break;
        case HMC939_Atten_4dB_num    : ret = TableName.Atten_Table_4dB_Value    ;break;
        case HMC939_Atten_3dB_num    : ret = TableName.Atten_Table_3dB_Value    ;break;
        case HMC939_Atten_2dB_num    : ret = TableName.Atten_Table_2dB_Value    ;break;
        case HMC939_Atten_1dB_num    : ret = TableName.Atten_Table_1dB_Value    ;break;
        case HMC939_Atten_0dB_num    : ret = TableName.Atten_Table_0dB_Value    ;break;

        default : printf("Critical Error\r\n");
    }
    return ret;

}


typedef enum{
    QPC6614_Offset_Sel ,
    HMC939_Offset_Sel  ,
    ADRF5720_Offset_Sel,
}offset_type_t;
uint8_t Atten_Offset_Calc(offset_type_t type,Atten_Table_Value_t TableName,uint8_t data){
    uint8_t ret = 0;
    switch(type){
        case QPC6614_Offset_Sel:    Atten_Offset_QPC6614(TableName,data); break;
        case HMC939_Offset_Sel:     Atten_Offset_HMC939(TableName,data);  break;
        case ADRF5720_Offset_Sel:   Atten_Offset_ADRF5720(TableName,data);break;
    }
    return ret;
}
void Atten_Init(void){
    QPC6614_Ach_atten_ctrl(ATT_Curr_Value.ATT_A_CH_CURR_150M,0);
    QPC6614_Ach_atten_ctrl(ATT_Curr_Value.ATT_A_CH_CURR_WIFI_1,1);
    QPC6614_Ach_atten_ctrl(ATT_Curr_Value.ATT_A_CH_CURR_WIFI_2,2);
    QPC6614_Ach_atten_ctrl(ATT_Curr_Value.ATT_A_CH_CURR_WIFI_3,3);
    QPC6614_Ach_atten_ctrl(ATT_Curr_Value.ATT_A_CH_CURR_WIFI_4,4);

    HMC939_Ach_atten_ctrl(ATT_Curr_Value.ATT_A_CH_CURR_30G_1,0);
    HMC939_Ach_atten_ctrl(ATT_Curr_Value.ATT_A_CH_CURR_30G_2,1);
    ADRF5720_Ach_atten_ctrl(ATT_Curr_Value.ATT_A_CH_CURR_30G_3);    



    QPC6614_Bch_atten_ctrl(ATT_Curr_Value.ATT_B_CH_CURR_150M,0);
    QPC6614_Bch_atten_ctrl(ATT_Curr_Value.ATT_B_CH_CURR_WIFI_1,1);
    QPC6614_Bch_atten_ctrl(ATT_Curr_Value.ATT_B_CH_CURR_WIFI_2,2);
    QPC6614_Bch_atten_ctrl(ATT_Curr_Value.ATT_B_CH_CURR_WIFI_3,3);
    QPC6614_Bch_atten_ctrl(ATT_Curr_Value.ATT_B_CH_CURR_WIFI_4,4);

    HMC939_Bch_atten_ctrl(ATT_Curr_Value.ATT_B_CH_CURR_30G_1,0);
    HMC939_Bch_atten_ctrl(ATT_Curr_Value.ATT_B_CH_CURR_30G_2,1);
    ADRF5720_Bch_atten_ctrl(ATT_Curr_Value.ATT_B_CH_CURR_30G_3);        
}
void Atten_Operate(uint8_t* data){
    AttenType_t Temp_Type = data[Bluecell_Type];
//    uint8_t ret[100] = {0,};
    switch(Temp_Type){
        case ATT_AB_CH_Read            :  /*memcpy(&ret[Bluecell_DATA],&data,) */
            data[Bluecell_STX] = 0xBE;
            data[Bluecell_Type]   = ATT_AB_CH_Read;
            memcpy(&data[Bluecell_DATA],&Atten_Setting.ATT_A_CH_150M,42);
            data[data[Bluecell_Length] + 3] = STH30_CreateCrc(&data[Bluecell_Type],data[Bluecell_Length]+2);
            data[data[Bluecell_Length] + 4] = 0xEB;
            Uart_Data_Send(data,data[Bluecell_Length] +5);
            break;
        case ATT_A_CH_150M             : 
            QPC6614_Ach_atten_ctrl(data[Bluecell_DATA ],0);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_CURR_150M,&data[Bluecell_DATA] ,1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_150M,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;
        case ATT_A_CH_WIFI2_4Ghz       : 
            for(uint8_t i = 0; i < 4; i++)
                QPC6614_Ach_atten_ctrl(data[Bluecell_DATA + i],i + 1);

            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_CURR_WIFI,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_WIFI2_4Ghz,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;
        case ATT_A_CH_WIFI5_8Ghz       : 
            for(uint8_t i = 0; i < 4; i++)
                QPC6614_Ach_atten_ctrl(data[Bluecell_DATA + i],i + 1);

            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_CURR_WIFI,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_WIFI5_8Ghz,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;
        case ATT_A_CH_30G_28_28_5      : 
            HMC939_Ach_atten_ctrl(data[Bluecell_DATA      ],0);
            HMC939_Ach_atten_ctrl(data[Bluecell_DATA   + 1],1);
            ADRF5720_Ach_atten_ctrl(data[Bluecell_DATA + 2]);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_CURR_30G,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN - 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_30G_28_28_5,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;              
        case ATT_A_CH_30G_28_5_29      : 
            HMC939_Ach_atten_ctrl(data[Bluecell_DATA      ],0);
            HMC939_Ach_atten_ctrl(data[Bluecell_DATA   + 1],1);
            ADRF5720_Ach_atten_ctrl(data[Bluecell_DATA + 2]);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_CURR_30G,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN - 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_30G_28_5_29,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;            
        case ATT_A_CH_30G_29_29_5      : 
            HMC939_Ach_atten_ctrl(data[Bluecell_DATA      ],0);
            HMC939_Ach_atten_ctrl(data[Bluecell_DATA   + 1],1);
            ADRF5720_Ach_atten_ctrl(data[Bluecell_DATA + 2]);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_CURR_30G,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN - 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_30G_29_29_5,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;            
        case ATT_A_CH_30G_29_5_30      : 
            HMC939_Ach_atten_ctrl(data[Bluecell_DATA      ],0);
            HMC939_Ach_atten_ctrl(data[Bluecell_DATA   + 1],1);
            ADRF5720_Ach_atten_ctrl(data[Bluecell_DATA + 2]);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_CURR_30G,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN - 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_CH_30G_29_5_30,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break; 
        case ATT_B_CH_150M             : 
            QPC6614_Bch_atten_ctrl(data[Bluecell_DATA],0);

            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_CURR_150M,&data[Bluecell_DATA] ,1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_150M,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;            
        case ATT_B_CH_WIFI2_4Ghz       : 
            for(uint8_t i = 0; i < 4; i++)
                QPC6614_Bch_atten_ctrl(data[Bluecell_DATA + i],i + 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_CURR_WIFI,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_WIFI2_4Ghz,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);

            break;            
        case ATT_B_CH_WIFI5_8Ghz       : 
            for(uint8_t i = 0; i < 4; i++)
                QPC6614_Bch_atten_ctrl(data[Bluecell_DATA + i],i + 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_CURR_WIFI,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_WIFI5_8Ghz,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;            
        case ATT_B_CH_30G_28_28_5      : 
            HMC939_Bch_atten_ctrl(data[Bluecell_DATA      ],0);
            HMC939_Bch_atten_ctrl(data[Bluecell_DATA   + 1],1);
            ADRF5720_Bch_atten_ctrl(data[Bluecell_DATA + 2]);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_CURR_30G,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN - 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_30G_28_28_5,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;
        case ATT_B_CH_30G_28_5_29      : 
            HMC939_Bch_atten_ctrl(data[Bluecell_DATA      ],0);
            HMC939_Bch_atten_ctrl(data[Bluecell_DATA   + 1],1);
            ADRF5720_Bch_atten_ctrl(data[Bluecell_DATA + 2]);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_CURR_30G,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN - 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_30G_28_5_29,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;
        case ATT_B_CH_30G_29_29_5      : 
            HMC939_Bch_atten_ctrl(data[Bluecell_DATA      ],0);
            HMC939_Bch_atten_ctrl(data[Bluecell_DATA   + 1],1);
            ADRF5720_Bch_atten_ctrl(data[Bluecell_DATA + 2]);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_CURR_30G,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN - 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_30G_29_29_5,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;
        case ATT_B_CH_30G_29_5_30      : 
            HMC939_Bch_atten_ctrl(data[Bluecell_DATA      ],0);
            HMC939_Bch_atten_ctrl(data[Bluecell_DATA   + 1],1);
            ADRF5720_Bch_atten_ctrl(data[Bluecell_DATA + 2]);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_CURR_30G,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN - 1);
            EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_CH_30G_29_5_30,&data[Bluecell_DATA] ,EEPROM_ATTEN_CURR_ST_LEN);
            break;
        /****************************TABLE************************************/
		case ATT_A_EN_150M			    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_150M			,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t));break;
		case ATT_A_EN_WIFI1_2_4Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_WIFI1_2_4Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_WIFI2_2_4Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_WIFI2_2_4Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_WIFI3_2_4Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_WIFI3_2_4Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_WIFI4_2_4Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_WIFI4_2_4Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_WIFI1_5_8Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_WIFI1_5_8Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_WIFI2_5_8Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_WIFI2_5_8Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_WIFI3_5_8Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_WIFI3_5_8Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_WIFI4_5_8Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_WIFI4_5_8Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G1_28_28_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G1_28_28_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G2_28_28_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G2_28_28_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G3_28_28_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G3_28_28_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G1_28_5_29Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G1_28_5_29Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G2_28_5_29Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G2_28_5_29Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G3_28_5_29Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G3_28_5_29Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G1_29_29_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G1_29_29_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G2_29_29_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G2_29_29_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G3_29_29_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G3_29_29_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G1_29_5_30Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G1_29_5_30Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G2_29_5_30Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G2_29_5_30Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_A_EN_30G3_29_5_30Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_A_EN_30G3_29_5_30Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_150M			    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_150M			,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_WIFI1_2_4Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_WIFI1_2_4Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_WIFI2_2_4Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_WIFI2_2_4Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_WIFI3_2_4Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_WIFI3_2_4Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_WIFI4_2_4Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_WIFI4_2_4Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_WIFI1_5_8Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_WIFI1_5_8Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_WIFI2_5_8Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_WIFI2_5_8Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_WIFI3_5_8Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_WIFI3_5_8Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_WIFI4_5_8Ghz	    :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_WIFI4_5_8Ghz	,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G1_28_28_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G1_28_28_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G2_28_28_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G2_28_28_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G3_28_28_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G3_28_28_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G1_28_5_29Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G1_28_5_29Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G2_28_5_29Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G2_28_5_29Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G3_28_5_29Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G3_28_5_29Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G1_29_29_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G1_29_29_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G2_29_29_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G2_29_29_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G3_29_29_5Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G3_29_29_5Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G1_29_5_30Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G1_29_5_30Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t)); break;
		case ATT_B_EN_30G2_29_5_30Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G2_29_5_30Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t));break;
		case ATT_B_EN_30G3_29_5_30Ghz   :  EEPROM_IM24CM01P_write(EEPROM_IM24CM01P_ID,EEPROM_ATT_B_EN_30G3_29_5_30Ghz,&data[Bluecell_DATA] ,sizeof(Atten_Table_Value_t));break;
        /****************************TABLE*********************/
		case ATT_A_EN_150M_R		    :   Atten_Table_Read(EEPROM_ATT_A_EN_150M			 ,ATT_A_EN_150M_Table			  ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_WIFI1_2_4Ghz_R    :   Atten_Table_Read(EEPROM_ATT_A_EN_WIFI1_2_4Ghz	 ,ATT_A_EN_WIFI1_2_4Ghz_Table     ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_WIFI2_2_4Ghz_R    :   Atten_Table_Read(EEPROM_ATT_A_EN_WIFI2_2_4Ghz	 ,ATT_A_EN_WIFI2_2_4Ghz_Table     ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_WIFI3_2_4Ghz_R    :   Atten_Table_Read(EEPROM_ATT_A_EN_WIFI3_2_4Ghz	 ,ATT_A_EN_WIFI3_2_4Ghz_Table     ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_WIFI4_2_4Ghz_R    :   Atten_Table_Read(EEPROM_ATT_A_EN_WIFI4_2_4Ghz	 ,ATT_A_EN_WIFI4_2_4Ghz_Table     ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_WIFI1_5_8Ghz_R    :   Atten_Table_Read(EEPROM_ATT_A_EN_WIFI1_5_8Ghz	 ,ATT_A_EN_WIFI1_5_8Ghz_Table     ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_WIFI2_5_8Ghz_R	:   Atten_Table_Read(EEPROM_ATT_A_EN_WIFI2_5_8Ghz	 ,ATT_A_EN_WIFI2_5_8Ghz_Table     ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_WIFI3_5_8Ghz_R	:   Atten_Table_Read(EEPROM_ATT_A_EN_WIFI3_5_8Ghz	 ,ATT_A_EN_WIFI3_5_8Ghz_Table     ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_WIFI4_5_8Ghz_R	:   Atten_Table_Read(EEPROM_ATT_A_EN_WIFI4_5_8Ghz	 ,ATT_A_EN_WIFI4_5_8Ghz_Table     ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G1_28_28_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G1_28_28_5Ghz,ATT_A_EN_30G1_28_28_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G2_28_28_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G2_28_28_5Ghz,ATT_A_EN_30G2_28_28_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G3_28_28_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G3_28_28_5Ghz,ATT_A_EN_30G3_28_28_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G1_28_5_29Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G1_28_5_29Ghz,ATT_A_EN_30G1_28_5_29Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G2_28_5_29Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G2_28_5_29Ghz,ATT_A_EN_30G2_28_5_29Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G3_28_5_29Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G3_28_5_29Ghz,ATT_A_EN_30G3_28_5_29Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G1_29_29_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G1_29_29_5Ghz,ATT_A_EN_30G1_29_29_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G2_29_29_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G2_29_29_5Ghz,ATT_A_EN_30G2_29_29_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G3_29_29_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G3_29_29_5Ghz,ATT_A_EN_30G3_29_29_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G1_29_5_30Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G1_29_5_30Ghz,ATT_A_EN_30G1_29_5_30Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G2_29_5_30Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G2_29_5_30Ghz,ATT_A_EN_30G2_29_5_30Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_A_EN_30G3_29_5_30Ghz_R :   Atten_Table_Read(EEPROM_ATT_A_EN_30G3_29_5_30Ghz,ATT_A_EN_30G3_29_5_30Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_150M_R			:   Atten_Table_Read(EEPROM_ATT_B_EN_150M			  ,ATT_B_EN_150M_Table            ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_WIFI1_2_4Ghz_R	:   Atten_Table_Read(EEPROM_ATT_B_EN_WIFI1_2_4Ghz	  ,ATT_B_EN_WIFI1_2_4Ghz_Table    ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_WIFI2_2_4Ghz_R	:   Atten_Table_Read(EEPROM_ATT_B_EN_WIFI2_2_4Ghz	  ,ATT_B_EN_WIFI2_2_4Ghz_Table    ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_WIFI3_2_4Ghz_R	:   Atten_Table_Read(EEPROM_ATT_B_EN_WIFI3_2_4Ghz	  ,ATT_B_EN_WIFI3_2_4Ghz_Table    ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_WIFI4_2_4Ghz_R	:   Atten_Table_Read(EEPROM_ATT_B_EN_WIFI4_2_4Ghz	  ,ATT_B_EN_WIFI4_2_4Ghz_Table    ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_WIFI1_5_8Ghz_R	:   Atten_Table_Read(EEPROM_ATT_B_EN_WIFI1_5_8Ghz	  ,ATT_B_EN_WIFI1_5_8Ghz_Table    ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_WIFI2_5_8Ghz_R	:   Atten_Table_Read(EEPROM_ATT_B_EN_WIFI2_5_8Ghz	  ,ATT_B_EN_WIFI2_5_8Ghz_Table    ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_WIFI3_5_8Ghz_R	:   Atten_Table_Read(EEPROM_ATT_B_EN_WIFI3_5_8Ghz	  ,ATT_B_EN_WIFI3_5_8Ghz_Table    ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_WIFI4_5_8Ghz_R	:   Atten_Table_Read(EEPROM_ATT_B_EN_WIFI4_5_8Ghz	  ,ATT_B_EN_WIFI4_5_8Ghz_Table    ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G1_28_28_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G1_28_28_5Ghz,ATT_B_EN_30G1_28_28_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G2_28_28_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G2_28_28_5Ghz,ATT_B_EN_30G2_28_28_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G3_28_28_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G3_28_28_5Ghz,ATT_B_EN_30G3_28_28_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G1_28_5_29Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G1_28_5_29Ghz,ATT_B_EN_30G1_28_5_29Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G2_28_5_29Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G2_28_5_29Ghz,ATT_B_EN_30G2_28_5_29Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G3_28_5_29Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G3_28_5_29Ghz,ATT_B_EN_30G3_28_5_29Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G1_29_29_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G1_29_29_5Ghz,ATT_B_EN_30G1_29_29_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G2_29_29_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G2_29_29_5Ghz,ATT_B_EN_30G2_29_29_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G3_29_29_5Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G3_29_29_5Ghz,ATT_B_EN_30G3_29_29_5Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G1_29_5_30Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G1_29_5_30Ghz,ATT_B_EN_30G1_29_5_30Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G2_29_5_30Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G2_29_5_30Ghz,ATT_B_EN_30G2_29_5_30Ghz_Table ,&data[Bluecell_STX]);	break;
		case ATT_B_EN_30G3_29_5_30Ghz_R :   Atten_Table_Read(EEPROM_ATT_B_EN_30G3_29_5_30Ghz,ATT_B_EN_30G3_29_5_30Ghz_Table ,&data[Bluecell_STX]);	break;
    }
}

void Atten_Table_Read(uint16_t Address,Atten_Table_Value_t TableName,uint8_t* data){
	memcpy(&data[Bluecell_DATA],&TableName.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));
	data[data[Bluecell_Length] + 3]  = STH30_CreateCrc(&data[Bluecell_Type],data[Bluecell_Length] + 2);
	data[data[Bluecell_Length] + 4]  = 0xeb;
	Uart_Data_Send(data,data[Bluecell_Length]+5);
}
void Atten_Operate_Mem_RW(uint8_t* data){
    AttenType_t Temp_Type = data[Bluecell_Type];
    uint8_t ResultBuf[100] ={0,};
    ResultBuf[Bluecell_STX]                   = data[Bluecell_STX];
    ResultBuf[Bluecell_Type]                  = data[Bluecell_Type];
    ResultBuf[Bluecell_Length]                = data[Bluecell_Length];
    ResultBuf[ResultBuf[Bluecell_Length] + 4] = data[data[Bluecell_Length] + 4];

    switch(Temp_Type){
        case ATT_AB_CH_Read            : 
            memcpy(&ResultBuf[Bluecell_DATA],&Atten_Setting.ATT_A_CH_150M,data[Bluecell_DATA]); 
            break;
        case ATT_A_CH_150M             : 
            Atten_Setting.ATT_A_CH_150M = data[Bluecell_DATA];
            data[Bluecell_DATA] = Atten_Offset_QPC6614(ATT_A_EN_150M_Table,data[Bluecell_DATA]);
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_A_CH_WIFI2_4Ghz       : 
            memcpy(&Atten_Setting.ATT_A_CH_WIFI2_4Ghz_QPC6614_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH);
            data[Bluecell_DATA]     = Atten_Offset_QPC6614(ATT_A_EN_WIFI1_2_4Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_QPC6614(ATT_A_EN_WIFI2_2_4Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_QPC6614(ATT_A_EN_WIFI3_2_4Ghz_Table,data[Bluecell_DATA + 2]);
            data[Bluecell_DATA + 3] = Atten_Offset_QPC6614(ATT_A_EN_WIFI4_2_4Ghz_Table,data[Bluecell_DATA + 3]);
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;
        case ATT_A_CH_WIFI5_8Ghz       : 
            memcpy(&Atten_Setting.ATT_A_CH_WIFI5_8Ghz_QPC6614_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH);
            data[Bluecell_DATA]     = Atten_Offset_QPC6614(ATT_A_EN_WIFI1_5_8Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_QPC6614(ATT_A_EN_WIFI2_5_8Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_QPC6614(ATT_A_EN_WIFI3_5_8Ghz_Table,data[Bluecell_DATA + 2]);
            data[Bluecell_DATA + 3] = Atten_Offset_QPC6614(ATT_A_EN_WIFI4_5_8Ghz_Table,data[Bluecell_DATA + 3]);            
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_A_CH_30G_28_28_5      : 
            memcpy(&Atten_Setting.ATT_A_CH_30G_28_28_5_HMC939_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH-1);
            data[Bluecell_DATA]       = Atten_Offset_HMC939(ATT_A_EN_30G1_28_28_5Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1]   = Atten_Offset_HMC939(ATT_A_EN_30G2_28_28_5Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_ADRF5720(ATT_A_EN_30G3_28_28_5Ghz_Table,data[Bluecell_DATA + 2]);            
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_A_CH_30G_28_5_29      : 
            memcpy(&Atten_Setting.ATT_A_CH_30G_28_5_29_HMC939_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH-1);
            data[Bluecell_DATA]     = Atten_Offset_HMC939(ATT_A_EN_30G1_28_5_29Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_HMC939(ATT_A_EN_30G2_28_5_29Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_ADRF5720(ATT_A_EN_30G3_28_5_29Ghz_Table,data[Bluecell_DATA + 2]);   
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_A_CH_30G_29_29_5      : 
             memcpy(&Atten_Setting.ATT_A_CH_30G_29_29_5_HMC939_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH-1);
            data[Bluecell_DATA]     = Atten_Offset_HMC939(ATT_A_EN_30G1_29_29_5Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_HMC939(ATT_A_EN_30G2_29_29_5Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_ADRF5720(ATT_A_EN_30G3_29_29_5Ghz_Table,data[Bluecell_DATA + 2]);
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_A_CH_30G_29_5_30      : 
            memcpy(&Atten_Setting.ATT_A_CH_30G_29_5_30_HMC939_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH-1);
            data[Bluecell_DATA]     = Atten_Offset_HMC939(ATT_A_EN_30G1_29_5_30Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_HMC939(ATT_A_EN_30G2_29_5_30Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_ADRF5720(ATT_A_EN_30G3_29_5_30Ghz_Table,data[Bluecell_DATA + 2]);            
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_B_CH_150M:
            Atten_Setting.ATT_B_CH_150M = data[Bluecell_DATA];
            data[Bluecell_DATA]     = Atten_Offset_QPC6614(ATT_B_EN_150M_Table,data[Bluecell_DATA]);
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_B_CH_WIFI2_4Ghz       : 
            memcpy(&Atten_Setting.ATT_B_CH_WIFI2_4Ghz_QPC6614_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH);
            data[Bluecell_DATA]     = Atten_Offset_QPC6614(ATT_B_EN_WIFI1_2_4Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_QPC6614(ATT_B_EN_WIFI2_2_4Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_QPC6614(ATT_B_EN_WIFI3_2_4Ghz_Table,data[Bluecell_DATA + 2]);
            data[Bluecell_DATA + 3] = Atten_Offset_QPC6614(ATT_B_EN_WIFI4_2_4Ghz_Table,data[Bluecell_DATA + 3]);
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_B_CH_WIFI5_8Ghz       : 
            memcpy(&Atten_Setting.ATT_B_CH_WIFI5_8Ghz_QPC6614_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH);
            data[Bluecell_DATA]     = Atten_Offset_QPC6614(ATT_B_EN_WIFI1_5_8Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_QPC6614(ATT_B_EN_WIFI2_5_8Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_QPC6614(ATT_B_EN_WIFI3_5_8Ghz_Table,data[Bluecell_DATA + 2]);
            data[Bluecell_DATA + 3] = Atten_Offset_QPC6614(ATT_B_EN_WIFI4_5_8Ghz_Table,data[Bluecell_DATA + 3]); 
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_B_CH_30G_28_28_5      : 
            memcpy(&Atten_Setting.ATT_B_CH_30G_28_28_5_HMC939_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH-1);
            data[Bluecell_DATA]     = Atten_Offset_HMC939(ATT_B_EN_30G1_28_28_5Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_HMC939(ATT_B_EN_30G2_28_28_5Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_ADRF5720(ATT_B_EN_30G3_28_28_5Ghz_Table,data[Bluecell_DATA + 2]);              
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_B_CH_30G_28_5_29      : 
            memcpy(&Atten_Setting.ATT_B_CH_30G_28_5_29_HMC939_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH-1);
            data[Bluecell_DATA]     = Atten_Offset_HMC939(ATT_B_EN_30G1_28_5_29Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_HMC939(ATT_B_EN_30G2_28_5_29Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_ADRF5720(ATT_B_EN_30G3_28_5_29Ghz_Table,data[Bluecell_DATA + 2]);              
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

        case ATT_B_CH_30G_29_29_5      : 
            memcpy(&Atten_Setting.ATT_B_CH_30G_29_29_5_HMC939_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH-1);
            data[Bluecell_DATA]     = Atten_Offset_HMC939(ATT_B_EN_30G1_29_29_5Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_HMC939(ATT_B_EN_30G2_29_29_5Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_ADRF5720(ATT_B_EN_30G3_29_29_5Ghz_Table,data[Bluecell_DATA + 2]);               
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);

            break;

        case ATT_B_CH_30G_29_5_30      :
            memcpy(&Atten_Setting.ATT_B_CH_30G_29_5_30_HMC939_1,&data[Bluecell_DATA],CHSET_UARTDATA_LENGTH-1);
            data[Bluecell_DATA]     = Atten_Offset_HMC939(ATT_B_EN_30G1_29_5_30Ghz_Table,data[Bluecell_DATA]);
            data[Bluecell_DATA + 1] = Atten_Offset_HMC939(ATT_B_EN_30G2_29_5_30Ghz_Table,data[Bluecell_DATA + 1]);
            data[Bluecell_DATA + 2] = Atten_Offset_ADRF5720(ATT_B_EN_30G3_29_5_30Ghz_Table,data[Bluecell_DATA + 2]);                
            memcpy(&ResultBuf[Bluecell_STX],&data[Bluecell_STX],data[Bluecell_Length] + 5);
            break;

            /****************************TABLE************************************/
    		 case ATT_A_EN_150M 			: memcpy(&ATT_A_EN_150M_Table.Atten_Table_31_5dB_Value			 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_150M_Table.Atten_Table_31_5dB_Value			 ,sizeof(Atten_Table_Value_t));break;			   
    		 case ATT_A_EN_WIFI1_2_4Ghz 	: memcpy(&ATT_A_EN_WIFI1_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI1_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;			 
    		 case ATT_A_EN_WIFI2_2_4Ghz 	: memcpy(&ATT_A_EN_WIFI2_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI2_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;
             case ATT_A_EN_WIFI3_2_4Ghz 	: memcpy(&ATT_A_EN_WIFI3_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI3_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;			 
    		 case ATT_A_EN_WIFI4_2_4Ghz 	: memcpy(&ATT_A_EN_WIFI4_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI4_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;			 
    		 case ATT_A_EN_WIFI1_5_8Ghz 	: memcpy(&ATT_A_EN_WIFI1_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI1_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;			 
    		 case ATT_A_EN_WIFI2_5_8Ghz 	: memcpy(&ATT_A_EN_WIFI2_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI2_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;			 
    		 case ATT_A_EN_WIFI3_5_8Ghz 	: memcpy(&ATT_A_EN_WIFI3_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI3_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;														  
    		 case ATT_A_EN_WIFI4_5_8Ghz 	: memcpy(&ATT_A_EN_WIFI4_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI4_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_A_EN_30G1_28_28_5Ghz	: memcpy(&ATT_A_EN_30G1_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G1_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G2_28_28_5Ghz	: memcpy(&ATT_A_EN_30G2_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G2_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G3_28_28_5Ghz	: memcpy(&ATT_A_EN_30G3_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G3_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G1_28_5_29Ghz	: memcpy(&ATT_A_EN_30G1_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G1_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G2_28_5_29Ghz	: memcpy(&ATT_A_EN_30G2_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G2_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G3_28_5_29Ghz	: memcpy(&ATT_A_EN_30G3_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G3_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G1_29_29_5Ghz	: memcpy(&ATT_A_EN_30G1_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G1_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G2_29_29_5Ghz	: memcpy(&ATT_A_EN_30G2_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G2_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G3_29_29_5Ghz	: memcpy(&ATT_A_EN_30G3_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G3_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G1_29_5_30Ghz	: memcpy(&ATT_A_EN_30G1_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G1_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G2_29_5_30Ghz	: memcpy(&ATT_A_EN_30G2_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G2_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_A_EN_30G3_29_5_30Ghz	: memcpy(&ATT_A_EN_30G3_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G3_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_150M 			: memcpy(&ATT_B_EN_150M_Table.Atten_Table_31_5dB_Value			 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_150M_Table.Atten_Table_31_5dB_Value			 ,sizeof(Atten_Table_Value_t));break;	  
    		 case ATT_B_EN_WIFI1_2_4Ghz 	: memcpy(&ATT_B_EN_WIFI1_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI1_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_B_EN_WIFI2_2_4Ghz 	: memcpy(&ATT_B_EN_WIFI2_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI2_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_B_EN_WIFI3_2_4Ghz 	: memcpy(&ATT_B_EN_WIFI3_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI3_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_B_EN_WIFI4_2_4Ghz 	: memcpy(&ATT_B_EN_WIFI4_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI4_2_4Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_B_EN_WIFI1_5_8Ghz 	: memcpy(&ATT_B_EN_WIFI1_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI1_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_B_EN_WIFI2_5_8Ghz 	: memcpy(&ATT_B_EN_WIFI2_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI2_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_B_EN_WIFI3_5_8Ghz 	: memcpy(&ATT_B_EN_WIFI3_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI3_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_B_EN_WIFI4_5_8Ghz 	: memcpy(&ATT_B_EN_WIFI4_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI4_5_8Ghz_Table.Atten_Table_31_5dB_Value	 ,sizeof(Atten_Table_Value_t));break;		
    		 case ATT_B_EN_30G1_28_28_5Ghz	: memcpy(&ATT_B_EN_30G1_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G1_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G2_28_28_5Ghz	: memcpy(&ATT_B_EN_30G2_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G2_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G3_28_28_5Ghz	: memcpy(&ATT_B_EN_30G3_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G3_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G1_28_5_29Ghz	: memcpy(&ATT_B_EN_30G1_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G1_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G2_28_5_29Ghz	: memcpy(&ATT_B_EN_30G2_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G2_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G3_28_5_29Ghz	: memcpy(&ATT_B_EN_30G3_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G3_28_5_29Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G1_29_29_5Ghz	: memcpy(&ATT_B_EN_30G1_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G1_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G2_29_29_5Ghz	: memcpy(&ATT_B_EN_30G2_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G2_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G3_29_29_5Ghz	: memcpy(&ATT_B_EN_30G3_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G3_29_29_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G1_29_5_30Ghz	: memcpy(&ATT_B_EN_30G1_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G1_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G2_29_5_30Ghz	: memcpy(&ATT_B_EN_30G2_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G2_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;	   
    		 case ATT_B_EN_30G3_29_5_30Ghz	: memcpy(&ATT_B_EN_30G3_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,&data[Bluecell_DATA],sizeof(Atten_Table_Value_t));memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G3_29_5_30Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));break;  

             /****************************TABLE************************************/
             case ATT_A_EN_150M_R              : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_150M_Table.Atten_Table_31_5dB_Value            ,sizeof(Atten_Table_Value_t));     
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_WIFI1_2_4Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI1_2_4Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_WIFI2_2_4Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI2_2_4Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_WIFI3_2_4Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI3_2_4Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_WIFI4_2_4Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI4_2_4Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_WIFI1_5_8Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI1_5_8Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_WIFI2_5_8Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI2_5_8Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_WIFI3_5_8Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI3_5_8Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_WIFI4_5_8Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_WIFI4_5_8Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G1_28_28_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G1_28_28_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G2_28_28_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G2_28_28_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G3_28_28_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G3_28_28_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G1_28_5_29Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G1_28_5_29Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G2_28_5_29Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G2_28_5_29Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G3_28_5_29Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G3_28_5_29Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G1_29_29_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G1_29_29_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G2_29_29_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G2_29_29_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G3_29_29_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G3_29_29_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G1_29_5_30Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G1_29_5_30Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G2_29_5_30Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G2_29_5_30Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_A_EN_30G3_29_5_30Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_A_EN_30G3_29_5_30Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_150M_R              : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_150M_Table.Atten_Table_31_5dB_Value            ,sizeof(Atten_Table_Value_t));     
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_WIFI1_2_4Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI1_2_4Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_WIFI2_2_4Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI2_2_4Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_WIFI3_2_4Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI3_2_4Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_WIFI4_2_4Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI4_2_4Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_WIFI1_5_8Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI1_5_8Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_WIFI2_5_8Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI2_5_8Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_WIFI3_5_8Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI3_5_8Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_WIFI4_5_8Ghz_R      : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_WIFI4_5_8Ghz_Table.Atten_Table_31_5dB_Value    ,sizeof(Atten_Table_Value_t));   
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G1_28_28_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G1_28_28_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G2_28_28_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G2_28_28_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G3_28_28_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G3_28_28_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G1_28_5_29Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G1_28_5_29Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G2_28_5_29Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G2_28_5_29Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G3_28_5_29Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G3_28_5_29Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G1_29_29_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G1_29_29_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G2_29_29_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G2_29_29_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G3_29_29_5Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G3_29_29_5Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G1_29_5_30Ghz_R   : memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G1_29_5_30Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
#if DEBUG_PRINT
        printf("LINE : %d \r\n",__LINE__);break;
#else
        break;
#endif
             case ATT_B_EN_30G2_29_5_30Ghz_R   : 
                memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G2_29_5_30Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
                break;
             case ATT_B_EN_30G3_29_5_30Ghz_R   : 
                memcpy(&ResultBuf[Bluecell_DATA],&ATT_B_EN_30G3_29_5_30Ghz_Table.Atten_Table_31_5dB_Value ,sizeof(Atten_Table_Value_t));      
                break;

            default:printf("[Error ]Defalut in %s      LINE :%d \r\n",__func__,__LINE__);break;
   }
    Atten_Operate(ResultBuf);
}


#if 0 // PYJ.2019.02.15_BEGIN -- 

void Atten_Alarm_Check(void){
    uint8_t i = ITH_GPIO_PIN29;
    if(ithGpioGet(ITH_GPIO_PIN29) == 1)
        Atten_ABChannel_Data.ATT_A_150M_ALARM = true;
    else
        Atten_ABChannel_Data.ATT_A_150M_ALARM = false;
    
    if(ithGpioGet(ITH_GPIO_PIN30) == 1)
        Atten_ABChannel_Data.ATT_A_WIFI_ALARM = true;
    else
        Atten_ABChannel_Data.ATT_A_WIFI_ALARM = false;
    
    if(ithGpioGet(ITH_GPIO_PIN31) == 1)
        Atten_ABChannel_Data.ATT_A_30G_ALARM = true;
    else
        Atten_ABChannel_Data.ATT_A_30G_ALARM = false;
    
    if(ithGpioGet(ITH_GPIO_PIN32) == 1)
        Atten_ABChannel_Data.ATT_B_150M_ALARM = true;
    else
        Atten_ABChannel_Data.ATT_B_150M_ALARM = false;
    
    if(ithGpioGet(ITH_GPIO_PIN33) == 1)
        Atten_ABChannel_Data.ATT_B_WIFI_ALARM = true;
    else
        Atten_ABChannel_Data.ATT_B_WIFI_ALARM = false;
    
    if(ithGpioGet(ITH_GPIO_PIN34) == 1)
        Atten_ABChannel_Data.ATT_B_30G_ALARM = true;
    else
        Atten_ABChannel_Data.ATT_B_30G_ALARM = false;   
    
}
#endif // PYJ.2019.02.15_END -- 


