One of the two MCUs is the master and the other is the slave. The master starts DMA sending/receiving every 5ms and triggers the slave to start DMA receiving/sending through the external interrupt signal (IND).
void MainFunctionRun(void)
{
if(!Task_Delay[0])
{
Task_Delay[0] = 5; //loop every 5ms
SpiMaster_EmitInd(PTE,IND);
DMA_Start(SPI_DMA_RX_CH,SPI_DMA_TX_CH); //master start DMA for spi
}
}
void PORTE_IRQHandler(void)
{
if(((PTE->PDIR >> IND) & 1) == 0) //slave received IND signal
{
DMA_Start(SPI_DMA_RX_CH,SPI_DMA_TX_CH); //slave start DMA for spi
}
else if(((PTE->PDIR >> ACK) & 1) == 0) //no use
{
}
PORTE->ISFR |= (1<<IND)|(1<<ACK);
}