From c7073853ebcbb8a94af0ef405cb05f94b7fd02e5 Mon Sep 17 00:00:00 2001 From: Ahmed BOUDJELIDA Date: Wed, 29 Nov 2023 15:21:27 +0100 Subject: [PATCH] contrib/firmware: Add direction control for 'SCL' i2c signal We want to keep the tri-state buffers located between the FPGA and the board, in 'Z' state until we launch an i2c connection. We launch an i2c start condition, make the SCL direction 'OUT' to start the i2c protocol and at the end of the i2c connection at the stop condition, we re-make the tri-state buffers at 'Z' state. Change-Id: Ic597a70d0427832547f6b539864c24ce20a18c64 Signed-off-by: Ahmed BOUDJELIDA Reviewed-on: https://review.openocd.org/c/openocd/+/7989 Tested-by: jenkins Reviewed-by: Antonio Borneo --- contrib/firmware/angie/c/include/io.h | 2 +- contrib/firmware/angie/c/src/i2c.c | 7 +++++++ contrib/firmware/angie/c/src/usb.c | 6 ------ .../angie/hdl/src/angie_bitstream.ucf | 1 + .../angie/hdl/src/angie_bitstream.vhd | 19 ++++++++++++------ src/jtag/drivers/angie/angie_bitstream.bit | Bin 340704 -> 340704 bytes src/jtag/drivers/angie/angie_firmware.bin | Bin 10158 -> 10256 bytes 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/contrib/firmware/angie/c/include/io.h b/contrib/firmware/angie/c/include/io.h index af488f4ed..19289d11d 100644 --- a/contrib/firmware/angie/c/include/io.h +++ b/contrib/firmware/angie/c/include/io.h @@ -66,7 +66,7 @@ #define PIN_SDA IOD0 #define PIN_SCL IOD1 #define PIN_SDA_DIR IOD2 -/* PD3 Not Connected */ +#define PIN_SCL_DIR IOD3 /* PD4 Not Connected */ /* PD5 Not Connected */ /* PD6 Not Connected */ diff --git a/contrib/firmware/angie/c/src/i2c.c b/contrib/firmware/angie/c/src/i2c.c index 53840100b..10a463bf7 100644 --- a/contrib/firmware/angie/c/src/i2c.c +++ b/contrib/firmware/angie/c/src/i2c.c @@ -14,6 +14,9 @@ void start_cd(void) { + PIN_SCL_DIR = 0; + PIN_SDA_DIR = 0; + delay_us(10); PIN_SDA = 0; //SDA = 1; delay_us(1); PIN_SCL = 0; //SCL = 1; @@ -40,6 +43,10 @@ void stop_cd(void) delay_us(1); PIN_SDA = 1; delay_us(1); + PIN_SDA_DIR = 1; + delay_us(1); + PIN_SCL_DIR = 1; + delay_us(1); } void clock_cd(void) diff --git a/contrib/firmware/angie/c/src/usb.c b/contrib/firmware/angie/c/src/usb.c index 1b7aa4765..de1964130 100644 --- a/contrib/firmware/angie/c/src/usb.c +++ b/contrib/firmware/angie/c/src/usb.c @@ -886,9 +886,6 @@ void io_init(void) PORTACFG = 0x01; /* 0: normal ou 1: alternate function (each bit) */ OEA = 0xEF; /* all OUT exept INIT_B IN */ IOA = 0xFF; - PIN_RDWR_B = 1; - PIN_CSI_B = 1; - PIN_PROGRAM_B = 1; /* PORT B */ OEB = 0xEF; /* all OUT exept TDO */ @@ -899,8 +896,6 @@ void io_init(void) PIN_TDI = 0; PIN_SRST = 1; - - /* PORT C */ PORTCCFG = 0x00; /* 0: normal ou 1: alternate function (each bit) */ OEC = 0xFF; @@ -909,5 +904,4 @@ void io_init(void) /* PORT D */ OED = 0xFF; IOD = 0xFF; - PIN_SDA_DIR = 0; } diff --git a/contrib/firmware/angie/hdl/src/angie_bitstream.ucf b/contrib/firmware/angie/hdl/src/angie_bitstream.ucf index 92a89c99e..9eb0c85c3 100644 --- a/contrib/firmware/angie/hdl/src/angie_bitstream.ucf +++ b/contrib/firmware/angie/hdl/src/angie_bitstream.ucf @@ -20,6 +20,7 @@ net SRST LOC = 'P61' ; net SDA LOC = 'P50' ; net SCL LOC = 'P51' ; net SDA_DIR LOC = 'P56' ; +net SCL_DIR LOC = 'P57' ; net SI_TDO LOC = 'P16' ; net SO_TRST LOC = 'P32' ; diff --git a/contrib/firmware/angie/hdl/src/angie_bitstream.vhd b/contrib/firmware/angie/hdl/src/angie_bitstream.vhd index 21ddb844a..6004bf2ff 100644 --- a/contrib/firmware/angie/hdl/src/angie_bitstream.vhd +++ b/contrib/firmware/angie/hdl/src/angie_bitstream.vhd @@ -26,8 +26,9 @@ entity S609 is port( SDA : inout std_logic; SDA_DIR : in std_logic; SCL : in std_logic; + SCL_DIR : in std_logic; - FTP : out std_logic_vector(7 downto 0):=(others => '1'); -- Test points + FTP : out std_logic_vector(7 downto 0); -- Test points SI_TDO : in std_logic; ST_0 : out std_logic; ST_1 : out std_logic; @@ -55,8 +56,6 @@ begin ST_0 <= '0'; ST_1 <= '1'; -ST_4 <= '0'; - --TDO: TDO <= not SI_TDO; @@ -75,13 +74,21 @@ SO_SDA_OUT <= SDA; process(SDA_DIR) begin - if(SDA_DIR = '1') then - ST_5 <= '1'; - else + if(SDA_DIR = '0') then ST_5 <= '0'; + else + ST_5 <= '1'; end if; end process; +process(SCL_DIR) +begin + if(SCL_DIR = '0') then + ST_4 <= '0'; + else + ST_4 <= '1'; + end if; +end process; --Points de test: FTP(0) <= SDA; diff --git a/src/jtag/drivers/angie/angie_bitstream.bit b/src/jtag/drivers/angie/angie_bitstream.bit index aebd3700b3c36cf4d1d83d7a3939a94eebcf1d41..7b3a88f7c8739accf2dc2512a6eab0480ccbda27 100644 GIT binary patch delta 1183 zcmZuwO-NKx6!yG3Z~mPbLvw7z8H>SmqI`pxnu^szf)Ui(v?v~En_8%}QlBJK($B>3 z;%S$hupdFNMT|Y@f?&*|O`D=cZ4A;u7ZJG9YNeg~#&J~M=5XIR-}%mWe%{J@>B@Sk z+EpS+XQItT{Y4I`p{1d*rM_|D`m1)m^IM<5d^O+~bXoBUPu*bCg5goR^N397vNT2X zkCS&mfN^bgc$}dZK$BB;=075MiLPc(7U!U9_Gp0CD?%Se<1`c?6EyQ3$|zEYxH)dT zjMSPk;Rfj4%9mm+pb?s=B?`}o>*-|5mV1Q&K$lZC0eue0`Q(%cw113*Fl|fJM_x}_ z>B~)Gr|C^Hgi>OjJ@r`dO`$Y$lv*+At$2X^m<@el+ip@t0dKq*=WrcJ2n&ZWvzZ8B z;f-<*o+4~Tw3LV(qiEfVo!Oi)2U-X^c-RB_Gy5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