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

📄 trace_btc.c

📁 lwip tcp/ip 协议栈 adsp BF533 DSP 移植 用 visual dsp++ 编译
💻 C
字号:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <btc.h>

#include "..\trace_int.h"



extern int _btc_nNumBtcMapEntries;
extern _BTC_MAP_DATA _btc_map[];


//#################################################################
//		TracePoll
//#################################################################
void TracePoll(TraceInfo *trc)
{
	int il;
	
	btc_poll();
	if (trc->m_BytesSent >0) {
		// the host has been notified to read the data
		if (trc->m_TrcData->NoTrcBytes == 0) {
			// the data has been read
			il = trc->m_NxtByte - trc->m_BytesSent;
			if (il > 0) {
				// we have some data to be moved down
				memcpy(trc->m_TrcData->TrcBytes,trc->m_TrcData->TrcBytes+trc->m_BytesSent,il);
				trc->m_NxtByte -= il;				
			}
			trc->m_BytesSent = 0;
		}
	}
}


//#################################################################
//		TraceWrite
//#################################################################
void TraceWrite(TraceInfo *trc)
{
	// it maybe sensible to tell the host to get some data
	if (trc->m_TrcData->NoTrcBytes == 0) {
		// tell the host to initiate reading
		trc->m_BytesSent = trc->m_NxtByte;
		trc->m_TrcData->NoTrcBytes = trc->m_NxtByte;
		while (trc->m_TrcData->NoTrcBytes >0) {
			TracePoll(trc);
			if (trc->m_TrcData->Active == 0) {
				trc->m_TrcData->NoTrcBytes=0; // act as if the data has been read
				trc->m_NxtByte = 0;
				trc->m_BytesSent = 0;
			}
		}
	}
	TracePoll(trc);
}


//#################################################################
//		TraceEmpty
//#################################################################
void TraceEmpty(TraceInfo *trc)
{
	// we have to wait till the there is at least room for one trace entry
	while (trc->m_NxtByte+trc->m_MaxBytes>=trc->m_BufSize) {
		TraceWrite(trc);
	}
}



//#################################################################
//		TraceInit
//#################################################################
int TraceInit(TraceInfo *trc, char *HostAddr, int portno)
{
   int i,res=1;
   
   // identify the base channel that we are to use
   for (i=0;i<_btc_nNumBtcMapEntries;i++) {
      if (strcmp(HostAddr,_btc_map[i].name) == 0) {
         // we have found the channel
	      _btc_map[i].length =  sizeof(TraceData)+trc->m_BufSize;
	      _btc_map[i].address = (long)trc->m_TrcData;
	      res = 0;
         break;
      }
   }
   
   btc_init();
   return res;
}

//#################################################################
//		TraceMaintain
//#################################################################
void TraceMaintain(TraceInfo *trc)
{
}

⌨️ 快捷键说明

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