From db6fbba73ed1d8e9ff1c171cb84c920bec3d6a39 Mon Sep 17 00:00:00 2001 From: Wielebny666 <31576684+Wielebny666@users.noreply.github.com> Date: Tue, 23 Jun 2020 16:02:50 +0200 Subject: [PATCH] spi_master: correctly set cs polarity All devices must be added to the same spi line before use. Partly solve this problem: https://github.com/espressif/esp-idf/pull/5490 --- components/hal/esp32/include/hal/spi_ll.h | 4 ++-- components/hal/esp32s2/include/hal/spi_ll.h | 2 +- components/hal/esp32s3/include/hal/spi_ll.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/hal/esp32/include/hal/spi_ll.h b/components/hal/esp32/include/hal/spi_ll.h index 73b8b01a6a..40a12209be 100644 --- a/components/hal/esp32/include/hal/spi_ll.h +++ b/components/hal/esp32/include/hal/spi_ll.h @@ -291,7 +291,7 @@ static inline void spi_ll_master_set_pos_cs(spi_dev_t *hw, int cs, uint32_t pos_ if (pos_cs) { hw->pin.master_cs_pol |= (1 << cs); } else { - hw->pin.master_cs_pol &= (1 << cs); + hw->pin.master_cs_pol &= ~(1 << cs); } } @@ -615,7 +615,7 @@ static inline void spi_ll_master_set_cksel(spi_dev_t *hw, int cs, uint32_t cksel if (cksel) { hw->pin.master_ck_sel |= (1 << cs); } else { - hw->pin.master_ck_sel &= (1 << cs); + hw->pin.master_ck_sel &= ~(1 << cs); } } diff --git a/components/hal/esp32s2/include/hal/spi_ll.h b/components/hal/esp32s2/include/hal/spi_ll.h index ca8f685c71..e80f3cb008 100644 --- a/components/hal/esp32s2/include/hal/spi_ll.h +++ b/components/hal/esp32s2/include/hal/spi_ll.h @@ -415,7 +415,7 @@ static inline void spi_ll_master_set_pos_cs(spi_dev_t *hw, int cs, uint32_t pos_ if (pos_cs) { hw->misc.master_cs_pol |= (1 << cs); } else { - hw->misc.master_cs_pol &= (1 << cs); + hw->misc.master_cs_pol &= ~(1 << cs); } } diff --git a/components/hal/esp32s3/include/hal/spi_ll.h b/components/hal/esp32s3/include/hal/spi_ll.h index d7989c0fd7..3475b3c14f 100644 --- a/components/hal/esp32s3/include/hal/spi_ll.h +++ b/components/hal/esp32s3/include/hal/spi_ll.h @@ -274,7 +274,7 @@ static inline void spi_ll_master_set_pos_cs(spi_dev_t *hw, int cs, uint32_t pos_ if (pos_cs) { hw->misc.master_cs_pol |= (1 << cs); } else { - hw->misc.master_cs_pol &= (1 << cs); + hw->misc.master_cs_pol &= ~(1 << cs); } }