author | William Roberts <williamr@symbian.org> |
Fri, 01 Oct 2010 11:40:18 +0100 | |
changeset 2 | 048b58430d46 |
parent 0 | 5de814552237 |
permissions | -rw-r--r-- |
0
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
1 |
/* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
8 |
* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
11 |
* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
13 |
* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
15 |
* naviengine_assp\uart\uart16550.cpp |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
16 |
* PDD for 16550 UART |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
17 |
* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
18 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
19 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
20 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
21 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
22 |
#include <drivers/comm.h> |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
23 |
#include <assp.h> |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
24 |
#include "../naviengine_priv.h" |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
25 |
#include "../naviengine.h" |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
26 |
#include "uart16550_ne.h" |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
27 |
#include <e32hal.h> |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
28 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
29 |
_LIT(KPddName,"Comm.16550_ne"); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
30 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
31 |
#define __COMMS_MACHINE_CODED__ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
32 |
#ifdef __COMMS_MACHINE_CODED__ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
33 |
#define DBASE_VPTR_OFFSET 4 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
34 |
#define RX_ISR_VT_OFFSET 0x24 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
35 |
#define CHK_TXB_VT_OFFSET 0x28 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
36 |
#define STATE_ISR_VT_OFFSET 0x2C |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
37 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
38 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
39 |
// needs ldd version.. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
40 |
const TInt KMinimumLddMajorVersion=1; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
41 |
const TInt KMinimumLddMinorVersion=1; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
42 |
const TInt KMinimumLddBuild=122; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
43 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
44 |
// The following defines when enabled can help debugging uart: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
45 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
46 |
// RX_WORKAROUND - The basic workaround. There is a small window where data loss could occur |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
47 |
// #define RX_WORKAROUND |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
48 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
49 |
// RX_WORKAROUND_SAVE - A more advanced workaround that notifies the LDD that there |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
50 |
// has been a read error. May cause new reporting of errors |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
51 |
// #define RX_WORKAROUND_SAVE |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
52 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
53 |
// TRACK_WORKAROUND - Records the number activations of the workaround |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
54 |
// and the state of the last one. printf's the values on on deconstruct |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
55 |
// #define TRACK_WORKAROUND |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
56 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
57 |
// TRACK_DISTRIBUTION - Records the number of bytes read at a time to |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
58 |
// demonstrate operation of fifo mode. printf's the values on on deconstruct |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
59 |
// #define TRACK_DISTRIBUTION |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
60 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
61 |
// DISABLE_RX_FLUSH - Disables RX Flush in uart configuration procedure. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
62 |
// #define DISABLE_RX_FLUSH |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
63 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
64 |
// TEMPORARY_SMP_FIX reduces the number of bytes pumped into the Tx FIFO from 16 to 8 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
65 |
// which works around a hardware problem not fully understood. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
66 |
#define TEMPORARY_SMP_FIX |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
67 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
68 |
// configuration data |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
69 |
static const TUint16 BaudRateDivisor[] = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
70 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
71 |
KBaudRateDiv_50, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
72 |
KBaudRateDiv_75, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
73 |
KBaudRateDiv_110, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
74 |
KBaudRateDiv_134, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
75 |
KBaudRateDiv_150, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
76 |
KBaudRateDiv_300, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
77 |
KBaudRateDiv_600, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
78 |
KBaudRateDiv_1200, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
79 |
KBaudRateDiv_1800, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
80 |
KBaudRateDiv_2000, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
81 |
KBaudRateDiv_2400, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
82 |
KBaudRateDiv_3600, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
83 |
KBaudRateDiv_4800, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
84 |
KBaudRateDiv_7200, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
85 |
KBaudRateDiv_9600, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
86 |
KBaudRateDiv_19200, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
87 |
KBaudRateDiv_38400, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
88 |
KBaudRateDiv_57600, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
89 |
KBaudRateDiv_115200, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
90 |
KBaudRateDiv_230400, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
91 |
}; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
92 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
93 |
class DDriverComm : public DPhysicalDevice |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
94 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
95 |
public: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
96 |
DDriverComm(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
97 |
~DDriverComm(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
98 |
virtual TInt Install(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
99 |
virtual void GetCaps(TDes8 &aDes) const; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
100 |
virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion &aVer); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
101 |
virtual TInt Validate(TInt aUnit, const TDesC8* anInfo, const TVersion &aVer); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
102 |
public: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
103 |
TDynamicDfcQue* iDfcQ; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
104 |
}; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
105 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
106 |
class DComm16550 : public DComm |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
107 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
108 |
public: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
109 |
DComm16550(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
110 |
~DComm16550(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
111 |
TInt DoCreate(TInt aUnit, const TDesC8* anInfo, TDynamicDfcQue* aDfcQ); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
112 |
public: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
113 |
virtual TInt Start(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
114 |
virtual void Stop(TStopMode aMode); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
115 |
virtual void Break(TBool aState); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
116 |
virtual void EnableTransmit(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
117 |
virtual TUint Signals() const; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
118 |
virtual void SetSignals(TUint aSetMask,TUint aClearMask); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
119 |
virtual TInt ValidateConfig(const TCommConfigV01 &aConfig) const; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
120 |
virtual void Configure(TCommConfigV01 &aConfig); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
121 |
virtual void Caps(TDes8 &aCaps) const; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
122 |
virtual TInt DisableIrqs(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
123 |
virtual void RestoreIrqs(TInt aIrq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
124 |
virtual TDfcQue* DfcQ(TInt aUnit); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
125 |
virtual void CheckConfig(TCommConfigV01& aConfig); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
126 |
public: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
127 |
static void Isr(TAny* aPtr); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
128 |
public: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
129 |
TInt iInterruptId; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
130 |
TInt iUnit; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
131 |
T16550Uart* iUart; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
132 |
TDynamicDfcQue* iDfcQ; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
133 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
134 |
#ifdef TRACK_WORKAROUND |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
135 |
TInt iWorkaround; // how many times did the workaround fire |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
136 |
TInt iWorkaroundLSR; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
137 |
TInt iWorkaroundISR; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
138 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
139 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
140 |
#ifdef TRACK_DISTRIBUTION |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
141 |
TUint iRead[33]; // array of how many bytes reported back to the ldd |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
142 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
143 |
}; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
144 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
145 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
146 |
DDriverComm::DDriverComm() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
147 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
148 |
// Constructor |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
149 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
150 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
151 |
iUnitsMask=~(0xffffffffu<<KNum16550Uarts); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
152 |
iVersion=TVersion(KCommsMajorVersionNumber,KCommsMinorVersionNumber,KCommsBuildVersionNumber); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
153 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
154 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
155 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
156 |
TInt DDriverComm::Install() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
157 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
158 |
// Install the driver |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
159 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
160 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
161 |
// Allocate a kernel thread to run the DFC |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
162 |
TInt r = Kern::DynamicDfcQCreate(iDfcQ, KUart16550ThreadPriority, KUar16550tDriverThread); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
163 |
if (r == KErrNone) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
164 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
165 |
#ifdef CPU_AFFINITY_ANY |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
166 |
NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
167 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
168 |
r = SetName(&KPddName); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
169 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
170 |
return r; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
171 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
172 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
173 |
/** |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
174 |
Destructor |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
175 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
176 |
DDriverComm::~DDriverComm() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
177 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
178 |
if (iDfcQ) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
179 |
iDfcQ->Destroy(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
180 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
181 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
182 |
void Get16550CommsCaps(TDes8& aCaps, TInt aUnit) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
183 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
184 |
TCommCaps3 capsBuf; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
185 |
TCommCapsV03 &c=capsBuf(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
186 |
c.iRate = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
187 |
KCapsBps150 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
188 |
|KCapsBps300 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
189 |
|KCapsBps600 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
190 |
|KCapsBps1200 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
191 |
|KCapsBps1800 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
192 |
|KCapsBps2000 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
193 |
|KCapsBps2400 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
194 |
|KCapsBps3600 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
195 |
|KCapsBps4800 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
196 |
|KCapsBps7200 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
197 |
|KCapsBps9600 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
198 |
|KCapsBps19200 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
199 |
|KCapsBps38400 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
200 |
|KCapsBps57600 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
201 |
|KCapsBps115200; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
202 |
if (aUnit != 2) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
203 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
204 |
c.iRate |= KCapsBps230400; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
205 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
206 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
207 |
c.iDataBits = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
208 |
KCapsData5 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
209 |
|KCapsData6 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
210 |
|KCapsData7 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
211 |
|KCapsData8; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
212 |
c.iStopBits = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
213 |
KCapsStop1 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
214 |
|KCapsStop2; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
215 |
c.iParity = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
216 |
KCapsParityNone |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
217 |
|KCapsParityEven |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
218 |
|KCapsParityOdd |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
219 |
|KCapsParityMark |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
220 |
|KCapsParitySpace; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
221 |
c.iSIR = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
222 |
switch (aUnit) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
223 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
224 |
case 0: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
225 |
c.iHandshake = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
226 |
KCapsObeyXoffSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
227 |
|KCapsSendXoffSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
228 |
|KCapsObeyCTSSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
229 |
|KCapsFailCTSSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
230 |
|KCapsFreeRTSSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
231 |
c.iSignals = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
232 |
KCapsSignalCTSSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
233 |
|KCapsSignalRTSSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
234 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
235 |
case 1: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
236 |
c.iHandshake = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
237 |
KCapsObeyXoffSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
238 |
|KCapsSendXoffSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
239 |
|KCapsObeyCTSSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
240 |
|KCapsFailCTSSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
241 |
|KCapsObeyDSRSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
242 |
|KCapsFailDSRSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
243 |
|KCapsObeyDCDSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
244 |
|KCapsFailDCDSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
245 |
|KCapsFreeRTSSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
246 |
|KCapsFreeDTRSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
247 |
c.iSignals = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
248 |
KCapsSignalCTSSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
249 |
|KCapsSignalRTSSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
250 |
|KCapsSignalDTRSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
251 |
|KCapsSignalDSRSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
252 |
|KCapsSignalDCDSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
253 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
254 |
default: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
255 |
case 2: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
256 |
c.iHandshake = |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
257 |
KCapsObeyXoffSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
258 |
|KCapsSendXoffSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
259 |
c.iSignals = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
260 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
261 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
262 |
c.iFifo=KCapsHasFifo; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
263 |
c.iNotificationCaps= |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
264 |
KNotifyDataAvailableSupported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
265 |
|KNotifySignalsChangeSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
266 |
c.iRoleCaps = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
267 |
c.iFlowControlCaps = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
268 |
c.iBreakSupported = ETrue; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
269 |
aCaps.FillZ(aCaps.MaxLength()); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
270 |
aCaps=capsBuf.Left(Min(capsBuf.Length(),aCaps.MaxLength())); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
271 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
272 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
273 |
void DDriverComm::GetCaps(TDes8 &aDes) const |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
274 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
275 |
// Return the drivers capabilities |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
276 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
277 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
278 |
Get16550CommsCaps(aDes, 0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
279 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
280 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
281 |
TInt DDriverComm::Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion& aVer) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
282 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
283 |
// Create a driver |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
284 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
285 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
286 |
DComm16550* pD=new DComm16550; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
287 |
aChannel=pD; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
288 |
TInt r=KErrNoMemory; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
289 |
if (pD) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
290 |
r=pD->DoCreate(aUnit,anInfo, iDfcQ); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
291 |
return r; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
292 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
293 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
294 |
TInt DDriverComm::Validate(TInt aUnit, const TDesC8* /*anInfo*/, const TVersion& aVer) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
295 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
296 |
// Validate the requested configuration |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
297 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
298 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
299 |
if ((!Kern::QueryVersionSupported(iVersion,aVer)) || (!Kern::QueryVersionSupported(aVer,TVersion(KMinimumLddMajorVersion,KMinimumLddMinorVersion,KMinimumLddBuild)))) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
300 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
301 |
if (TUint(aUnit)>=TUint(KNum16550Uarts)) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
302 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
303 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
304 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
305 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
306 |
DComm16550::DComm16550() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
307 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
308 |
// Constructor |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
309 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
310 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
311 |
// iTransmitting=EFalse; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
312 |
iInterruptId=-1; // -1 means not bound |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
313 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
314 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
315 |
DComm16550::~DComm16550() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
316 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
317 |
// Destructor |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
318 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
319 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
320 |
if (iUart) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
321 |
delete iUart; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
322 |
if (iInterruptId>=0) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
323 |
Interrupt::Unbind(iInterruptId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
324 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
325 |
#ifdef TRACK_WORKAROUND |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
326 |
if (iWorkaround) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
327 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
328 |
Kern::Printf("########################################"); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
329 |
Kern::Printf("####%d iWorkaround %d LSR 0x%x ISR 0x%x", iUnit, iWorkaround, iWorkaroundLSR, iWorkaroundISR); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
330 |
Kern::Printf("########################################"); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
331 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
332 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
333 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
334 |
Kern::Printf("####%d iWorkaround %d LSR 0x%x ISR 0x%x", iUnit, iWorkaround, iWorkaroundLSR, iWorkaroundISR); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
335 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
336 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
337 |
#ifdef TRACK_DISTRIBUTION |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
338 |
Kern::Printf("####%d iRead: %d, %d %d %d %d %d %d %d %d, %d %d %d %d %d %d %d %d, %d %d %d %d %d %d %d %d, %d %d %d %d %d %d %d", |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
339 |
iUnit, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
340 |
iRead[0], |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
341 |
iRead[1], iRead[2], iRead[3], iRead[4], iRead[5], iRead[6], iRead[7], iRead[8], |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
342 |
iRead[9], iRead[10], iRead[11], iRead[12], iRead[13], iRead[14], iRead[15], iRead[16], |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
343 |
iRead[17], iRead[18], iRead[19], iRead[20], iRead[21], iRead[22], iRead[23], iRead[24], |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
344 |
iRead[25], iRead[26], iRead[27], iRead[28], iRead[29], iRead[30], iRead[31], iRead[32]); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
345 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
346 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
347 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
348 |
TInt DComm16550::DoCreate(TInt aUnit, const TDesC8* /*anInfo*/, TDynamicDfcQue* aDfcQ) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
349 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
350 |
// Sets up the PDD |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
351 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
352 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
353 |
TUint base; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
354 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
355 |
switch (aUnit) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
356 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
357 |
case 0: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
358 |
base=KHwBaseUart0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
359 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
360 |
case 1: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
361 |
base=KHwBaseUart1; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
362 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
363 |
case 2: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
364 |
base=KHwBaseUart2; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
365 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
366 |
default: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
367 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
368 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
369 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
370 |
iUnit=aUnit; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
371 |
iDfcQ = aDfcQ; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
372 |
TInt irq=KIntIdUart0+aUnit; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
373 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
374 |
// bind to UART interrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
375 |
TInt r=Interrupt::Bind(irq,Isr,this); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
376 |
if (r>=0) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
377 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
378 |
iInterruptId = r; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
379 |
r = KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
380 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
381 |
iUart = new T16550Uart; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
382 |
if (iUart) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
383 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
384 |
iUart->iBase = (TUint8*)base; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
385 |
iUart->SetIER(0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
386 |
iUart->SetLCR(0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
387 |
iUart->SetFCR(0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
388 |
iUart->SetMCR(0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
389 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
390 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
391 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
392 |
Interrupt::Unbind(iInterruptId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
393 |
r = KErrNoMemory; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
394 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
395 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
396 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
397 |
#ifdef TRACK_WORKAROUND |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
398 |
iWorkaround = iWorkaroundLSR = iWorkaroundISR = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
399 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
400 |
return r; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
401 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
402 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
403 |
TDfcQue* DComm16550::DfcQ(TInt /*aUnit*/) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
404 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
405 |
// Return the DFC queue to be used for this device |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
406 |
// For PC cards, use the PC card controller thread for the socket in question. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
407 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
408 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
409 |
return iDfcQ; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
410 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
411 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
412 |
TInt DComm16550::Start() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
413 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
414 |
// Start receiving characters |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
415 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
416 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
417 |
// if EnableTransmit() called before Start() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
418 |
iTransmitting=EFalse; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
419 |
iUart->SetIER(K16550IER_RDAI|K16550IER_RLSI|K16550IER_MSI); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
420 |
iLdd->UpdateSignals(Signals()); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
421 |
Interrupt::Enable(iInterruptId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
422 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
423 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
424 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
425 |
TBool FinishedTransmitting(TAny* aPtr) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
426 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
427 |
DComm16550& d=*(DComm16550*)aPtr; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
428 |
return d.iUart->TestLSR(K16550LSR_TxIdle); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
429 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
430 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
431 |
void DComm16550::Stop(TStopMode aMode) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
432 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
433 |
// Stop receiving characters |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
434 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
435 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
436 |
switch (aMode) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
437 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
438 |
case EStopNormal: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
439 |
case EStopPwrDown: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
440 |
iUart->SetIER(0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
441 |
Interrupt::Disable(iInterruptId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
442 |
iTransmitting=EFalse; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
443 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
444 |
// wait for uart to stop tranmitting |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
445 |
Kern::PollingWait(FinishedTransmitting,this,3,100); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
446 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
447 |
case EStopEmergency: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
448 |
iUart->SetIER(0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
449 |
Interrupt::Disable(iInterruptId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
450 |
iTransmitting=EFalse; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
451 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
452 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
453 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
454 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
455 |
void DComm16550::Break(TBool aState) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
456 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
457 |
// Start or stop the uart breaking |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
458 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
459 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
460 |
if (aState) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
461 |
iUart->ModifyLCR(0,K16550LCR_TxBreak); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
462 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
463 |
iUart->ModifyLCR(K16550LCR_TxBreak,0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
464 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
465 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
466 |
void DComm16550::EnableTransmit() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
467 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
468 |
// Start sending characters. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
469 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
470 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
471 |
TBool tx = (TBool)__e32_atomic_swp_ord32(&iTransmitting, 1); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
472 |
if (tx) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
473 |
return; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
474 |
iUart->ModifyIER(0,K16550IER_THREI); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
475 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
476 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
477 |
TUint DComm16550::Signals() const |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
478 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
479 |
// Read and translate the modem lines |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
480 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
481 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
482 |
TUint msr=iUart->MSR(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
483 |
msr=((msr>>4)&0x0f); // true input signals |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
484 |
TUint sig=msr & 3; // CTS,DSR OK |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
485 |
if (msr & 4) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
486 |
sig|=KSignalRNG; // swap DCD,RNG |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
487 |
if (msr & 8) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
488 |
sig|=KSignalDCD; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
489 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
490 |
return sig; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
491 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
492 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
493 |
void DComm16550::SetSignals(TUint aSetMask, TUint aClearMask) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
494 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
495 |
// Set signals. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
496 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
497 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
498 |
TUint set=0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
499 |
TUint clear=0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
500 |
if (aSetMask & KSignalRTS) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
501 |
set|=K16550MCR_RTS; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
502 |
if (aSetMask & KSignalDTR) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
503 |
set|=K16550MCR_DTR; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
504 |
if (aClearMask & KSignalRTS) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
505 |
clear|=K16550MCR_RTS; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
506 |
if (aClearMask & KSignalDTR) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
507 |
clear|=K16550MCR_DTR; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
508 |
iUart->ModifyMCR(clear,set); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
509 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
510 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
511 |
TInt DComm16550::ValidateConfig(const TCommConfigV01 &aConfig) const |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
512 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
513 |
// Check a config structure. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
514 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
515 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
516 |
if (aConfig.iSIREnable==ESIREnable) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
517 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
518 |
switch (aConfig.iParity) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
519 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
520 |
case EParityNone: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
521 |
case EParityOdd: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
522 |
case EParityEven: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
523 |
case EParityMark: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
524 |
case EParitySpace: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
525 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
526 |
default: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
527 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
528 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
529 |
// if (TUint(aConfig.iRate)>TUint(EBps115200)) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
530 |
// return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
531 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
532 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
533 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
534 |
void DComm16550::CheckConfig(TCommConfigV01& aConfig) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
535 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
536 |
// do nothing |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
537 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
538 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
539 |
TInt DComm16550::DisableIrqs() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
540 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
541 |
// Disable normal interrupts |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
542 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
543 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
544 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
545 |
return NKern::DisableInterrupts(1); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
546 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
547 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
548 |
void DComm16550::RestoreIrqs(TInt aLevel) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
549 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
550 |
// Restore normal interrupts |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
551 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
552 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
553 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
554 |
NKern::RestoreInterrupts(aLevel); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
555 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
556 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
557 |
void DComm16550::Configure(TCommConfigV01 &aConfig) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
558 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
559 |
// Set up the Uart |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
560 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
561 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
562 |
// wait for uart to stop tranmitting |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
563 |
Kern::PollingWait(FinishedTransmitting,this,3,100); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
564 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
565 |
TUint lcr=0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
566 |
switch (aConfig.iDataBits) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
567 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
568 |
case EData5: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
569 |
lcr=K16550LCR_Data5; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
570 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
571 |
case EData6: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
572 |
lcr=K16550LCR_Data6; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
573 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
574 |
case EData7: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
575 |
lcr=K16550LCR_Data7; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
576 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
577 |
case EData8: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
578 |
lcr=K16550LCR_Data8; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
579 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
580 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
581 |
switch (aConfig.iStopBits) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
582 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
583 |
case EStop1: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
584 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
585 |
case EStop2: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
586 |
lcr|=K16550LCR_Stop2; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
587 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
588 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
589 |
switch (aConfig.iParity) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
590 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
591 |
case EParityNone: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
592 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
593 |
case EParityEven: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
594 |
lcr|=K16550LCR_ParityEnable|K16550LCR_ParityEven; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
595 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
596 |
case EParityOdd: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
597 |
lcr|=K16550LCR_ParityEnable; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
598 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
599 |
case EParityMark: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
600 |
lcr|=K16550LCR_ParityEnable|K16550LCR_ParityMark; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
601 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
602 |
case EParitySpace: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
603 |
lcr|=K16550LCR_ParityEnable|K16550LCR_ParitySpace; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
604 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
605 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
606 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
607 |
/* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
608 |
S18599EJ1V5UM.pdf page 746 uart configuration |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
609 |
Caution: Must not change the baud rate while any data transfers are executing. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
610 |
If the baud rate is necessary to changed, please apply following sequence. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
611 |
... (inlined with code) ... |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
612 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
613 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
614 |
// 1) Put UART in Local loop-back mode (write 1 to MCR4 bit). |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
615 |
iUart->ModifyMCR(0,K16550MCR_LocalLoop); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
616 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
617 |
// 2) Clear transmit FIFO (write 1 to FCR2 bit). |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
618 |
iUart->SetFCR(K16550FCR_TxReset); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
619 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
620 |
// 3) Wait 1 character period (ex. 100µs at 115kbps) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
621 |
NKern::Sleep(1); // sleep 1ms (for, 9600 bump up to 2ms?) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
622 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
623 |
// 4) Clear receive buffer (read RBR register until LSR0 bit becomes 0). |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
624 |
TInt maxdrain = 1000; // arbitrary count (fifo depth is 16 bytes) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
625 |
while (iUart->TestLSR(K16550LSR_RxReady) && --maxdrain) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
626 |
iUart->RxData(); // read character from RBR |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
627 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
628 |
// 5) Clear receive FIFO (write 1 to FCR1 bit). |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
629 |
iUart->SetFCR(K16550FCR_RxReset); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
630 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
631 |
// 6) Change the baud rate (write 1 to LCR7, write DLL and DLH, and then write 0 to LCR7). |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
632 |
iUart->SetLCR(lcr|K16550LCR_DLAB); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
633 |
iUart->SetBaudRateDivisor(BaudRateDivisor[(TInt)aConfig.iRate]); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
634 |
iUart->SetLCR(lcr); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
635 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
636 |
// 7) Go back to normal mode (write 0 to MCR4 bit). |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
637 |
iUart->ModifyMCR(K16550MCR_LocalLoop, 0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
638 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
639 |
// Enable fifo mode |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
640 |
//iUart->SetFCR(K16550FCR_Enable | K16550FCR_TxRxRdy | K16550FCR_RxTrig8); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
641 |
iUart->SetFCR(K16550FCR_Enable | K16550FCR_RxTrig8); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
642 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
643 |
#ifndef DISABLE_RX_FLUSH |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
644 |
// Read characters from RBR; this isn't part of the recommended baud rate change code |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
645 |
// but this has fixed the problem with ISR running indefinitely. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
646 |
TInt j; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
647 |
for (j=0;j<16;j++) // Fifo buffer is 16 bytes deep |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
648 |
iUart->RxData(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
649 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
650 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
651 |
#ifdef TRACK_DISTRIBUTION |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
652 |
// blank an array of 33 integers 0 to 32 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
653 |
TInt i=0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
654 |
for (i=0;i<33;i++) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
655 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
656 |
iRead[i]=0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
657 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
658 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
659 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
660 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
661 |
void DComm16550::Caps(TDes8 &aCaps) const |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
662 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
663 |
// return our caps |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
664 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
665 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
666 |
Get16550CommsCaps(aCaps,iUnit); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
667 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
668 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
669 |
void DComm16550::Isr(TAny* aPtr) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
670 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
671 |
// Service the UART interrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
672 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
673 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
674 |
DComm16550& d=*(DComm16550*)aPtr; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
675 |
T16550Uart& u=*d.iUart; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
676 |
TUint rx[32]; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
677 |
TUint xon=d.iLdd->iRxXonChar; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
678 |
TUint xoff=d.iLdd->iRxXoffChar; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
679 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
680 |
TUint isr=u.ISR(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
681 |
if (isr & K16550ISR_NotPending) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
682 |
return; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
683 |
isr&=K16550ISR_IntIdMask; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
684 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
685 |
// if receive data available or line status interrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
686 |
if (isr==K16550ISR_RDAI || isr==K16550ISR_RLSI) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
687 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
688 |
TInt rxi=0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
689 |
TInt x=0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
690 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
691 |
#if defined(RX_WORKAROUND) || defined(RX_WORKAROUND_SAVE) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
692 |
// It has been observed that the hardware can assert RDAI without asserting RxReady |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
693 |
// This is nasty but it reads from the head of the fifo, ORs in a faked error |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
694 |
// and saves it in the buffer, later on in the loop it will be passed to the ldd |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
695 |
// as data with an error |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
696 |
if (!(u.LSR() & K16550LSR_RxReady)) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
697 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
698 |
#ifdef TRACK_WORKAROUND |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
699 |
++d.iWorkaround; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
700 |
d.iWorkaroundLSR=u.LSR(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
701 |
d.iWorkaroundISR=u.ISR(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
702 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
703 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
704 |
#ifdef RX_WORKAROUND_SAVE |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
705 |
// save the character and flag error, this is a bit risky as it could report errors |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
706 |
rx[rxi++]=(u.RxData() | KReceiveIsrFrameError); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
707 |
#else // or just discard it (normal workaround) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
708 |
u.RxData(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
709 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
710 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
711 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
712 |
while (u.TestLSR(K16550LSR_RxReady|K16550LSR_RxParityErr|K16550LSR_RxOverrun|K16550LSR_RxFrameErr|K16550LSR_RxBreak) && Kern::PowerGood()) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
713 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
714 |
TUint lsr=0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
715 |
// checks for EIF flag |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
716 |
if (isr==K16550ISR_RLSI) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
717 |
lsr=u.LSR()&(K16550LSR_RxParityErr|K16550LSR_RxOverrun|K16550LSR_RxFrameErr); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
718 |
TUint ch=u.RxData(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
719 |
// if error in this character |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
720 |
if (lsr) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
721 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
722 |
if (lsr & K16550LSR_RxParityErr) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
723 |
ch|=KReceiveIsrParityError; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
724 |
if (lsr & K16550LSR_RxBreak) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
725 |
ch|=KReceiveIsrBreakError; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
726 |
if (lsr & K16550LSR_RxFrameErr) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
727 |
ch|=KReceiveIsrFrameError; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
728 |
if (lsr & K16550LSR_RxOverrun) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
729 |
ch|=KReceiveIsrOverrunError; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
730 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
731 |
if (ch==xon) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
732 |
x=1; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
733 |
else if (ch==xoff) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
734 |
x=-1; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
735 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
736 |
rx[rxi++]=ch; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
737 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
738 |
#ifdef TRACK_DISTRIBUTION |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
739 |
d.iRead[rxi]++; // record how many bytes we're reporting |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
740 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
741 |
d.ReceiveIsr(rx,rxi,x); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
742 |
return; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
743 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
744 |
// if TFS flag and TIE |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
745 |
if (isr==K16550ISR_THREI) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
746 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
747 |
TInt n; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
748 |
#ifdef TEMPORARY_SMP_FIX |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
749 |
for (n=0; n<8; ++n) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
750 |
#else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
751 |
for (n=0; n<16; ++n) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
752 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
753 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
754 |
TInt r=d.TransmitIsr(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
755 |
if (r<0) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
756 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
757 |
//no more to send |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
758 |
// Disable the TX interrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
759 |
u.ModifyIER(K16550IER_THREI,0); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
760 |
d.iTransmitting=EFalse; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
761 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
762 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
763 |
u.SetTxData(r); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
764 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
765 |
d.CheckTxBuffer(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
766 |
return; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
767 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
768 |
// must be signal change |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
769 |
d.StateIsr(d.Signals()); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
770 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
771 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
772 |
DECLARE_STANDARD_PDD() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
773 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
774 |
return new DDriverComm; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
775 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
776 |