author | Simon Howkins <simonh@symbian.org> |
Mon, 29 Nov 2010 13:27:18 +0000 | |
changeset 122 | d8dcdd4c8ab4 |
parent 69 | 39ed99121282 |
permissions | -rwxr-xr-x |
0 | 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 |
||
69
39ed99121282
fixed another issue with uart / and crash-debugger
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
63
diff
changeset
|
35 |
// Add new line and wait for uart to fihish any transmission (i.e. crash info from fifo) |
39ed99121282
fixed another issue with uart / and crash-debugger
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
63
diff
changeset
|
36 |
uart.Write('\r'); |
39ed99121282
fixed another issue with uart / and crash-debugger
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
63
diff
changeset
|
37 |
uart.Write('\n'); |
39ed99121282
fixed another issue with uart / and crash-debugger
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
63
diff
changeset
|
38 |
while(!uart.TxFifoEmpty()); |
39ed99121282
fixed another issue with uart / and crash-debugger
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
63
diff
changeset
|
39 |
|
0 | 40 |
// We don't know what state the UART is in, so reinitialize it |
41 |
uart.Init(); |
|
42 |
uart.DefineMode( Omap3530Uart::TUart::EUart ); |
|
43 |
uart.SetBaud( Omap3530Uart::TUart::E115200 ); |
|
44 |
uart.SetDataFormat( Omap3530Uart::TUart::E8Data, Omap3530Uart::TUart::E1Stop, Omap3530Uart::TUart::ENone ); |
|
45 |
uart.Enable(); |
|
46 |
} |
|
47 |
} |
|
48 |
||
49 |
void CrashDebugger::UartOut(TUint aChar) |
|
50 |
{ |
|
51 |
const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() ); |
|
52 |
||
53 |
if( portNumber >= 0 ) |
|
54 |
{ |
|
55 |
Omap3530Uart::TUart uart( portNumber ); |
|
56 |
||
57 |
TUint c=0; |
|
63 | 58 |
|
0 | 59 |
while ( !uart.RxFifoEmpty() ) |
60 |
{ |
|
61 |
if ( CheckPower() ) |
|
62 |
{ |
|
63 |
return; |
|
64 |
} |
|
65 |
||
66 |
c = uart.Read(); |
|
67 |
||
68 |
if ( c == 19 ) // XOFF |
|
69 |
{ |
|
70 |
FOREVER |
|
71 |
{ |
|
72 |
while( uart.RxFifoEmpty() ) |
|
73 |
{ |
|
74 |
if ( CheckPower() ) |
|
75 |
{ |
|
76 |
return; |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
c = uart.Read(); |
|
81 |
||
82 |
if ( c == 17 ) // XON |
|
83 |
{ |
|
84 |
break; |
|
85 |
} |
|
86 |
else if ( c == 3 ) // Ctrl C |
|
87 |
{ |
|
88 |
Leave(KErrCancel); |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
else if ( c == 3 ) // Ctrl C |
|
93 |
{ |
|
94 |
Leave(KErrCancel); |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
while ( uart.TxFifoFull() ) |
|
99 |
{ |
|
100 |
CheckPower(); |
|
101 |
} |
|
102 |
||
103 |
uart.Write( aChar ); |
|
104 |
} |
|
105 |
} |
|
106 |
||
107 |
TUint8 CrashDebugger::UartIn() |
|
108 |
{ |
|
109 |
const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() ); |
|
110 |
||
111 |
if( portNumber >= 0 ) |
|
112 |
{ |
|
113 |
Omap3530Uart::TUart uart( portNumber ); |
|
114 |
||
115 |
while ( uart.RxFifoEmpty() ) |
|
116 |
{ |
|
117 |
if ( CheckPower() ) |
|
118 |
{ |
|
119 |
return 0x0d; |
|
120 |
} |
|
121 |
} |
|
122 |
return uart.Read(); |
|
123 |
} |
|
124 |
||
125 |
return 0; |
|
126 |
} |
|
127 |
||
128 |
TBool CrashDebugger::CheckPower() |
|
129 |
{ |
|
130 |
// |
|
131 |
// Check if power supply is stable and return ETrue if not |
|
132 |
// |
|
133 |
return EFalse; // EXAMPLE ONLY |
|
134 |
} |
|
135 |