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

SPI error

Hi, 

I have compilation error to use SPI. 

Checking project status
Building ‘ble_app_beacon_pca10056_s140’ from solution ‘ble_app_beacon_pca10056_s140’ in configuration ‘Release’
Linking ble_app_beacon_pca10056_s140.elf
Output/ble_app_beacon_pca10056_s140 Release/Obj/AS3933.o: In function `nrf_drv_spi_transfer':
undefined reference to `nrfx_spim_xfer'
Output/ble_app_beacon_pca10056_s140 Release/Obj/AS3933.o: In function `Init_AS3933':
undefined reference to `nrf_drv_spi_init'
Build failed

I have enabled NRFX_SPI_Enabled , SPI_SPI0_Enabled, NRFX_SPIM_Enabled and NRFX_SPIM0_Enabled.

Below is the details.

Here is portion of codes;

#include <stdbool.h>

#include <stdint.h>
#include "nrf_drv_spi.h"
#include "nordic_common.h"
#include "bsp.h"
#include "nrf_gpio.h"
#include "app_error.h"
#include "nrf_delay.h"
#include "include\AS3933.h"


#define AS3933_SPI_INSTANCE 0
static const nrf_drv_spi_t AS3933_SPI = NRF_DRV_SPI_INSTANCE(AS3933_SPI_INSTANCE); /**< SPI instance. */


volatile bool AS3933_SPI_XFER_Done;

void as_SPI_TX_Byte(uint8_t v);
uint8_t as_SPI_Rx_Byte(uint8_t v);
void AS3933_SPI_Event_Handler(nrf_drv_spi_evt_t const * p_event, void *p_context)
{
AS3933_SPI_XFER_Done = true;
}

void as_SPI_TX_Byte(uint8_t v){
uint8_t SPI_RX;

AS3933_SPI_XFER_Done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&AS3933_SPI, &v, 1, &SPI_RX, 1));
while(!AS3933_SPI_XFER_Done);
}


uint8_t as_SPI_Rx_Byte(uint8_t v){
uint8_t SPI_RX;
uint8_t SPI_TX = v;

AS3933_SPI_XFER_Done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&AS3933_SPI, &SPI_TX, 1, &SPI_RX, 1));
while(!AS3933_SPI_XFER_Done);

return SPI_RX;
}

void Init_AS3933(void)
{

nrf_drv_spi_config_t AS3933_SPI_Config = NRF_DRV_SPI_DEFAULT_CONFIG;
AS3933_SPI_Config.ss_pin = AS3933_SPI_SS_PIN;
AS3933_SPI_Config.miso_pin = AS3933_SPI_MISO_PIN;
AS3933_SPI_Config.mosi_pin = AS3933_SPI_MOSI_PIN;
AS3933_SPI_Config.sck_pin = AS3933_SPI_SCK_PIN;

APP_ERROR_CHECK(nrf_drv_spi_init(&AS3933_SPI , &AS3933_SPI_Config, AS3933_SPI_Event_Handler, NULL));

AS3933_SPI_XFER_Done = false;
nrf_gpio_pin_set(AS3933_SPI_SS_PIN);
as_SPI_TX_Byte(0);
as_SPI_TX_Byte(R0);
as_SPI_TX_Byte(R1);
as_SPI_TX_Byte(R2);
as_SPI_TX_Byte(R3);
as_SPI_TX_Byte(R4);
as_SPI_TX_Byte(R5);
as_SPI_TX_Byte(R6);
as_SPI_TX_Byte(R7);
as_SPI_TX_Byte(R8);
as_SPI_TX_Byte(R9);
nrf_gpio_pin_clear(AS3933_SPI_SS_PIN);
nrf_delay_ms(1); as_trim_osc(); nrf_delay_ms(1);
as_trim_osc();
as_clear_wake();
as_reset_rssi();
as_clear_false();
}

Please advise how to solve.

Thanks.

Br,

KonSang

Parents Reply Children
No Data
Related