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

Single Byte SPI transfer with SDK15.2

I'm trying to implement the workaround for PAN58 on an nRF52832 device using SDK15.2

I've copied in the code from a previous post but I keep getting an error when I declare 'NRF_SPIM_Type * p_spim = TCspi.p_registers;' in the set up. The error I get says 'nrf_drv_spi_t {aka const struct <anonymous>}' has no member named 'p_registers'.

Init code is included. What am I doing wrong?

void Init_TC_SPI(void) {
  ret_code_t ret;
  // Configure SPIM-0 for TFT operation
  nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
  spi_config.ss_pin = SPIM_CS;
  spi_config.miso_pin = SPIM_MISO;
  spi_config.mosi_pin = SPIM_MOSI;
  spi_config.sck_pin = SPIM_CLK;
  spi_config.mode = NRF_DRV_SPI_MODE_1;
  spi_config.frequency = NRF_DRV_SPI_FREQ_4M;
  //    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
  ret = nrf_drv_spi_init(&TCspi, &spi_config, spi_event_handler, NULL);
  //ret = nrf_drv_spi_init(&TCspi, &spi_config, NULL, NULL);
  //if(ret!=NRFX_SUCCESS) { SET_ERR(w9_SPI_init_failed);}

  // ### Workaround Section Start ###

  uint32_t err_code;
  NRF_SPIM_Type * p_spim = TCspi.p_registers;
  //NRF_SPIM_Type * p_spim = TCspi.p_reg;
  //Initialize GPIOTE and PPI drivers for the workaround
  err_code = nrf_drv_gpiote_init();
  APP_ERROR_CHECK(err_code);

  // Initializes the GPIOTE channel so that SCK toggles generates events
  nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
  err_code = nrf_drv_gpiote_in_init(SPIM_CLK, &config, in_pin_handler);
  APP_ERROR_CHECK(err_code);

  err_code = nrf_drv_ppi_init();
  APP_ERROR_CHECK(err_code);

  // Allocate first unused PPI channel
  err_code = nrf_drv_ppi_channel_alloc(&ppi_channel);
  APP_ERROR_CHECK(err_code);

  // Assign the PPI channel to the SCK pin
  err_code = nrf_drv_ppi_channel_assign(ppi_channel,
      nrf_drv_gpiote_in_event_addr_get(SPIM_CLK),
      (uint32_t)&p_spim->TASKS_STOP);
 

  APP_ERROR_CHECK(err_code);
  // ### Workaround Section End   ###
}

Related