?? mt8986lib.c
字號:
/* mt8986Lib.c - MT89L86 timeslot switcher initialization
*
* Copyright 2004-2007 ZTE, Inc.
* author: ZhengQishan
* date: 2004.02
*
* modification history
*------------------------------
*
*/
#include "mt8986.h"
LOCAL STATUS le1ve_MT8986SwitchEnable(unsigned int slotNo,int inStream,int outStream ,int inChannel, int outChannel);
LOCAL STATUS le1ve_MT8986SwitchDisable(unsigned int slotNo,int inStream,int outStream ,int inChannel, int outChannel);
STATUS le1veMt8986Init(int slot )
{
int stream,channel;
STATUS result = OK;
/*TDM交換網初始化*/
/*Interface Mode Selection Register:
bit7: Device Main Operation(DMO).
if 1 - Different I/O data rate.
bit6-5:Input Data Rate Selection.
0 0 2.048 Mb/s
0 1 4.096 Mb/s
1 0 8.192 Mb/s
1 1 reserved
bit4-3 ODR1 ODR0 Output Rate
0 0 2.048 Mb/s
0 1 4.096 Mb/s
1 0 8.192 Mb/s
1 1 reserved
bit2-1: 00b - 8 inputs x 8 outputs - Non Blocking
bit0:Clock Mode. 硬件要求配置為0
*/
LE1VE_MT89L86_REG_WRITE(slot, MT89L86_IMSR_REG, 0x00);
/*Stream Pair Selection Register:
bit7-6 reserved
bit5-3 Stream Pair A selection.
bit2-0 Stream Pair B selection.
我們不會用到
*/
LE1VE_MT89L86_REG_WRITE(slot, MT89L86_SPSR_REG, 0x01);
/*Frame Input Offset Register
bit7-5:Offset Bits 2-0.
OFB2 OFB1 OFB0 Number of Clock Periods
0 0 0 Normal Operation. No bit offsetting.
0 0 1 1
0 1 0 2
0 1 1 3
1 0 0 4
1 0 1 Reserved
1 1 0 Reserved
1 1 1 Reserved
根據物理信號配置
*/
LE1VE_MT89L86_REG_WRITE(slot, MT89L86_FIOR_REG, 0x00);
/*-------------------------------------------------
disable掉所有的8個Stream的所有32個時隙
-------------------------------------------------*/
for(stream = 0; stream<= 8; stream++)
{
for(channel = 0; channel<=31; channel++)
{
LE1VE_MT89L86_REG_WRITE(slot, MT89L86_CTRL_REG, 0x10|(1<<3)|stream);
LE1VE_MT89L86_REG_WRITE(slot, (MT89L86_CHAN_REG_BASE + channel)*4, 0x00);
}
}
/*debug*/
enableMt8986(slot);
return result;
}
LOCAL STATUS le1ve_MT8986SwitchEnable(unsigned int slotNo,int inStream,int outStream ,int inChannel, int outChannel)
{
if (slotNo>8)
return ERROR;
/*添加控制*/
/*Stream#in ,Connection Low */
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|inStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+inChannel)*4,((outStream<<5)|outChannel));
/*Stream#out ,Connection Low*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|outStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+outChannel)*4,((inStream<<5)|inChannel));
/*Stream#In ,Connection High*/
/*Connection Memory High bit0: 1- OE enables the output drivers on a per-channel basis.
0 - disable*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|(1<<3)|inStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+inChannel)*4,0x1);
/*Stream#Out ,Connection High*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|(1<<3)|outStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+outChannel)*4,0x1);
return OK;
}
LOCAL STATUS le1ve_MT8986SwitchDisable(unsigned int slotNo,int inStream,int outStream ,int inChannel, int outChannel)
{
if (outStream == 0x02)
{
/*Stream#In ,Connection High*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|(1<<3)|inStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+inChannel)*4,0x00);
/*Stream#out Connection High*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|(1<<3)|outStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+outChannel)*4,0x00);
/*Stream#out ,Connection Low*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|outStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+outChannel)*4,0x055);
/*Stream#out Connection High*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|(1<<3)|outStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+outChannel)*4,0x05);
}
else
{
/*Stream#In ,Connection High*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|(1<<3)|inStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+inChannel)*4,0x00);
/*Stream#out Connection High*/
LE1VE_MT89L86_REG_WRITE(slotNo,MT89L86_CTRL_REG,0x10|(1<<3)|outStream);
LE1VE_MT89L86_REG_WRITE(slotNo,(MT89L86_CHAN_REG_BASE+outChannel)*4,0x00);
}
return OK;
}
/*====================================DEBUG==============================*/
void enableMt8986(int slot)
{
int inStream, outStream, chan;
if (slot > 8 )
{
printf("Error slot number!\n");
return;
}
for (inStream = 0; inStream < 4; inStream ++)
{
outStream = inStream + 4;
for (chan = 0; chan <= 31; chan ++)
le1ve_MT8986SwitchEnable(slot, inStream, outStream, chan, chan);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -