Forum Discussion
Altera_Forum
Honored Contributor
12 years agoNo. I don't really know what i am supposed to test.
EDIT: It works now. TOUCH_i2c_SCL is supposed to be an output ...
library ieee;
USE IEEE.STD_LOGIC_1164.all;
entity Touchpaneltest is
port (
CLOCK_50 : in std_logic;
--//////////////////////// LED ////////////////////////
LEDG : out std_logic_vector(8 downto 0); -- LED Green
LEDR : out std_logic_vector(17 downto 0); -- LED Red
--//////////////////////// TOUCH ////////////////////////
TOUCH_INT_n : in std_logic;
TOUCH_I2C_SCL : out std_logic;
TOUCH_I2C_SDA : inout std_logic
);
end Touchpaneltest;
architecture verhalten of Touchpaneltest is
component i2c_touch_config is
port(
-- Host Side
iCLK : in std_logic; -- Connect to 50 MHz Clock
iRSTN : in std_logic; -- Connnct to system reset signal
iTRIG : in std_logic; -- Connect to Interrupt Pin of Touch IC
oREADY : out std_logic; -- Rising Trigger when following six output data is valid
oREG_X1 : out std_logic_vector(9 downto 0); -- 10-bits X coordinate of first touch point
oREG_Y1 : out std_logic_vector(8 downto 0); -- 9-bits Y coordinate of first touch point
oREG_X2 : out std_logic_vector(9 downto 0); -- 10-bits X coordinate of second touch point
oREG_Y2 : out std_logic_vector(8 downto 0); -- 9-bits Y coordinate of second touch point
oREG_TOUCH_COUNT : out std_logic_vector(1 downto 0); -- 2-bits touch count. Valid value is 0, 1, 2
oREG_GESTURE : out std_logic_vector(7 downto 0); -- 8-bits gesture ID
-- I2C Side
I2C_SCLK : out std_logic; -- Connect to I2C Clock Pin of Touch IC
I2C_SDAT : inout std_logic); -- Connect to I2C Data Pin of Touch IC
end component;
SIGNAL SIG_oREADY : std_logic;
SIGNAL SENSOR_X1, SENSOR_X2 : std_logic_vector(9 downto 0);
SIGNAL SENSOR_Y1, SENSOR_Y2 : std_logic_vector(8 downto 0);
SIGNAL SIG_TOUCH_COUNT : std_logic_vector(1 downto 0);
SIGNAL SIG_GESTURE : std_logic_vector(7 downto 0);
begin
terasictouch: i2c_touch_config
port map(
iCLK => CLOCK_50,
iRSTN => '1',
iTRIG => TOUCH_INT_n,
oREADY => SIG_oREADY,
oREG_X1 => SENSOR_X1,
oREG_Y1 => SENSOR_Y1,
oREG_X2 => SENSOR_X2,
oREG_Y2 => SENSOR_Y2,
oREG_TOUCH_COUNT => SIG_TOUCH_COUNT,
oREG_GESTURE => SIG_GESTURE,
-- I2C Side
I2C_SCLK => TOUCH_I2C_SCL,
I2C_SDAT => TOUCH_I2C_SDA);
Led_test: PROCESS(TOUCH_INT_n) IS
begin
if rising_edge(TOUCH_INT_n) then
LEDR <= "00000000"&SENSOR_X1(9 downto 0);
if ( SIG_oREADY = '1') then
LEDG(7) <= '1';
else
LEDG(7) <= '0';
end if;
case SIG_TOUCH_COUNT is
when "00" => LEDG(0) <= '0'; LEDG(1) <= '0';
when "01" => LEDG(0) <= '1'; LEDG(1) <= '0';
when "10" => LEDG(0) <= '0'; LEDG(1) <= '1';
when "11" => LEDG(0) <= '1'; LEDG(1) <= '1';
when others => null;
end case;
end if;
END PROCESS Led_test;
end verhalten;