LVMakerHub / LINX

LabVIEW Community Edition LINX
Other
109 stars 114 forks source link

SPI communication with STM32 using linx #128

Closed L1ikhith closed 2 months ago

L1ikhith commented 2 months ago

Hello, i was getting errors with one of the SPI functions in LinxWiringDevice. The issue is in LinxWiringDevice. cpp, the bitOrder in SPI.setBitOrder(bitOrder) is defined as unsigned char but in STM32 SPI file it was defined as Enum. Is there a way to make the function variable as Enum instead of unsigned char

REF: SPI.cpp:

`void SPIClass::setBitOrder(BitOrder bitOrder) { _spiSettings.bitOrder = bitOrder;

spi_init(&_spi, _spiSettings.clockFreq, _spiSettings.dataMode, _spiSettings.bitOrder); }`

Wiring_constants.h

enum BitOrder { LSBFIRST = 0, MSBFIRST = 1 };

LinuxWiringDevice.cpp int LinxWiringDevice::SpiSetBitOrder(unsigned char channel, unsigned char bitOrder) { SPI.setBitOrder(bitOrder); return 0; }

samkristoff commented 2 months ago

Can you link to the SPI.cpp file you're referring to?

samkristoff commented 2 months ago

Is this the BitOrder you're rerring to: https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/cores/maple/wirish_constants.h

Can you ellaborate on the erorrs? Are you building the C++ code and getting compile time errors, runtime errors, etc?

Thanks!

L1ikhith commented 2 months ago

Hello @samkristoff thanks for the quick response, here are the links to the files SPI.cpp: https://github.com/stm32duino/Arduino_Core_STM32/blob/main/libraries/SPI/src/SPI.cpp Wiring_constants.h :https://github.com/stm32duino/Arduino_Core_STM32/blob/main/cores/arduino/wiring_constants.h

ERROR screenshot Screenshot (1)

samkristoff commented 2 months ago

Hey, can you just cast the bitOrder to unsigned char on line 310 like this:

SPI.setBitOrder((unsigned char)bitOrder);

L1ikhith commented 2 months ago

Thanks @samkristoff for now there is no error