SPI on nRF52-PCA10040 possible? #nrf52832


moritzgerlich@...
 

Hi Joe,
thanks again for your fast answer.

I tried to run spi_loopback/spi.c
on nrf52840_pca10056 but i am still running into problems.

I will explain the problem, if someone has the time to take a short glimpse over it, i would very much appreciate it.

The idea/goal is just to send data via spi_transceive.
To do so i changed the main method to setup the tx and rx buffers
as well as struct device *spi_fast.

The spi_config is setup before with:

struct spi_config spi_cfg_fast = {
    .frequency = FAST_FREQ,
    .operation = SPI_OP_MODE_MASTER | SPI_MODE_CPOL |
    SPI_MODE_CPHA | SPI_WORD_SET(8) | SPI_LINES_SINGLE,
    .slave = SPI_SLAVE,
    .cs = SPI_CS,
};

I also added CONFIG_SPI=y in the nrf52840_pca10056.conf file.

The main method is:

void test_main(void)
{
//setup the buffers here
    const struct spi_buf tx_bufs[] = {
            {
                .buf = buffer_tx,
                .len = BUF_SIZE,
            },
        };
        const struct spi_buf rx_bufs[] = {
            {
                .buf = buffer_rx,
                .len = BUF_SIZE,
            },
        };
        const struct spi_buf_set tx = {
            .buffers = tx_bufs,
            .count = ARRAY_SIZE(tx_bufs)
        };
        const struct spi_buf_set rx = {
            .buffers = rx_bufs,
            .count = ARRAY_SIZE(rx_bufs)
        };
//finishesd setting buffers

//setup the device
    struct device *spi_fast;
    spi_fast = device_get_binding(SPI_DRV_NAME);
//finished setting up device

//check parameters
    printk("%s\n",SPI_DRV_NAME);
    printk("%i\n",SPI_SLAVE);
    printk("%i\n",SLOW_FREQ);
    printk("%i\n",FAST_FREQ);
//finished checking parameters

    int ret;
    ret= spi_transceive(spi_fast, &spi_cfg_fast, &tx, NULL);

    if (ret) {
        SYS_LOG_ERR("Code %d", ret);
    }

    printk("Still alive and trying.\n");
}

The problem is, that if i flash the board i get the following output:


The program hangs at spi_transceive and never reaches printk("Still alive and trying.\n");

However if i set ret= spi_transceive(spi_fast, &spi_cfg_fast, &NULL, &NULL); so output is set to NULL i get:




Does someone have an idea what is going wrong?


Thanks again.


Johannes Hutter
 

Hi Moritz,

SPI does not have DTS support in nordic boards yet, so you still have to set it up via Kconfig until https://github.com/zephyrproject-rtos/zephyr/issues/8758 is completely resolved.

The first part of

zephyr/tests/drivers/spi/spi_loopback/boards/nrf52_pca10040.conf

should be a good starting point for your case. You have to set CONFIG_SPI=y then.

Regards,
Joe

On Mon, Aug 6, 2018 at 9:15 AM <moritzgerlich@...> wrote:

Hello at all,

i have a question concerning the nRF52-PCA10040.

I want to connect the nRF52-PCA10040 to another board via SPI. However i cannot
figure out a possible way to do so. The provided samples weren't particulary helpful.
Did someone use SPI with one of the nRF52XX boards and would have an
idea (or a sample code) for using/setting up the SPI device?

Thanks in advance for any kind of help!

--

Johannes Hutter
Embedded Software Lead
Mail: johannes@...

 

Workaround GmbH (ProGlove)  
Building 64.08a, 
Rupert-Mayer-Straße 44, 81379 München



Managing Director: Thomas Kirchner 
HRB: 216605 | AG München 
USt.-IdNr.: DE298859320

 



moritzgerlich@...
 

Hello at all,

i have a question concerning the nRF52-PCA10040.

I want to connect the nRF52-PCA10040 to another board via SPI. However i cannot
figure out a possible way to do so. The provided samples weren't particulary helpful.
Did someone use SPI with one of the nRF52XX boards and would have an
idea (or a sample code) for using/setting up the SPI device?

Thanks in advance for any kind of help!