Modify LPTIA gain control function.

This commit is contained in:
Benny Liu
2021-08-26 14:54:58 +08:00
parent f552bdacab
commit 2b2fc8f3ec
4 changed files with 26 additions and 27 deletions
@@ -195,8 +195,8 @@ static void LP_cali_config (void)
w32_REG(0x0000003E);
select_REG(LPTIASW0); //LPTIASW0
w32_REG(0x000002B4); // SW2 | SW4 | SW5
select_REG(LPTIACON0); //LPTIACON0
w32_REG(0x00002038); //RF 0 | RTIA 200R | Rload 0 | High Current Mode
// select_REG(LPTIACON0); //LPTIACON0
// w32_REG(0x00002038); //RF 0 | RTIA 200R | Rload 0 | High Current Mode
select_REG(LPDACCON0); //LPDACCON0
w32_REG(0x00000001);
@@ -165,8 +165,8 @@ static void VinADCGainCtrl(uint8_t VinADCLevel){
static void HSTIAGainCtrl(uint8_t HSTIALevel) {
/* HSRTIACON[12:5] = CTIACON, fix at 4pF;
HSRTIACON[4] = TIASW6CON, diode not in parallel with RTIA;
HSRTIACON[3:0] = RTIA */
HSRTIACON[4] = TIASW6CON, diode not in parallel with RTIA;
HSRTIACON[3:0] = RTIA */
uint32_t reg;
uint8_t data;
@@ -221,23 +221,22 @@ static void HSTIAGainCtrl2(uint8_t ret) {
}
static void LPTIAGainCtrl(uint8_t ret){
/* LPTIACON0[15:13] = RLPF, disconnect low pass filter;
LPTIACON0[12:10] = RLOAD, set at 0R;
LPTIACON0[9:5] = RTIA;
LPTIACON0[4:3] = IBOOST, High current mode; */
uint32_t code;
uint16_t mask;
uint16_t data;
mask = (31 << 5); //mask bit[9:5]
select_REG(LPTIACON0); //LPTIACON0
code = r32_REG();
code = 0x0000001E;
if (ret == LPRTIA_200R) {
data = 1; //200R
}
else if (ret == LPRTIA_4K) {
data = 5; //4K
else if (ret == LPRTIA_3K) {
data = 4; //3K
}
else if (ret == LPRTIA_12K) {
data = 9; //12K
else if (ret == LPRTIA_40K) {
data = 15; //40K
}
else if (ret == LPRTIA_512K) {
data = 26; //512K
@@ -246,7 +245,7 @@ static void LPTIAGainCtrl(uint8_t ret){
data = 1;
}
code = (code & (~mask)) | (data << 5);
code = (code) | ((uint32_t)(data) << 5);
select_REG(LPTIACON0); //LPTIACON0
w32_REG(code);
@@ -750,7 +749,7 @@ static void AutoChangeLPTIAGain(int32_t RealCurrent){
else if (RealCurrent < LPTIA_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*LPTIA_GAIN_MID2_BOUNDARY1){
I_GAIN_100K_counter++;
if(I_GAIN_100K_counter > 2){
instru.ADCGainLv = LPRTIA_12K;
instru.ADCGainLv = LPRTIA_40K;
LPTIAGainCtrl(instru.ADCGainLv);
I_GAIN_100K_counter = 0;
}
@@ -759,7 +758,7 @@ static void AutoChangeLPTIAGain(int32_t RealCurrent){
else{
I_GAIN_3K_counter++;
if(I_GAIN_3K_counter > 2){
instru.ADCGainLv = LPRTIA_4K;
instru.ADCGainLv = LPRTIA_3K;
LPTIAGainCtrl(instru.ADCGainLv);
I_GAIN_3K_counter = 0;
}
@@ -776,7 +775,7 @@ static void AutoChangeLPTIAGain(int32_t RealCurrent){
}
}
}
else if(instru.ADCGainLv == LPRTIA_4K){
else if(instru.ADCGainLv == LPRTIA_3K){
// switch to 4 level current(large)
if(RealCurrent > LPTIA_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*LPTIA_GAIN_MID2_BOUNDARY2){
I_GAIN_100R_counter++;
@@ -800,7 +799,7 @@ static void AutoChangeLPTIAGain(int32_t RealCurrent){
else{
I_GAIN_100K_counter++;
if(I_GAIN_100K_counter > 2){
instru.ADCGainLv = LPRTIA_12K;
instru.ADCGainLv = LPRTIA_40K;
LPTIAGainCtrl(instru.ADCGainLv);
I_GAIN_100K_counter = 0;
}
@@ -817,7 +816,7 @@ static void AutoChangeLPTIAGain(int32_t RealCurrent){
}
}
}
else if(instru.ADCGainLv == LPRTIA_12K){
else if(instru.ADCGainLv == LPRTIA_40K){
// switch to 1 level current(small)
if(RealCurrent < LPTIA_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*LPTIA_GAIN_MID1_BOUNDARY1){
I_GAIN_3M_counter++;
@@ -841,7 +840,7 @@ static void AutoChangeLPTIAGain(int32_t RealCurrent){
else{
I_GAIN_3K_counter++;
if(I_GAIN_3K_counter > 2){
instru.ADCGainLv = LPRTIA_4K;
instru.ADCGainLv = LPRTIA_3K;
LPTIAGainCtrl(instru.ADCGainLv);
I_GAIN_3K_counter = 0;
}
@@ -873,7 +872,7 @@ static void AutoChangeLPTIAGain(int32_t RealCurrent){
else if(RealCurrent > LPTIA_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*LPTIA_GAIN_MID1_BOUNDARY2){
I_GAIN_3K_counter++;
if(I_GAIN_3K_counter > 2){
instru.ADCGainLv = LPRTIA_4K;
instru.ADCGainLv = LPRTIA_3K;
LPTIAGainCtrl(instru.ADCGainLv);
I_GAIN_3K_counter = 0;
}
@@ -882,7 +881,7 @@ static void AutoChangeLPTIAGain(int32_t RealCurrent){
else{
I_GAIN_100K_counter++;
if(I_GAIN_100K_counter > 2){
instru.ADCGainLv = LPRTIA_12K;
instru.ADCGainLv = LPRTIA_40K;
LPTIAGainCtrl(instru.ADCGainLv);
I_GAIN_100K_counter = 0;
}
@@ -117,8 +117,8 @@ struct HEADSTAGE_INSTRUCTION {
// EIS LPTIA Iin Gain Level //
#define LPRTIA_512K 0x00
#define LPRTIA_12K 0x01
#define LPRTIA_4K 0x02
#define LPRTIA_40K 0x01
#define LPRTIA_3K 0x02
#define LPRTIA_200R 0x03
#define LPRTIA_GAIN_AUTO 0x04
@@ -440,9 +440,9 @@ characteristic change event
// product information
#define DEVICE_NAME "Elite"
#define MAJOR_PRODUCT_NUMBER 0 //0:Elite ,1:Neulive
#define MINOR_PRODUCT_NUMBER 2 //1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat 4:Elite_EIS
#define MINOR_PRODUCT_NUMBER 4 //1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat 4:Elite_EIS
#define MAJOR_VERSION_NUMBER 1
#define MINOR_VERSION_NUMBER 6
#define MINOR_VERSION_NUMBER 0
#define ELITE_VERSION_EIS
//#define ELITE_VERSION_1_4
//#define ELITE_VERSION_1_3