Re: Using SPI Port Question - Fanstel BT840


Jeremy Herbert
 

Hi Mike,

I am not an expert on Zephyr, in fact I am roughly in the same position as you. But I have recently solved this problem so I thought I should share. I apologise in advance if some of this is obvious to you already.

The ADXL372 example will not be useful to you, because Zephyr already has a driver for that specific device. This abstracts away the direct bus access.

The first thing you need to do is ensure that the SPI peripheral is mapped to the correct pins. You can do this in the dts file for the board, or using a dts overlay. Something like this is what I would normally use for the nrf52840:

&spi1 {
    compatible = "nordic,nrf-spi";
    status = "okay";
    sck-pin = <14>;
    mosi-pin = <13>;
    miso-pin = <15>;
    cs-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;
    clock-frequency = <1000000>;
};


There is no driver for this FRAM device, so the example does indeed use the bare API to control the SPI bus.

The main use of the raw SPI API is in the function mb85rs64v_access. Note that the Zephyr APIs use a structure-in-structure approach, where you pass a spi_buf_set which contains one or more spi_buf. If you cross-reference that code with the documentation here: https://docs.zephyrproject.org/latest/reference/peripherals/spi.html it should make more sense.

Hope this helps.

Thanks,
Jeremy

Join users@lists.zephyrproject.org to automatically receive all group messages.