text
stringlengths 0
234
|
|---|
end if;
|
end SPI_Mode;
|
-----------
|
-- Write --
|
-----------
|
procedure Write (This : Three_Axis_Gyroscope; Addr : Register; Data : UInt8)
|
is
|
Status : SPI_Status;
|
begin
|
SPI_Mode (This, Enabled => True);
|
This.Port.Transmit (SPI_Data_8b'(1 => UInt8 (Addr)), Status);
|
if Status /= Ok then
|
raise Program_Error;
|
end if;
|
This.Port.Transmit (SPI_Data_8b'(1 => Data), Status);
|
if Status /= Ok then
|
raise Program_Error;
|
end if;
|
SPI_Mode (This, Enabled => False);
|
end Write;
|
----------
|
-- Read --
|
----------
|
procedure Read
|
(This : Three_Axis_Gyroscope;
|
Addr : Register;
|
Data : out UInt8)
|
is
|
Status : SPI_Status;
|
Tmp_Data : SPI_Data_8b (1 .. 1);
|
begin
|
SPI_Mode (This, Enabled => True);
|
This.Port.Transmit (SPI_Data_8b'(1 => UInt8 (Addr) or ReadWrite_CMD),
|
Status);
|
if Status /= Ok then
|
raise Program_Error;
|
end if;
|
This.Port.Receive (Tmp_Data, Status);
|
if Status /= Ok then
|
raise Program_Error;
|
end if;
|
Data := Tmp_Data (Tmp_Data'First);
|
SPI_Mode (This, Enabled => False);
|
end Read;
|
----------------
|
-- Read_UInt8s --
|
----------------
|
procedure Read_UInt8s
|
(This : Three_Axis_Gyroscope;
|
Addr : Register;
|
Buffer : out SPI_Data_8b;
|
Count : Natural)
|
is
|
Index : Natural := Buffer'First;
|
Status : SPI_Status;
|
Tmp_Data : SPI_Data_8b (1 .. 1);
|
begin
|
SPI_Mode (This, Enabled => True);
|
This.Port.Transmit
|
(SPI_Data_8b'(1 => UInt8 (Addr) or ReadWrite_CMD or MultiUInt8_CMD),
|
Status);
|
if Status /= Ok then
|
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;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.