Hi all,
I have some issues about using the SPI module.
I want to use the S32k148 SPI0 to control two slave PMIC(FS65) and EEPROM(M95M01)
Because of the different baudrate and framsize, need to re-initialize the SPI0 configurations in the runtime. Before SPI data transmited, deinit the SPI first and then re-init SPI with the corresponded configuration.
status_t StartBlockingTransfer_SPI0(lpspi_which_pcs_t cs, uint8_t* u8_tx_buff, uint8_t* u8_rx_buff, uint16_t u16_len, uint32_t u32_timeout)
{
static uint8_t cs_temp;
if(cs_temp != cs){
cs_temp = cs;
SPI_MasterDeinit(&spi0Instance);
SPI_MasterInit(&spi0Instance, &spi0MasterConfig[cs]);
}else{
}
//LPSPI_DRV_SetPcs(0U, cs, LPSPI_ACTIVE_LOW);
return SPI_MasterTransferBlocking(&spi0Instance, u8_tx_buff, u8_rx_buff, u16_len, (uint16_t)u32_timeout);
}
Below are the SPI0 configurations for the 2 slave devices.
spi_master_t spi0MasterConfig[2] =
{
[0] ={//PMIC
.baudRate = 500000,
.ssPolarity = SPI_ACTIVE_LOW,
.frameSize = 16U,
.clockPhase = READ_ON_EVEN_EDGE,
.clockPolarity = SPI_ACTIVE_HIGH ,
.bitOrder = SPI_TRANSFER_MSB_FIRST,
.transferType = LPSPI_USING_INTERRUPTS,
.rxDMAChannel = 255U,
.txDMAChannel = 255U,
.callback = NULL,
.callbackParam = NULL,
.ssPin = 0,
.extension = NULL
},
[1] = {//EEPROM
.baudRate = 1000000, //1MHz
.ssPolarity = SPI_ACTIVE_LOW,
.frameSize = 8U,
.clockPhase = READ_ON_ODD_EDGE,
.clockPolarity = SPI_ACTIVE_HIGH ,
.bitOrder = SPI_TRANSFER_MSB_FIRST,
.transferType = LPSPI_USING_INTERRUPTS,
.rxDMAChannel = 255U,
.txDMAChannel = 255U,
.callback = NULL,
.callbackParam = NULL,
.ssPin = 1,
.extension = NULL,
}
};
Now I want to change the different configurations after the EEPROM page-write(256 bytes) transmitted completely, how could I make it?
About 16 bytes transmitted and then SPI0 deinit.

Leon