Upload files to "SPI2Slave_T4"
Added swap pins function. (MOSI / MISO)
This commit is contained in:
parent
6ddc406a40
commit
39752647df
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user