omap3530/shared/monitor/monitor.cpp
changeset 0 6663340f3fc9
child 63 8cf16be5c3dd
equal deleted inserted replaced
-1:000000000000 0:6663340f3fc9
       
     1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // omap3530/shared/monitor/monitor.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <monitor.h>
       
    19 #include <assp/omap3530_assp/omap3530_assp_priv.h>
       
    20 #include <assp/omap3530_assp/omap3530_uart.h>
       
    21 #include <assp/omap3530_assp/omap3530_prcm.h>
       
    22 
       
    23 void CrashDebugger::InitUart()
       
    24 	{
       
    25 	const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() );
       
    26 
       
    27 	if( portNumber >= 0 )
       
    28 		{
       
    29 		Omap3530Uart::TUart uart( portNumber );
       
    30 
       
    31 		// Ensure UART clocks are running
       
    32 		Prcm::SetClockState( uart.PrcmInterfaceClk(),Prcm::EClkOn );
       
    33 		Prcm::SetClockState( uart.PrcmFunctionClk(), Prcm::EClkOn );
       
    34 	
       
    35 		// We don't know what state the UART is in, so reinitialize it
       
    36 		uart.Init();
       
    37 		uart.DefineMode( Omap3530Uart::TUart::EUart );
       
    38 		uart.SetBaud( Omap3530Uart::TUart::E115200 );
       
    39 		uart.SetDataFormat( Omap3530Uart::TUart::E8Data, Omap3530Uart::TUart::E1Stop, Omap3530Uart::TUart::ENone );
       
    40 		uart.Enable();
       
    41 		}
       
    42 	}
       
    43 
       
    44 void CrashDebugger::UartOut(TUint aChar)
       
    45 	{
       
    46 	const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() );
       
    47 
       
    48 	if( portNumber >= 0 )
       
    49 		{
       
    50 		Omap3530Uart::TUart uart( portNumber );
       
    51 
       
    52 		TUint c=0;
       
    53 
       
    54 		while ( !uart.RxFifoEmpty() )
       
    55 			{ 
       
    56 			if ( CheckPower() )
       
    57 				{
       
    58 				return;
       
    59 				}
       
    60 
       
    61 			c = uart.Read();
       
    62 			
       
    63 			if ( c == 19 )            // XOFF
       
    64 				{
       
    65 				FOREVER
       
    66 					{
       
    67 					while( uart.RxFifoEmpty() )
       
    68 						{
       
    69 						if ( CheckPower() )
       
    70 							{
       
    71 							return;
       
    72 							}
       
    73 						}
       
    74 
       
    75 					c = uart.Read();
       
    76 					
       
    77 					if ( c == 17 )    // XON
       
    78 						{
       
    79 						break;
       
    80 						}
       
    81 					else if ( c == 3 )		// Ctrl C
       
    82 						{
       
    83 						Leave(KErrCancel);
       
    84 						}
       
    85 					}
       
    86 				}
       
    87 			else if ( c == 3 )		// Ctrl C
       
    88 				{
       
    89 				Leave(KErrCancel);
       
    90 				}
       
    91 			}
       
    92 
       
    93 		while ( uart.TxFifoFull() )
       
    94 			{
       
    95 			CheckPower();
       
    96 			}
       
    97 
       
    98 		uart.Write( aChar );
       
    99 		}
       
   100 	}
       
   101 
       
   102 TUint8 CrashDebugger::UartIn()
       
   103 	{
       
   104 	const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() );
       
   105 
       
   106 	if( portNumber >= 0 )
       
   107 		{
       
   108 		Omap3530Uart::TUart uart( portNumber );
       
   109 
       
   110 		while ( uart.RxFifoEmpty() )
       
   111 			{
       
   112 			if ( CheckPower() )
       
   113 				{
       
   114 				return 0x0d;
       
   115 				}
       
   116 			}
       
   117 		return uart.Read();
       
   118 		}
       
   119 	
       
   120 	return 0;
       
   121 	}
       
   122 
       
   123 TBool CrashDebugger::CheckPower()
       
   124 	{
       
   125 	//
       
   126 	// Check if power supply is stable and return ETrue if not
       
   127 	//
       
   128 	return EFalse;	// EXAMPLE ONLY
       
   129 	}
       
   130