From 67d7fad76488cf482a974785128dbf4c1afd2cd3 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. --- components/soc/esp32/include/hal/spi_ll.h | 4 ++-- components/soc/esp32s2beta/include/hal/spi_ll.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/soc/esp32/include/hal/spi_ll.h b/components/soc/esp32/include/hal/spi_ll.h index aaa4fa7aba..836b049182 100644 --- a/components/soc/esp32/include/hal/spi_ll.h +++ b/components/soc/esp32/include/hal/spi_ll.h @@ -287,7 +287,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); } } @@ -611,7 +611,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/soc/esp32s2beta/include/hal/spi_ll.h b/components/soc/esp32s2beta/include/hal/spi_ll.h index 3f70b228ef..6be21f3508 100644 --- a/components/soc/esp32s2beta/include/hal/spi_ll.h +++ b/components/soc/esp32s2beta/include/hal/spi_ll.h @@ -322,7 +322,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); } }