sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\d32comm.h sl@0: // sl@0: // sl@0: sl@0: //#define _DEBUG_DEVCOMM sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __D32COMM_H__ sl@0: #define __D32COMM_H__ sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Enumeration of number of data bits for serial port configuration. sl@0: Typically, these values are used to initialize the iDataBits of sl@0: TCommConfigV01 before calling DComm::Configure() or any other serial sl@0: comm API to configure the serial port's databits size. sl@0: */ sl@0: enum TDataBits {EData5,EData6,EData7,EData8}; sl@0: /** sl@0: Enumeration of number of stop bits for serial port configuration. sl@0: Typically, these values are used to initialize the iStopBits of sl@0: TCommConfigV01 before calling DComm::Configure() or any other serial sl@0: comm API to configure the serial port's stopbits. sl@0: */ sl@0: enum TStopBits {EStop1,EStop2}; sl@0: /** sl@0: Enumeration of types of parity for serial port configuration. sl@0: Typically, these values are used to initialize the iParity of sl@0: TCommConfigV01 before calling DComm::Configure() or any other serial sl@0: comm API to configure the serial port's parity setting. sl@0: */ sl@0: enum TParity {EParityNone,EParityEven,EParityOdd,EParityMark,EParitySpace}; sl@0: /** sl@0: Enumeration of baud rates in bits per second for serial port configuration. sl@0: * e.g EBps115200 is for 115200Bps data rate sl@0: Typically, these values are used to initialize the iRate of TCommConfigV01 sl@0: before calling DComm::Configure() or any other serial comm API to configure sl@0: the serial port's baud rate. sl@0: */ sl@0: enum TBps sl@0: { sl@0: EBps50, sl@0: EBps75, sl@0: EBps110, sl@0: EBps134, sl@0: EBps150, sl@0: EBps300, sl@0: EBps600, sl@0: EBps1200, sl@0: EBps1800, sl@0: EBps2000, sl@0: EBps2400, sl@0: EBps3600, sl@0: EBps4800, sl@0: EBps7200, sl@0: EBps9600, sl@0: EBps19200, sl@0: EBps38400, sl@0: EBps57600, sl@0: EBps115200, sl@0: EBps230400, sl@0: EBps460800, sl@0: EBps576000, sl@0: EBps1152000, sl@0: EBps4000000, sl@0: EBps921600, sl@0: EBpsAutobaud=0x40000000, sl@0: EBpsSpecial=0x80000000, sl@0: }; sl@0: /** sl@0: Enumeration of Fifo status (enable and disable) for serial port configuration. sl@0: Typically, these values are used to initialize the iFifo of TCommConfigV01 sl@0: before calling DComm::Configure() or any other serial comm API to configure sl@0: the serial port's fifo. sl@0: */ sl@0: enum TFifo sl@0: { sl@0: EFifoEnable,EFifoDisable, sl@0: }; sl@0: /** sl@0: Enumeration of SIR status (enable and disable) for serial comm configuration. sl@0: Typically, these values are used to initialize the iSIREnable of TCommConfigV01 sl@0: before calling DComm::Configure() or any other serial comm API to configure sl@0: the serial port's SIR (infrared) settings. sl@0: */ sl@0: enum TSir sl@0: { sl@0: ESIREnable,ESIRDisable, sl@0: }; sl@0: sl@0: const TInt KConfigMaxTerminators=4; sl@0: // DTE Constants sl@0: const TUint KConfigObeyXoff=0x01; sl@0: const TUint KConfigSendXoff=0x02; sl@0: const TUint KConfigObeyCTS=0x04; sl@0: const TUint KConfigFailCTS=0x08; sl@0: const TUint KConfigObeyDSR=0x10; sl@0: const TUint KConfigFailDSR=0x20; sl@0: const TUint KConfigObeyDCD=0x40; sl@0: const TUint KConfigFailDCD=0x80; sl@0: const TUint KConfigFreeRTS=0x100; sl@0: const TUint KConfigFreeDTR=0x200; sl@0: // DCE Constants sl@0: const TUint KConfigObeyDTR=0x400; sl@0: const TUint KConfigFailDTR=0x800; sl@0: const TUint KConfigObeyRTS=0x1000; sl@0: const TUint KConfigFailRTS=0x2000; sl@0: const TUint KConfigFreeDSR=0x4000; sl@0: const TUint KConfigFreeCTS=0x8000; sl@0: const TUint KConfigFreeDCD=0x10000; sl@0: const TUint KConfigFreeRI=0x20000; sl@0: const TUint KConfigWriteBufferedComplete=0x80000000; sl@0: // sl@0: const TUint KConfigParityErrorFail=0; sl@0: const TUint KConfigParityErrorIgnore=0x01; sl@0: const TUint KConfigParityErrorReplaceChar=0x02; sl@0: const TUint KConfigXonXoffDebug=0x80000000; sl@0: // sl@0: const TUint KSignalCTS=0x01; sl@0: const TUint KSignalDSR=0x02; sl@0: const TUint KSignalDCD=0x04; sl@0: const TUint KSignalRNG=0x08; sl@0: const TUint KSignalRTS=0x10; sl@0: const TUint KSignalDTR=0x20; sl@0: const TUint KSignalBreak=0x40; sl@0: sl@0: const TUint KSignalChanged=0x1000; sl@0: const TUint KCTSChanged=KSignalCTS*KSignalChanged; sl@0: const TUint KDSRChanged=KSignalDSR*KSignalChanged; sl@0: const TUint KDCDChanged=KSignalDCD*KSignalChanged; sl@0: const TUint KRNGChanged=KSignalRNG*KSignalChanged; sl@0: const TUint KRTSChanged=KSignalRTS*KSignalChanged; sl@0: const TUint KDTRChanged=KSignalDTR*KSignalChanged; sl@0: const TUint KBreakChanged=KSignalBreak*KSignalChanged; sl@0: sl@0: const TUint KSignalDTEOutputs=KSignalRTS|KSignalDTR; sl@0: const TUint KSignalDTEInputs=KSignalCTS|KSignalDSR|KSignalDCD|KSignalRNG; sl@0: const TUint KSignalDCEInputs=KSignalDTEOutputs; sl@0: const TUint KSignalDCEOutputs=KSignalDTEInputs; sl@0: sl@0: const TUint KConfigSIRPulseWidthMaximum=0x01; sl@0: const TUint KConfigSIRPulseWidthMinimum=0x02; sl@0: sl@0: // more SIRSettings for selecting the IR range sl@0: const TUint KConfigSIRShutDown=0x10; sl@0: const TUint KConfigSIRMinimumRange=0x20; sl@0: const TUint KConfigSIRMediumRange=0x40; sl@0: const TUint KConfigSIRMaximumRange=0x80; sl@0: sl@0: /** sl@0: Comms configuration structure. sl@0: Class to hold the configuration settings for serial comm port sl@0: sl@0: This class provides the serial port configuration block interface of serial comms (c32). sl@0: A serial comm client sets up a serial port before use, by providing a configuration block. sl@0: TCommConfigV01 is initialized with settings for serial port and used to configure the sl@0: serial port by calling DComm::Configure(TCommConfigV01 &aConfig) or any other serial comm sl@0: API to configure the serial port. sl@0: */ sl@0: class TCommConfigV01 sl@0: { sl@0: public: sl@0: /** sl@0: Data rate in bits per second. sl@0: @see TBps sl@0: */ sl@0: TBps iRate; sl@0: /** sl@0: Character width in bits. sl@0: @see TDataBits sl@0: */ sl@0: TDataBits iDataBits; sl@0: /** sl@0: Number of stop bits. sl@0: @see TStopBits sl@0: */ sl@0: TStopBits iStopBits; sl@0: /** sl@0: Type of parity. sl@0: @see TParity sl@0: */ sl@0: TParity iParity; sl@0: /** sl@0: Type of Handshaking control. sl@0: Possible values can be KConfigObeyXXX or KConfigSendXXX or KConfigFailXXX or KConfigFreeXXX sl@0: */ sl@0: TUint iHandshake; sl@0: /** sl@0: Type of error to generate on a parity failure. sl@0: Possible values can be KConfigParityErrorFail or KConfigParityErrorIgnore or KConfigParityErrorReplaceChar sl@0: */ sl@0: TUint iParityError; sl@0: /** sl@0: FIFO status, enabled or disabled. sl@0: @see TFifo sl@0: */ sl@0: TUint iFifo; sl@0: /** sl@0: Special data rate, not listed under TBps. Use this, when iRate is set to EBpsSpecial sl@0: */ sl@0: TInt iSpecialRate; sl@0: /** sl@0: Count of number of special characters used as terminators (<=KConfigMaxTerminators) sl@0: */ sl@0: TInt iTerminatorCount; sl@0: /** sl@0: Array of special characters which can be used as terminators sl@0: */ sl@0: TText8 iTerminator[KConfigMaxTerminators]; sl@0: /** sl@0: Character used to signal the transmitter to resume sending when using XON/XOFF handshaking sl@0: i.e character used as XON - software flow control sl@0: */ sl@0: TText8 iXonChar; sl@0: /** sl@0: Character used to signal the transmitter to suspend sending when using XON/XOFF handshaking sl@0: i.e character used as XOFF - software flow control sl@0: */ sl@0: TText8 iXoffChar; sl@0: /** sl@0: Character used to replace the characters received with a parity error. sl@0: This is used when iParityError is set to KConfigParityErrorReplaceChar sl@0: */ sl@0: TText8 iParityErrorChar; sl@0: /** sl@0: Switch the SIR encoding hardware on and off. sl@0: @see TSir sl@0: */ sl@0: TSir iSIREnable; sl@0: /** sl@0: SIR hardware control setting. Possible value can be one of KConfigSIRXXX sl@0: */ sl@0: TUint iSIRSettings; sl@0: }; sl@0: /** sl@0: Package buffer for a TCommConfigV01 object. sl@0: sl@0: TCommConfig packages the comms configuration structure TCommConfigV01 to a buffer. sl@0: This is used with API of serial comms like RComm::Config(TDes8 &aConfig) and sl@0: RComm::SetConfig(TDesC8 &aConfig) where config structure is passed as buffer. sl@0: sl@0: @see TCommConfigV01 sl@0: */ sl@0: typedef TPckgBuf TCommConfig; sl@0: sl@0: // TCommConfigV02 is deprecated. sl@0: // sl@0: class TCommConfigV02: public TCommConfigV01 sl@0: { sl@0: public: sl@0: TInt iTxShutdownTimeout; sl@0: }; sl@0: sl@0: // TCommConfig2 is deprecated sl@0: // sl@0: typedef TPckgBuf TCommConfig2; sl@0: sl@0: // sl@0: const TUint KCapsBps50=0x00000001; sl@0: const TUint KCapsBps75=0x00000002; sl@0: const TUint KCapsBps110=0x00000004; sl@0: const TUint KCapsBps134=0x00000008; sl@0: const TUint KCapsBps150=0x00000010; sl@0: const TUint KCapsBps300=0x00000020; sl@0: const TUint KCapsBps600=0x00000040; sl@0: const TUint KCapsBps1200=0x00000080; sl@0: const TUint KCapsBps1800=0x00000100; sl@0: const TUint KCapsBps2000=0x00000200; sl@0: const TUint KCapsBps2400=0x00000400; sl@0: const TUint KCapsBps3600=0x00000800; sl@0: const TUint KCapsBps4800=0x00001000; sl@0: const TUint KCapsBps7200=0x00002000; sl@0: const TUint KCapsBps9600=0x00004000; sl@0: const TUint KCapsBps19200=0x00008000; sl@0: const TUint KCapsBps38400=0x00010000; sl@0: const TUint KCapsBps57600=0x00020000; sl@0: const TUint KCapsBps115200=0x00040000; sl@0: const TUint KCapsBps230400=0x00080000; sl@0: const TUint KCapsBps460800=0x00100000; sl@0: const TUint KCapsBps576000 =0x00200000; sl@0: const TUint KCapsBps1152000=0x00400000; sl@0: const TUint KCapsBps4000000=0x00800000; sl@0: const TUint KCapsBps921600=0x01000000; sl@0: const TUint KCapsBpsAutobaud=0x40000000; sl@0: const TUint KCapsBpsSpecial=0x80000000; sl@0: // sl@0: const TUint KCapsData5=0x01; sl@0: const TUint KCapsData6=0x02; sl@0: const TUint KCapsData7=0x04; sl@0: const TUint KCapsData8=0x08; sl@0: // sl@0: const TUint KCapsStop1=0x01; sl@0: const TUint KCapsStop2=0x02; sl@0: // sl@0: const TUint KCapsParityNone=0x01; sl@0: const TUint KCapsParityEven=0x02; sl@0: const TUint KCapsParityOdd=0x04; sl@0: const TUint KCapsParityMark=0x08; sl@0: const TUint KCapsParitySpace=0x10; sl@0: // sl@0: const TUint KCapsSignalCTSSupported=0x01; sl@0: const TUint KCapsSignalDSRSupported=0x02; sl@0: const TUint KCapsSignalDCDSupported=0x04; sl@0: const TUint KCapsSignalRNGSupported=0x08; sl@0: const TUint KCapsSignalRTSSupported=0x10; sl@0: const TUint KCapsSignalDTRSupported=0x20; sl@0: // sl@0: const TUint KCapsObeyXoffSupported=0x01; sl@0: const TUint KCapsSendXoffSupported=0x02; sl@0: const TUint KCapsObeyCTSSupported=0x04; sl@0: const TUint KCapsFailCTSSupported=0x08; sl@0: const TUint KCapsObeyDSRSupported=0x10; sl@0: const TUint KCapsFailDSRSupported=0x20; sl@0: const TUint KCapsObeyDCDSupported=0x40; sl@0: const TUint KCapsFailDCDSupported=0x80; sl@0: const TUint KCapsFreeRTSSupported=0x100; sl@0: const TUint KCapsFreeDTRSupported=0x200; sl@0: // DCE Constants sl@0: const TUint KCapsObeyRTSSupported=0x400; sl@0: const TUint KCapsObeyDTRSupported=0x800; sl@0: // sl@0: const TUint KCapsHasFifo=0x01; sl@0: // sl@0: const TUint KCapsSIR115kbps=0x01; sl@0: const TUint KCapsSIR2400bpsOnly=0x02; sl@0: const TUint KCapsSIR4Mbs=0x04; sl@0: // sl@0: const TUint KNotifySignalsChangeSupported=0x01; sl@0: const TUint KNotifyRateChangeSupported=0x02; sl@0: const TUint KNotifyDataFormatChangeSupported=0x04; sl@0: const TUint KNotifyHandshakeChangeSupported=0x08; sl@0: const TUint KNotifyBreakSupported=0x10; sl@0: const TUint KNotifyFlowControlChangeSupported=0x20; sl@0: const TUint KNotifyDataAvailableSupported=0x40; sl@0: const TUint KNotifyOutputEmptySupported=0x80; sl@0: // sl@0: const TUint KCapsRoleSwitchSupported=0x01; sl@0: // sl@0: const TUint KCapsFlowControlStatusSupported=0x01; sl@0: // sl@0: const TUint KRateChanged=0x01; sl@0: const TUint KDataFormatChanged=0x02; sl@0: const TUint KHandshakeChanged=0x04; sl@0: // sl@0: sl@0: /** sl@0: Comms capability structure. sl@0: Class to query the capability settings for serial comm port device. sl@0: Members of this class are filled with the capabilities of the comm port device. sl@0: */ sl@0: sl@0: class TCommCapsV01 sl@0: { sl@0: public: sl@0: /** sl@0: Data rates supported, in bits per second. sl@0: The value is a bitmask made by OR-ing KCapsBpsXXX values. sl@0: Each set bit corresponds to a supported bit rate. sl@0: */ sl@0: TUint iRate; sl@0: /** sl@0: Character widths supported, in bits. sl@0: The value is a bitmask made by OR-ing a combination of KCapsData5, KCapsData6, KCapsData7 and KCapsData8 values. sl@0: Each set bit corresponds to a supported character width. sl@0: */ sl@0: TUint iDataBits; sl@0: /** sl@0: Number of stop bits supported. sl@0: The value is one of KCapsStop1, KCapsStop2 or KCapsStop1|KCapsStop2. sl@0: Each set bit corresponds to a supported number of stop bit. sl@0: */ sl@0: TUint iStopBits; sl@0: /** sl@0: Parity types supported. sl@0: The value is a bitmask made by OR-ing a combination of KCapsParityNone, KCapsParityEven, KCapsParityOdd, KCapsParityMark and KCapsParitySpace values. sl@0: Each set bit corresponds to a supported parity type. sl@0: */ sl@0: TUint iParity; sl@0: /** sl@0: Type of Handshaking protocols supported by the device. sl@0: The value is a bitmask made by OR-ing a combination of KCapsObeyXXX, KCapsSendXXX, KCapsFailXXX and KCapsFreeXXX values. sl@0: Each set bit corresponds to a supported handshaking protocol. sl@0: */ sl@0: TUint iHandshake; sl@0: /** sl@0: Type of Signals supported by the device. sl@0: The value is a bitmask made by OR-ing a combination of KCapsSignalXXX values. sl@0: Each set bit corresponds to a supported signal. sl@0: */ sl@0: TUint iSignals; sl@0: /** sl@0: Whether Fifo is enabled or disabled. sl@0: Value is KCapsHasFifo if enabled, 0 otherwise sl@0: */ sl@0: TUint iFifo; sl@0: /** sl@0: Capabilities of the SIR encoding hardware. sl@0: The value is a bitmask made by OR-ing a combination of KCapsSIR115kbps, KCapsSIR2400bpsOnly and KCapsSIR4Mbps values. sl@0: Each set bit corresponds to a supported SIR capability. sl@0: */ sl@0: TUint iSIR; sl@0: }; sl@0: /** sl@0: Package buffer for a TCommCapsV01 object. sl@0: sl@0: TCommCaps packages the comms capability structure TCommCapsV01 in a buffer. sl@0: This is used by serial comms APIs to pass the capability structure as a buffer, sl@0: for example in RComm::Caps(TDes8 &aCaps). sl@0: sl@0: @see TCommCapsV01 sl@0: */ sl@0: typedef TPckgBuf TCommCaps; sl@0: sl@0: /** sl@0: Comms capability structure. sl@0: Class to query the capability settings for serial comm port. sl@0: Members of this class are filled with the capabilities of the comm port. sl@0: sl@0: @see TCommCapsV01 sl@0: */ sl@0: class TCommCapsV02 : public TCommCapsV01 sl@0: { sl@0: public: sl@0: /** sl@0: Specifies the notifications that are supported for the serial comm port. sl@0: The field is a bitmask made by OR-ing a combination of: sl@0: -KNotifySignalsChangeSupported sl@0: -KNotifyRateChangeSupported sl@0: -KNotifyDataFormatChangeSupported sl@0: -KNotifyHandshakeChangeSupported sl@0: -KNotifyBreakSupported sl@0: -KNotifyFlowControlChangeSupported sl@0: -KNotifyDataAvailableSupported sl@0: -KNotifyOutputEmptySupported sl@0: Each set bit corresponds to a supported notification type. sl@0: */ sl@0: TUint iNotificationCaps; sl@0: /** sl@0: Specifies whether Role Switch is supported or not. sl@0: If supported the value is KCapsRoleSwitchSupported, otherwise Zero sl@0: */ sl@0: TUint iRoleCaps; sl@0: /** sl@0: Specifies whether Flow Control Status is supported or not. sl@0: If supported the value is KCapsFlowControlStatusSupported, otherwise Zero sl@0: */ sl@0: TUint iFlowControlCaps; sl@0: }; sl@0: sl@0: /** sl@0: Package buffer for a TCommCapsV02 object. sl@0: sl@0: TCommCaps2 packages the comms capability structure TCommCapsV02 in a buffer. sl@0: This is used by serial comms to pass the capability structure as a buffer, sl@0: for example in RComm::Caps(TDes8 &aCaps) sl@0: sl@0: @see TCommCapsV02 sl@0: */ sl@0: typedef TPckgBuf TCommCaps2; sl@0: sl@0: sl@0: /** sl@0: Comms capability structure. sl@0: Class to hold the capability settings for serial comm port. sl@0: sl@0: This class is used to query the capabilities of the serial comm port. sl@0: Members of this class are filled with the capabilities of the comm port. sl@0: sl@0: @see TCommCapsV02 sl@0: */ sl@0: class TCommCapsV03 : public TCommCapsV02 sl@0: { sl@0: public: sl@0: /** sl@0: Specifies whether break is supported or not. sl@0: ETrue if Supported, EFalse otherwise. sl@0: */ sl@0: TBool iBreakSupported; sl@0: }; sl@0: sl@0: /** sl@0: Package buffer for a TCommCapsV03 object. sl@0: sl@0: TCommCaps3 packages the comms capability structure TCommCapsV03 in a buffer. sl@0: This is used by serial comms APIs to pass the capability structure as a buffer, sl@0: for example in RComm::Caps(TDes8 &aCaps) sl@0: sl@0: @see TCommCapsV03 sl@0: */ sl@0: typedef TPckgBuf TCommCaps3; sl@0: sl@0: /** sl@0: Structure that holds the capabilities of the Comms factory object. Only Version is supported. sl@0: This structure is packaged within a descriptor when passed to methods such as RDevice::GetCaps() sl@0: */ sl@0: class TCapsDevCommV01 sl@0: { sl@0: public: sl@0: /** sl@0: Version of the device sl@0: @see TVersion sl@0: */ sl@0: TVersion version; sl@0: }; sl@0: sl@0: /** sl@0: Comms Notification configuration structure sl@0: Class to hold the notification configuration of the device. sl@0: Notifications are only used with DCE (modem) comms ports. sl@0: */ sl@0: class TCommNotificationV01 sl@0: { sl@0: public: sl@0: /** sl@0: Specifies which of the configuration members have changed sl@0: This value is a bitmask made by OR-ing a combination of KRateChanged,KDataFormatChanged and KHandshakeChanged values. sl@0: Each set bit corresponds to a change in the configuration notification. sl@0: @see TCommCapsV01 sl@0: */ sl@0: TUint iChangedMembers; sl@0: /** sl@0: Data rate in bits per second. sl@0: @see TBps sl@0: */ sl@0: TBps iRate; sl@0: /** sl@0: Character width in bits. sl@0: @see TDataBits sl@0: */ sl@0: TDataBits iDataBits; sl@0: /** sl@0: Number of stop bits. sl@0: @see TStopBits sl@0: */ sl@0: TStopBits iStopBits; sl@0: /** sl@0: Type of parity. sl@0: @see TParity sl@0: */ sl@0: TParity iParity; sl@0: /** sl@0: Type of Handshaking control. sl@0: Possible values can be any combination of KConfigObeyXXX, KConfigSendXXX, KConfigFailXXX and KConfigFreeXXX. sl@0: */ sl@0: TUint iHandshake; sl@0: }; sl@0: /** sl@0: Package buffer for a TCommNotificationV01 object. sl@0: Packages TCommNotificationV01 within a buffer. sl@0: @see TCommNotificationV01 sl@0: */ sl@0: typedef TPckgBuf TCommNotificationPckg; sl@0: // sl@0: const TUint KDataAvailableNotifyFlag=0x80000000; sl@0: // sl@0: #ifdef _DEBUG_DEVCOMM sl@0: class TCommDebugInfo sl@0: { sl@0: public: sl@0: TBool iRxBusy; sl@0: TBool iRxHeld; sl@0: TInt iRxLength; sl@0: TInt iRxOffset; sl@0: TInt iRxIntCount; sl@0: TInt iRxErrCount; sl@0: TInt iRxBufCount; sl@0: TBool iTxBusy; sl@0: TBool iTxHeld; sl@0: TInt iTxLength; sl@0: TInt iTxOffset; sl@0: TInt iTxIntCount; sl@0: TInt iTxErrCount; sl@0: TInt iTxBufCount; sl@0: TBool iDrainingRxBuf; sl@0: TBool iFillingTxBuf; sl@0: TBool iRunningDfc; sl@0: TInt iDfcCount; sl@0: TInt iDfcReqSeq; sl@0: TInt iDfcHandlerSeq; sl@0: TInt iDoDrainSeq; sl@0: TBool iTxDfcPend; sl@0: TBool iRxDfcPend; sl@0: TInt iTxChars, iRxChars; sl@0: TInt iTxXon, iTxXoff, iRxXon, iRxXoff; sl@0: }; sl@0: typedef TPckgBuf TCommDebugInfoPckg; sl@0: #endif sl@0: // sl@0: sl@0: /** sl@0: The externally visible interface through which the clients can access serial devices. sl@0: It also represents a user side handle to the serial device driver. sl@0: */ sl@0: class RBusDevComm : public RBusLogicalChannel sl@0: { sl@0: public: sl@0: /** sl@0: Serial device driver build version. sl@0: */ sl@0: enum TVer sl@0: { sl@0: /** Major Version */ sl@0: EMajorVersionNumber=1, sl@0: /** Minor Version */ sl@0: EMinorVersionNumber=0, sl@0: /** Build Version */ sl@0: EBuildVersionNumber=KE32BuildVersionNumber sl@0: }; sl@0: sl@0: /** sl@0: Asynchronous request types sl@0: */ sl@0: enum TRequest sl@0: { sl@0: /** Read request */ sl@0: ERequestRead=0x0, sl@0: /** Cancel read request */ sl@0: ERequestReadCancel=0x1, sl@0: /** Write reqeust */ sl@0: ERequestWrite=0x1, sl@0: /** Cancel write request */ sl@0: ERequestWriteCancel=0x2, sl@0: /** Break request */ sl@0: ERequestBreak=0x2, sl@0: /** Cancel break request */ sl@0: ERequestBreakCancel=0x4, sl@0: /** Signal change notification request */ sl@0: ERequestNotifySignalChange=0x3, sl@0: /** Cancel signal change notification request */ sl@0: ERequestNotifySignalChangeCancel=0x8, sl@0: }; sl@0: sl@0: /** sl@0: Synchronous request types sl@0: */ sl@0: enum TControl sl@0: { sl@0: /** Get the current configuration */ sl@0: EControlConfig, sl@0: /** Set the device configuration */ sl@0: EControlSetConfig, sl@0: /** Get the device capabilities */ sl@0: EControlCaps, sl@0: /** Read the state of Modem control signals supported */ sl@0: EControlSignals, sl@0: /** Set the state of output modem control signals */ sl@0: EControlSetSignals, sl@0: /** Query the driver receive buffer for data availability */ sl@0: EControlQueryReceiveBuffer, sl@0: /** Reset the driver buffers */ sl@0: EControlResetBuffers, sl@0: /** Get the driver receive buffer length */ sl@0: EControlReceiveBufferLength, sl@0: /** Set the driver receive buffer length */ sl@0: EControlSetReceiveBufferLength, sl@0: /** Get the minimum turnaround time between a receive and subsequent transmission operation */ sl@0: EControlMinTurnaroundTime, sl@0: /** Set the minimum turnaround time between a receive and subsequent transmission operation */ sl@0: EControlSetMinTurnaroundTime, sl@0: #ifdef _DEBUG_DEVCOMM sl@0: /** Get debug information from the driver */ sl@0: EControlDebugInfo sl@0: #endif sl@0: }; sl@0: sl@0: public: sl@0: #ifndef __KERNEL_MODE__ sl@0: sl@0: /** sl@0: This function opens a channel and creates a handle to the serial driver. sl@0: @param aUnit The unit number of the serial device. sl@0: @return KErrNone, if successful; sl@0: otherwise one of the other system-wide error codes. sl@0: KErrPermissionDenied if the port given in aName is wrong or if the request fails the CSY's own security check; sl@0: KErrNotSupported if this port is not supported by the CSY or the hardware; sl@0: KErrLocked if the port has already been opened; sl@0: KErrAccessDenied if the device driver encounteres a problem opening the hardware port. sl@0: */ sl@0: inline TInt Open(TInt aUnit); sl@0: sl@0: /** sl@0: Get the version number required by the driver sl@0: @return The version number required by the driver sl@0: @see TVersion sl@0: */ sl@0: inline TVersion VersionRequired() const; sl@0: sl@0: /** sl@0: Read from the channel sl@0: @param aStatus The asynchronous request status sl@0: @param aDes Buffer to be filled in by the driver sl@0: */ sl@0: inline void Read(TRequestStatus &aStatus,TDes8 &aDes); sl@0: sl@0: /** sl@0: Read from the channel sl@0: @param aStatus The asynchronous request status sl@0: @param aDes Buffer to be filled in by the driver sl@0: @param aLength The length of the data to be read sl@0: */ sl@0: inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength); sl@0: sl@0: /** sl@0: Read one or more characters from the channel. sl@0: If there is data in the serial driver's buffer when ReadOneOrMore() is called it will sl@0: read as much data as possible (up to the maximum length of the supplied buffer) sl@0: and then return. sl@0: If there is no data in the buffer the request will complete as soon as one or more bytes arrive at the serial hardware. sl@0: @param aStatus The asynchronous request status sl@0: @param aDes Buffer to be filled in by the driver sl@0: */ sl@0: inline void ReadOneOrMore(TRequestStatus &aStatus,TDes8 &aDes); sl@0: sl@0: /** sl@0: Cancel a pending read request sl@0: */ sl@0: inline void ReadCancel(); sl@0: sl@0: /** sl@0: Write to the channel sl@0: @param aStatus The asynchronous request status sl@0: @param aDes Buffer containing the data to be sent sl@0: */ sl@0: inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes); sl@0: sl@0: /** sl@0: Write to the channel sl@0: @param aStatus The asynchronous request status sl@0: @param aDes Buffer containing the data to be sent sl@0: @param aLength The length of the data to be sent sl@0: */ sl@0: inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength); sl@0: sl@0: /** sl@0: Cancel a pending write request sl@0: */ sl@0: inline void WriteCancel(); sl@0: sl@0: /** sl@0: Causes a break condition to be transmitted to the receiving device sl@0: @param aStatus The asynchronous request status sl@0: @param aTime The time interval in microseconds after which the break condition will be released sl@0: */ sl@0: inline void Break(TRequestStatus &aStatus,TInt aTime); sl@0: sl@0: /** sl@0: Cancel a pending break request sl@0: */ sl@0: inline void BreakCancel(); sl@0: sl@0: /** sl@0: Get the current configuration of the serial device sl@0: @param aConfig A packaged object to be filled with the configuration information by the driver sl@0: @see TCommConfigV02 sl@0: */ sl@0: inline void Config(TDes8 &aConfig); sl@0: sl@0: /** sl@0: Set the cofiguration of the serial device sl@0: @param aConfig A packaged object containing the configuration information sl@0: @see TCommConfigV02 sl@0: */ sl@0: inline TInt SetConfig(const TDesC8 &aConfig); sl@0: sl@0: /** sl@0: Get the capabilities of the serial device. sl@0: @param aCaps A packaged object to be filled with the capabilities of the device. sl@0: @see TCommCapsV03 sl@0: */ sl@0: inline void Caps(TDes8 &aCaps); sl@0: sl@0: /** sl@0: Get the status of the control lines sl@0: @return A bitmask of KSignalCTS, KSignalDSR, KSignalDCD, KSignalRNG, sl@0: KSignalRTS, KSignalDTR, KSignalBreak sl@0: */ sl@0: inline TUint Signals(); sl@0: sl@0: /** sl@0: Set and clear the control lines sl@0: @param aSetMask Bitmask of signals to set sl@0: @param aClearMask Bitmask of signals to clear sl@0: @see Signals for a list of signals sl@0: */ sl@0: inline void SetSignals(TUint aSetMask,TUint aClearMask); sl@0: sl@0: /** sl@0: Get the number of unread characters in the receive buffer of the driver sl@0: @return The number of unread characters sl@0: */ sl@0: inline TInt QueryReceiveBuffer(); sl@0: sl@0: /** sl@0: Reset the receive and transmit buffers. sl@0: */ sl@0: inline void ResetBuffers(); sl@0: sl@0: /** sl@0: Get the length of the receive buffer sl@0: @return The length of the receive buffer sl@0: */ sl@0: inline TInt ReceiveBufferLength(); sl@0: sl@0: /** sl@0: Set the length of the receive buffer sl@0: @param aLength The length of the receive buffer to be set sl@0: */ sl@0: inline TInt SetReceiveBufferLength(TInt aLength); sl@0: sl@0: /** sl@0: Request notification when one of the signals change. sl@0: The signals that could change are KSignalCTS, KSignalDSR, KSignalDCD, KSignalRNG, sl@0: KSignalRTS, KSignalDTR, KSignalBreak. sl@0: @param aStatus The asynchronous request status sl@0: @param aSignals Pointer to the bitmask containing the changed signals sl@0: @param aSignalMask Bitmask of signals to be monitored sl@0: */ sl@0: inline void NotifySignalChange(TRequestStatus& aStatus,TUint& aSignals,TUint aSignalMask=0x3F); sl@0: sl@0: /** sl@0: Cancel a pending signal change notification request sl@0: */ sl@0: inline void NotifySignalChangeCancel(); sl@0: sl@0: /** sl@0: Request notification when there is data available to be read from the driver receive buffer sl@0: @param aStatus The asynchronous request status sl@0: */ sl@0: inline void NotifyReceiveDataAvailable(TRequestStatus& aStatus); sl@0: sl@0: /** sl@0: Cancel a pending data notification request sl@0: */ sl@0: inline void NotifyReceiveDataAvailableCancel(); sl@0: sl@0: /** sl@0: Get the minimum turnaround time before a transmission can begin after a receive operation sl@0: @return The turnaround time in microseconds sl@0: */ sl@0: inline TUint MinTurnaroundTime(); sl@0: sl@0: /** sl@0: Set the minimum turnaround time between a receive and the next transmission operation sl@0: @param aMicroSeconds The turnaround time in microseconds sl@0: */ sl@0: inline TInt SetMinTurnaroundTime(TUint aMicroSeconds); sl@0: sl@0: #ifdef _DEBUG_DEVCOMM sl@0: /** sl@0: Get the debug information sl@0: @param aInfo a packaged object to be filled by the driver with debug information sl@0: @see TCommDebugInfo sl@0: */ sl@0: inline void DebugInfo(TDes8 &aInfo); sl@0: #endif sl@0: #endif sl@0: }; sl@0: sl@0: class RBusDevCommDCE : public RBusLogicalChannel sl@0: { sl@0: public: sl@0: enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber}; sl@0: enum TRequest sl@0: { sl@0: ERequestRead=0x0,ERequestReadCancel=0x1, sl@0: ERequestWrite=0x1,ERequestWriteCancel=0x2, sl@0: ERequestBreak=0x2,ERequestBreakCancel=0x4, sl@0: ERequestNotifySignalChange=0x3,ERequestNotifySignalChangeCancel=0x8, sl@0: ERequestNotifyFlowControlChange=0x4,ERequestNotifyFlowControlChangeCancel=0x10, sl@0: ERequestNotifyConfigChange=0x5,ERequestNotifyConfigChangeCancel=0x20 sl@0: }; sl@0: enum TControl sl@0: { sl@0: EControlConfig,EControlSetConfig,EControlCaps, sl@0: EControlSignals,EControlSetSignals, sl@0: EControlQueryReceiveBuffer,EControlResetBuffers, sl@0: EControlReceiveBufferLength,EControlSetReceiveBufferLength, sl@0: EControlFlowControlStatus, sl@0: #ifdef _DEBUG_DEVCOMM sl@0: EControlDebugInfo sl@0: #endif sl@0: }; sl@0: public: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline TInt Open(TInt aUnit); sl@0: inline TVersion VersionRequired() const; sl@0: inline void Read(TRequestStatus &aStatus,TDes8 &aDes); sl@0: inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength); sl@0: inline void ReadOneOrMore(TRequestStatus &aStatus,TDes8 &aDes); sl@0: inline void ReadCancel(); sl@0: inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes); sl@0: inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength); sl@0: inline void WriteCancel(); sl@0: inline void Break(TRequestStatus &aStatus,TInt aTime); sl@0: inline void BreakCancel(); sl@0: inline void Config(TDes8 &aConfig); sl@0: inline TInt SetConfig(const TDesC8 &aConfig); sl@0: inline void Caps(TDes8 &aCaps); sl@0: inline TUint Signals(); sl@0: inline void SetSignals(TUint aSetMask,TUint aClearMask); sl@0: inline TInt QueryReceiveBuffer(); sl@0: inline void ResetBuffers(); sl@0: inline TInt ReceiveBufferLength(); sl@0: inline TInt SetReceiveBufferLength(TInt aLength); sl@0: inline void NotifySignalChange(TRequestStatus& aStatus,TUint& aSignals,TUint aSignalMask=0x3F); sl@0: inline void NotifySignalChangeCancel(); sl@0: inline void NotifyReceiveDataAvailable(TRequestStatus& aStatus); sl@0: inline void NotifyReceiveDataAvailableCancel(); sl@0: inline void NotifyFlowControlChange(TRequestStatus& aStatus); sl@0: inline void NotifyFlowControlChangeCancel(); sl@0: inline void GetFlowControlStatus(TFlowControl& aFlowControl); sl@0: inline void NotifyConfigChange(TRequestStatus& aStatus, TDes8& aNewConfig); sl@0: inline void NotifyConfigChangeCancel(); sl@0: #ifdef _DEBUG_DEVCOMM sl@0: inline void DebugInfo(TDes8 &aInfo); sl@0: #endif sl@0: #endif sl@0: }; sl@0: sl@0: #include sl@0: #endif