Upload files to "SPI2Slave_T4"

Added swap pins function. (MOSI / MISO)
This commit is contained in:
Adema 2025-05-28 09:48:07 +02:00
parent 6ddc406a40
commit 39752647df
2 changed files with 10 additions and 1 deletions

View File

@ -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();

View File

@ -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);
}