📄 e1.c
字号:
InputStr -= f2; /*去掉空格*/ *InputStr = '\0';}#define GET_BUFF_SIZE 80const char *GetWord(const char *InputStr);const char *GetWord(const char *InputStr) /*抓一个word,返回首地址*/{ static char buff[GET_BUFF_SIZE]; char *wptr = buff; int i; i = 0; while( (*InputStr != '\0') && (i < GET_BUFF_SIZE) ) { if( *InputStr != ' ') { while( (*InputStr != '\0') && (*InputStr != ' ') ) { *wptr++ = *InputStr++; } break; } InputStr++; i++; } *wptr = '\0'; return buff;}const char *SkipWord(const char *InputStr);const char *SkipWord(const char *InputStr){ while( *InputStr != '\0' ) { if( *InputStr == ' ') { do { InputStr++; } while( *InputStr == ' ' ); break; } InputStr++; } return InputStr;}UINT MatchCmd( const char *des, const char *sur);UINT MatchCmd( const char *des, const char *sur){ UINT len; len = strlen(des); if(len >= 1) if( 0 == strncmp(des, sur, len) ) return 0; return 1;}UINT MatchCmdTab( const char *msg, CMD_TABLE *cmd, UINT cmds);UINT MatchCmdTab( const char *msg, CMD_TABLE *cmd, UINT cmds){ UINT i; for( i = 0; i < cmds; i++ ) { if( MatchCmd(msg,cmd[i].cmd) == 0 ) break; } return i;}void PrintMoreHelp(XAVI_CMD *cmdptr);void PrintMoreHelp(XAVI_CMD *cmdptr){ printf("%-16s - %s\n",cmdptr->cmd,cmdptr->cmdhelp); }UINT IndexValue(XAVI_CMD *cmd,UINT value);UINT IndexValue(XAVI_CMD *cmd,UINT value){ UINT i; for( i = 0; i < cmd->maxcmds; i++ ) { if( value == (cmd->cmdtable)[i].value ) break; } return i;}const UCHAR* GetValueStr(XAVI_CMD *cmd,UINT value);const UCHAR* GetValueStr(XAVI_CMD *cmd,UINT value){ UINT i; static UCHAR null[80]; i = IndexValue(cmd,value); if( i < cmd->maxcmds) return (cmd->cmdtable)[i].cmd; sprintf(null,"0x%X",value); return null;}BOOL RunCmd( const char *msg, XAVI_CMD *cmd,int *value);//1008BOOL RunCmd( const char *msg, XAVI_CMD *cmd,int *value)//1008{ #ifdef DRV_DEBUG UINT x; #endif UINT i; i = MatchCmdTab(msg,cmd->cmdtable,cmd->maxcmds); if( i < cmd->maxcmds ) { *value = (cmd->cmdtable)[i].value; return TRUE; //1008 } else { #ifdef DRV_DEBUG i = sscanf(msg,"0x%x",&x); if( 0 == i ) { PrintMoreHelp(cmd); if( 0 != strlen(msg) ) { printf("error prompt '%s'\n",msg); } printf("%16s is '%s'\n","now",GetValueStr(cmd,*value)); } else { *value = x; } #else if( strlen(msg) == 0 ) {//1008 printf("%s is '%s'\n",cmd->cmd,GetValueStr(cmd,*value)); return FALSE;//1008 }//1008 else {//1008 printf("Invalid prompt '%s',trp 'help %s'\n",msg,cmd->cmd); return FALSE;//1008 }//1008 #endif }}int SystemDefault(E1 *e1);#define BT8370_RESET_INTERVAL 100void reset_bt8370(void);void reset_bt8370(void){ un_bt8370_reg bt; /*reset的过程 1。先设register crc0的reset位为0 2。延时6us 3.reset 在设为1*/ BGET(cr0); bt.cr0.reset = 0; BSET(cr0); timer_ms_wait(BT8370_RESET_INTERVAL); /*定义BT8370_reset_interval 为100*/ bt.cr0.reset = 1; BSET(cr0); timer_ms_wait(BT8370_RESET_INTERVAL); //do ( BGET(cr0); } while( bt.cr0.reset ); BGET(cr0); if( bt.cr0.reset ) /*reset后reset位应该置0,若仍为1,则报reset error*/ kprintf("Reset BT8370 Fail !\n"); //fr8370_ptr->liu_conf->rst_liu=1;}void init_bt8370(void);void init_bt8370(void){ U8 i,j,k; un_bt8370_reg bt; /*un_bt8370_reg是一个union类型数据*/ reset_bt8370(); /* initialize Bt8370 */ bt8370.jat_cr = 0xa4; /* 002 */ bt8370.ier4 = 0xff; /* 00F */ bt8370.ier3 = 0x00; /* 010 */ bt8370.ier2 = 0x00; /* 011 */ bt8370.ier1 = 0x00; /* 012 */ //bt8370.ier0 = 0x3f; /* 012 */ bt8370.loop = 0x00; /* 014 */ bt8370.dl3_ts = 0x00; /* 015 */ bt8370.dl3_bit = 0xFF; /* 016 */ bt8370.pio = 0xFD; /* 018 */ bt8370.poe = 0x38; /* 019 */ bt8370.cmux = 0x08; //0x0A /* 01A */ bt8370.tmux = 0x00; /* 01B */ bt8370.test = 0x00; /* 01C */ bt8370.lpf = 0x33; /* 023 */ bt8370.vga_max = 0x1D; /* 024 */ bt8370.eq_dat = 0x00; /* 025 */ bt8370.eq_ptr = 0x07; /* 026 */ bt8370.dslice = 0xBA; /* 027 */ bt8370.eq_out = 0xDA; /* 028 */ bt8370.pre_eq = 0xA6; /* 02A */ bt8370.rlb = 0x00; /* 042 */ bt8370.ralm = 0x00; /* 045 */ bt8370.latch = 0x07; /* 046 */ bt8370.terror = 0x00; /* 073 */ bt8370.tman = 0x00; /* 074 */ bt8370.talm = 0x00; /* 075 */ bt8370.tpatt = 0x00; /* 076 */ bt8370.tlb = 0x00; /* 077 */ bt8370.tsa4 = 0xFF; /* 07B */ bt8370.tsa5 = 0xFF; /* 07C */ bt8370.tsa6 = 0xFF; /* 07D */ bt8370.tsa7 = 0xFF; /* 07E */ bt8370.tsa8 = 0xFF; /* 07F */ bt8370.cphase = 0x67; /* 092 */ bt8370.ctest =0x00; /* 093 */ bt8370.bop =0x00; /* 0A0 */ bt8370.tbop = 0x00; /* 0A1 */ bt8370.dl1_bit = 0x00; /* 0A5 */ bt8370.prm=0x00; /* 0AA */ bt8370.tdl1_eom =0xFF; /* 0AC */ bt8370.tdl1 = 0xFF; /* 0AD */ bt8370.dl2_ts = 0x00; /* 0AF */ bt8370.dl2_bit=0x00; /* 0B0 */ bt8370.dl2_ctl=0x00; /* 0B1 */ bt8370.rdl2_ffc=0x00; /* 0B2 */ bt8370.tdl2_fec=0x00; /* 0B6 */ bt8370.tdl2_eom = 0xFF; /* 0B7 */ bt8370.tdl2 = 0xFF; /* 0B8 */ bt8370.dl_test1 =0x00; /* 0BA */ bt8370.dl_test2 = 0x00; /* 0BB */ bt8370.dl_test3 = 0x00; /* 0BC */ bt8370.dl_test4 = 0x00; /* 0BD */ bt8370.dl_test5 = 0x00; /* 0BE */ bt8370.rsb_cr = 0x80; /* 0D1 */ bt8370.rsync_bit = 0x00; /* 0D2 */ bt8370.rsync_ts = 0x00; /* 0D3 */ bt8370.tsb_cr = 0x80; /* 0D4 */ bt8370.tsync_bit = 0x00; /* 0D5 */ bt8370.tsync_ts = 0x00; /* 0D6 */ bt8370.rsync_frm = 0x00; /* 0D8 */ bt8370.rsig_cr = 0x01; /* 0D7 */ //?? /* E1 ram */ for ( i=1 ; i <= 31; i++) { bt8370.sbc[i] = 0x00; } /* RAM Buffer Information */ bt8370.sbc[0]= 0x01; /* 0E0 */ for ( i=25 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.sbc[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.tpc[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.tsig[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.tslip_lo[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.tslip_hi[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.rpc[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.rsig[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.rslip_lo[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* For F9-100 SBC */ { bt8370.rslip_hi[i] = 0x00; } /* E1 Specific */ //bt8370.cr0 = 0x08; /* 001 */ bt8370.ier7 = 0xf6; /* 00C */ //bt8370.ier7 = 0x06; /* 00C */ bt8370.ier6 = 0x00; /* 00D */ bt8370.ier5 = 0x00; /* 00E */ bt8370.ier0 = 0x3f; /* 013 */ bt8370.eq_dat = 0xfa; /* 025 */ bt8370.liu_cr = 0xC1; /* 020 */ // Reset RLIU bt8370.liu_cr = 0x41; /* 020 */ bt8370.rliu_cr = 0x31; /* 022 */ //******************************another add***************0404******************* bt8370.gain[0] = 0x16; /* 038 */ bt8370.gain[1] = 0x1F; /* 039 */ bt8370.gain[2] = 0x21; /* 03a */ bt8370.gain[3] = 0x24; /* 03b */ bt8370.gain[4] = 0x26; /* 03c */ bt8370.rcr0 = 0x59;//0x19 frame mode; /* 040 */ bt8370.rpatt = 0x39; /* 041 */ bt8370.lba = 0x08; /* 043 */ bt8370.lbd = 0x24; /* 044 */ bt8370.tliu_cr = 0x4C; /* 068 */ bt8370.shape[0] = 0x18; /* 060 */ bt8370.shape[1] = 0x18; /* 061 */ bt8370.shape[2] = 0x18; /* 062 */ bt8370.shape[3] = 0x18; /* 063 */ bt8370.shape[4] = 0; /* 064 */ bt8370.shape[5] = 0; /* 065 */ bt8370.shape[6] = 0; /* 066 */ bt8370.shape[7] = 0; /* 067 */ bt8370.tcr0 = 0x04; /* 070 */ bt8370.tcr1 = 0x51; /* 071 */ bt8370.tfrm = 0x00; //0x0F frame mode; /* 072 */ bt8370.lbp = 0x7A; /* 078 */ bt8370.clad_cr = 0x08; /* 090 */ bt8370.csel = 0x11; /* 091 */ bt8370.dl1_ts = 0x00; /* 0A4 */ bt8370.dl1_ctl = 0x00; /* 0A6 */ bt8370.rdl1_ffc =0x00 ; /* 0A7 */ bt8370.tdl1_fec = 0x00; /* 0AB */ bt8370.sbc[0] = 0x01; bt8370.sbi_cr = 0x46; /* 0D0 */ bt8370.rsig_cr = 0x00; /* 0D7 */ //device=fr8370_mode_ptr->version->hardware_part_number; //device_rev=fr8370_mode_ptr->version->hardware_rev_number; /* E1 needs SBC25-32 and TPC0 to be 0x01 */ for ( i=25 ; i <= 32; i++) /* For F9-100 SBC */ { bt8370.sbc[i] = 0x01; } /********************************** another add 0404***********************/ for ( i=0 ; i <= 31; i++) /*0E0~0FF*/ { bt8370.sbc[i] = 0x01; } bt8370.tpc[0] = 0x01;//E1 is 0x01,T1 is 0x0f for ( i=1 ; i <= 31; i++) { bt8370.tpc[i] = 0x00; /*100~11F*/ //E1 is 0x00,T1 is 0x0f } for ( i=0 ; i <= 31; i++) /*0E0~0FF*/ { bt8370.tsig[i] = 0x0f; /* 120 - 13F */ } for ( i=0 ; i <= 31; i++) /* 140 - 15F */ { bt8370.tslip_lo[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* 160 - 17F */ { bt8370.tslip_hi[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* 180 - 19F */ { bt8370.rpc[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* 1A0 - 1BF */ { bt8370.rsig[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* 1C0 - 1DF */ { bt8370.rslip_lo[i] = 0x00; } for ( i=0 ; i <= 31; i++) /* 1E0 - 1FF */ { bt8370.rslip_hi[i] = 0x00; } /* e1->fmode=2; e1->tliu=0x4c; e1->rliu=I431; e1->cmux=0x0f; e1->cladi=CLADI_2048; e1->clado=CLADO_2048B; */ ////////////////////////////////////////////////////implement RLIU Long and Short Haul coefficients start///////////////////// /*Re-load the default settings for Long Haul Adaptive mode*/ bt.byte = 0x31; BSET(rliu_cr); /*Set VGA_MAX for Long Haul setting.*/ bt.byte = 0x34; BSET(vga_max); /*Load the default values for the GAIN Thresholds.*/ bt.byte = 0x16; BSET(gain[0]); bt.byte = 0x1f; BSET(gain[1]); bt.byte = 0x21; BSET(gain[2]); bt.byte = 0x24; BSET(gain[3]); bt.byte = 0x26; BSET(gain[4]); /*Load the default pre-load coefficients. */ bt.byte = 0x0; BSET(eq_ptr); for(i = 0,j=0,k=0; k<48; i++,k++) { bt.byte = k; BSET(eq_ptr); bt.byte = aCoeff_default[j][i]; BSET(eq_dat); if(i > 7) { j++; i = 0; } } /*Turn on PRE_EQ when VGA >= 0x28 (about 26 dB) and turn off when VGA is <=0x24 (about 21 dB).*/ /*Monitor PRE_EQ to manually turn it on or off. */ //preEqMonitor(&e1); /*RESET LIU (RST_LIU)*/ bt.byte = 0xC1; BSET(liu_cr); bt.byte = 0x41; BSET(liu_cr); /*Save the VGA value.*/ //iVga_old = iVga_new; /*Set the state to Long Haul settings.*/ //iEqState = LONG_HAUL_STATE; //kprintf("Initialise to long_haul!\n"); ////////////////////////////////////////////////////implement RLIU Long and Short Haul coefficients end///////////////////// }////////////////////////////////////////////////////implement RLIU Long and Short Haul coefficients start/////////////////////void preEqMonitor(void);void coeffWrite(void);void long_haul(void);void short_haul(void);void eqCoeff(void);void eqCoeff(void){ un_bt8370_reg bt; BGET(vga); iVga_new = bt.byte & 0x3f; if(rliu_haul) if( iVga_new != iVga_temp ) { kprintf("iVga_old =0x%x\n",iVga_temp); kprintf("iVga_new =0x%x\n",iVga_new); kprintf("----------------\n"); } iVga_temp = iVga_new; /* Beginning of the state machine */ switch(iEqState) { case SHORT_HAUL_STATE: /** Short Haul State **/ { short_haul(); break; } case LONG_HAUL_STATE: /* Long Haul, Adaptive state */ { long_haul(); break; } default: { iEqState = LONG_HAUL_STATE; break; } } /* End of the state machine */}/*************************************************************************Function: void long_haul(tT1E1_DEV *pT1E1Dv)*Desc: Checks the VGA and if VGA <= 0x1d and RALOS_CNT == 0 loads theShort Haul * settings and sets the state to Short Haul state.*Called by: eqCoeff().*Calls to: none*Input parameters: pointer to bt8370 device.*Output parameLineters: none************************************************************************/void long_haul(void){ un_bt8370_reg bt; //if( iVga_new <= 0x14 ) if( iVga_new <= 0x1d ) { /*Load the setting for Short Haul.*/ /*Freezing the equalizer from adapting. */ bt.byte = 0x39; BSET(rliu_cr); /* Keep the VGA at 0x34 for Long Haul applications (0 to
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -