diff options
author | wmeadows <wmeadows@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2003-09-03 21:08:07 +0000 |
---|---|---|
committer | wmeadows <wmeadows@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2003-09-03 21:08:07 +0000 |
commit | b92cedfb41980df16f45381949f263ac9f4a1fc1 (patch) | |
tree | 719b049b96abce35c572447042e7ba4363b51b6f /wctdm.c | |
parent | 4e7d8961e2949b5dd88b150b679b7800e8f30401 (diff) |
Try Manual Calibration Routines
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@239 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wctdm.c')
-rwxr-xr-x | wctdm.c | 80 |
1 files changed, 78 insertions, 2 deletions
@@ -644,6 +644,80 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card) } +static int wcfxs_manual_calibrate(struct wcfxs *wc, int card){ + unsigned long origjiffies; + unsigned char i; + + wcfxs_setreg(wc, card, 21, 0);//(0) Disable all interupts in DR21 + wcfxs_setreg(wc, card, 22, 0);//(0)Disable all interupts in DR21 + wcfxs_setreg(wc, card, 23, 0);//(0)Disable all interupts in DR21 + wcfxs_setreg(wc, card, 64, 0);//(0) + + wcfxs_setreg(wc, card, 97, 0x18); //(0x18)Calibrations without the ADC and DAC offset and without common mode calibration. + wcfxs_setreg(wc, card, 96, 0x47); //(0x47) Calibrate common mode and differential DAC mode DAC + ILIM + + origjiffies=jiffies; + while( wcfxs_getreg(wc,card,96)!=0 ){ + if((jiffies-origjiffies)>80) + return -1; + } +//Initialized DR 98 and 99 to get consistant results. +// 98 and 99 are the results registers and the search should have same intial conditions. + +/*******************************The following is the manual gain mismatch calibration****************************/ +/*******************************This is also available as a function *******************************************/ + // Delay 10ms + origjiffies=jiffies; + while((jiffies-origjiffies)<1); + wcfxs_setreg_indirect(wc, card, 88,0); + wcfxs_setreg_indirect(wc,card,89,0); + wcfxs_setreg_indirect(wc,card,90,0); + wcfxs_setreg_indirect(wc,card,91,0); + wcfxs_setreg_indirect(wc,card,92,0); + wcfxs_setreg_indirect(wc,card,93,0); + + wcfxs_setreg(wc, card, 98,0x10); // This is necessary if the calibration occurs other than at reset time + wcfxs_setreg(wc, card, 99,0x10); + + for ( i=0x1f; i>0; i--) + { + wcfxs_setreg(wc, card, 98,i); + origjiffies=jiffies; + while((jiffies-origjiffies)<4); + if((wcfxs_getreg(wc,card,88)) == 0) + break; + } // for + + for ( i=0x1f; i>0; i--) + { + wcfxs_setreg(wc, card, 99,i); + origjiffies=jiffies; + while((jiffies-origjiffies)<4); + if((wcfxs_getreg(wc,card,89)) == 0) + break; + }//for + +/*******************************The preceding is the manual gain mismatch calibration****************************/ +/**********************************The following is the longitudinal Balance Cal***********************************/ + wcfxs_setreg(wc,card,64,1); + while((jiffies-origjiffies)<10); // Sleep 100? + + wcfxs_setreg(wc, card, 64, 0); + wcfxs_setreg(wc, card, 23, 0x4); // enable interrupt for the balance Cal + wcfxs_setreg(wc, card, 97, 0x1); // this is a singular calibration bit for longitudinal calibration + wcfxs_setreg(wc, card, 96,0x40); + + wcfxs_getreg(wc,card,96); /* Read Reg 96 just cause */ + + wcfxs_setreg(wc, card, 21, 0xFF); + wcfxs_setreg(wc, card, 22, 0xFF); + wcfxs_setreg(wc, card, 23, 0xFF); + + /**The preceding is the longitudinal Balance Cal***/ + return(0); + +} +#if 0 static int wcfxs_calibrate(struct wcfxs *wc, int card) { unsigned long origjiffies; @@ -672,7 +746,7 @@ static int wcfxs_calibrate(struct wcfxs *wc, int card) } return 0; } - +#endif static int wcfxs_init_proslic(struct wcfxs *wc, int card) { @@ -732,7 +806,7 @@ static int wcfxs_init_proslic(struct wcfxs *wc, int card) } #ifndef NO_CALIBRATION /* Perform calibration */ - if (wcfxs_calibrate(wc, card)) { + if (wcfxs_manual_calibrate(wc, card)) { printk("ProSlic died on Calibration.\n"); return -1; } @@ -808,6 +882,8 @@ static inline void wcfxs_check_hook(struct wcfxs *wc, int card) if (!res && (res != wc->lasttxhook[card])) { if (wc->palarms[card]++ < MAX_ALARMS) { printk("Power alarm on module %d, resetting!\n", card + 1); + if (wc->lasttxhook[card] == 4) + wc->lasttxhook[card] = 1; wcfxs_setreg(wc, card, 64, wc->lasttxhook[card]); } else { if (wc->palarms[card] == MAX_ALARMS) |