LIS3D using SPI issues
-
Im reconfiguring 1HCL 3.5FW for a custom board. I want to use the LIS3D on the SPI PA(15-19) of SAME5x , no other peripherals on the SPI bus. Heres part of my .h config;
#define SUPPORT_SPI_SENSORS 1 //**REMAPP**//# define SUPPORT_I2C_SENSORS 1 /**REMAPPED**/# define SUPPORT_I2C_SENSORS 0 # define SUPPORT_LIS3DH #if SUPPORT_LIS3DH # define ACCELEROMETER_USES_SPI (1) // accelerometer is connected via SPI constexpr Pin Lis3dhCsPin = PortAPin(18); // same as encoder CS pin constexpr Pin Lis3dhInt1Pin = PortAPin(12); // same as io1.in # endif // Shared SPI (used for interface to encoders, not for temperature sensors) constexpr uint8_t SspiSercomNumber = 1; constexpr uint32_t SspiDataInPad = 3; constexpr Pin SSPIMosiPin = PortAPin(16); constexpr GpioPinFunction SSPIMosiPinPeriphMode = GpioPinFunction::C; constexpr Pin SSPISclkPin = PortAPin(17); constexpr GpioPinFunction SSPISclkPinPeriphMode = GpioPinFunction::C; constexpr Pin SSPIMisoPin = PortAPin(19); constexpr GpioPinFunction SSPIMisoPinPeriphMode = GpioPinFunction::C;
Im getting a bunch of errors
Any help on clearing this up? Thanks!
-
@wayneosdias I've just committed a change to Duet3Expansion 3.5-dev to fix those compile errors.
-
@dc42 I updated the LISAccelerometer.cpp and now getting the following errors:
-
@wayneosdias if in file EXP1HCL.h I change the value of
# define SUPPORT_I2C_SENSORS
from 1 to 0 then I get just one compilation error, not the ones you report. I suspect you may have changed the definition ofSUPPORT_SPI_SENORS
from 1 to 0 because that would disabled the shared SPI code, leading to those compilation errors.I have committed a fix for the compilation error that I saw. Note, SPI-connected accelerometers on expansion boards have never been tested so there may be further issues with the code.
-
@dc42
Hi David, I didn't change the #define SUPPORT_SPI_SENSORS 1, but I did change quite a bit of the file. For the sake of completeness I attached my full config file. I've tried being very explicit of my flagging changes by prefacing changes, eg;//**REMAPP**//constexpr size_t MaxPortsPerHeater = 1; /**REMAPPED**/constexpr size_t MaxPortsPerHeater = 0;
I don't expect you to comb thru my full config, but if you do take a look and see anything off it'd be great if you let me know
Meantime Ill revert the LIS3DH back to I2. I only made that change as I prefer SPI to I2C. But if SPI is causing probs and hasnt been tested then Ill go back I2C.
Thanks again
-
@wayneosdias
Unwinding my SPI and I2C changes I see a change that I didn't make that I should have://**REMAPP**//# define ACCELEROMETER_USES_SPI (0) // accelerometer is connected via SPI /**REMAPPED**/# define ACCELEROMETER_USES_SPI (1) // accelerometer is connected via SPI
I tried that but still errors. I still plan to unwind everything and go back to I2C
-
@dc42
SPI success! Before unwinding everything, I took another look at the git repo and spotted LISAccelerometer.cpp had been updated after my other file update. I updated that file and everything compiles for LIS3D on SPI.Ill mark this question as solved once I confirm HW function. I have the chip carrier for the SAME5 on order but probably won't rec for a couple weeks. I may just order the PCB regardless as I need the machine back up and running and the accelerometer no critical for its fxn.