os/kernelhwsrv/kernel/eka/include/drivers/adc.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/adc.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,96 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\include\drivers\adc.h
    1.18 +// ADC controller header file
    1.19 +// Currently only used in Series 5mx port
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @internalTechnology
    1.26 +*/
    1.27 +
    1.28 +#ifndef __M32ADC_H__
    1.29 +#define __M32ADC_H__
    1.30 +#include <platform.h>
    1.31 +
    1.32 +const TInt KNumAdcChannelPriorities=4;
    1.33 +
    1.34 +// ADC operation is specified by a list of commands
    1.35 +// Each command is specified by a 32 bit word:
    1.36 +// Bit 16=1 -> wait for n ms before proceeding to next command (n=bits 0-15)
    1.37 +// Bit 17=1 -> do preamble
    1.38 +// Bit 18=1 -> do postamble
    1.39 +// Bit 19=1 -> take a reading
    1.40 +// Bit 20=1 -> don't store reading
    1.41 +
    1.42 +enum TAdcCommand
    1.43 +	{
    1.44 +	EAdcCmdWait=0x10000,
    1.45 +	EAdcCmdPreamble=0x20000,
    1.46 +	EAdcCmdPostamble=0x40000,
    1.47 +	EAdcCmdReading=0x80000,
    1.48 +	EAdcCmdDiscard=0x100000,
    1.49 +	EAdcCmdDummyReading=0x180000,
    1.50 +	};
    1.51 +
    1.52 +class DAdc;
    1.53 +class TAdcChannel : public TPriListLink
    1.54 +	{
    1.55 +public:
    1.56 +	IMPORT_C TAdcChannel(TInt anAdc);
    1.57 +public:
    1.58 +	IMPORT_C void Read(TInt* aReadingBuffer);
    1.59 +public:
    1.60 +	IMPORT_C virtual void Preamble();
    1.61 +	IMPORT_C virtual void Postamble();
    1.62 +	virtual void Complete()=0;
    1.63 +public:
    1.64 +	DAdc* iAdc;
    1.65 +	TInt iChannelId;
    1.66 +	TInt iCommandCount;
    1.67 +	const TInt* iCommandList;
    1.68 +	TInt* iReadings;
    1.69 +	};
    1.70 +
    1.71 +NONSHARABLE_CLASS(DAdc) : public DBase
    1.72 +	{
    1.73 +public:
    1.74 +	DAdc();
    1.75 +	~DAdc();
    1.76 +public:
    1.77 +	virtual void StartConversion(TInt aChannelId)=0;
    1.78 +public:
    1.79 +	void Add(TAdcChannel* aChannel);
    1.80 +	void Execute(TAdcChannel* aChannel);
    1.81 +	void NextCommand();
    1.82 +	void Start();
    1.83 +	void ConversionComplete(TInt aValue);
    1.84 +	void TimerExpired();
    1.85 +	TInt DoSetMinPriority(TInt aPriority);
    1.86 +	IMPORT_C static TInt SetMinPriority(TInt anAdc, TInt aPriority);
    1.87 +public:
    1.88 +	TPriList<TAdcChannel,KNumAdcChannelPriorities> iList;
    1.89 +	TAdcChannel* iCurrentChannel;
    1.90 +	TInt iCurrentCommand;
    1.91 +	const TInt* iCommandPtr;
    1.92 +	TInt iCommandCount;
    1.93 +	NTimer iTimer;
    1.94 +	TInt iMinPriority;
    1.95 +	static DAdc** TheAdcs;
    1.96 +	static TInt NumberOfAdcs;
    1.97 +	};
    1.98 +
    1.99 +#endif