AnsweredAssumed Answered

FRDM-K22F undefined reference to `SPI_DRV_MasterInit'

Question asked by Christian Caicedo on Jan 26, 2015
Latest reply on Jan 27, 2015 by Anthony Huereca

Hello everyone,

 

I am trying to work on getting the SPI communication going with the FRDM-K22F ev board, but when I compile my code, I get the following errors:

C:\Freescale\workspaces\KSDK_guide\Debug/../Sources/main.c:128: undefined reference to `SPI_DRV_MasterInit' C:\Freescale\workspaces\KSDK_guide\Debug/../Sources/main.c:129: undefined reference to `SPI_DRV_MasterConfigureBus' C:\Freescale\workspaces\KSDK_guide\Debug/../Sources/main.c:132: undefined reference to `SPI_DRV_MasterTransferBlocking' C:\Freescale\workspaces\KSDK_guide\Debug/../Sources/main.c:137: undefined reference to `SPI_DRV_MasterDeinit'

 

In addition, I also get the following warnings:

'Building file: ../Sources/main.c' 'Invoking: Cross ARM C Compiler' arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections  -g3 -D"CPU_MK22FN512VDC12" -I"../Sources" -I"../Sources/Board" -I"../Sources/Utilities" -I"../Project_Settings/Startup_Code" -I"../SDK/platform/CMSIS/Include" -I"../SDK/platform/CMSIS/Include/device" -I"../SDK/platform/CMSIS/Include/device/MK22F51212" -I"C:\Freescale\KSDK_1.1.0/platform/utilities/inc" -I"C:\Freescale\KSDK_1.1.0/platform/utilities/src" -I"C:\Freescale\KSDK_1.1.0/platform/osa/inc" -I"C:\Freescale\KSDK_1.1.0/platform/drivers/inc" -I"C:\Freescale\KSDK_1.1.0/platform/drivers/src" -I"C:\Freescale\KSDK_1.1.0/platform/system/inc" -I"C:\Freescale\KSDK_1.1.0/platform/hal/inc" -I"C:\Freescale\KSDK_1.1.0/platform/hal/src" -std=c99 -MMD -MP -MF"Sources/main.d" -MT"Sources/main.o" -c -o "Sources/main.o" "../Sources/main.c" In file included from ../Sources/main.c:10:0: C:\Freescale\KSDK_1.1.0/platform/hal/inc/fsl_spi_hal.h: In function 'SPI_HAL_Enable': C:\Freescale\KSDK_1.1.0/platform/hal/inc/fsl_spi_hal.h:204:5: warning: implicit declaration of function 'BW_SPI_C1_SPE' [-Wimplicit-function-declaration]      BW_SPI_C1_SPE(baseAddr, 1);

 

I get a bunch of similar warnings from above, all related to the fsl_spi_hal.h ; Below is my code snipped:

#include "fsl_device_registers.h" #include "board.h" #include <stdio.h>
#include "fsl_spi_hal.h" #include "fsl_spi_master_driver.h" #include "fsl_i2c_master_driver.h"  void func(){ //init the spi module     SPI_DRV_MasterInit(SPI_instance,&mstate);     SPI_DRV_MasterConfigureBus(SPI_instance,  &userConfig,  &calculatedBaudRate);       //configure the spi bus      statRet = SPI_DRV_MasterTransferBlocking(SPI_instance,                                           NULL,                                           sendBuff,receiveBuff,                                           numBytes, timeOut);       SPI_DRV_MasterDeinit(SPI_instance); }

 

I read somewhere else that this is possible due to a linker/path error. But the weird thing is that if I try I2C it works fine and does not complain at all. And since I2C and SPI are in the same path (drivers/inc), I see no reason why SPI won't work, but I2C does. Here are 2 images, 1 for the build includes paths, and 1 for the includes tree

Include_Compiler.png

Includes_tree.png

It just drives me nuts that the UART, and I2C work fine, but the SPI will not! Any help will be extremely appreciated.

 

Note: I build the project from scratch utilizing this guide called "Writing my first KSDK Application in KDS - Hello World and Toggle LED with GPIO Interrupt.PDF" that I found floating around in another thread. It also does not work if I import the Demo "Hello World" project. Same error.

Outcomes