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

📄 dss.c

📁 Using DSP/BIOS I/O in Multichannel Systems
💻 C
字号:
/* 
   Copyright Texas Instruments 1998
   Texas Instruments Proprietary Data -- Internal Data
   Jack Greenbaum, TI Santa Barbara, greenbaum@ti.com
*/
/*
 *  ======== dss.c ========
 *! Revision History
 *! ================
 */

#include <std.h>
#include <log.h>
#include <swi.h>
#include <pip.h>
#include "dss_isr.h"

/* Objects from configuration are defined here */
#include "dss.h"
extern far LOG_Obj trace;

PIP_Obj far *txPips[2] =
{
    &txPip0,
    &txPip1
};

PIP_Obj far *rxPips[2] =
{
    &rxPip0,
    &rxPip1
};

Void
DSS_init(Void)
{
    dss_isr_init();
    dss_isr_set_swi_n(&DSS_swi, 0);
    dss_isr_set_swi_n(&DSS_swi, 1);
  
    /* these enable interrupts, maybe a problem? */
    DSS_txPrime(0, 0);
    DSS_txPrime(1, 0);    
    DSS_rxPrime(0, 0);
    DSS_rxPrime(1, 0);    
}

/*
 * DSS swi is posted by the isr
 */
void
DSS_swi_fxn(int arg0, int arg1)
{
    Uns mbox = SWI_getmbox();
    Bool calledByIsr = mbox & DSS_ISR_HWI_FLAG;

#if DEBUG
	LOG_printf(&trace, "DSS_swi_fxn with mbox=0x%x  ISR=0x%x", mbox, calledByIsr);
#endif

    if (mbox & DSS_ISR_TX_0_FLAG) {
		DSS_txPrime(0, calledByIsr);
    }
    if (mbox & DSS_ISR_TX_1_FLAG) {
		DSS_txPrime(1, calledByIsr);
    } 
    if (mbox & DSS_ISR_RX_0_FLAG) {
		DSS_rxPrime(0, calledByIsr);
    }
    if (mbox & DSS_ISR_RX_1_FLAG) {
		DSS_rxPrime(1, calledByIsr);
    }  
}

/*
 *  ======= DSS_txPrime ========
 *  This must be called  by the notifyReader function of the txPips
 */
void
DSS_txPrime(int chan, int calledByIsr)
{
    dss_isr_stop();

    if (dss_isr_get_txCnt_n(chan) == 0) {
#if DEBUG
    	LOG_printf(&trace, "txP count=0");
#endif
		/* return empty buffer back to client */
		if (calledByIsr && dss_isr_get_txBuf_n(chan) != NULL) {
#if DEBUG
			LOG_printf(&trace, "txP calling PIP_free for PIP:0x%x", txPips[chan]);
#endif	    
			LOG_message("ISR calling PIP_free for txPip 0x%x", (Arg)txPips[chan]);
	    	PIP_free(txPips[chan]);
		}
	
		/* if there is a frame on the tx queue */
		if (txPips[chan]->readerNumFrames > 0) {
#if DEBUG
			LOG_printf(&trace, "txP setting new buffer");
#endif
			LOG_message("ISR calling PIP_get for txPip 0x%x", (Arg)txPips[chan]);
	    	PIP_get(txPips[chan]);
	    	dss_isr_set_txBuf_n(txPips[chan]->readerAddr,
								txPips[chan]->readerSize*2, 
								chan);
		} 
		else {
#if DEBUG
			LOG_printf(&trace, "txP no frame; setting buffer to NULL");
#endif
	    	dss_isr_set_txBuf_n(NULL, 0, chan);
		}
    }     
#if DEBUG
    else {
    	LOG_printf(&trace, "txP count>0");
    }
#endif
    dss_isr_start();
}

/*
 *  ======= DSS_rxPrime ========
 *  This must be the notifyWriter function of the rxPips
 */
void
DSS_rxPrime(int chan, int calledByIsr)
{
    dss_isr_stop();
    
    if (dss_isr_get_rxCnt_n(chan) == 0 ) {
#if DEBUG
    	LOG_printf(&trace, "rxP count=0");  
#endif
		/* return full frame back to client */
		if (calledByIsr && dss_isr_get_rxBuf_n(chan) != NULL) { 
#if DEBUG
			LOG_printf(&trace, "rxP calling PIP_put for PIP:0x%x", rxPips[chan]);
#endif
			LOG_message("ISR calling PIP_put for rxPip 0x%x", (Arg)rxPips[chan]);
	    	PIP_put(rxPips[chan]);
		}

		/* if there is a frame on the rx queue */
		if (rxPips[chan]->writerNumFrames > 0) { 
#if DEBUG
			LOG_printf(&trace, "rxP setting new buffer");
#endif
			LOG_message("ISR calling PIP_alloc for rxPip 0x%x", (Arg)rxPips[chan]);
	    	PIP_alloc(rxPips[chan]);
	    	dss_isr_set_rxBuf_n(rxPips[chan]->writerAddr,
								rxPips[chan]->writerSize*2, 
								chan);
		} 
		else { 
#if DEBUG
			LOG_printf(&trace, "rxP no frame; setting buffer to NULL"); 
#endif
	    	dss_isr_set_rxBuf_n(NULL, 0, chan);
		}
    }
#if DEBUG
    else {
    	LOG_printf(&trace, "rxP count>0");
    }
#endif
    dss_isr_start();
}

⌨️ 快捷键说明

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