⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nvr4101siusio.c

📁 IXP425的BSP代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    }/********************************************************************************* nvr4101SIUInt - interrupt level processing** This routine handles interrupts from the SIU.** RETURNS: N/A*/void nvr4101SIUInt    (    NVR4101_SIU_CHAN *pChan    )    {    UINT16 	statusReg;    char	outChar;    /* get status from the SIU (not ICU) subsystem.  */    statusReg = *VR4101_SIUINTREG;    /* write status value back out to clear the various sources */    *VR4101_SIUINTREG = statusReg;    /* handle receiver interrupt */    if (statusReg & RX_INT_SOURCES)	{	(*pChan->putRcvChar) (pChan->putRcvArg, 			      nvr4101SIURxWordToChar (*VR4101_SIURXDATREG));	}    /* handle transmitter interrupt */    if (statusReg & TX_INT_SOURCES)	{	/* Disable the sequencer */	*VR4101_SIUCNTREG &= ~VR4101_SIU_TXE;	if ((*pChan->getTxChar) (pChan->getTxArg, &outChar) != ERROR)	    {	    /* transmit the next character */	    nvr4101SIUTxOutput (pChan, outChar);	    }	else	    {	    /* note that TxStartup will need to generate next character */	    pChan->txActive = FALSE;	    }	}    }/********************************************************************************* nvr4101SIUTxStartup - transmitter startup routine.** This routine is called to restart data output.  the VR4101 does not* provide a mechanism to regenerate a transmit interrupt, so this* function needs to perform the work involved in setting up the data* transmission.** RETURNS: OK, or ENOSYS if in polled mode.*/LOCAL int nvr4101SIUTxStartup    (    NVR4101_SIU_CHAN *pChan     )    {    char outChar;    int oldLevel;    if (pChan->channelMode == SIO_MODE_INT)	{	oldLevel = intLock ();	/* ignore request if expecting transmitter interrupt */	if (pChan->txActive)	    {	    intUnlock (oldLevel);	    return (OK);	    }	/* mark that we've started transmission */	pChan->txActive = TRUE;	intUnlock (oldLevel);	/* initiate transmission of the next character */	(void) (*pChan->getTxChar) (pChan->getTxArg, &outChar);	nvr4101SIUTxOutput (pChan, outChar);	return (OK);	}    else	{	return (ENOSYS);	}    }/******************************************************************************** nvr4101SIUTxOutput - Transmit requested character.* * This function sets up the transmitter to send the requested character.** RETURNS: N/A*/LOCAL void nvr4101SIUTxOutput    (    NVR4101_SIU_CHAN *pChan,    char outChar    )    {    UINT32 txAdr;    /* encode the character, and place in the output buffer */    *pChan->pTxWord = nvr4101SIUCharToTxWord (outChar);	        /* write the buffer address to the the DMA address registers. */        txAdr = K0_TO_K1 (pChan->pTxWord);    *VR4101_STXDMAADRLREG = (UINT16) txAdr;    *VR4101_STXDMAADRHREG = (UINT16) (txAdr >> 16);    /* start the transmit sequencer */    *VR4101_SIUCNTREG |= VR4101_SIU_TXE;    }/******************************************************************************** nvr4101SIUPollOutput - output a character in polled mode.** RETURNS: OK if a character arrived, EIO on device error, EAGAIN*          if the output buffer if full.*/LOCAL int nvr4101SIUPollOutput    (    NVR4101_SIU_CHAN *  pChan,    char            outChar    )    {    /* if haven't gotten DMA interrupt, we're still transmitting */    if (pChan->txActive && 	((*VR4101_SIUINTREG & TX_INT_SOURCES) == 0))	return (EAGAIN);    /* mark that we're starting transmission */    pChan->txActive = TRUE;    /* clear the interrupt bits */    *VR4101_SIUINTREG = TX_INT_SOURCES;    /* disable the sequencer */    *VR4101_SIUCNTREG &= ~VR4101_SIU_TXE;    /* ok to send the character */    nvr4101SIUTxOutput (pChan, outChar);    return (OK);    }/******************************************************************************** nvr4101SIUPollInput - poll the device for input.** RETURNS: OK if a character arrived, EIO on device error, EAGAIN*          if the input buffer if empty.*/LOCAL int nvr4101SIUPollInput    (    NVR4101_SIU_CHAN *  pChan,    char *          thisChar    )    {    /* if no receiver interrupt, no character */    if (!(*VR4101_SIUINTREG & RX_INT_SOURCES))	return (EAGAIN);    /* clear the interrupt */    *VR4101_SIUINTREG = RX_INT_SOURCES;    /* read the character */    *thisChar = nvr4101SIURxWordToChar (*VR4101_SIURXDATREG);    return (OK);    }/******************************************************************************** nvr4101SIUCallbackInstall - install ISR callbacks to get/put chars.*/LOCAL int nvr4101SIUCallbackInstall    (    SIO_CHAN *  pSioChan,    int         callbackType,    STATUS      (*callback)(),    void *      callbackArg    )    {    NVR4101_SIU_CHAN * pChan = (NVR4101_SIU_CHAN *) pSioChan;    switch (callbackType)        {        case SIO_CALLBACK_GET_TX_CHAR:            pChan->getTxChar    = callback;            pChan->getTxArg     = callbackArg;            return (OK);        case SIO_CALLBACK_PUT_RCV_CHAR:            pChan->putRcvChar   = callback;            pChan->putRcvArg    = callbackArg;            return (OK);        default:            return (ENOSYS);        }    }/******************************************************************************** nvr4101SIUIntMask - Mask interrupts from the SIU.* * This function masks all possible interrupts from the SIU subsystem.** RETURNS: N/A*/void nvr4101SIUIntMask()    {    int oldLevel;    oldLevel = intLock ();    *VR4101_ICU_MSIUINTREG &= ~(RX_INT_SOURCES | TX_INT_SOURCES);    intUnlock (oldLevel);    }/******************************************************************************** nvr4101SIUIntUnmask - Unmask interrupts from the SIU.* * This function unmasks all desired interrupts from the SIU subsystem.** RETURNS: N/A*/		void nvr4101SIUIntUnmask()    {    int oldLevel;    oldLevel = intLock ();    *VR4101_ICU_MSIUINTREG |= (RX_INT_SOURCES | TX_INT_SOURCES);    intUnlock (oldLevel);    }/******************************************************************************** nvr4101SIUCharToTxWord - Translate character to output word format.* * This routine performs the bit manipulations required to convert * a character into the output word format required by the SIU.  * This routine only supports 8-bit word lengths, two stop bits* and no parity.** RETURNS: The translated output character.*/UINT16 nvr4101SIUCharToTxWord    (    char outChar    )    {    /* char --> [1][char][0] */    return ((0x100 | (UINT16) outChar) << 1);    }/******************************************************************************** nvr4101SIURxWordToChar - Extract character from received word.* * This function performs the bit manipulations required to extract* the received character from its encoded word.  This routine only* supports 8-bit word lengths, one stop bit and no parity.** RETURNS: The received character.*/LOCAL char nvr4101SIURxWordToChar    (    UINT16 inWord    )    {    return (char) (inWord >> 8);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -