I'm using an S32K344 and I'm not sure how to set which SPI instance to use for a device. How do I set this to use instance 2?
For example here is how I configured the SpiExternalDevice:
When I run the generate code the instance is set to 0
/* Lpspi_Ip_DeviceAttributes_SpiPhyUnit_1_LEDS Device Attribute Configuration of Spi*/
const Lpspi_Ip_ExternalDeviceType Lpspi_Ip_DeviceAttributes_SpiPhyUnit_1_LEDS_Instance_0_BOARD_InitPeripherals =
{
0U, /* Instance */
(uint32)(LPSPI_CCR_SCKPCS(1U) | LPSPI_CCR_PCSSCK(1U) | LPSPI_CCR_SCKDIV(12U) | LPSPI_CCR_DBT(0U)), /* ccr */
(uint32)(LPSPI_TCR_WIDTH(0U) | LPSPI_TCR_CPOL(0U) | LPSPI_TCR_CPHA(1U) | LPSPI_TCR_PRESCALE(0U) | LPSPI_TCR_PCS(0U) | LPSPI_TCR_CONT(1U)) /* TCR */
#if (STD_ON == LPSPI_IP_HALF_DUPLEX_MODE_SUPPORT)
,(uint32)0U /* This device do not support half duplex mode */
#endif
, &Lpspi_Ip_DeviceParamsCfg_BOARD_InitPeripherals[1U]
};
Solved! Go to Solution.
Hi @tommy1231
To assign the corresponding configurations to a specific SpiPhyUnit, you need to modify the SpiHwUnit parameter, as shown in the following image.
Hi @tommy1231
How to set which SPI instance to use for a device. How do I set this to use instance 2?
The LPSPI instances are configured in the Peripherals tool in the "SPIGeneral " tab. The SpiPhyUnit is where you configure the LPSPI instance. I suggest checking the Lpspi_Flexio_Ip_Transfer example so you can get familiar with the configurations and functionality of the driver.
B.R.
VaneB
Thank you for the feedback. The problem is the instance also gets included in the output for the spidriver
Here it is in the mex file, which does not have anything for the instance,
/* Lpspi_Ip_DeviceAttributes_SpiExternalDevice_0 Device Attribute Configuration of Spi*/
const Lpspi_Ip_ExternalDeviceType Lpspi_Ip_DeviceAttributes_SpiExternalDevice_0_Instance_0_BOARD_InitPeripherals =
{
0U, /* Instance */
(uint32)(LPSPI_CCR_SCKPCS(19U) | LPSPI_CCR_PCSSCK(19U) | LPSPI_CCR_SCKDIV(198U) | LPSPI_CCR_DBT(126U)), /* ccr */
(uint32)(LPSPI_TCR_WIDTH(0U) | LPSPI_TCR_CPOL(1U) | LPSPI_TCR_CPHA(1U) | LPSPI_TCR_PRESCALE(2U) | LPSPI_TCR_PCS(0U) | LPSPI_TCR_CONT(1U)) /* TCR */
#if (STD_ON == LPSPI_IP_HALF_DUPLEX_MODE_SUPPORT)
,(uint32)0U /* This device do not support half duplex mode */
#endif
, &Lpspi_Ip_DeviceParamsCfg_BOARD_InitPeripherals[0U]
};
Notice that this includes the instance. How do I set the instance?
Hi VaneB,
Thank you for the response. In my case I have 2 SPI phy lines defined. How would I configure which SPI phy to attach the SPI driver configuration to? It seems to just take the first item in the phy list. I will have multiple configurations in the SPI driver and need to assign them to different SpyPhyUnit.
Hi @tommy1231
To assign the corresponding configurations to a specific SpiPhyUnit, you need to modify the SpiHwUnit parameter, as shown in the following image.