]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
Update endpoint with I2C sensor option
authorJan Michel <j.michel@gsi.de>
Mon, 26 Nov 2018 10:43:44 +0000 (11:43 +0100)
committerJan Michel <j.michel@gsi.de>
Mon, 26 Nov 2018 10:43:44 +0000 (11:43 +0100)
trb_net16_endpoint_hades_full.vhd
trb_net16_endpoint_hades_full_handler_record.vhd
trb_net_components.vhd
trb_net_std.vhd

index 2dc2f83cc1d8a586830347808a26e4fe6f7274a5..645d7143a3833fdadd3c4caac3bab031818fb61d 100644 (file)
@@ -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
index 18565315d226e5beba3227378fd12223adab87d5..c2fcdf8cacf352cffdd81d2bff6769107abc2ede 100644 (file)
@@ -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,
 
index 2cf3a7bd738465ac103d013262a39f9813eb6745..027ae18cb897915ecf9ffb4bf163213f502b71b4 100644 (file)
@@ -725,6 +725,8 @@ end component;
       REGIO_IDRAM_ADDR_IN       : in    std_logic_vector(2 downto 0)                             := "000";\r
       REGIO_IDRAM_WR_IN         : in    std_logic                                                := '0';\r
       REGIO_ONEWIRE_INOUT       : inout std_logic;  --temperature sensor\r
+      I2C_SCL                   : inout std_logic;\r
+      I2C_SDA                   : inout std_logic;      \r
       REGIO_ONEWIRE_MONITOR_IN  : in    std_logic                                                := '0';\r
       REGIO_ONEWIRE_MONITOR_OUT : out   std_logic;\r
       REGIO_VAR_ENDPOINT_ID     : in    std_logic_vector(15 downto 0)                            := (others => '0');\r
@@ -853,6 +855,8 @@ end component;
       BUS_UNKNOWN_ADDR_IN          : in    std_logic                                                := '0';\r
       --Onewire\r
       ONEWIRE_INOUT                : inout std_logic;  --temperature sensor\r
+      I2C_SCL                      : inout std_logic;\r
+      I2C_SDA                      : inout std_logic;      \r
       ONEWIRE_MONITOR_IN           : in    std_logic                                                := '0';\r
       ONEWIRE_MONITOR_OUT          : out   std_logic;\r
       --Config endpoint id, if not statically assigned\r
@@ -1331,7 +1335,27 @@ end component;
 \r
 \r
 \r
-\r
+  component trb_net_i2cwire is\r
+    generic(\r
+      USE_TEMPERATURE_READOUT : integer range 0 to 1 := 1;\r
+      CLK_PERIOD : integer := 10  --clk period in ns\r
+    );\r
+    port(\r
+      CLK               : in    std_logic;\r
+      RESET             : in    std_logic;\r
+      READOUT_ENABLE_IN : in    std_logic := '1';\r
+      --connection to I2C interface\r
+      SCL_INOUT         :  inout  std_logic;\r
+      SDA_INOUT         :  inout  std_logic;\r
+      --connection to id ram, according to memory map in TrbNetRegIO\r
+      DATA_OUT          : out    std_logic_vector(15 downto 0);\r
+      ADDR_OUT          : out    std_logic_vector(2 downto 0);\r
+      WRITE_OUT         : out    std_logic;\r
+      TEMP_OUT          : out    std_logic_vector(11 downto 0);\r
+      ID_OUT            : out    std_logic_vector(63 downto 0);\r
+      STAT              : out    std_logic_vector(31 downto 0)\r
+    );\r
+  end component;\r
 \r
 \r
 \r
index 8c8a237d56693e499d32e90b67c4223bb4783217..e896faf412d73a9ff1ffd448d05db3f1660d0089 100644 (file)
@@ -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;