text
stringlengths
0
234
Rates : out Angle_Rates)
is
Ctrl4 : UInt8;
UInt8s_To_Read : constant Integer := 6; -- ie, three 2-UInt8 integers
-- the number of UInt8s in an Angle_Rates record object
Received : SPI_Data_8b (1 .. UInt8s_To_Read);
begin
Read (This, CTRL_REG4, Ctrl4);
Read_UInt8s (This, OUT_X_L, Received, UInt8s_To_Read);
-- The above has the effect of separate reads, as follows:
-- Read (This, OUT_X_L, Received (1));
-- Read (This, OUT_X_H, Received (2));
-- Read (This, OUT_Y_L, Received (3));
-- Read (This, OUT_Y_H, Received (4));
-- Read (This, OUT_Z_L, Received (5));
-- Read (This, OUT_Z_H, Received (6));
if (Ctrl4 and Endian_Selection_Mask) = L3GD20_Big_Endian'Enum_Rep then
Swap2 (Received (1)'Address);
Swap2 (Received (3)'Address);
Swap2 (Received (5)'Address);
end if;
Rates.X := As_Angle_Rate_Pointer (Received (1)'Address).all;
Rates.Y := As_Angle_Rate_Pointer (Received (3)'Address).all;
Rates.Z := As_Angle_Rate_Pointer (Received (5)'Address).all;
end Get_Raw_Angle_Rates;
--------------------------
-- Configure_Interrupt1 --
--------------------------
procedure Configure_Interrupt1
(This : in out Three_Axis_Gyroscope;
Triggers : Threshold_Event_List;
Latched : Boolean := False;
Active_Edge : Interrupt1_Active_Edge := L3GD20_Interrupt1_High_Edge;
Combine_Events : Boolean := False;
Sample_Count : Sample_Counter := 0)
is
Config : UInt8;
Ctrl3 : UInt8;
begin
Read (This, CTRL_REG3, Ctrl3);
Ctrl3 := Ctrl3 and 16#DF#;
Ctrl3 := Ctrl3 or Active_Edge'Enum_Rep;
Ctrl3 := Ctrl3 or INT1_Interrupt_Enable;
Write (This, CTRL_REG3, Ctrl3);
if Sample_Count > 0 then
Set_Duration_Counter (This, Sample_Count);
end if;
Config := 0;
if Latched then
Config := Config or Int1_Latch_Enable_Bit;
end if;
if Combine_Events then
Config := Config or Logically_And_Or_Events_Bit;
end if;
for Event of Triggers loop
Config := Config or Axes_Interrupt_Enablers (Event.Axis);
end loop;
Write (This, INT1_CFG, Config);
for Event of Triggers loop
Set_Threshold (This, Event.Axis, Event.Threshold);
end loop;
end Configure_Interrupt1;
----------------------------
-- Set_Interrupt_Pin_Mode --
----------------------------
procedure Set_Interrupt_Pin_Mode
(This : in out Three_Axis_Gyroscope;
Mode : Pin_Modes)
is
Ctrl3 : UInt8;
begin
Read (This, CTRL_REG3, Ctrl3);
Ctrl3 := Ctrl3 and (not Interrupt_Pin_Mode_Bit);
Ctrl3 := Ctrl3 or Mode'Enum_Rep;
Write (This, CTRL_REG3, Ctrl3);
end Set_Interrupt_Pin_Mode;
-----------------------
-- Enable_Interrupt1 --
-----------------------
procedure Enable_Interrupt1 (This : in out Three_Axis_Gyroscope) is