omap3530/omap3530_drivers/euart/euart.cpp
author george.norton
Thu, 01 Jul 2010 17:46:13 +0100
changeset 39 cdb163c0843f
permissions -rw-r--r--
Initial contribution of the euart driver by Accenture. Known issues ============ When the FIFO is enabled we seem to get some dropped characters, as a temporary workaround a polling mode is enabled.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     1
// This component and the accompanying materials are made available
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     2
// under the terms of the License "Symbian Foundation License v1.0"
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     3
// which accompanies this distribution, and is available
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     4
// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     5
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     6
// Initial Contributors:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     7
// Accenture
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     8
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
     9
// Contributors:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    10
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    11
// Description:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    12
// \sf\adaptation\beagleboard\omap3530\omap3530_drivers\euart\euart.cpp
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    13
// pdd for serial ports
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    14
// assume Modem Control Signals change cause an interrupt
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    15
// 
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    16
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    17
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    18
#include <d32comm.h>
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    19
#include <beagle\variant.h>
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    20
#include "euart.h"
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    21
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    22
#define TX_POLLING_HACK
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    23
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    24
_LIT(KPddName,"Comm.Beagle");
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    25
using namespace Omap3530Uart;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    26
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    27
DDriverComm::DDriverComm()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    28
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    29
// Constructor
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    30
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    31
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    32
	iUnitsMask=0x7;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    33
	iVersion=TVersion(KCommsMajorVersionNumber,KCommsMinorVersionNumber,KCommsBuildVersionNumber);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    34
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    35
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    36
TInt DDriverComm::Install()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    37
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    38
// Install the driver
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    39
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    40
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    41
	return SetName(&KPddName);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    42
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    43
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    44
void GetTemplateCommsCaps(TDes8 &aCaps, TInt aUnit)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    45
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    46
	TCommCaps2 capsBuf;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    47
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    48
	// Fill in the Caps structure with the relevant information for this Unit, e.g
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    49
	TCommCapsV02 &c=capsBuf();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    50
	c.iRate=KCapsBps1200|KCapsBps2400|KCapsBps4800|KCapsBps9600|KCapsBps19200|KCapsBps38400|
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    51
			KCapsBps57600|KCapsBps115200|KCapsBps230400|KCapsBps460800|KCapsBps4000000;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    52
			
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    53
	c.iDataBits=KCapsData5|KCapsData6|KCapsData7|KCapsData8;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    54
	c.iStopBits=KCapsStop1|KCapsStop2;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    55
	c.iParity=KCapsParityNone|KCapsParityEven|KCapsParityOdd|KCapsParityMark|KCapsParitySpace;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    56
	c.iHandshake=0; //(OR in all KCapsObeyXXXSupported, KCapsSendXXXSupported, KCapsFailXXXSupported, KCapsFreeXXXSupported
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    57
				    // as required for this Unit's configuration);.
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    58
	c.iSignals=0;   //(OR in as many KCapsSignalXXXSupported as Modem control signals controllable by this Unit);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    59
	c.iSIR=0; 		//(0 or OR in as many KCapsSIRXXX as IR bit rates supported);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    60
	c.iNotificationCaps=0; //(OR in as many KNotifyXXXSupported as notifications supported by this Unit);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    61
	c.iFifo=0;				//(0 or KCapsHasFifo);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    62
	c.iRoleCaps=0;			//(0 or KCapsRoleSwitchSupported);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    63
	c.iFlowControlCaps=0;	//(0 or KCapsFlowControlStatusSupported);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    64
	/** @see TCommCapsV02 */
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    65
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    66
	aCaps=capsBuf.Left(Min(capsBuf.Length(),aCaps.MaxLength()));
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    67
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    68
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    69
void DDriverComm::GetCaps(TDes8 &aDes) const
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    70
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    71
// Return the drivers capabilities
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    72
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    73
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    74
	GetTemplateCommsCaps(aDes, 0);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    75
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    76
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    77
TInt DDriverComm::Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion& aVer)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    78
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    79
// Create a driver
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    80
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    81
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    82
	DCommBeagle* pD=new DCommBeagle;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    83
	aChannel=pD;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    84
	TInt r=KErrNoMemory;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    85
	if (pD)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    86
		r=pD->DoCreate(aUnit,anInfo);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    87
	return r;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    88
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    89
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    90
TInt DDriverComm::Validate(TInt aUnit, const TDesC8* /*anInfo*/, const TVersion& aVer)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    91
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    92
//	Validate the requested configuration (Version and Unit)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    93
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    94
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    95
	if ((!Kern::QueryVersionSupported(iVersion,aVer)) || (!Kern::QueryVersionSupported(aVer,TVersion(KMinimumLddMajorVersion,KMinimumLddMinorVersion,KMinimumLddBuild))))
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    96
		return KErrNotSupported;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    97
		
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    98
	if(aUnit<0 || aUnit >2)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
    99
		return KErrNotSupported;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   100
		
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   101
	return KErrNone;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   102
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   103
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   104
DCommBeagle::DCommBeagle()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   105
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   106
// Constructor
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   107
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   108
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   109
	gData=0;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   110
	iInterruptId=-1;		// -1 means not bound
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   111
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   112
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   113
DCommBeagle::~DCommBeagle()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   114
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   115
// Destructor
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   116
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   117
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   118
	if (iInterruptId>=0)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   119
		Interrupt::Unbind(iInterruptId);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   120
	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   121
	if (iDfcQ)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   122
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   123
		iDfcQ->Destroy();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   124
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   125
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   126
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   127
const TInt KDCommBeagleDfcThreadPriority = 24;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   128
_LIT(KDCommBeagleDfcThread,"DCommBeagleDfcThread");
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   129
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   130
TInt DCommBeagle::DoCreate(TInt aUnit, const TDesC8* /*anInfo*/)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   131
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   132
// Sets up the PDD
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   133
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   134
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   135
	iUnit=aUnit;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   136
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   137
	//  Create own DFC queue
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   138
	TInt r = Kern::DynamicDfcQCreate(iDfcQ, KDCommBeagleDfcThreadPriority, KDCommBeagleDfcThread);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   139
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   140
	if (r != KErrNone)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   141
		return r; 	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   142
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   143
	// Set iPortAddr and irq with the Linear Base address of the UART and the Interrupt ID coresponding to aUnit
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   144
	iUart = new TUart((TUartNumber)aUnit);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   145
	Prcm::SetClockState(iUart->PrcmInterfaceClk(), Prcm::EClkOn);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   146
	Prcm::SetClockState(iUart->PrcmFunctionClk(), Prcm::EClkOn);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   147
	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   148
	// bind to UART interrupt
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   149
	r=Interrupt::Bind(iUart->InterruptId(),Isr,this);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   150
	if (r==KErrNone)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   151
		iInterruptId=iUart->InterruptId();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   152
	return r;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   153
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   154
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   155
TDfcQue* DCommBeagle::DfcQ(TInt aUnit)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   156
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   157
// Return the DFC queue to be used for this device
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   158
// For UARTs just use the standard low priority DFC queue
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   159
// For Serial PC cards, use the PC card controller thread for the socket in question.
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   160
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   161
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   162
	return aUnit==iUnit ? iDfcQ : NULL;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   163
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   164
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   165
TInt DCommBeagle::Start()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   166
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   167
// Start receiving characters
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   168
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   169
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   170
	if(iUnit == Kern::SuperPage().iDebugPort)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   171
		Variant::MarkDebugPortOff();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   172
	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   173
	iTransmitting=EFalse;			// if EnableTransmit() called before Start()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   174
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   175
	if(iUart==NULL)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   176
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   177
		return KErrNotReady;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   178
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   179
	iSignals=Signals();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   180
	iLdd->UpdateSignals(iSignals);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   181
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   182
	Interrupt::Enable(iInterruptId);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   183
	iUart->EnableInterrupt(TUart::EIntRhr);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   184
	return KErrNone;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   185
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   186
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   187
TBool FinishedTransmitting(TAny* aPtr)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   188
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   189
	DCommBeagle* self = (DCommBeagle*)aPtr;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   190
	if(self->iUart==NULL)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   191
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   192
		return ETrue;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   193
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   194
		
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   195
	if(!self->iUart->TxFifoEmpty())
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   196
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   197
		return EFalse;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   198
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   199
	return ETrue;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   200
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   201
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   202
void DCommBeagle::Stop(TStopMode aMode)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   203
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   204
// Stop receiving characters
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   205
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   206
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   207
	switch (aMode)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   208
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   209
		case EStopNormal:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   210
		case EStopPwrDown:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   211
			iUart->DisableInterrupt(TUart::EIntRhr);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   212
			iUart->DisableInterrupt(TUart::EIntThr);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   213
			Interrupt::Disable(iInterruptId);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   214
			
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   215
			// wait for uart to stop tranmitting
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   216
			Kern::PollingWait(FinishedTransmitting,this,3,100);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   217
			
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   218
			iTransmitting=EFalse;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   219
			
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   220
			iUart->Disable();			
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   221
			Prcm::SetClockState(iUart->PrcmFunctionClk(), Prcm::EClkOff);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   222
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   223
		case  EStopEmergency:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   224
			iUart->DisableInterrupt(TUart::EIntRhr);			
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   225
			iUart->DisableInterrupt(TUart::EIntThr);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   226
			Interrupt::Disable(iInterruptId);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   227
			iTransmitting=EFalse;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   228
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   229
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   230
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   231
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   232
void DCommBeagle::Break(TBool aState)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   233
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   234
// Start or stop the uart breaking
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   235
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   236
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   237
	if (aState)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   238
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   239
		//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   240
		// TO DO: (mandatory)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   241
		//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   242
		// Enable sending a Break (space) condition
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   243
		//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   244
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   245
	else
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   246
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   247
		//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   248
		// TO DO: (mandatory)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   249
		//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   250
		// Stop sending a Break (space) condition
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   251
		//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   252
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   253
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   254
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   255
void DCommBeagle::EnableTransmit()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   256
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   257
// Start sending characters.
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   258
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   259
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   260
	TBool tx=(TBool)NKern::SafeSwap((TAny*)ETrue,(TAny*&)iTransmitting);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   261
	if (tx)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   262
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   263
		return;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   264
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   265
	TInt r = 0;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   266
	#ifdef TX_POLLING_HACK
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   267
	while (Kern::PowerGood())
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   268
	#else
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   269
	while (Kern::PowerGood() && !iUart->TxFifoFull())
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   270
	#endif
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   271
		{	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   272
		r=TransmitIsr();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   273
		if(r<0)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   274
			{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   275
			//no more to send
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   276
			iTransmitting=EFalse;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   277
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   278
			}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   279
		#ifdef TX_POLLING_HACK
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   280
		while(iUart->TxFifoFull());
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   281
		#endif
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   282
		iUart->Write(r);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   283
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   284
	TInt irq=0;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   285
	if (!iInInterrupt)					// CheckTxBuffer adds a Dfc: can only run from ISR or with NKernel locked
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   286
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   287
		NKern::Lock();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   288
		irq=NKern::DisableAllInterrupts();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   289
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   290
	CheckTxBuffer();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   291
	if (!iInInterrupt)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   292
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   293
		NKern::RestoreInterrupts(irq);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   294
		NKern::Unlock();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   295
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   296
	if (r>=0)											// only enable interrupt if there's more data to send
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   297
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   298
		iUart->EnableInterrupt(TUart::EIntThr);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   299
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   300
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   301
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   302
TUint DCommBeagle::Signals() const
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   303
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   304
// Read and translate the modem lines
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   305
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   306
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   307
	TUint signals=0;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   308
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   309
	// TO DO: (mandatory)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   310
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   311
	// If the UART corresponding to iUnit supports Modem Control Signals, read them and return a bitmask with one or 
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   312
	// more of the following OR-ed in:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   313
	// - KSignalDTR,
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   314
	// - KSignalRTS,
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   315
	// - KSignalDSR,
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   316
	// - KSignalCTS,
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   317
	// - KSignalDCD.
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   318
	// 
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   319
	return signals;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   320
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   321
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   322
void DCommBeagle::SetSignals(TUint aSetMask, TUint aClearMask)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   323
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   324
// Set signals.
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   325
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   326
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   327
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   328
	// TO DO: (mandatory)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   329
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   330
	// If the UART corresponding to iUnit supports Modem Control Signals, converts the flags in aSetMask and aClearMask 
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   331
	// into hardware-specific bitmasks to write to the UART modem/handshake output register(s). 
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   332
	// aSetMask, aClearMask will have one or more of the following OR-ed in:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   333
	// - KSignalDTR,
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   334
	// - KSignalRTS,
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   335
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   336
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   337
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   338
TInt DCommBeagle::ValidateConfig(const TCommConfigV01 &aConfig) const
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   339
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   340
// Check a config structure.
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   341
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   342
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   343
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   344
	// TO DO: (mandatory)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   345
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   346
	// Checks the the options in aConfig are supported by the UART corresponding to iUnit
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   347
	// May need to check:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   348
	//  - aConfig.iParity (contains one of EParityXXX)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   349
	/** @see TParity */
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   350
	//  - aConfig.iRate (contains one of EBpsXXX)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   351
	/** @see TBps */
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   352
	//  - aConfig.iDataBits (contains one of EDataXXX)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   353
	/** @see TDataBits */
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   354
	//  - aConfig.iStopBits (contains one of EStopXXX)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   355
	/** @see TDataBits */
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   356
	//  - aConfig.iHandshake (contains one of KConfigObeyXXX or KConfigSendXXX or KConfigFailXXX or KConfigFreeXXX)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   357
	//  - aConfig.iParityError (contains KConfigParityErrorFail or KConfigParityErrorIgnore or KConfigParityErrorReplaceChar)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   358
	//  - aConfig.iFifo (contains ether EFifoEnable or EFifoDisable)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   359
	/** @see TFifo */
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   360
	//  - aConfig.iSpecialRate (may contain a rate not listed under TBps)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   361
	//  - aConfig.iTerminatorCount (conatains number of special characters used as terminators)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   362
	//  - aConfig.iTerminator[] (contains a list of special characters which can be used as terminators)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   363
	//  - aConfig.iXonChar (contains the character used as XON - software flow control)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   364
	//  - aConfig.iXoffChar (contains the character used as XOFF - software flow control)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   365
	//  - aConfig.iParityErrorChar (contains the character used to replace bytes received with a parity error)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   366
	//  - aConfig.iSIREnable (contains either ESIREnable or ESIRDisable)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   367
	/** @see TSir */
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   368
	//  - aConfig.iSIRSettings (contains one of KConfigSIRXXX)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   369
	// and returns KErrNotSupported if the UART corresponding to iUnit does not support this configuration
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   370
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   371
	return KErrNone;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   372
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   373
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   374
void DCommBeagle::CheckConfig(TCommConfigV01& aConfig)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   375
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   376
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   377
	// TO DO: (optional)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   378
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   379
	// Validates the default configuration that is defined when a channel is first opened
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   380
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   381
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   382
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   383
TInt DCommBeagle::DisableIrqs()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   384
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   385
// Disable normal interrupts
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   386
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   387
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   388
	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   389
	return NKern::DisableInterrupts(1);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   390
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   391
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   392
void DCommBeagle::RestoreIrqs(TInt aLevel)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   393
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   394
// Restore normal interrupts
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   395
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   396
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   397
	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   398
	NKern::RestoreInterrupts(aLevel);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   399
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   400
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   401
void DCommBeagle::Configure(TCommConfigV01 &aConfig)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   402
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   403
// Configure the UART from aConfig
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   404
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   405
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   406
	Kern::PollingWait(FinishedTransmitting,this,3,100);	// wait for uart to stop tranmitting
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   407
	iUart->Disable();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   408
	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   409
	iUart->Init();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   410
	iUart->DefineMode(TUart::EUart);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   411
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   412
	switch(aConfig.iRate)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   413
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   414
		case EBps1200:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   415
			iUart->SetBaud(TUart::E1200);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   416
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   417
		case EBps2400:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   418
			iUart->SetBaud(TUart::E2400);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   419
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   420
		case EBps4800:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   421
			iUart->SetBaud(TUart::E4800);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   422
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   423
		case EBps9600:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   424
			iUart->SetBaud(TUart::E9600);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   425
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   426
		case EBps19200:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   427
			iUart->SetBaud(TUart::E19200);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   428
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   429
		case EBps38400:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   430
			iUart->SetBaud(TUart::E38400);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   431
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   432
		case EBps57600:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   433
			iUart->SetBaud(TUart::E57600);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   434
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   435
		case EBps460800:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   436
			iUart->SetBaud(TUart::E460800);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   437
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   438
		case EBps115200:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   439
		default:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   440
			iUart->SetBaud(TUart::E115200);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   441
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   442
	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   443
	TUart::TDataBits databits = (TUart::TDataBits)aConfig.iDataBits;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   444
	TUart::TStopBits stopbits;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   445
	switch(aConfig.iStopBits)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   446
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   447
		case EStop2:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   448
			stopbits=TUart::E2Stop;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   449
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   450
		case EStop1:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   451
		default:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   452
			stopbits=TUart::E1Stop;		
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   453
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   454
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   455
	TUart::TParity parity;	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   456
	switch(aConfig.iParity)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   457
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   458
		case EParityEven:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   459
			parity=TUart::EEven;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   460
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   461
		case EParityOdd:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   462
			parity=TUart::EOdd;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   463
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   464
		case EParityMark:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   465
			parity=TUart::EMark;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   466
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   467
		case EParitySpace:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   468
			parity=TUart::ESpace;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   469
			break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   470
		case EParityNone:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   471
		default:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   472
			parity=TUart::ENone;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   473
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   474
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   475
	iUart->SetDataFormat(databits, stopbits, parity);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   476
	iUart->EnableFifo(TUart::EEnabled, TUart::ETrigger8, TUart::ETrigger8);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   477
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   478
	iUart->Enable();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   479
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   480
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   481
void DCommBeagle::Caps(TDes8 &aCaps) const
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   482
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   483
// return our caps
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   484
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   485
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   486
	GetTemplateCommsCaps(aCaps,iUnit);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   487
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   488
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   489
void DCommBeagle::Isr(TAny* aPtr)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   490
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   491
// Service the UART interrupt
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   492
//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   493
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   494
	DCommBeagle& d=*(DCommBeagle*)aPtr;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   495
	d.iInInterrupt=1;										// going in...
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   496
	TUint xon=d.iLdd->iRxXonChar;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   497
	TUint xoff=d.iLdd->iRxXoffChar;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   498
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   499
	// Read the interrupt source register to determine if it is a Receive, Transmit or Modem Signals change interrupt.
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   500
	// If required also, clear interrupts at the source.
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   501
	// Then process the interrupt condition as in the following pseudo-code extract:
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   502
	//
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   503
	TUint interruptId = IIR::iMem.Read(*(d.iUart));
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   504
	TUint interruptEn = IER::iMem.Read(*(d.iUart));	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   505
	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   506
	if((interruptId & IIR::IT_TYPE::ETHR) && (interruptEn & IER::THR_IT::KMask) )
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   507
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   508
		while(Kern::PowerGood() && !d.iUart->TxFifoFull())	
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   509
			{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   510
			TInt r=d.TransmitIsr();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   511
			if(r<0)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   512
				{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   513
				// Disable the Transmit Interrupt in Hardware
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   514
				d.iUart->DisableInterrupt(TUart::EIntThr);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   515
				d.iTransmitting=EFalse;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   516
				break;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   517
				}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   518
			d.iUart->Write(r);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   519
			}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   520
		d.CheckTxBuffer();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   521
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   522
		
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   523
	if((interruptId & IIR::IT_TYPE::ERHR) && (interruptEn & IER::RHR_IT::KMask) )
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   524
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   525
		TUint rx[32];
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   526
		TInt rxi=0;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   527
		TInt x=0;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   528
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   529
		while(!d.iUart->RxFifoEmpty() && rxi<32)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   530
			{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   531
			TUint ch = d.iUart->Read();
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   532
			if (ch==xon)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   533
				x=1;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   534
			else if (ch==xoff)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   535
				x=-1;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   536
			else
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   537
				rx[rxi++]=ch;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   538
			}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   539
		d.ReceiveIsr(rx,rxi,x);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   540
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   541
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   542
	if((interruptId & IIR::IT_TYPE::EModem) && (interruptEn & IER::MODEM_STS_IT::KMask) )
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   543
		{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   544
		TUint signals=d.Signals()&KDTEInputSignals;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   545
		if (signals != d.iSignals)
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   546
			{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   547
			d.iSignals=signals;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   548
			d.iLdd->StateIsr(signals);
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   549
			}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   550
		}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   551
	d.iInInterrupt=0;										// going out...
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   552
	}
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   553
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   554
DECLARE_STANDARD_PDD()
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   555
	{
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   556
	return new DDriverComm;
cdb163c0843f Initial contribution of the euart driver by Accenture.
george.norton
parents:
diff changeset
   557
	}