ad_spi_open( NAME ) in SmartSnippets Studio gives undefined reference

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
6 posts / 0 new
Last post
Myken
Offline
Last seen:1 year 8 months ago
加入:2016-07-13 20:06
ad_spi_open( NAME ) in SmartSnippets Studio gives undefined reference

Hello,

Trying to get a project compiled in the SmartSnippets Studio (v2.0.7.1335), cloned project is dk_apps/features/ble_peripheral.

All works great but in one of my files I have a statement [ dev = ad_spi_open( MYNAME ) ]

The compiler complains with an error undefined reference to 'MYNAME'

The project includes an include file my_platform_devices.h which has the statement:

SPI_BUS(SPI1)
SPI_SLAVE_DEVICE(SPI1, MYNAME, HW_GPIO_PORT_3, HW_GPIO_PIN_2, HW_SPI_WORD_8BIT,
HW_SPI_POL_LOW, HW_SPI_PHA_MODE_0, HW_SPI_FREQ_DIV_8, 0);
SPI_BUS_END

If I hover over the statement in the c file I even see the define in the include file.

Any suggestions on where to look/how to resolve this?

SDK=DA1468x_DA15xxx_SDK_1.0.14.1081

Thanks.

Device:
PM_Dialog
Offline
Last seen:3 days 4 hours ago
工作人员
加入:2018-02-08 11:03
Hi Myken,

Hi Myken,

Did you create a spi_device object like follow?

spi_device dev = ad_spi_open(MYNAME);

请试试这个,让我知道。

Also, I would strongly recommend you to have a look atSPI Adapter Concepttutorial from our support portal.

Thanks, PM_Dialog

Myken
Offline
Last seen:1 year 8 months ago
加入:2016-07-13 20:06
Yes, I did:

Yes, I did:

spi_device dev; dev = ad_spi_open( MYNAME );

Forgot to copy first part.

Basically the software as is works and runs, that is I compiled and linked it using plain makefiles and tested it (works okay).
Now I try to get the same project working in SmartSnippets Studio. All is good except this part.
So probably there is something wrong in the project setup in SmartSnippets Studio.

If I do (in my_platform_devices.h):

SPI_BUS(SPI1) SPI_SLAVE_DEVICE(SPI1, MYOTHERNAME, HW_GPIO_PORT_3, ......

I get an error during compiling the file (my_spi_file.c) with the spi_device dev = ad_spi_open( MYNAME );
error: 'MYNAME' undeclared (first use in this function)

If I change it back to:

SPI_BUS(SPI1) SPI_SLAVE_DEVICE(SPI1, MYNAME, HW_GPIO_PORT_3, ......

I don't get a compiler error but a linking error
我的_spi_file.o: In function 'my_function':
我的_spi_file.c:xxx: undefined reference to 'MYNAME'

I can see that the file sdk/adapters/scr/ad_spi.c is compiled (have .o and .d files)
I included the ad_spi.h file.

If I open the my_platform_devices.h file I see in the "outline" tab MYNAME: const void* const, don't know if that mean anything.

My code looks identical to the code in "5. Code Overview" from the tutorial you reference to (MYNAME iso ECHO_LOOP).

Something wrong with compile/linking order??? Forgot to tick a box?

Thanks.

PM_Dialog
Offline
Last seen:3 days 4 hours ago
工作人员
加入:2018-02-08 11:03
HI Myken,

HI Myken,

Thanks for your inputs. Let me check and try to replicate your issue and I will get back to you as soon as possible.

Thanks, PM_Dialog

Myken
Offline
Last seen:1 year 8 months ago
加入:2016-07-13 20:06
Never mind, just (3 minutes

Never mind, just (3 minutes ago) found the solution.
Turns out, my platform_devices.h file was not in the config subdirectory of my (cloned) project. With makefiles that is not important, apparently in SmartSnippets it is.

PM_Dialog
Offline
Last seen:3 days 4 hours ago
工作人员
加入:2018-02-08 11:03
Hi Myken,

Hi Myken,

Glad that you figured your issue out and thanks for your indication.

Regards, PM_Dialog