/*! * Gets a command response from the radio chip * * @param cmd Command ID * @param pollCts Set to poll CTS * @param byteCount Number of bytes to get from the radio chip. * @param pData Pointer to where to put the data. */ void radio_comm_ReadData(U8 cmd, U8 pollCts, U8 byteCount, U8* pData) { if(pollCts) { while(!ctsWentHigh) { radio_comm_PollCTS(); } } radio_hal_ClearNsel(); radio_hal_SpiWriteByte(cmd); radio_hal_SpiReadData(byteCount, pData); radio_hal_SetNsel(); ctsWentHigh = 0; }
void radio_comm_ReadData(U8 cmd, uint8 pollCts, U16 byteCount, U8* pData) { if(pollCts) { while(!ctsWentHigh) { radio_comm_PollCTS(); } } radio_hal_ClearNsel(); //int TimBaseVal=GetTimingBase(); radio_hal_SpiWriteByte(cmd); radio_hal_SpiReadData(byteCount, pData); radio_hal_SetNsel(); ctsWentHigh = 0; }
U8 radio_comm_GetResp(U8 byteCount, U8* pData) { SEGMENT_VARIABLE(ctsVal = 0u, U8); SEGMENT_VARIABLE(errCnt = RADIO_CTS_TIMEOUT, U16); while (errCnt != 0) //wait until radio IC is ready with the data { radio_hal_ClearNsel(); radio_hal_SpiWriteByte(0x44); //read CMD buffer ctsVal = radio_hal_SpiReadByte(); if (ctsVal == 0xFF) { if (byteCount) { radio_hal_SpiReadData(byteCount, pData); } radio_hal_SetNsel(); break; } radio_hal_SetNsel(); errCnt--; } if (errCnt == 0) { while(1) { /* ERROR!!!! CTS should never take this long. */ #ifdef RADIO_COMM_ERROR_CALLBACK RADIO_COMM_ERROR_CALLBACK(); #endif } } if (ctsVal == 0xFF) { ctsWentHigh = 1; } return ctsVal; }