text
stringlengths
0
234
------------------------
procedure Set_Device_Address
(This : in out VL53L0X_Ranging_Sensor;
Addr : HAL.I2C.I2C_Address;
Status : out Boolean)
is
begin
Write (This, REG_I2C_SLAVE_DEVICE_ADDRESS, UInt8 (Addr / 2), Status);
if Status then
This.I2C_Address := Addr;
end if;
end Set_Device_Address;
---------------
-- Data_Init --
---------------
procedure Data_Init
(This : in out VL53L0X_Ranging_Sensor;
Status : out Boolean)
is
Regval : UInt8;
begin
-- Set I2C Standard mode
Write (This, 16#88#, UInt8'(16#00#), Status);
if not Status then
return;
end if;
-- This.Device_Specific_Params.Read_Data_From_Device_Done := False;
--
-- -- Set default static parameters:
-- -- set first temporary value 9.44MHz * 65536 = 618_660
-- This.Device_Specific_Params.Osc_Frequency := 618_660;
--
-- -- Set default cross talk compenstation rate to 0
-- This.Device_Params.X_Talk_Compensation_Rate_Mcps := 0.0;
--
-- This.Device_Params.Device_Mode := Single_Ranging;
-- This.Device_Params.Histogram_Mode := Disabled;
-- TODO: Sigma estimator variable
if Status then
Write (This, 16#80#, UInt8'(16#01#), Status);
end if;
if Status then
Write (This, 16#FF#, UInt8'(16#01#), Status);
end if;
if Status then
Write (This, 16#00#, UInt8'(16#00#), Status);
end if;
if Status then
Read (This, 16#91#, This.Stop_Variable, Status);
end if;
if Status then
Write (This, 16#00#, UInt8'(16#01#), Status);
end if;
if Status then
Write (This, 16#FF#, UInt8'(16#00#), Status);
end if;
if Status then
Write (This, 16#80#, UInt8'(16#00#), Status);
end if;
-- disable SIGNAL_RATE_MSRC (bit 1) and SIGNAL_RATE_PRE_RANGE (bit 4)
-- limit checks
if Status then
Read (This, REG_MSRC_CONFIG_CONTROL, Regval, Status);
end if;
if Status then
Write (This, REG_MSRC_CONFIG_CONTROL, Regval or 16#12#, Status);
end if;
if Status then
-- Set final range signal rate limit to 0.25 MCPS
Status := Set_Signal_Rate_Limit (This, 0.25);
end if;
if Status then
Write (This, REG_SYSTEM_SEQUENCE_CONFIG, UInt8'(16#FF#), Status);
end if;
end Data_Init;
-----------------
-- Static_Init --
-----------------
procedure Static_Init
(This : in out VL53L0X_Ranging_Sensor;
GPIO_Function : VL53L0X_GPIO_Functionality;
Status : out Boolean)
is
type SPAD_Map is array (UInt8 range 1 .. 48) of Boolean
with Pack, Size => 48;
subtype SPAD_Map_Bytes is UInt8_Array (1 .. 6);
function To_Map is new Ada.Unchecked_Conversion
(SPAD_Map_Bytes, SPAD_Map);