New SPI invert hardware SS function in hall-spi and SPI library (#11297)
* Add files via upload * Add files via upload * Update SPI.h * Update esp32-hal-spi.c renamed invert_out to ss_invert to be more intuitive * Update esp32-hal-spi.h Removed the out from the function name spiSSInvertout. * Update SPI.cpp Removed the out from the function name spiSSInvertout. * Update cores/esp32/esp32-hal-spi.c Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
parent
9193c9db1e
commit
b461e01e22
4 changed files with 17 additions and 1 deletions
|
|
@ -74,6 +74,7 @@ struct spi_struct_t {
|
|||
int8_t miso;
|
||||
int8_t mosi;
|
||||
int8_t ss;
|
||||
bool ss_invert;
|
||||
};
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
|
|
@ -365,7 +366,7 @@ bool spiAttachSS(spi_t *spi, uint8_t ss_num, int8_t ss) {
|
|||
return false;
|
||||
}
|
||||
pinMode(ss, OUTPUT);
|
||||
pinMatrixOutAttach(ss, SPI_SS_IDX(spi->num, ss_num), false, false);
|
||||
pinMatrixOutAttach(ss, SPI_SS_IDX(spi->num, ss_num), spi->ss_invert, false);
|
||||
spiEnableSSPins(spi, (1 << ss_num));
|
||||
spi->ss = ss;
|
||||
if (!perimanSetPinBus(ss, ESP32_BUS_TYPE_SPI_MASTER_SS, (void *)(spi->num + 1), spi->num, -1)) {
|
||||
|
|
@ -435,6 +436,12 @@ void spiSSDisable(spi_t *spi) {
|
|||
SPI_MUTEX_UNLOCK();
|
||||
}
|
||||
|
||||
void spiSSInvert(spi_t *spi, bool invert) {
|
||||
if (spi) {
|
||||
spi->ss_invert = invert;
|
||||
}
|
||||
}
|
||||
|
||||
void spiSSSet(spi_t *spi) {
|
||||
if (!spi) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ void spiSSSet(spi_t *spi);
|
|||
void spiSSClear(spi_t *spi);
|
||||
|
||||
void spiWaitReady(spi_t *spi);
|
||||
//invert hardware SS
|
||||
void spiSSInvert(spi_t *spi, bool invert);
|
||||
|
||||
uint32_t spiGetClockDiv(spi_t *spi);
|
||||
uint8_t spiGetDataMode(spi_t *spi);
|
||||
|
|
|
|||
|
|
@ -144,6 +144,12 @@ void SPIClass::setHwCs(bool use) {
|
|||
_use_hw_ss = use;
|
||||
}
|
||||
|
||||
void SPIClass::setSSInvert(bool invert) {
|
||||
if (_spi) {
|
||||
spiSSInvert(_spi, invert);
|
||||
}
|
||||
}
|
||||
|
||||
void SPIClass::setFrequency(uint32_t freq) {
|
||||
SPI_PARAM_LOCK();
|
||||
//check if last freq changed
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ public:
|
|||
void end();
|
||||
|
||||
void setHwCs(bool use);
|
||||
void setSSInvert(bool invert); //use before setHwCS for change to be used by setHwCs
|
||||
void setBitOrder(uint8_t bitOrder);
|
||||
void setDataMode(uint8_t dataMode);
|
||||
void setFrequency(uint32_t freq);
|
||||
|
|
|
|||
Loading…
Reference in a new issue