This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52 as SPI master with Multiple Slaves

Hello, my project has 3 different devices (2 sensor and flash memory) on the same SPI bus all with their own CS. I ran across the following question, which has a response for a workaround for the NRF51. Upon jumping into the NRF52 SDK 12.2 documentation and it looks like the SPI structure has slightly changed.

Is the given solution in the previous post still applicable and if so what changes need to be made to make it work with the SDK 12.2.

If not what is the best route I need to implement 3 slaves on SPI. (GPIOTE and handle each CS individually?)

Thanks in advance

Parents
  • I did the following to add this capability:

    1. I moved the definition of spi_control_block_t from nrf_drv_spi.c to nrf_drv_spi.h, just above the declaration of nrf_drv_spi_init

    2. Also added #include "nrf_drv_common.h" to the top of nrf_drv_spi.h for compiling

    3. This allows the spi_control_block_t struct to be accessed my any source code that includes "nrf_drv_spi.h". Here is my CS change function:

      /*

      • Function for changing Chip Selecti pins in the nRF52 */

      void spi_switch_chips( uint32_t chip_select ) { volatile spi_control_block_t * my_setup = mw_spi_instance.drv_inst_idx; my_setup->ss_pin = chip_select;

       //A Slave select must be set as high before setting it as output,
       //because during connect it to the pin it causes glitches.
       nrf_gpio_pin_set(my_setup->ss_pin);
       nrf_gpio_cfg_output(my_setup->ss_pin);
       nrf_gpio_pin_set(my_setup->ss_pin);
      

      }

  • What Should i write in case of nrf51422? in place of mw_spi_instance.drv_inst_idx ? Please help, Thank you in advance.

Reply Children
No Data
Related