You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
The compile isn't including in spi.c
The compiler knows what the function looks like because of spi.h but the
linker can't find the code body.
Did you use my makefile or do one yourself?
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
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#3
Hi,
Trying to make an SPI transfer on a Raspberry Pi Zero.
Using your code and library :
Then on the pi :
g++ spi-test.c -o spitest
Gives the following error :
Please let me know if you spot an error, for now I'm stuck. Probably something obvious as I'm not an expert.
Thanks
The text was updated successfully, but these errors were encountered: