Trying to use SPI with RT1020 and Zephyr

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trying to use SPI with RT1020 and Zephyr

918 Views
f_und_e
Contributor II

Hi there,

 

I've been trying to get the SPI periphal running with Zephyr on the RT1020 evaluation board. Sadly,

I get a very unspecific error:

undefined reference to `__device_dts_ord_83'

 

My prj.conf looks like this:

CONFIG_GPIO=y
CONFIG_SPI=y

I tried other arguments like CONFIG_SPI_ASYNC but that did not change anything.

I am using an .overlay file to add an SPI device:

&lpspi1 {
        trinamic: trinamic@0 {
        compatible = "vnd,spi-device";
        reg = <0>;
        spi-max-frequency = <100000>;
        label = "trinamic";
        };
};

 

My code looks like that:

Spoiler
#include <zephyr.h>
#include <drivers/spi.h>
#include <drivers/gpio.h>

#define SPI_TEST_DEV DT_COMPAT_GET_ANY_STATUS_OKAY(trinamic)
#define SPI_OP SPI_OP_MODE_MASTER | SPI_MODE_CPOL | SPI_MODE_CPHA | SPI_WORD_SET(8) | SPI_LINES_SINGLE

uint8_t my_buffer[4] = {1, 1, 1, 1};
struct spi_buf my_spi_buffer[1];
const struct spi_buf_set tx_buff = {my_spi_buffer, 1};

const struct spi_dt_spec spi_dev =
    SPI_DT_SPEC_GET(DT_NODELABEL(trinamic), SPI_OP, 0);
uint8_t once = 0;

void main(void)
{

    if (once == 0)
    {

        my_spi_buffer[0].buf = my_buffer;
        my_spi_buffer[0].len = 4;

        spi_write_dt(&spi_dev, &tx_buff);

        once = 1;
    }
}

I don't really get it, sadly the loopback spi example is quite confusing aswell. It would be very kind if someone could help me! Thank you very much.

 

All the best

Labels (1)
0 Kudos
2 Replies

759 Views
cooked
Contributor I

Hi @f_und_e , I've been working with Zephyr+TMC recently. Although I've not tested it on NXP yet, you might find the code useful.

Here a description of the progress so far https://www.stefanocottafavi.com/zephyr_os_trinamic/

And here the repo https://github.com/cooked/zephyr-trinamic . The driver for the TMC5160 should be fine for your 5130.

Let me know if that works for you.

cheers,

stef

0 Kudos

815 Views
f_und_e
Contributor II

I figured it out. Devicetrees and stuff are confusing.. I'll do a write up in the future. If you need guidance you can look at some code here:

https://github.com/pitchbent/tmc5130_test

0 Kudos