sl@0: // Copyright (c) 1998-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\drivers\adc.h sl@0: // ADC controller header file sl@0: // Currently only used in Series 5mx port sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __M32ADC_H__ sl@0: #define __M32ADC_H__ sl@0: #include sl@0: sl@0: const TInt KNumAdcChannelPriorities=4; sl@0: sl@0: // ADC operation is specified by a list of commands sl@0: // Each command is specified by a 32 bit word: sl@0: // Bit 16=1 -> wait for n ms before proceeding to next command (n=bits 0-15) sl@0: // Bit 17=1 -> do preamble sl@0: // Bit 18=1 -> do postamble sl@0: // Bit 19=1 -> take a reading sl@0: // Bit 20=1 -> don't store reading sl@0: sl@0: enum TAdcCommand sl@0: { sl@0: EAdcCmdWait=0x10000, sl@0: EAdcCmdPreamble=0x20000, sl@0: EAdcCmdPostamble=0x40000, sl@0: EAdcCmdReading=0x80000, sl@0: EAdcCmdDiscard=0x100000, sl@0: EAdcCmdDummyReading=0x180000, sl@0: }; sl@0: sl@0: class DAdc; sl@0: class TAdcChannel : public TPriListLink sl@0: { sl@0: public: sl@0: IMPORT_C TAdcChannel(TInt anAdc); sl@0: public: sl@0: IMPORT_C void Read(TInt* aReadingBuffer); sl@0: public: sl@0: IMPORT_C virtual void Preamble(); sl@0: IMPORT_C virtual void Postamble(); sl@0: virtual void Complete()=0; sl@0: public: sl@0: DAdc* iAdc; sl@0: TInt iChannelId; sl@0: TInt iCommandCount; sl@0: const TInt* iCommandList; sl@0: TInt* iReadings; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(DAdc) : public DBase sl@0: { sl@0: public: sl@0: DAdc(); sl@0: ~DAdc(); sl@0: public: sl@0: virtual void StartConversion(TInt aChannelId)=0; sl@0: public: sl@0: void Add(TAdcChannel* aChannel); sl@0: void Execute(TAdcChannel* aChannel); sl@0: void NextCommand(); sl@0: void Start(); sl@0: void ConversionComplete(TInt aValue); sl@0: void TimerExpired(); sl@0: TInt DoSetMinPriority(TInt aPriority); sl@0: IMPORT_C static TInt SetMinPriority(TInt anAdc, TInt aPriority); sl@0: public: sl@0: TPriList iList; sl@0: TAdcChannel* iCurrentChannel; sl@0: TInt iCurrentCommand; sl@0: const TInt* iCommandPtr; sl@0: TInt iCommandCount; sl@0: NTimer iTimer; sl@0: TInt iMinPriority; sl@0: static DAdc** TheAdcs; sl@0: static TInt NumberOfAdcs; sl@0: }; sl@0: sl@0: #endif