kernel/eka/include/drivers/adc.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32\include\drivers\adc.h
       
    15 // ADC controller header file
       
    16 // Currently only used in Series 5mx port
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalTechnology
       
    23 */
       
    24 
       
    25 #ifndef __M32ADC_H__
       
    26 #define __M32ADC_H__
       
    27 #include <platform.h>
       
    28 
       
    29 const TInt KNumAdcChannelPriorities=4;
       
    30 
       
    31 // ADC operation is specified by a list of commands
       
    32 // Each command is specified by a 32 bit word:
       
    33 // Bit 16=1 -> wait for n ms before proceeding to next command (n=bits 0-15)
       
    34 // Bit 17=1 -> do preamble
       
    35 // Bit 18=1 -> do postamble
       
    36 // Bit 19=1 -> take a reading
       
    37 // Bit 20=1 -> don't store reading
       
    38 
       
    39 enum TAdcCommand
       
    40 	{
       
    41 	EAdcCmdWait=0x10000,
       
    42 	EAdcCmdPreamble=0x20000,
       
    43 	EAdcCmdPostamble=0x40000,
       
    44 	EAdcCmdReading=0x80000,
       
    45 	EAdcCmdDiscard=0x100000,
       
    46 	EAdcCmdDummyReading=0x180000,
       
    47 	};
       
    48 
       
    49 class DAdc;
       
    50 class TAdcChannel : public TPriListLink
       
    51 	{
       
    52 public:
       
    53 	IMPORT_C TAdcChannel(TInt anAdc);
       
    54 public:
       
    55 	IMPORT_C void Read(TInt* aReadingBuffer);
       
    56 public:
       
    57 	IMPORT_C virtual void Preamble();
       
    58 	IMPORT_C virtual void Postamble();
       
    59 	virtual void Complete()=0;
       
    60 public:
       
    61 	DAdc* iAdc;
       
    62 	TInt iChannelId;
       
    63 	TInt iCommandCount;
       
    64 	const TInt* iCommandList;
       
    65 	TInt* iReadings;
       
    66 	};
       
    67 
       
    68 NONSHARABLE_CLASS(DAdc) : public DBase
       
    69 	{
       
    70 public:
       
    71 	DAdc();
       
    72 	~DAdc();
       
    73 public:
       
    74 	virtual void StartConversion(TInt aChannelId)=0;
       
    75 public:
       
    76 	void Add(TAdcChannel* aChannel);
       
    77 	void Execute(TAdcChannel* aChannel);
       
    78 	void NextCommand();
       
    79 	void Start();
       
    80 	void ConversionComplete(TInt aValue);
       
    81 	void TimerExpired();
       
    82 	TInt DoSetMinPriority(TInt aPriority);
       
    83 	IMPORT_C static TInt SetMinPriority(TInt anAdc, TInt aPriority);
       
    84 public:
       
    85 	TPriList<TAdcChannel,KNumAdcChannelPriorities> iList;
       
    86 	TAdcChannel* iCurrentChannel;
       
    87 	TInt iCurrentCommand;
       
    88 	const TInt* iCommandPtr;
       
    89 	TInt iCommandCount;
       
    90 	NTimer iTimer;
       
    91 	TInt iMinPriority;
       
    92 	static DAdc** TheAdcs;
       
    93 	static TInt NumberOfAdcs;
       
    94 	};
       
    95 
       
    96 #endif