Skip to content

Commit

Permalink
contrib/firmware: Add direction control for 'SCL' i2c signal
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7989
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
  • Loading branch information
Ahmed BOUDJELIDA authored and borneoa committed Jan 13, 2024
1 parent 995a7af commit c707385
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion contrib/firmware/angie/c/include/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
7 changes: 7 additions & 0 deletions contrib/firmware/angie/c/src/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions contrib/firmware/angie/c/src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand All @@ -909,5 +904,4 @@ void io_init(void)
/* PORT D */
OED = 0xFF;
IOD = 0xFF;
PIN_SDA_DIR = 0;
}
1 change: 1 addition & 0 deletions contrib/firmware/angie/hdl/src/angie_bitstream.ucf
Original file line number Diff line number Diff line change
Expand Up @@ -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' ;
Expand Down
19 changes: 13 additions & 6 deletions contrib/firmware/angie/hdl/src/angie_bitstream.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,8 +56,6 @@ begin
ST_0 <= '0';
ST_1 <= '1';

ST_4 <= '0';

--TDO:
TDO <= not SI_TDO;

Expand All @@ -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;
Expand Down
Binary file modified src/jtag/drivers/angie/angie_bitstream.bit
Binary file not shown.
Binary file modified src/jtag/drivers/angie/angie_firmware.bin
Binary file not shown.

0 comments on commit c707385

Please sign in to comment.