nrf52833 SPI Master Mode Changeover

I need to set the SPI Mode NRF_DRV_SPI_MODE_0 for a 2nd chip (on the same SCK/MISO/MOSI) to NRF_DRV_SPI_MODE_1.The chipselect is handle by the application.

I can't do the nrf_drv_spi_uninit until the function nrf_drv_spi_init returns an error message "NRF_ERROR_INVALID_STATE".
Is there a function that returns me only the NRFX_DRV_STATE_UNINITIALIZED state?
Is it possible to change to the mode NRF_DRV_SPI_MODE_1 without calling nrf_drv_spi_init (..) again?

Regards

Ralf

Parents
  • Hi,

    I can't do the nrf_drv_spi_uninit until the function nrf_drv_spi_init returns an error message "NRF_ERROR_INVALID_STATE".

    Not sure if I understand what you are saying here. You should be able to call nrf_drv_spi_uninit() once nrf_drv_spi_init() have returned NRF_SUCCESS.

    Is there a function that returns me only the NRFX_DRV_STATE_UNINITIALIZED state?

    There is no API to get the state of the SPI driver if that is what you are asking. You should be able to remember the state of the driver in your application by setting/clearing a flag once nrf_drv_spi_init/nrf_drv_spi_uninit have been called.

    Is it possible to change to the mode NRF_DRV_SPI_MODE_1 without calling nrf_drv_spi_init (..) again?

    There is no API in the driver to change only the SPI mode, but it could possibly be done using the HAL function(s) nrf_spi_configure()/nrf_spim_configure(), if you make sure that any ongoing transfers are completed/aborted first.

    Best regards,
    Jørgen

     

Reply
  • Hi,

    I can't do the nrf_drv_spi_uninit until the function nrf_drv_spi_init returns an error message "NRF_ERROR_INVALID_STATE".

    Not sure if I understand what you are saying here. You should be able to call nrf_drv_spi_uninit() once nrf_drv_spi_init() have returned NRF_SUCCESS.

    Is there a function that returns me only the NRFX_DRV_STATE_UNINITIALIZED state?

    There is no API to get the state of the SPI driver if that is what you are asking. You should be able to remember the state of the driver in your application by setting/clearing a flag once nrf_drv_spi_init/nrf_drv_spi_uninit have been called.

    Is it possible to change to the mode NRF_DRV_SPI_MODE_1 without calling nrf_drv_spi_init (..) again?

    There is no API in the driver to change only the SPI mode, but it could possibly be done using the HAL function(s) nrf_spi_configure()/nrf_spim_configure(), if you make sure that any ongoing transfers are completed/aborted first.

    Best regards,
    Jørgen

     

Children
Related