text
stringlengths
0
234
UInt16 (Reg_Addr),
Memory_Size_8b,
Data,
Status);
if Status /= Ok then
raise Program_Error with "Timeout while reading TC data";
end if;
return Data (1);
end Read_Register;
--------------------
-- Write_Register --
--------------------
procedure Write_Register (This : in out STMPE811_Device;
Reg_Addr : UInt8;
Data : UInt8) is
Status : I2C_Status;
begin
This.Port.Mem_Write (This.I2C_Addr,
UInt16 (Reg_Addr),
Memory_Size_8b,
(1 => Data),
Status);
if Status /= Ok then
raise Program_Error with "Timeout while reading TC data";
end if;
end Write_Register;
---------------
-- IOE_Reset --
---------------
procedure IOE_Reset (This : in out STMPE811_Device) is
begin
This.Write_Register (IOE_REG_SYS_CTRL1, 16#02#);
-- Give some time for the reset
This.Time.Delay_Milliseconds (2);
This.Write_Register (IOE_REG_SYS_CTRL1, 16#00#);
end IOE_Reset;
--------------------------
-- IOE_Function_Command --
--------------------------
procedure IOE_Function_Command (This : in out STMPE811_Device;
Func : UInt8;
Enabled : Boolean)
is
Reg : UInt8 := This.Read_Register (IOE_REG_SYS_CTRL2);
begin
-- CTRL2 functions are disabled when corresponding bit is set
if Enabled then
Reg := Reg and (not Func);
else
Reg := Reg or Func;
end if;
This.Write_Register (IOE_REG_SYS_CTRL2, Reg);
end IOE_Function_Command;
-------------------
-- IOE_AF_Config --
-------------------
procedure IOE_AF_Config (This : in out STMPE811_Device;
Pin : UInt8;
Enabled : Boolean) is
Reg : UInt8 := This.Read_Register (IOE_REG_GPIO_AF);
begin
if Enabled then
Reg := Reg or Pin;
else
Reg := Reg and (not Pin);
end if;
This.Write_Register (IOE_REG_GPIO_AF, Reg);
end IOE_AF_Config;
----------------
-- Get_IOE_ID --
----------------
function Get_IOE_ID (This : in out STMPE811_Device) return UInt16 is
begin
return (UInt16 (This.Read_Register (0)) * (2**8))
or UInt16 (This.Read_Register (1));
end Get_IOE_ID;
----------------
-- Initialize --
----------------