From bb2767721945fa3496f777aa95eaab0137795137 Mon Sep 17 00:00:00 2001 From: Ahmed BOUDJELIDA Date: Mon, 16 Oct 2023 11:05:59 +0200 Subject: [PATCH] contrib/firmware: add 'send not acknowledged' function to the i2c bit-banging implementation Change-Id: I60597ebc126da4acb00654513b96f52261253e12 Signed-off-by: Ahmed BOUDJELIDA Reviewed-on: https://review.openocd.org/c/openocd/+/7811 Tested-by: jenkins Reviewed-by: Antonio Borneo --- contrib/firmware/angie/c/include/i2c.h | 1 + contrib/firmware/angie/c/src/i2c.c | 10 ++++++++++ contrib/firmware/angie/c/src/usb.c | 3 +++ 3 files changed, 14 insertions(+) diff --git a/contrib/firmware/angie/c/include/i2c.h b/contrib/firmware/angie/c/include/i2c.h index 06185efb4d..d0404923b3 100644 --- a/contrib/firmware/angie/c/include/i2c.h +++ b/contrib/firmware/angie/c/include/i2c.h @@ -19,6 +19,7 @@ void repeated_start(void); void stop_cd(void); void clock_cd(void); void send_ack(void); +void send_nack(void); bool get_ack(void); uint8_t get_address(uint8_t adr, uint8_t rdwr); diff --git a/contrib/firmware/angie/c/src/i2c.c b/contrib/firmware/angie/c/src/i2c.c index a7004bfac9..53840100b9 100644 --- a/contrib/firmware/angie/c/src/i2c.c +++ b/contrib/firmware/angie/c/src/i2c.c @@ -60,6 +60,16 @@ void send_ack(void) delay_us(1); } +void send_nack(void) +{ + PIN_SDA = 1; + delay_us(1); + PIN_SCL = 1; + delay_us(1); + PIN_SCL = 0; + delay_us(1); +} + bool get_ack(void) { PIN_SDA_DIR = 1; diff --git a/contrib/firmware/angie/c/src/usb.c b/contrib/firmware/angie/c/src/usb.c index 0a43ff9f65..1b7aa47658 100644 --- a/contrib/firmware/angie/c/src/usb.c +++ b/contrib/firmware/angie/c/src/usb.c @@ -798,6 +798,9 @@ void i2c_recieve(void) EP8FIFOBUF[count - 1] = receive_byte(); + /* send Nack: */ + send_nack(); + /* stop */ stop_cd();