AVR-Ada Wiki
Ada cross compiler and libraries for AVR µCs
Status: Beta
Brought to you by:
rolf_ebert
Package AVR.ADC provides a control API to the Analog to Digital Converter channels.
with Interfaces; use Interfaces; package AVR.ADC is pragma Preelaborate; type Clock_Scale is new Unsigned_8 range 1 .. 7; Scale_By_2 : constant Clock_Scale := 1; Scale_By_4 : constant Clock_Scale := 2; Scale_By_8 : constant Clock_Scale := 3; Scale_By_16 : constant Clock_Scale := 4; Scale_By_32 : constant Clock_Scale := 5; Scale_By_64 : constant Clock_Scale := 6; Scale_By_128 : constant Clock_Scale := 7; type Reference_Voltage is (Ext_Ref, -- provide external reference voltage to AVCC pin Is_Vcc, -- use Vcc (typ. 5V or 3.3V) as reference Int_Ref); -- typ. 2.56V or 1.1V, see data sheet Max_ADC_Channels : constant := 8; type ADC_Channel_T is new Unsigned_8 range 0 .. Max_ADC_Channels - 1; -- result type of the AD conversion subtype Conversion_10bit is Unsigned_16 range 0 .. 2**10 - 1; subtype Conversion_8bit is Unsigned_8; procedure Set_Prescaler (Scale : Clock_Scale); procedure Set_Reference (Ref : Reference_Voltage); procedure Init (Scale : Clock_Scale; Ref : Reference_Voltage); procedure Start_Conversion (Ch : ADC_Channel_T); function Conversion_Is_Active return Boolean; function Last_Result return Conversion_10Bit; function Convert_10bit (Ch : ADC_Channel_T) return Conversion_10bit; function Convert_8bit (Ch : ADC_Channel_T) return Conversion_8bit; end AVR.ADC;