From aab678bdf84ae77abfba56cf8f127b6abd39c628 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Mon, 26 Nov 2018 11:43:44 +0100 Subject: [PATCH] Update endpoint with I2C sensor option --- trb_net16_endpoint_hades_full.vhd | 26 +++++++++++++++++++ ...t16_endpoint_hades_full_handler_record.vhd | 7 ++++- trb_net_components.vhd | 26 ++++++++++++++++++- trb_net_std.vhd | 2 +- 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/trb_net16_endpoint_hades_full.vhd b/trb_net16_endpoint_hades_full.vhd index 2dc2f83..645d714 100644 --- a/trb_net16_endpoint_hades_full.vhd +++ b/trb_net16_endpoint_hades_full.vhd @@ -136,6 +136,8 @@ entity trb_net16_endpoint_hades_full is REGIO_IDRAM_ADDR_IN : in std_logic_vector(2 downto 0) := "000"; REGIO_IDRAM_WR_IN : in std_logic := '0'; REGIO_ONEWIRE_INOUT : inout std_logic; --temperature sensor + I2C_SCL : inout std_logic; + I2C_SDA : inout std_logic; REGIO_ONEWIRE_MONITOR_IN : in std_logic := '0'; REGIO_ONEWIRE_MONITOR_OUT : out std_logic; REGIO_VAR_ENDPOINT_ID : in std_logic_vector(15 downto 0) := (others => '0'); @@ -698,6 +700,30 @@ begin STAT => buf_stat_onewire ); end generate; + gen_i2c : if REGIO_USE_1WIRE_INTERFACE = c_I2C generate + REGIO_ONEWIRE_MONITOR_OUT <= '0'; + REGIO_ONEWIRE_INOUT <= '0'; + i2c_interface : trb_net_i2cwire + generic map( + USE_TEMPERATURE_READOUT => c_YES, + CLK_PERIOD => 10 + ) + port map( + CLK => CLK, + RESET => RESET, + READOUT_ENABLE_IN => '1', + --connection to I2C interface + SCL_INOUT => I2C_SCL, + SDA_INOUT => I2C_SDA, + --connection to id ram, according to memory map in TrbNetRegIO + DATA_OUT => ONEWIRE_DATA, + ADDR_OUT => ONEWIRE_ADDR, + WRITE_OUT => ONEWIRE_WRITE, + TEMP_OUT => temperature, + ID_OUT => UNIQUE_ID_OUT, + STAT => buf_stat_onewire + ); + end generate; end generate; end generate; gentermbuf: if USE_CHANNEL(i) = c_NO generate diff --git a/trb_net16_endpoint_hades_full_handler_record.vhd b/trb_net16_endpoint_hades_full_handler_record.vhd index 1856531..c2fcdf8 100644 --- a/trb_net16_endpoint_hades_full_handler_record.vhd +++ b/trb_net16_endpoint_hades_full_handler_record.vhd @@ -20,6 +20,7 @@ entity trb_net16_endpoint_hades_full_handler_record is BROADCAST_BITMASK : std_logic_vector(7 downto 0) := x"FF"; REGIO_INIT_ENDPOINT_ID : std_logic_vector(15 downto 0) := x"0001"; REGIO_USE_VAR_ENDPOINT_ID : integer range c_NO to c_YES := c_NO; + REGIO_USE_1WIRE_INTERFACE : integer range 0 to 3 := c_YES; TIMING_TRIGGER_RAW : integer range 0 to 1 := c_YES; --Configure data handler DATA_INTERFACE_NUMBER : integer range 1 to 16 := 1; @@ -63,6 +64,8 @@ entity trb_net16_endpoint_hades_full_handler_record is BUS_MASTER_ACTIVE : in std_logic := '0'; --Onewire ONEWIRE_INOUT : inout std_logic; + I2C_SCL : inout std_logic; + I2C_SDA : inout std_logic; --Config endpoint id, if not statically assigned REGIO_VAR_ENDPOINT_ID : in std_logic_vector (15 downto 0) := (others => '0'); TIMERS_OUT : out TIMERS; @@ -186,7 +189,7 @@ begin REGIO_COMPILE_TIME => (others => '0'), REGIO_INCLUDED_FEATURES => INCLUDED_FEATURES, REGIO_HARDWARE_VERSION => HARDWARE_INFO, - REGIO_USE_1WIRE_INTERFACE => c_YES, + REGIO_USE_1WIRE_INTERFACE => REGIO_USE_1WIRE_INTERFACE, REGIO_USE_VAR_ENDPOINT_ID => REGIO_USE_VAR_ENDPOINT_ID, TIMING_TRIGGER_RAW => TIMING_TRIGGER_RAW, CLOCK_FREQUENCY => CLOCK_FREQUENCY @@ -264,6 +267,8 @@ begin REGIO_ONEWIRE_INOUT => ONEWIRE_INOUT, REGIO_ONEWIRE_MONITOR_IN => '0', REGIO_ONEWIRE_MONITOR_OUT => open, + I2C_SCL => I2C_SCL, + I2C_SDA => I2C_SDA, REGIO_VAR_ENDPOINT_ID => REGIO_VAR_ENDPOINT_ID, MY_ADDRESS_OUT => TIMERS_OUT.network_address, diff --git a/trb_net_components.vhd b/trb_net_components.vhd index 2cf3a7b..027ae18 100644 --- a/trb_net_components.vhd +++ b/trb_net_components.vhd @@ -725,6 +725,8 @@ end component; REGIO_IDRAM_ADDR_IN : in std_logic_vector(2 downto 0) := "000"; REGIO_IDRAM_WR_IN : in std_logic := '0'; REGIO_ONEWIRE_INOUT : inout std_logic; --temperature sensor + I2C_SCL : inout std_logic; + I2C_SDA : inout std_logic; REGIO_ONEWIRE_MONITOR_IN : in std_logic := '0'; REGIO_ONEWIRE_MONITOR_OUT : out std_logic; REGIO_VAR_ENDPOINT_ID : in std_logic_vector(15 downto 0) := (others => '0'); @@ -853,6 +855,8 @@ end component; BUS_UNKNOWN_ADDR_IN : in std_logic := '0'; --Onewire ONEWIRE_INOUT : inout std_logic; --temperature sensor + I2C_SCL : inout std_logic; + I2C_SDA : inout std_logic; ONEWIRE_MONITOR_IN : in std_logic := '0'; ONEWIRE_MONITOR_OUT : out std_logic; --Config endpoint id, if not statically assigned @@ -1331,7 +1335,27 @@ end component; - + component trb_net_i2cwire is + generic( + USE_TEMPERATURE_READOUT : integer range 0 to 1 := 1; + CLK_PERIOD : integer := 10 --clk period in ns + ); + port( + CLK : in std_logic; + RESET : in std_logic; + READOUT_ENABLE_IN : in std_logic := '1'; + --connection to I2C interface + SCL_INOUT : inout std_logic; + SDA_INOUT : inout std_logic; + --connection to id ram, according to memory map in TrbNetRegIO + DATA_OUT : out std_logic_vector(15 downto 0); + ADDR_OUT : out std_logic_vector(2 downto 0); + WRITE_OUT : out std_logic; + TEMP_OUT : out std_logic_vector(11 downto 0); + ID_OUT : out std_logic_vector(63 downto 0); + STAT : out std_logic_vector(31 downto 0) + ); + end component; diff --git a/trb_net_std.vhd b/trb_net_std.vhd index 8c8a237..e896faf 100644 --- a/trb_net_std.vhd +++ b/trb_net_std.vhd @@ -63,7 +63,7 @@ package trb_net_std is constant c_YES : integer := 1; constant c_NO : integer := 0; constant c_MONITOR : integer := 2; - + constant c_I2C : integer := 3; --standard values constant std_SBUF_VERSION : integer := c_SBUF_FULL; -- 2.43.0