Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI Example #3

Open
Fredovsky opened this issue Apr 10, 2021 · 1 comment
Open

SPI Example #3

Fredovsky opened this issue Apr 10, 2021 · 1 comment

Comments

@Fredovsky
Copy link

Hi,

Trying to make an SPI transfer on a Raspberry Pi Zero.

Using your code and library :

#include "spi.h"

/* Initialize SPI 8 bits, 1Mhz, Mode 0, no semaphore locks */
SPI_HANDLE spi = SpiOpenPort(0, 8, 1000000, SPI_MODE_0, false);

int  main(){
        if (spi)
        {
              uint8_t buf[3] = { 0x01, 0x02, 0xAA };  // Data to send
              SpiWriteAndRead(spi, &buf[0], &buf[0], 3, false);   // Transfer buffer data to SPI
              SpiClosePort(spi);
        }
return 0;
}

Then on the pi :

g++ spi-test.c -o spitest

Gives the following error :

/usr/bin/ld: /tmp/ccMiUj6A.o: in function `__static_initialization_and_destruction_0(int, int)':
spi-test.c:(.text+0x9c): undefined reference to `SpiOpenPort'
collect2: error: ld returned 1 exit status

Please let me know if you spot an error, for now I'm stuck. Probably something obvious as I'm not an expert.

Thanks

@LdB-ECM
Copy link
Owner

LdB-ECM commented Apr 12, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants