32 #ifndef _ADF7030_1__STATE_C_ 34 #define _ADF7030_1__STATE_C_ 42 #include <drivers/spi/adi_spi.h> 45 #include <devices/rf/adf703x/adf7030-1__spi.h> 46 #include <devices/rf/adf703x/adf7030-1__mem.h> 47 #include <devices/rf/adf703x/adf7030-1__state.h> 68 #pragma diag_suppress=Pm073,Pm143 95 ADI_SPI_HANDLE hSPIDevice,
100 ADI_SPI_TRANSCEIVER Transceiver;
103 Transceiver.TransmitterBytes = 1;
104 Transceiver.ReceiverBytes = 1;
105 Transceiver.pTransmitter = spi_txbuf;
106 Transceiver.pReceiver = spi_rxbuf;
107 Transceiver.nTxIncrement = 0u;
108 Transceiver.nRxIncrement = Transceiver.nTxIncrement;
111 spi_txbuf[0] = (uint8_t)(RADIO_CMD | PHY_CMD);
114 if(adi_spi_ReadWrite(hSPIDevice, &Transceiver) != ADI_SPI_SUCCESS)
125 }
while((PHY_STATUS.
CMD_READY == 0) && (PHY_STATUS.
FW_STATUS == TRANSITION_STATUS_TRANSITION));
132 ADI_SPI_HANDLE *hDevice = hSPIDevice;
133 ADI_SPI_RESULT eResult;
134 hDevice->bBlockingMode =
true;
138 ADI_SPI_RESULT result = ADI_SPI_SUCCESS;
139 volatile uint16_t nStatus;
142 if (ADI_SPI_VALIDATE_HANDLE(hDevice))
144 eResult = ADI_SPI_INVALID_HANDLE;
148 if (ADI_SPI_STATE_MASTER != hDevice->eDevState)
150 eResult = ADI_SPI_ERR_NOT_INITIALIZED;
154 if ((NULL == pXfr->pTransmitter) && (NULL == pXfr->pReceiver))
156 eResult = ADI_SPI_INVALID_POINTER;
161 if ((hDevice->bDmaMode==
true) && ((pXfr->TransmitterBytes&1u)!=0u))
163 eResult = ADI_SPI_INVALID_PARAM;
168 if ((hDevice->bDmaMode==
true) && ((pXfr->ReceiverBytes&1u)!=0u))
170 eResult = ADI_SPI_INVALID_PARAM;
174 if (((pXfr->pReceiver != NULL) && (pXfr->ReceiverBytes == 0u)) || ((pXfr->pReceiver == NULL) && ((pXfr->ReceiverBytes > 0u))))
176 eResult = ADI_SPI_INVALID_PARAM;
181 if (((pXfr->pTransmitter != NULL) && (pXfr->TransmitterBytes == 0u)) || ((pXfr->pTransmitter == NULL) && (pXfr->TransmitterBytes > 0u)))
183 eResult = ADI_SPI_INVALID_PARAM;
188 if ((hDevice->bDmaMode==
true) && (pXfr->TransmitterBytes != 0u) &&(((uint32_t)pXfr->pTransmitter&0x1u) !=0u ) )
190 eResult = ADI_SPI_INVALID_PARAM;
195 if ( (hDevice->bDmaMode ==
true)
196 && ((pXfr->ReceiverBytes != 0u) && (((uint32_t)pXfr->pReceiver & 0x1u) != 0u) ))
198 eResult = ADI_SPI_INVALID_PARAM;
204 if ( (hDevice->bDmaMode==
true)
205 && ( ((pXfr->ReceiverBytes & (~(uint32_t)BITM_SPI_CNT_VALUE)) !=0u)
206 || ((pXfr->TransmitterBytes & (~(uint32_t)BITM_SPI_CNT_VALUE)) !=0u)))
208 eResult = ADI_SPI_INVALID_PARAM;
212 if (((pXfr->ReceiverBytes == 0u) && (pXfr->TransmitterBytes == 0u)))
214 eResult = ADI_SPI_INVALID_PARAM;
220 ADI_DISABLE_INT(hDevice->pDevInfo->eIRQn);
221 hDevice->pSpi->CTL &= (uint16_t)~(BITM_SPI_CTL_TIM | BITM_SPI_CTL_RFLUSH | BITM_SPI_CTL_TFLUSH);
222 hDevice->pSpi->IEN |= (BITM_SPI_IEN_XFRDONE);
224 hDevice->pTxBuffer = spi_txbuf;
225 hDevice->pRxBuffer = spi_rxbuf;
226 hDevice->TxRemaining = 1;
227 hDevice->RxRemaining = 1;
228 hDevice->TxIncrement = 1;
229 hDevice->RxIncrement = 1;
232 nStatus = hDevice->pSpi->STAT;
233 hDevice->pSpi->STAT = nStatus;
235 hDevice->pSpi->CTL |= ( BITM_SPI_CTL_MASEN) ;
238 if (ADI_SPI_SUCCESS != (result = AssertChipSelect(hDevice,
true)))
244 if (ADI_SPI_SUCCESS != (result = hDevice->FunctionTable.pInitDescriptorsFcn(hDevice)))
246 AssertChipSelect(hDevice,
false);
251 if (hDevice->bBlockingMode ==
true)
253 #if (ADI_CFG_ENABLE_RTOS_SUPPORT == 1) 254 PEND_EVENT(hDevice,ADI_SPI_SEMAPHORE_FAILED);
256 #if (ADI_CFG_ENTER_LOW_PWR_MODE_SUPPORT == 1) 261 PEND_EVENT(hDevice,ADI_SPI_FAILED);
265 adi_spi_MasterComplete(hDevice,&bComplete);
266 while (bComplete ==
false)
268 adi_spi_MasterComplete(hDevice,&bComplete);
280 hDevice->bBlockingMode =
false;
#define ADF7030_1_SPI_BUFFER_SIZE
uint32_t adf7030_1__XferCmd(ADI_SPI_HANDLE hSPIDevice, ADI_ADF7030_1_RADIO_STATE PHY_CMD)
Generic Radio PHY Command Transfers.
uint32_t adf7030_1__SPI_rd_byte_b_a(ADI_SPI_HANDLE hSPIDevice, ADI_ADF7030_1_RADIO_SPI_PNTR_TYPE pntrID, uint32_t AddrIn, uint32_t num_xfrs, uint8_t *pDataOut)
Read a number of bytes(s) from memory of the adf7030-1 to Host starting at location pointed by "pntr"...
ADI_ADF7030_1_RADIO_STATE