/************************************************************************************************** * @fn npSpiMonitor * * @brief This function monitors the SPI signals for error conditions and for the end of a * transaction. If an error is detected it attempts to recover. * * input parameters * * None. * * output parameters * * None. * * @return None. ************************************************************************************************** */ void npSpiMonitor(void) { if (ZNP_CFG1_UART == znpCfg1) { return; } if (npSpiState == NP_SPI_IDLE) { /* Poll for MRDY in case it was set before slave had setup the ISR. * Also, async responses may get queued, so flush them out here. */ if ((GPIOPinRead(HAL_SPI_MRDY_BASE, HAL_SPI_MRDY_PIN) == 0) || npSpiReadyCallback()) { npSpiAReqReady(); } } }
/************************************************************************************************** * @fn npSpiMonitor * * @brief This function monitors the SPI signals for error conditions and for the end of a * transaction. If an error is detected it attempts to recover. * * input parameters * * None. * * output parameters * * None. * * @return None. ************************************************************************************************** */ void npSpiMonitor(void) { switch (halSpiState) { case NP_SPI_SYNCH: break; case NP_SPI_IDLE: NP_SPI_ASSERT((NP_RDYIn_IFG & NP_RDYIn_BIT) == 0); break; case NP_SPI_WAIT_RX: NP_SPI_ASSERT((HAL_DMA_CHECK_IRQ(HAL_DMA_CH_RX)) == 0); break; case NP_SPI_WAIT_TX: NP_SPI_ASSERT((HAL_DMA_CHECK_IRQ(HAL_DMA_CH_TX)) == 0); break; case NP_SPI_WAIT_AREQ: break; default: NP_SPI_ASSERT(0); break; } if (halSpiState == NP_SPI_IDLE) { /* Poll for MRDY in case it was set before slave had setup the ISR. * Also, async responses may get queued, so flush them out here. */ if ((NP_RDYIn == 0) || (npSpiReadyCallback())) { npSpiAReqReady(); } } }
/************************************************************************************************** * @fn npSpiIdle * * @brief This function returns true if SPI is idle and there is no queued data. * * input parameters * * None. * * output parameters * * None. * * @return True if SPI is idle with no queued data. ************************************************************************************************** */ bool npSpiIdle(void) { return (halSpiState == NP_SPI_IDLE && !npSpiReadyCallback()); }