From 39752647dfea81c0339630af6ecfd449856625ad Mon Sep 17 00:00:00 2001 From: Adema Date: Wed, 28 May 2025 09:48:07 +0200 Subject: [PATCH] Upload files to "SPI2Slave_T4" Added swap pins function. (MOSI / MISO) --- SPI2Slave_T4/SPI2Slave_T4.h | 1 + SPI2Slave_T4/SPI2Slave_T4.tpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/SPI2Slave_T4/SPI2Slave_T4.h b/SPI2Slave_T4/SPI2Slave_T4.h index bd9ad6b..a5a904d 100644 --- a/SPI2Slave_T4/SPI2Slave_T4.h +++ b/SPI2Slave_T4/SPI2Slave_T4.h @@ -34,6 +34,7 @@ SPI2Slave_T4_CLASS class SPI2Slave_T4 : public SPI2Slave_T4_Base { void onReceive(_SPI_ptr handler) { _spihandler = handler; } bool active(); bool available(); + void swapPins(bool enable = 1); void pushr(uint32_t data); uint32_t popr(); diff --git a/SPI2Slave_T4/SPI2Slave_T4.tpp b/SPI2Slave_T4/SPI2Slave_T4.tpp index 17db783..7368db6 100644 --- a/SPI2Slave_T4/SPI2Slave_T4.tpp +++ b/SPI2Slave_T4/SPI2Slave_T4.tpp @@ -42,6 +42,14 @@ SPI2Slave_T4_FUNC SPI2Slave_T4_OPT::SPI2Slave_T4() { } +SPI2Slave_T4_FUNC void SPI2Slave_T4_OPT::swapPins(bool enable) { + SLAVE_PORT_ADDR; + SLAVE_CR &= ~LPSPI_CR_MEN; /* Disable Module */ + SLAVE_CFGR1 = (SLAVE_CFGR1 & 0xFCFFFFFF) | (enable) ? (3UL << 24) : (0UL << 24); + SLAVE_CR |= LPSPI_CR_MEN; /* Enable Module */ +} + + SPI2Slave_T4_FUNC bool SPI2Slave_T4_OPT::active() { SLAVE_PORT_ADDR; return ( !(SLAVE_SR & (1UL << 9)) ) ? 1 : 0; @@ -90,7 +98,7 @@ SPI2Slave_T4_FUNC void __attribute__((section(".fustrun"))) SPI2Slave_T4_OPT::SL } if ( (SLAVE_SR & (1UL << 1)) ) { spiRx[spiRxIdx] = SLAVE_RDR; - if (spiRxIdx < 255) spiRxIdx++; + if (spiRxIdx < 256) spiRxIdx++; SLAVE_SR = (1UL << 1); }