Dear All,
Could some one help to answer my commented questions below ? thank you so much !
1.
//Definition at line 743 of file hal_nrf.c.
uint8_t hal_nrf_read_reg ( uint8_t reg )
{ uint8_t temp; CSN_LOW(); HAL_NRF_HW_SPI_WRITE(reg); while(HAL_NRF_HW_SPI_BUSY) {} temp = HAL_NRF_HW_SPI_READ(); HAL_NRF_HW_SPI_WRITE(0U); // Why this second SPI write operation is needed? what is the Parameter 0U means ? reg or command? or dummy ? while(HAL_NRF_HW_SPI_BUSY) {} temp = HAL_NRF_HW_SPI_READ(); // Seems the temp above already got the value, why need this temp and returned ? does this related to SPIRDAT have both two bytes deep? CSN_HIGH(); return temp; }
-------------------------------------------------------------------------
2.
//Definition at line 762 of file hal_nrf.c.
uint8_t hal_nrf_write_reg(uint8_t reg, uint8_t value)
{
uint8_t retval;
/*lint -esym(550,dummy) symbol not accessed*/
/*lint -esym(438,dummy) last assigned value not used*/
/*lint -esym(838,dummy) previously assigned value not used*/
uint8_t volatile dummy;
CSN_LOW();
HAL_NRF_HW_SPI_WRITE((W_REGISTER + reg));
while(HAL_NRF_HW_SPI_BUSY) {}
retval = HAL_NRF_HW_SPI_READ();
HAL_NRF_HW_SPI_WRITE(value);
while(HAL_NRF_HW_SPI_BUSY) {}
dummy = HAL_NRF_HW_SPI_READ();
CSN_HIGH();
return retval; // Why return retval rather than dummy ?
}
Best regards,
Kevin.