AnsweredAssumed Answered

SPI interrupt MISO line K22 and FreeRTOS driver

Question asked by Juan Pablo Echeverria on Jul 19, 2016
Latest reply on Jul 20, 2016 by Juan Pablo Echeverria

I'musing FreeRTOS SPI diver with SDK 2.0 and I need a interrupt for MISO line.

 

More in detail, I'm using AD7793 ADC and this chip have a feature that use the MISO line to indicatewhen a conversion is ready. Now, this is very useful for given the development I have in hand right now and I want to know how implement this interrupt using FreeRTOS and DSPI driver.

 

I've tried configuring the MISO pin as input with interrupt but is not working.

 

This is the configuration for my normal SPI:

 

void SetSPIConfig() {   dspi_master_config_t masterConfig;   uint32_t sourceClock;   status_t status;   /*Master config*/   masterConfig.whichCtar = kDSPI_Ctar0;   masterConfig.ctarConfig.baudRate = TRANSFER_BAUDRATE;   masterConfig.ctarConfig.bitsPerFrame = 8;   masterConfig.ctarConfig.cpol = kDSPI_ClockPolarityActiveLow;   masterConfig.ctarConfig.cpha = kDSPI_ClockPhaseSecondEdge;   masterConfig.ctarConfig.direction = kDSPI_MsbFirst;   masterConfig.ctarConfig.pcsToSckDelayInNanoSec = 2000;   masterConfig.ctarConfig.lastSckToPcsDelayInNanoSec = 2000;   masterConfig.ctarConfig.betweenTransferDelayInNanoSec = 1000;     masterConfig.whichPcs = kDSPI_Pcs1;   masterConfig.pcsActiveHighOrLow = kDSPI_PcsActiveLow;     masterConfig.enableContinuousSCK = false;   masterConfig.enableRxFifoOverWrite = false;   masterConfig.enableModifiedTimingFormat = false;   masterConfig.samplePoint = kDSPI_SckToSin0Clock;     NVIC_SetPriority(SPI0_IRQn, 6);     sourceClock = CLOCK_GetFreq(DSPI_MASTER_CLK_SRC);   status = DSPI_RTOS_Init(&master_rtos_handle, DSPI_MASTER_BASEADDR, &masterConfig, sourceClock);     if (status != kStatus_Success)   {   PRINTF("DSPI master: error during initialization. \r\n");   //vTaskSuspend(NULL);   }   }             

 

and the functions to eanble pin interrupt

void EnableSPIDataInInterrupt(void) {   DSPI_RTOS_Deinit(&master_rtos_handle);   gpio_pin_config_t pin_config;   pin_config.pinDirection = kGPIO_DigitalInput;   PORT_SetPinMux( PORTD,   3U,   kPORT_MuxAsGpio);     PORT_SetPinInterruptConfig(PORTD,3U, kPORT_InterruptRisingEdge);   EnableIRQ(PORTD_IRQn);   NVIC_SetPriority(PORTD_IRQn, 6);   GPIO_PinInit(GPIOD,3U,&pin_config);   //PORT_SetPinMux(PORTD, 3U, kPORT_MuxAlt2); // pin 60 , PTD3, SPI0_SIN, alt2, MISO }   

 

Now, once I have the interrupt I release a semaphore that reconfigure the pin as SPI MISO and read the data in AD7793 and back to configure the pin as simple input interrupt with a semaphore lock.

 

If there is a more fancy or proper way to do this please let me know.

 

Thanks in advance,

 

JP

Outcomes