Platform: S32DS 3.5.14
Hi,
I'm using the S32K344-EVB with LPSPI1 as Master and LPSPI2 as Slave. I'm facing an issue where the RX data is not being received, even though interrupts are enabled for both.
#define BUFFER_SIZE 10U
#define MASTER_EXTERNAL_DEVICE (Lpspi_Ip_DeviceAttributes_SpiExternalDevice_0_Instance_1_BOARD_InitPeripherals)
#define SLAVE_EXTERNAL_DEVICE (Lpspi_Ip_DeviceAttributes_SpiExternalDevice_1_Instance_1_BOARD_InitPeripherals)
static uint8 TxMasterBuffer[BUFFER_SIZE] = {0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA};
static uint8 RxMasterBuffer[BUFFER_SIZE] = {0};
static uint8 TxSlaveBuffer[BUFFER_SIZE] = {0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA};
static uint8 RxSlaveBuffer[BUFFER_SIZE] = {0};
int main(void)
{
/* Initialize system clock, pin muxing, and interrupts */
Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
IntCtrl_Ip_Init(&IntCtrlConfig_0);
/* Initialize LPSPI1 (Master) and LPSPI2 (Slave) */
Lpspi_Ip_Init(&Lpspi_Ip_PhyUnitConfig_SpiPhyUnit_0_Instance_1_BOARD_InitPeripherals); // Master
Lpspi_Ip_Init(&Lpspi_Ip_PhyUnitConfig_SpiPhyUnit_1_Instance_2_BOARD_InitPeripherals); // Slave
/* Set transfer mode to interrupt for both */
Lpspi_Ip_UpdateTransferMode(MASTER_EXTERNAL_DEVICE.Instance, LPSPI_IP_INTERRUPT); // Master
Lpspi_Ip_UpdateTransferMode(SLAVE_EXTERNAL_DEVICE.Instance, LPSPI_IP_INTERRUPT); // Slave
/* Start Slave transfer first */
(void)Lpspi_Ip_AsyncTransmit(
&SLAVE_EXTERNAL_DEVICE,
TxSlaveBuffer,
RxSlaveBuffer,
BUFFER_SIZE,
SpiSlave_Callback);
/* Then start Master transfer */
(void)Lpspi_Ip_AsyncTransmit(
&MASTER_EXTERNAL_DEVICE,
TxMasterBuffer,
RxMasterBuffer,
BUFFER_SIZE,
NULL);
while (1)
{
// Idle loop; transfers are handled via interrupts
}
return 0;
}