From 0d0e2851f3f287ed178a908a33eb873161317770 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Wed, 12 May 2021 20:12:23 +0300 Subject: [PATCH 1/2] Access ESP32-S3 I2C FIFO using 32bits I2C FIFO on ESP32-S3 (and others) MUST be read/written 32bits at a time. --- components/hal/esp32s3/include/hal/i2c_ll.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/hal/esp32s3/include/hal/i2c_ll.h b/components/hal/esp32s3/include/hal/i2c_ll.h index 877a916130..999dd6d308 100644 --- a/components/hal/esp32s3/include/hal/i2c_ll.h +++ b/components/hal/esp32s3/include/hal/i2c_ll.h @@ -571,7 +571,7 @@ static inline void i2c_ll_get_scl_timing(i2c_dev_t *hw, int *high_period, int *l static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) { for (int i = 0; i< len; i++) { - hw->fifo_data.data = ptr[i]; + hw->fifo_data.val = ptr[i]; } } @@ -587,7 +587,7 @@ static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) static inline void i2c_ll_read_rxfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) { for(int i = 0; i < len; i++) { - ptr[i] = hw->fifo_data.data; + ptr[i] = hw->fifo_data.val; } } From c31ba2b21bf77b34cfc656c2523487e90061633d Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 13 May 2021 11:26:14 +0300 Subject: [PATCH 2/2] Change i2c_struct to force 32bit access --- components/hal/esp32s3/include/hal/i2c_ll.h | 4 ++-- components/soc/esp32s3/include/soc/i2c_struct.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/hal/esp32s3/include/hal/i2c_ll.h b/components/hal/esp32s3/include/hal/i2c_ll.h index 999dd6d308..877a916130 100644 --- a/components/hal/esp32s3/include/hal/i2c_ll.h +++ b/components/hal/esp32s3/include/hal/i2c_ll.h @@ -571,7 +571,7 @@ static inline void i2c_ll_get_scl_timing(i2c_dev_t *hw, int *high_period, int *l static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) { for (int i = 0; i< len; i++) { - hw->fifo_data.val = ptr[i]; + hw->fifo_data.data = ptr[i]; } } @@ -587,7 +587,7 @@ static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) static inline void i2c_ll_read_rxfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) { for(int i = 0; i < len; i++) { - ptr[i] = hw->fifo_data.val; + ptr[i] = hw->fifo_data.data; } } diff --git a/components/soc/esp32s3/include/soc/i2c_struct.h b/components/soc/esp32s3/include/soc/i2c_struct.h index 69c5d568d4..d68164946e 100644 --- a/components/soc/esp32s3/include/soc/i2c_struct.h +++ b/components/soc/esp32s3/include/soc/i2c_struct.h @@ -116,8 +116,8 @@ typedef volatile struct { } fifo_conf; union { struct { - uint8_t data; - uint8_t reserved[3]; + uint32_t data : 8; + uint32_t reserved8 : 24; }; uint32_t val; } fifo_data;