I'm using the C40_Ip_Example_S32K344 to develop Flash operations. I've imported the C40 component (obviously the corresponding generated files) into a custom project and functions for erasing, writing and reading work only with DomainIdValue = 0, because otherwise code keeps looping into the "do-while" attached below, because ActualDomainIDs = 0 and DomainIdValue = 1.
Into C40_Ip_Example_S32K344 code example FLS_MASTER_ID = 0 (then FLS_MASTER_ID is assigned to DomainIdValue when calling C40 functions).
/**
* Function Name C40_Ip_MainInterfaceWriteJobAddress
* Description Write the address in the PEADR register
*/
static C40_Ip_StatusType C40_Ip_MainInterfaceWriteJobAddress(uint32 PhysicalAddress,
uint8 DomainIdValue
)
{
C40_Ip_StatusType ReturnCode = STATUS_C40_IP_SUCCESS;
uint8 ActualDomainIDs;
/* Write the address in the PEADR register */
do
{
#if (STD_ON == C40_IP_ENABLE_USER_MODE_SUPPORT)
OsIf_Trusted_Call1param(C40_Ip_MainInterfaceWriteLogicalAddress, PhysicalAddress);
#else
C40_Ip_MainInterfaceWriteLogicalAddress(PhysicalAddress);
#endif
ActualDomainIDs = (uint8)((C40_Ip_pFlashBaseAddress->MCR & FLASH_MCR_PEID_MASK) >> FLASH_MCR_PEID_SHIFT);
#if (STD_ON == C40_TIMEOUT_SUPERVISION_ENABLED)
C40_Ip_u32ElapsedTicks += OsIf_GetElapsed(&C40_Ip_u32CurrentTicks, (OsIf_CounterType)C40_TIMEOUT_TYPE);
if (C40_Ip_u32ElapsedTicks >= C40_Ip_u32TimeoutTicks)
{
/* Errors Timeout because wait for the Done bit long time*/
ReturnCode = STATUS_C40_IP_ERROR_TIMEOUT;
break;
}
#endif
}
while (ActualDomainIDs != DomainIdValue);
return ReturnCode;
}
I didn't understand the usage of DomainIdValue input argument: is it the Core number to use for executing the erase/write operation?
In my project, Core 0 is running code (from Flash block 1) and Core 1 is running this functions (from Flash block 1) for erasing a sector into Flash block 2: just to be clear, running C40 functions from Core 1 with DomainIdValue = 0 works, but not with DomainIdValue = 1.