Hi there,
Can you please help me with setup Platform independent driver from ST with Zephyr?
I made some progress.
https://github.com/sayahoyahoy/lis2-pid-example/tree/main
As a beginner, I have no clue about manually controlling SPI.
Thus, I use lis2dh_raw_read and lis2dh_raw_write from the Zephyr driver.
I created a fake device to fill bus_cfg.
I used raw read/write in platform_write functions, as mentioned in the README.
I read lis2dh12_device_id_get(), which returned 0x33... so I assumed it can communicate with the sensor.
I must set .cs to NULL:
.config = {
.operation = SPI_OP_MODE_MASTER | SPI_WORD_SET(8) | SPI_TRANSFER_MSB, // | SPI_MODE_CPOL | SPI_MODE_CPHA,
.frequency = 10000000, // 10 MHz
.slave = 0,
.cs = NULL,
// .cs = &my_spi_cs,
};
Otherwise, I get:
[00:00:00.506,591] <err> os: ***** BUS FAULT *****
[00:00:00.506,591] <err> os: Instruction bus error
[00:00:00.506,622] <err> os: r0/a1: 0x200004c0 r1/a2: 0x00000001 r2/a3: 0x00000001
[00:00:00.506,622] <err> os: r3/a4: 0x21650000 r12/ip: 0x00000000 r14/lr: 0x000036f7
[00:00:00.506,652] <err> os: xpsr: 0x40000000
[00:00:00.506,652] <err> os: Faulting instruction address (r15/pc): 0x21650000
[00:00:00.506,683] <err> os: >>> ZEPHYR FATAL ERROR 27: Unknown error on CPU 0
[00:00:00.506,713] <err> os: Current thread: 0x20000be8 (unknown)
[00:00:01.730,743] <err> os: Halting system
I have no clue how to set it correctly.
However, measuring doesn't work and returns only weird values:
raw: 13107 13107 13107
I tried something with manually controlling the CS pin, but I have no idea.
How do I properly set up the SPI so that it communicates correctly? :)
thank you!