Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing SPI handle to to SPI interrupt #7

Open
aman4512 opened this issue Jul 25, 2020 · 2 comments
Open

Passing SPI handle to to SPI interrupt #7

aman4512 opened this issue Jul 25, 2020 · 2 comments

Comments

@aman4512
Copy link

I don't understand how the SPI handle is passed to the SPI interrupt. Relevant lines in code
file: stm32f407xx_spi_driver.c

void SPI_IRQHandling(SPI_Handle_t *pHandle)
{

	uint8_t temp1 , temp2;
	//first lets check for TXE
	temp1 = pHandle->pSPIx->SR & ( 1 << SPI_SR_TXE);
	temp2 = pHandle->pSPIx->CR2 & ( 1 << SPI_CR2_TXEIE);

	if( temp1 && temp2)
	{
		//handle TXE
		spi_txe_interrupt_handle(pHandle);
	}

	// check for RXNE
	temp1 = pHandle->pSPIx->SR & ( 1 << SPI_SR_RXNE);
	temp2 = pHandle->pSPIx->CR2 & ( 1 << SPI_CR2_RXNEIE);

	if( temp1 && temp2)
	{
		//handle RXNE
		spi_rxne_interrupt_handle(pHandle);
	}

	// check for ovr flag
	temp1 = pHandle->pSPIx->SR & ( 1 << SPI_SR_OVR);
	temp2 = pHandle->pSPIx->CR2 & ( 1 << SPI_CR2_ERRIE);

	if( temp1 && temp2)
	{
		//handle ovr error
		spi_ovr_err_interrupt_handle(pHandle);
	}


}

I'm architecting a similar application and need to pass SPI information from various applications. I'm using a different controller (dsPIC33). I do not understand how the different SPI handles declared in my application is passed to the interrupt context.

@Abhiyadav0
Copy link

Recheck and debug your code

@RohitAthithya
Copy link

Usually such handles are declared global variable => thus scope of these vars. are for entire program!
So as control goes to ISR, we still retain the updated info! - ISR is a function too, in the main file!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants