text
stringlengths 0
234
|
|---|
raise Program_Error;
|
end if;
|
for K in 1 .. Count loop
|
This.Port.Receive (Tmp_Data, Status);
|
if Status /= Ok then
|
raise Program_Error;
|
end if;
|
Buffer (Index) := Tmp_Data (Tmp_Data'First);
|
Index := Index + 1;
|
end loop;
|
SPI_Mode (This, Enabled => False);
|
end Read_UInt8s;
|
---------------
|
-- Configure --
|
---------------
|
procedure Configure
|
(This : in out Three_Axis_Gyroscope;
|
Power_Mode : Power_Mode_Selection;
|
Output_Data_Rate : Output_Data_Rate_Selection;
|
Axes_Enable : Axes_Selection;
|
Bandwidth : Bandwidth_Selection;
|
BlockData_Update : Block_Data_Update_Selection;
|
Endianness : Endian_Data_Selection;
|
Full_Scale : Full_Scale_Selection)
|
is
|
Ctrl1 : UInt8;
|
Ctrl4 : UInt8;
|
begin
|
Ctrl1 := As_UInt8 (Power_Mode) or
|
As_UInt8 (Output_Data_Rate) or
|
As_UInt8 (Axes_Enable) or
|
As_UInt8 (Bandwidth);
|
Ctrl4 := As_UInt8 (BlockData_Update) or
|
As_UInt8 (Endianness) or
|
As_UInt8 (Full_Scale);
|
Write (This, CTRL_REG1, Ctrl1);
|
Write (This, CTRL_REG4, Ctrl4);
|
end Configure;
|
-----------
|
-- Sleep --
|
-----------
|
procedure Sleep (This : in out Three_Axis_Gyroscope) is
|
Ctrl1 : UInt8;
|
Sleep_Mode : constant := 2#1000#; -- per the Datasheet, Table 22, pg 32
|
begin
|
Read (This, CTRL_REG1, Ctrl1);
|
Ctrl1 := Ctrl1 or Sleep_Mode;
|
Write (This, CTRL_REG1, Ctrl1);
|
end Sleep;
|
--------------------------------
|
-- Configure_High_Pass_Filter --
|
--------------------------------
|
procedure Configure_High_Pass_Filter
|
(This : in out Three_Axis_Gyroscope;
|
Mode_Selection : High_Pass_Filter_Mode;
|
Cutoff_Frequency : High_Pass_Cutoff_Frequency)
|
is
|
Ctrl2 : UInt8;
|
begin
|
-- note that the two high-order bits must remain zero, per the datasheet
|
Ctrl2 := As_UInt8 (Mode_Selection) or As_UInt8 (Cutoff_Frequency);
|
Write (This, CTRL_REG2, Ctrl2);
|
end Configure_High_Pass_Filter;
|
-----------------------------
|
-- Enable_High_Pass_Filter --
|
-----------------------------
|
procedure Enable_High_Pass_Filter (This : in out Three_Axis_Gyroscope) is
|
Ctrl5 : UInt8;
|
begin
|
Read (This, CTRL_REG5, Ctrl5);
|
-- set HPen bit
|
Ctrl5 := Ctrl5 or HighPass_Filter_Enable;
|
Write (This, CTRL_REG5, Ctrl5);
|
end Enable_High_Pass_Filter;
|
------------------------------
|
-- Disable_High_Pass_Filter --
|
------------------------------
|
procedure Disable_High_Pass_Filter (This : in out Three_Axis_Gyroscope) is
|
Ctrl5 : UInt8;
|
begin
|
Read (This, CTRL_REG5, Ctrl5);
|
-- clear HPen bit
|
Ctrl5 := Ctrl5 and (not HighPass_Filter_Enable);
|
Write (This, CTRL_REG5, Ctrl5);
|
end Disable_High_Pass_Filter;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.