Low Power Serial Peripheral Interface (LPSPI) Peripheral Driver.
The LPSPI driver allows communication on an SPI bus using the LPSPI module in the S32144K processor.
Features
- Interrupt based
- Master or slave operation
- Provides blocking and non-blocking transmit and receive functions
- RX and TX hardware buffers (4 words)
- 4 configurable chip select
- Configurable baud rate
How to integrate LPSPI in your application
In order to use the LPSPI driver it must be first initialized in either master or slave mode, using functions LPSPI_DRV_MasterInit() or LPSPI_DRV_SlaveInit(). Once initialized, it cannot be initialized again for the same LPSPI module instance until it is de-initialized, using LPSPI_DRV_MasterDeinit() or LPSPI_DRV_SlaveDeinit(). Different LPSPI module instances can function independently of each other.
In each mode (master/slave) are available two types of transfers: blocking and non-blocking. The functions which initiate blocking transfers will configure the time out for transmission. If time expires LPSPI_MasterTransferBlocking/LPSPI_SlaveTransferBlocking will return error and the transmission will be aborted.
Important Notes
- The driver enables the interrupts for the corresponding LPSPI module, but any interrupt priority setting must be done by the application.
- The watermarks will be set by the application.
- The driver will configure SCK to PCS delay, PCS to SCK delay, delay between transfers with default values. If you application needs other values for this parameters LPSPI_DRV_MasterSetDelay function can be uesd.
Example code
.isPcsContinuous = false,
.bitcount = 8U,
.lpspiSrcClk = 8000000U,
.lsbFirst = false,
};
.bitcount = 8U,
.lsbFirst = false,
};
masterDataSend = (uint8_t*)calloc(100, sizeof(uint8_t));
masterDataReceive = (uint8_t*)calloc(100, sizeof(uint8_t));
slaveDataSend = (uint8_t*)calloc(100, sizeof(uint8_t));
slaveDataReceive = (uint8_t*)calloc(100, sizeof(uint8_t));
bufferSize = 100U;
testStatus[0] = true;
slaveDataReceive, bufferSize);
masterDataReceive, bufferSize, TIMEOUT);
|
| LPSPI Driver |
| Low Power Serial Peripheral Interface Peripheral Driver.
|
|
| LPSPI HAL |
| Low Power Serial Peripheral Interface Hardware Abstraction Layer.
|
|