Ejemplo n.º 1
0
INLINE void WriteHex(Byte const * const &s, UInt32 const &len) {
	if (s == NULL) {
		WriteNull();
		return;
	}
    Write("\nLen = ");
    SByte buf[32];
    var chars = Converts::Convert(len, buf);
    Write(buf, chars);
    for(UInt32 i = 0; i < 16 - chars; ++i)
        WriteChar(' ');
    if (len == 0)
        return;
    Write("0  1  2  3  | 4  5  6  7  | 8  9  A  B  | C  D  E  F\n");
    for(UInt32 i = 0; i < len; ++i) {
        if ((i % 16) == 0) {
            if (i)
                WriteChar('\n');
            WriteHex(i);
            Write("              ");
        }
        else if (i && (i % 4 == 0))
            Write("   ");
        else WriteChar(' ');
        WriteHex(s[i]);
    }
    WriteChar('\n');
    //Write("----------------------------------+-------------+-------------+------------\n");
}
Ejemplo n.º 2
0
static char* BuildSRecord(char* pa, WORD sType, DWORD addr,
			  const BYTE* data, int nCount)
{
  WORD  addrLen;
  WORD  sRLen;
  WORD  checkSum;
  WORD  i;

  switch (sType) {
  case 0:
  case 1:
  case 9:
    addrLen = 2;
    break;
  case 2:
  case 8:
    addrLen = 3;
    break;
  case 3:
  case 7:
    addrLen = 4;
    break;
  default:
    return pa;
  } /* switch */

  *pa++ = 'S';
  *pa++ = (char)(sType + '0');
  sRLen = addrLen + nCount + 1;
  checkSum = 0;
  pa = WriteHex(pa, (BYTE)sRLen, &checkSum);

  /* Write address field */
  for (i = 1; i <= addrLen; i++) {
    pa = WriteHex(pa, (BYTE)(addr >> (8 * (addrLen - i))), &checkSum);
  } /* for */

  /* Write code/data fields */
  for (i = 0; i < nCount; i++) {
    pa = WriteHex(pa, *data++, &checkSum);
  } /* for */

  /* Write checksum field */
  checkSum = ~checkSum;
  pa = WriteHex(pa, (BYTE)checkSum, &checkSum);
  *pa++ = '\0';
  return pa;
}
Ejemplo n.º 3
0
void WriteData(int id,char szMessage[],int nLen)
{
	int i;
	if (global.nDisplayAscii==1) WriteLog(id,szMessage);
	else if (global.nDisplayAscii==2) WriteHex(id,szMessage,nLen);
	else
	{
	   for(i=0;i<nLen;i++) 
		if (szMessage[i]<30) 
		{
			WriteHex(id,szMessage,nLen);
			return;
		}
	   WriteLog(id,szMessage);
	}
	return;
}
Ejemplo n.º 4
0
int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    UART_1_Start();
    UART_1_PutString("\n \r");
    
    uint8 v1 = 18;
    uint8 v2 = rearrange(v1);
    WriteHex(v2);
    for(;;)
    {
        /* Place your application code here. */
    }
}
Ejemplo n.º 5
0
void Calibrate_Menu(void)
{
uchar i;
uint Addr;

  for(;;)
  {
    switch (ScanCode)
    {
      case 0x7E:                        //Enter
        ScanCode = 0;
        Addr = calAddr;
        //Запоминаем калибровачные значения
        for (i = 0; i < 5; i++)
        {
          EEPutInt(Addr, CalValue[i].Max); Addr += 2;
          EEPutInt(Addr, CalValue[i].Min); Addr += 2;
          EEPutInt(Addr, CalValue[i].Avg); Addr += 2;
        }
        ClrAllDisp();
//        Flags &= ~(1 << calibrate);
        return;

      case 0xEE:			//Среднее значение (Esc)
        ScanCode = 0;
        ClrAllDisp();
        return;
    }
    if (Sec == 0)
    {
      SetCursDisp(1, 10);
      WriteHex((uchar)(CalValue[1].Min>>8));
      WriteHex((uchar)(CalValue[1].Min));
      Sec = 40;
    }
  }
Ejemplo n.º 6
0
const long * KTextPipe::Percent(TCHAR tag, const long * data, const DicItem * dic)
{
	static double dummy = sin(0.0); // just to link-in floating point support

	int len = 0;

	switch ( tag )
	{
		case '_': len = 4; break;			// skip 4 bytes

		case '0': WriteDec(data[0]); break; // decimal signed long
		case '1': WriteDec(data[1]); break;	// decimal signed long
		case '2': WriteDec(data[2]); break;	// decimal signed long
		case '3': WriteDec(data[3]); break;	// decimal signed long
		case '4': WriteDec(data[4]); break;	// decimal signed long
		case '5': WriteDec(data[5]); break;	// decimal signed long
		case '6': WriteDec(data[6]); break;	// decimal signed long
		case '7': WriteDec(data[7]); break;	// decimal signed long
		case '8': WriteDec(data[8]); break;	// decimal signed long
		case '9': WriteDec(data[9]); break;	// decimal signed long

		case 'b': WriteDec((long)(* ((unsigned char *) data)));	// signed char
				  len = 1;
				  break;

		case 'c': 
			{
				char ch = * data & 0xFF;

				if ( (ch>=' ') && (ch<=0x7F) )
					Put(ch);
				else
					Put('.');
				len = 1;
			}
			break;

		case 'd': WriteDec(                data[0]); len=4; break;  // decimal   signed long
		case 'u': WriteDec((unsigned long) data[0]); len=4; break;  // decimal unsigned long
		case 'x': WriteHex(                data[0]); len=4; break;  // hex     unsigned long

		case 'D': WriteDec((long)         (* ((short *)          data))); len=2; break; // signed short
		case 'U': WriteDec((unsigned long)(* ((unsigned short *) data))); len=2; break; // signed short
		case 'X': WriteHex(                * ((unsigned short *) data));  len=2; break; // unsigned short

		case 'S': WriteString(data, -1, true);   break; // wide string
		case 's': WriteString(data, -1, false);	 break; // ascii string

		case 'f': { TCHAR t[32]; float f = * (float *) data; _stprintf(t, _T("%8.5f"), f); Write(t); } // float
				  len = 4;
				  break;
							  
		case 'n': m_nCount++;					// sequence count: 1 1 2 2 ...
				  WriteDec((long)(m_nCount/2));
				  break;
	
		case 'm': m_mCount++;					// sequence count: 1 1 2 2 ...
				  WriteDec((long)(m_mCount/2));
				  break;
							  							  
		case 'L': Write(data[0], dic); len = 4; // dic
				  break;

		default : assert(false);
	}

	return (const long *) ( (const char *) data + len);
}
Ejemplo n.º 7
0
void KTextPipe::WriteArray(const void * Array, long count, long elmsize, bool decimal)
{
	if ( ! m_bOpened )
		return;

	assert(Array);

	const char  * bArray = (const char *)  Array;
	const short * sArray = (const short *) Array;
	const long  * lArray = (const long *)  Array;
	const RECT  * rArray = (const RECT *)  Array;
	
	Put('{'); Put(' ');
	for (long i=0; i<count; i++)
	{
		if ( i )
		{
			Put(','); 
			
			if ( m_linelen > 78 )
				Newline();
			else
				Put(' ');
		}

		switch ( elmsize )
		{
			case 1:  
				if (decimal) 
					WriteDec((long) bArray[i]); 
				else 
					WriteHex(bArray[i] & 0xFF); 
				break;
			
			case 2:  
				if (decimal) 
					WriteDec((long) sArray[i]); 
				else 
					WriteHex(sArray[i] & 0xFFFF); 
				break;

			case 4:  
				if (decimal) 
					WriteDec(lArray[i]); 
				else 
					WriteHex(lArray[i]); 
				break;

			case sizeof(RECT):
				Write("{ "); WriteDec(rArray[i].left);
				Put(',');    WriteDec(rArray[i].top);
				Put(',');    WriteDec(rArray[i].right);
				Put(',');    WriteDec(rArray[i].bottom);
				Write(" }");
				break;

			default: assert(FALSE);
		}

	}

	Put(' '); Put('}');
}
Ejemplo n.º 8
0
INLINE void Write(Byte  const * const &buf, UInt32 const &len) {
    WriteHex(buf, len);
}
Ejemplo n.º 9
0
template<UInt32 len> void Write(Byte  const (&s)[len]) {
    WriteHex(s, len);
}
Ejemplo n.º 10
0
INLINE void Write(Binary  const &a) {
    WriteHex(a.Buffer(), a.Length());
}
Ejemplo n.º 11
0
int main() 
{

    rtx_dbug_outs((CHAR *)"rtx: Entering main()\r\n");

    /* get the third party test proc initialization info */
    __REGISTER_TEST_PROCS_ENTRY__();
	
	rtxEnd = &(_end);
	m_nextPid = 1;
	
	// Setting up trap # 0
    // Load vector table for trap # 0
    asm( "move.l #asm_trap_entry, %d0" );
    asm( "move.l %d0, 0x10000080" );
	
	#ifdef _DEBUG_
	rtx_dbug_outs( (CHAR*)"Start\r\n" );
	WriteHex((int)malloc(0) );
	rtx_dbug_outs( (CHAR*)" Address before PCBS\r\n" );
	#endif
	// Allocate and initialize pcbs and its stacks
	//rtxProcess* pcbs = AllocatePCBs( MAX_NUMPROCS );
	pcbs = AllocatePCBs( MAX_NUMPROCS );
	#ifdef _DEBUG_
	WriteHex((int)malloc(0) );
	rtx_dbug_outs( (CHAR*)" Address after PCBS\r\n" );
	#endif
	// Initialize the process manager
	rtxProcMan = InitProcessManager();
	#ifdef _DEBUG_
	WriteHex((int)malloc(0) );
	rtx_dbug_outs( (CHAR*)" Address after Procman?\r\n" );
	#endif
	// Create the null process
	rtxProcess* nullProc = CreateProcess( pcbs, null_process, AllocateStack(256), 0, NULLPROCPRIORITY );
	nullProc->status = READY;
	rtxProcMan->nullProc = nullProc;
	#ifdef _DEBUG_
	WriteHex((int)malloc(0) );
	rtx_dbug_outs( (CHAR*)" Address after nullproc?\r\n" );
	#endif
	//Create the Processes
	rtxProcess* cp2 = CreateProcess( pcbs, &keyboardCommandDecoder, AllocateStack(2048), KCDPID, MEDIUM );
	rtxProcess* cp1 = CreateProcess( pcbs, &CRTDisplay, AllocateStack(512), CRTPID, MEDIUM);
	rtxProcess* cp3 = CreateProcess( pcbs, &UART_PROCESS, AllocateStack(512), UARTPID, HIGH );
	
	CRT = cp1;
   	KCD = cp2;
	UART = cp3;	
	
	// Creating and enqueueing the test processes
	for( m_nextPid = 1 ; m_nextPid < (NUM_TEST_PROCS + 1); m_nextPid++ ){
		EnqueueProcess( 
			rtxProcMan, 
			CreateProcess( 
				pcbs, 
				g_test_proc[m_nextPid-1].entry, 
				AllocateStack( g_test_proc[m_nextPid-1].sz_stack ),
				g_test_proc[m_nextPid-1].pid,
				g_test_proc[m_nextPid-1].priority
			),
			READYQUEUE
		);
	}
	
	// Set the next pid to be 1 greater than last test proc pid
	//m_nextPid = g_test_proc[m_nextPid-2].pid + 1;
	
	// Initialize some of our own system processes
	
	EnqueueProcess( rtxProcMan, cp2,READYQUEUE);
	EnqueueProcess( rtxProcMan, cp1,READYQUEUE );

	
	
	// Initialize the scheduler
	InitializeScheduler( (ProcessManager*)(rtxProcMan) );
	
	// Time to allocate and initialize free memory
	UINT32 numTotalBlocks = ( (UINT32)0x10200000 - (UINT32)malloc(0)) / sizeof(MemoryBlock);
	
	//numTotalBlocks = 1;
	#ifdef _DEBUG_
	WriteHex((int)malloc(0) );
	rtx_dbug_outs( (CHAR*)" Address At start of freemem\r\n" );
	#endif
	// Allocate free memory and create memory table
	MemoryBlock* memstart = AllocateFreeMemory( sizeof(MemoryBlock), numTotalBlocks );
	#ifdef _DEBUG_
	WriteHex((int)malloc(0) );
	rtx_dbug_outs( (CHAR*)" Address after freemem?\r\n" );
	rtx_dbug_outs( (CHAR*)"Allocated Free Memory\r\n" );
	#endif
	InitMemQueue( &freeMemory );
	InitializeMemory( &freeMemory, memstart, numTotalBlocks );
	#ifdef _DEBUG_	
    rtx_dbug_outs( (CHAR*)"Number of free memory blocks: " );
    WriteNumber( freeMemory.count );	
    WriteLine();

	rtx_dbug_outs( (CHAR*)"Initialized Free Memory\r\n" );
	#endif
	
	UINT32 mask;
	
	//disable all interupts 
	asm( "move.w #0x2700,%sr" );
	
	coldfire_vbr_init();
	
	//store the serial ISR at user vector #64
	asm( "move.l #asm_serial_entry,%d0" );
	asm( "move.l %d0,0x10000100" );

	//reset the entire UART 
	SERIAL1_UCR = 0x10;

	//reset the receiver 
	SERIAL1_UCR = 0x20;
	
	//reset the transmitter 
	SERIAL1_UCR = 0x30;

	//reset the error condition
	SERIAL1_UCR = 0x40;

	//install the interupt
	SERIAL1_ICR = 0x17;
	SERIAL1_IVR = 64;

	//enable interrupts on rx only
	SERIAL1_IMR = 0x02;

	//set the baud rate
	SERIAL1_UBG1 = 0x00;
#ifdef _CFSERVER_           /* add -D_CFSERVER_ for cf-server build */
	SERIAL1_UBG2 = 0x49;    /* cf-server baud rate 19200 */ 
#else
	SERIAL1_UBG2 = 0x92;    /* lab board baud rate 9600 */
#endif 

	//set clock mode
	SERIAL1_UCSR = 0xDD;

	//setup the UART (no parity, 8 bits )
	SERIAL1_UMR = 0x13;
	
	//setup the rest of the UART (noecho, 1 stop bit )
	SERIAL1_UMR = 0x07;

	//setup for transmit and receive
	SERIAL1_UCR = 0x05;

	//enable interupts
	mask = SIM_IMR;
	mask &= 0x0003dfff;
	SIM_IMR = mask;

	//enable all interupts
	asm( "move.w #0x2000,%sr" );
	// end of keyboard interrupts
	
	
	// Start it up
	ScheduleNextProcess( rtxProcMan, NULL );
	
    return 0;
}