📄 patchi2c.c
字号:
*((unsigned long *)(immr + 0x2138)) = 0x6a29df61;
*((unsigned long *)(immr + 0x213c)) = 0xe7c9edf9;
*((unsigned long *)(immr + 0x2140)) = 0x7e9a30d5;
*((unsigned long *)(immr + 0x2144)) = 0x1458bfff;
*((unsigned long *)(immr + 0x2148)) = 0xf3c85fff;
*((unsigned long *)(immr + 0x214c)) = 0xdfffa7f8;
*((unsigned long *)(immr + 0x2150)) = 0x5f5bbffe;
*((unsigned long *)(immr + 0x2154)) = 0x7f7d10d0;
*((unsigned long *)(immr + 0x2158)) = 0x144d5f33;
*((unsigned long *)(immr + 0x215c)) = 0xbfffaf78;
*((unsigned long *)(immr + 0x2160)) = 0x5f5bbffd;
*((unsigned long *)(immr + 0x2164)) = 0xa7f85f33;
*((unsigned long *)(immr + 0x2168)) = 0xbffe77fd;
*((unsigned long *)(immr + 0x216c)) = 0x30bd4e08;
*((unsigned long *)(immr + 0x2170)) = 0xfdcfe5ff;
*((unsigned long *)(immr + 0x2174)) = 0x6e0faff8;
*((unsigned long *)(immr + 0x2178)) = 0x7eef7e9f;
*((unsigned long *)(immr + 0x217c)) = 0xfdeff1cf;
*((unsigned long *)(immr + 0x2180)) = 0x5f17abf8;
*((unsigned long *)(immr + 0x2184)) = 0x0d5b5f5b;
*((unsigned long *)(immr + 0x2188)) = 0xffef79f7;
*((unsigned long *)(immr + 0x218c)) = 0x309eafdd;
*((unsigned long *)(immr + 0x2190)) = 0x5f3147f8;
*((unsigned long *)(immr + 0x2194)) = 0x5f31afed;
*((unsigned long *)(immr + 0x2198)) = 0x7fdd50af;
*((unsigned long *)(immr + 0x219c)) = 0x497847fd;
*((unsigned long *)(immr + 0x21a0)) = 0x7f9e7fed;
*((unsigned long *)(immr + 0x21a4)) = 0x7dfd70a9;
*((unsigned long *)(immr + 0x21a8)) = 0xef7e7ece;
*((unsigned long *)(immr + 0x21ac)) = 0x6ba07f9e;
*((unsigned long *)(immr + 0x21b0)) = 0x2d227efd;
*((unsigned long *)(immr + 0x21b4)) = 0x30db5f5b;
*((unsigned long *)(immr + 0x21b8)) = 0xfffd5f5b;
*((unsigned long *)(immr + 0x21bc)) = 0xffef5f5b;
*((unsigned long *)(immr + 0x21c0)) = 0xffdf0c9c;
*((unsigned long *)(immr + 0x21c4)) = 0xafed0a9a;
*((unsigned long *)(immr + 0x21c8)) = 0xafdd0c37;
*((unsigned long *)(immr + 0x21cc)) = 0x5f37afbd;
*((unsigned long *)(immr + 0x21d0)) = 0x7fbdb081;
*((unsigned long *)(immr + 0x21d4)) = 0x5f8147f8;
*((unsigned long *)(immr + 0x2f00)) = 0x3e303430;
*((unsigned long *)(immr + 0x2f04)) = 0x34343737;
*((unsigned long *)(immr + 0x2f08)) = 0xabbf9b99;
*((unsigned long *)(immr + 0x2f0c)) = 0x4b4fbdbd;
*((unsigned long *)(immr + 0x2f10)) = 0x59949334;
*((unsigned long *)(immr + 0x2f14)) = 0x9fff37fb;
*((unsigned long *)(immr + 0x2f18)) = 0x9b177dd9;
*((unsigned long *)(immr + 0x2f1c)) = 0x936956bb;
*((unsigned long *)(immr + 0x2f20)) = 0xfbdd697b;
*((unsigned long *)(immr + 0x2f24)) = 0xdd2fd113;
*((unsigned long *)(immr + 0x2f28)) = 0x1db9f7bb;
*((unsigned long *)(immr + 0x2f2c)) = 0x36313963;
*((unsigned long *)(immr + 0x2f30)) = 0x79373369;
*((unsigned long *)(immr + 0x2f34)) = 0x3193137f;
*((unsigned long *)(immr + 0x2f38)) = 0x7331737a;
*((unsigned long *)(immr + 0x2f3c)) = 0xf7bb9b99;
*((unsigned long *)(immr + 0x2f40)) = 0x9bb19795;
*((unsigned long *)(immr + 0x2f44)) = 0x77fdfd3d;
*((unsigned long *)(immr + 0x2f48)) = 0x573b773f;
*((unsigned long *)(immr + 0x2f4c)) = 0x737933f7;
*((unsigned long *)(immr + 0x2f50)) = 0xb991d115;
*((unsigned long *)(immr + 0x2f54)) = 0x31699315;
*((unsigned long *)(immr + 0x2f58)) = 0x31531694;
*((unsigned long *)(immr + 0x2f5c)) = 0xbf4fbdbd;
*((unsigned long *)(immr + 0x2f60)) = 0x35931497;
*((unsigned long *)(immr + 0x2f64)) = 0x35376956;
*((unsigned long *)(immr + 0x2f68)) = 0xbd697b9d;
*((unsigned long *)(immr + 0x2f6c)) = 0x96931313;
*((unsigned long *)(immr + 0x2f70)) = 0x19797937;
*((unsigned long *)(immr + 0x2f74)) = 0x69350000;
}/* end UcodeCopy() */
/**************************************************************
*
* Function Name: RLI2CInit
* Description: I2C Initialization Routine using relocated
* I2C parameters.
* Input Parameters: none
* Return Values: none
*
*************************************************************/
void RLI2CInit()
{
EPPC *immr = (EPPC *) (GetIMMR() & 0xffff0000); /* Get IMMR Value. */
RTXBD *rtx = (RTXBD *) immr->udata_bd_ucode2; /* Pntr to DPRAM BD area */
char *txbuf;
unsigned short *rpbase; /* Pointer to relocated I2C parameters */
struct i2c_pram *rli2cparams; /* Relocated I2C parameters */
unsigned long templong; /* Temporary pointer. */
/* Configure Port B pins to enable I2CSDA and I2CSCL */
immr->pip_pbodr |= (0x0030); /* Set I2CSDA and I2CSCL to open-drain */
immr->pip_pbpar |= (0x00000030);/* Enable I2CSDA and I2CSCL as outputs */
immr->pip_pbdir |= (0x00000030);
/* Get original I2C PRAM base. */
templong = (unsigned long) (& (immr->pram[PAGE1_PRAM].scc.pothers.i2c_idma.i2c) );
templong = templong + 0x0000002c; /* Add offset to RPBASE location. */
rpbase = (unsigned short *) templong; /* Point to RPBASE in old I2C param area */
*rpbase = 0x1fc0; /* Move parameters to DSP2 PRAM area */
/* (Offset from DPRAM base) */
/* Put I2C parameters in DSP2 PRAM area */
rli2cparams = (struct i2c_pram *) (& (immr->pram[PAGE4_PRAM].scc.pothers.smc_modem.modem_param) );
/********************************************************************/
/* Initialize I2C Parameter RAM */
/* I2C Parameter values that must normally be initialized. */
rli2cparams->rfcr = 0x10;
rli2cparams->tfcr = 0x10;
rli2cparams->mrblr = BUFF_MAX_LEN;
rli2cparams->rbase = (unsigned short) & rtx->rxbd[0]; /* point RBASE to first RX BD */
rli2cparams->tbase = (unsigned short) & rtx->txbd; /* point TBASE to TX BD */
/* I2C Parameter values that must initialized when using microcode patch. */
/* Normally, these do not have to be initialized. */
rli2cparams->rstate = 0;
rli2cparams->tstate = 0;
rli2cparams->rbptr = rli2cparams->rbase;
rli2cparams->tbptr = rli2cparams->tbase;
/********************************************************************/
/* I2C Registers */
immr->i2c_i2mod = 0x00; /* Disable I2C before initializing it */
immr->i2c_i2add = 0x80; /* Station address = 0x80 */
immr->i2c_i2brg = 0x20; /* Arbitrary choice of baud rate: BRGCLK/32 */
immr->i2c_i2cer = 0x17; /* Clear out I2C events */
immr->i2c_i2cmr = 0x00; /* Disable interrupts from I2C */
immr->i2c_i2mod = 0x01;
/* Note: Original version of MPC860 manual states that the REVD=1 in */
/* the I2CMOD register sends MSB first (I2C normal operation). This */
/* was an ERRATUM. REVD must be set to zero for normal I2C operation. */
/********************************************************************/
/* I2C Buffers */
/* Init RX BD */
rtx->rxbd[0].bd_length = 0; /* reset */
rtx->rxbd[0].bd_addr = (char *) & rtxbuf[0];/* point RX BD to first RX buffer */
rtx->rxbd[0].bd_cstatus = 0xa000; /* ready and wrap */
/* Init TX BD */
rtx->txbd.bd_length = 0x0019;
rtx->txbd.bd_addr = (char *) & rtxbuf[TXBD_INDX];
txbuf = (char *) rtx->txbd.bd_addr; /* Put address and message in TX buffer */
txbuf[0] = 0x80; /* TX address and write command,Send to our own address 0x80 */
strcpy((txbuf+1), "In-a-gadda-da-vida, baby");
rtx->txbd.bd_cstatus = 0xac00; /* ready, wrap, last, and start */
}/* end RLI2CInit() */
/**************************************************************
* Function Name: I2CStart
* Description: I2C Start routine.
* Sets master mode and starts the transmitter.
* Input Parameters: none
* Return Values: none
*
*************************************************************/
void I2CStart()
{
EPPC *immr = (EPPC *) (GetIMMR() & 0xffff0000); /* Get IMMR Value. */
immr->i2c_i2com = 0x81; /* Set master mode and issue start command */
}/* end I2CStart() */
/**************************************************************
* Function Name: GetIMMR
* Description: Returns the current value in IMMR register.
* Input Parameters: none
* Return Values: none
*
*************************************************************/
GetIMMR()
{
asm(" mfspr r3,638 "); /* IMMR is spr #638 */
} /* end GetIMMR() */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -