// ----------------------------------------------------------------------------- //! \brief This routine is used to handle an MRDY transition from a task //! context. Certain operations such as UART_read() cannot be //! performed from a HWI context //! //! \return void // ----------------------------------------------------------------------------- void NPITL_handleRemRdyEvent(void) { _npiCSKey_t key; key = NPIUtil_EnterCS(); //If the UART port is closed, then open it if(HS_GPIO_STATE & handshakingState) { NPITL_setPM(); //Close the GPIO, then //Open the UART PIN_close(hNpiHandshakePins); transportOpen(npiTLParams.portBoardID, &npiTLParams.portParams.uartParams, NPITL_transmissionCallBack, NPITL_chirpRecievedCB); handshakingState |= HS_WAITFORCHIRP|HS_UART_STATE; //Clear GPIO flag, we are no longer in this state handshakingState &= ~HS_GPIO_STATE; } else { //Once UART is open //Handle the RemRdy Event transportRemRdyEvent(); } NPIUtil_ExitCS(key); }
// ----------------------------------------------------------------------------- //! \brief This routine is used to handle an MRDY transition from a task //! context. Certain operations such as UART_read() cannot be //! performed from a HWI context //! //! \return void // ----------------------------------------------------------------------------- void NPITL_handleRemRdyEvent(void) { _npiCSKey_t key; key = NPIUtil_EnterCS(); // Check to make sure this event is not occurring during the next packet // transmission if (PIN_getInputValue(remRdyPIN) == 0 || (npiTxActive && mrdyPktStamp == txPktCount)) { transportRemRdyEvent(); npiRxActive = TRUE; LocRDY_ENABLE(); } NPIUtil_ExitCS(key); }
// ----------------------------------------------------------------------------- //! \brief This routine initializes the transport layer and opens the port //! of the device. Note that based on project defines, either the //! UART, or SPI driver can be used. //! //! \param[in] params - Transport Layer parameters //! //! \return void // ----------------------------------------------------------------------------- void NPITL_openTL(NPITL_Params *params) { _npiCSKey_t key; key = NPIUtil_EnterCS(); // Set NPI Task Call backs memcpy(&taskCBs, ¶ms->npiCallBacks, sizeof(params->npiCallBacks)); // Allocate memory for Transport Layer Tx/Rx buffers npiBufSize = params->npiTLBufSize; npiRxBuf = NPIUTIL_MALLOC(params->npiTLBufSize); memset(npiRxBuf, 0, npiBufSize); npiTxBuf = NPIUTIL_MALLOC(params->npiTLBufSize); memset(npiTxBuf, 0, npiBufSize); // This will be updated to be able to select SPI/UART TL at runtime // Now only compile time with the NPI_USE_[UART,SPI] flag #if defined(NPI_USE_UART) transportOpen(params->portBoardID, ¶ms->portParams.uartParams, NPITL_transmissionCallBack); #elif defined(NPI_USE_SPI) transportOpen(params->portBoardID, ¶ms->portParams.spiParams, NPITL_transmissionCallBack); #endif //NPI_USE_UART #if (NPI_FLOW_CTRL == 1) // Assign PIN IDs to remRdy and locRrdy #ifdef NPI_MASTER remRdyPIN = (params->srdyPinID & IOC_IOID_MASK); locRdyPIN = (params->mrdyPinID & IOC_IOID_MASK); #else remRdyPIN = (params->mrdyPinID & IOC_IOID_MASK); locRdyPIN = (params->srdyPinID & IOC_IOID_MASK); #endif //NPI_MASTER // Add PIN IDs to PIN Configuration npiHandshakePinsCfg[REM_RDY_PIN_IDX] |= remRdyPIN; npiHandshakePinsCfg[LOC_RDY_PIN_IDX] |= locRdyPIN; // Initialize LOCRDY/REMRDY. Enable int after callback registered hNpiHandshakePins = PIN_open(&npiHandshakePins, npiHandshakePinsCfg); PIN_registerIntCb(hNpiHandshakePins, NPITL_remRdyPINHwiFxn); PIN_setConfig(hNpiHandshakePins, PIN_BM_IRQ, remRdyPIN | PIN_IRQ_BOTHEDGES); // Enable wakeup PIN_setConfig(hNpiHandshakePins, PINCC26XX_BM_WAKEUP, remRdyPIN | PINCC26XX_WAKEUP_NEGEDGE); remRdy_state = PIN_getInputValue(remRdyPIN); // If MRDY is already low then we must initiate a read because there was // a prior MRDY negedge that was missed if (!remRdy_state) { NPITL_setPM(); if (taskCBs.remRdyCB) { transportRemRdyEvent(); LocRDY_ENABLE(); } } #endif // NPI_FLOW_CTRL = 1 #if (NPI_FLOW_CTRL == 0) // This call will start repeated Uart Reads when Power Savings is disabled transportRead(); #endif // NPI_FLOW_CTRL = 0 NPIUtil_ExitCS(key); }