Hello everyone!
I am trying to add a SPI Master instance for my custom PCB, im using spi example as reference but im having a specific problem, and it is that the program dont pass the SPI initialization code line (not even return a error code).
My code look like this:
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(0);
void nrf_spi_init(void){
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = SPI_CS;
spi_config.miso_pin = SPI_MISO;
spi_config.mosi_pin = SPI_MOSI;
spi_config.sck_pin = SPI_SCLK;
turn_on_led(RGB_LEDS_B);
ret_code_t err_code = nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL);
switch(err_code){
case NRF_SUCCESS:
turn_on_led(RGB_LEDS_G);
break;
default:
turn_on_led(RGB_LEDS_R);
break;
}
}As you can see, i am using a RGB Leds to check what part of the code is executing well. The think is that the code compile well, flash well, but never pass the "nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL);" line. (The LED keep BLUE and not even the Green or Red LED turns on).
I have the next definitions on sdk_config.h:
#ifndef SPI_ENABLED #define SPI_ENABLED 1 #endif #ifndef SPI0_ENABLED #define SPI0_ENABLED 1 #endif #ifndef SPI1_ENABLED #define SPI1_ENABLED 0 #endif #ifndef NRFX_SPI_ENABLED #define NRFX_SPI_ENABLED 1 #endif #ifndef NRFX_SPI0_ENABLED #define NRFX_SPI0_ENABLED 1 #endif #ifndef NRFX_SPI1_ENABLED #define NRFX_SPI1_ENABLED 0 #endif #ifndef NRFX_SPIM_ENABLED #define NRFX_SPIM_ENABLED 0 #endif #ifndef NRFX_SPIM0_ENABLED #define NRFX_SPIM0_ENABLED 0 #endif #ifndef NRFX_SPIM1_ENABLED #define NRFX_SPIM1_ENABLED 0 #endif
I literally try every combination of this Defines ( SPIM enabled, SPI+SPIM, Only SPIM, etc) But nothing works. If someone have gone through something similar it will be very usefull for me, i will really appretiace the help.
Regards.