This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf 52840 SPIS irq multiple times

Hi,

I am trying to  use the SPIS 1 on the nrf52840 but when i compile the program i get the following problem:

Rebuilding ‘zephyr/isr_tables.c’ from solution ‘build’ in configuration ‘Common’
1> Combining ‘zephyr/isr_tables.c’
1> gen_isr_tables.py: multiple registrations at table_index 4 for irq 4 (0x4)
1> Has IRQ_CONNECT or IRQ_DIRECT_CONNECT accidentally been invoked on the same irq multiple times?
1> Traceback (most recent call last):
1> File "C:/Users/ncs/v1.2.0/zephyr/arch/common/gen_isr_tables.py", line 316, in <module>
1> main()
1> File "C:/Users/ncs/v1.2.0/zephyr/arch/common/gen_isr_tables.py", line 307, in main
1> + "\nHas IRQ_CONNECT or IRQ_DIRECT_CONNECT accidentally been invoked on the same irq multiple times?"
1> File "C:/Users/ncs/v1.2.0/zephyr/arch/common/gen_isr_tables.py", line 36, in error
1> raise Exception()
1> Exception

I am using SEGGER whit the "nrf Connect for Desktop"

Here is the code i am trying to get to work. (This code worked when i was only using Zephyr)

#include "..\config.h"
#include <string.h>
#include <sys/printk.h>
#include <drivers/spi.h>
#include <nrfx_spis.h>
#include <stdbool.h>
#include "..\error.h"
//
/* create a instance for the SPIS*/
static const nrfx_spis_t spis_p_instance = NRFX_SPIS_INSTANCE(1);

/* SPI settings */
static const nrfx_spis_config_t spis_p_config =
{
	.miso_pin 	    = DT_ALIAS_SPI_1_MISO_PIN,
	.mosi_pin 	    = DT_ALIAS_SPI_1_MOSI_PIN,
	.sck_pin 	    = DT_ALIAS_SPI_1_SCK_PIN,
	.csn_pin 	    = 35,
	.mode 		    = NRF_SPIS_MODE_0,
	.bit_order      = NRF_SPIS_BIT_ORDER_MSB_FIRST,
	.csn_pullup	= NRF_GPIO_PIN_PULLDOWN,
	.miso_drive     = NRF_GPIO_PIN_S0S1,
	.def            = 0xFF,
	.orc          	= 0xFE,
	.irq_priority	= NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY,
};


/* TX & RX buffers */
#define BUFFER_SIZE 50
#define TEST_STRING "nRF52840: Good Morning"
static u8_t       m_tx_buf[BUFFER_SIZE] = TEST_STRING;		// TX buffer
static u8_t       m_rx_buf[BUFFER_SIZE];					// RX buffer
static const u8_t m_length = sizeof(m_tx_buf);				// Transfer length


/* Interrupt for received message */
static void spis_event_handler(nrfx_spis_evt_t const * p_event, void * p_context)
{
    if (p_event->evt_type == NRFX_SPIS_XFER_DONE)
    {
    	u8_t *str = m_rx_buf;
        printk("Transfer completed. Received: %s\n", str);

	    // reset interupt and buffers

        memset(m_tx_buf, 0, BUFFER_SIZE);
        strcat(m_tx_buf, "nRF52840: ");
        strcat(m_tx_buf, m_rx_buf);
        memset(m_rx_buf, 0, BUFFER_SIZE);
        nrfx_err_t volatile ret =  nrfx_spis_buffers_set(&spis_p_instance, m_tx_buf, m_length, m_rx_buf, m_length);
    	if(ret != NRFX_SUCCESS)
    	{
    		printk("error = %x\n", ret);
    	}
    }
}


/* Initiating Test_SPIS.c */
extern int init_SPIS(void)
{
	nrfx_err_t volatile ret;
	IRQ_CONNECT(DT_ALIAS_SPI_1_IRQ_0, DT_ALIAS_SPI_1_IRQ_0_PRIORITY, nrfx_isr, nrfx_spis_1_irq_handler, 0);

	// Init SPIS
	ret = nrfx_spis_init(&spis_p_instance, &spis_p_config, spis_event_handler, NULL);
	if(ret != NRFX_SUCCESS)
	{
		printk("error = %x\n", ret);
		return -1;
	}
	// setup interupt and buffers
	ret =  nrfx_spis_buffers_set(&spis_p_instance, m_tx_buf, m_length, m_rx_buf, m_length);
	if(ret != NRFX_SUCCESS)
	{
		printk("error = %x\n", ret);
		return -1;
	}
	return 0;
}

Related