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

TWI master and slave on the same port

Hi

I am using the nRF52840 with an external sensor which I need to config (nRF is the master). after this, nRF is acting like a I2C slave (twis) and i like to trigger an interrupt as soon as the sensor is sending some data (sensor = master, nRF = slave) To read out values from the sensor, nRF will change to master, sensor to slave.

nRF is always the master or the slave, not both at the same time of course.

Master communication is running, but as soon as I enabled the twis in the SDK config, I got the Error of an already defined IRQ:

multiple definition of `SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler;

what I found in the DevZone is that nRF is using the same IDs and it would be possible to solve this with the function

nrfx_err_t nrfx_prs_acquire(void       const * p_base_addr,
                            nrfx_irq_handler_t irq_handler);

Is tis correct? How do I have to implement this function to solve the Error?

Do you have an example which shows how should this be implemented?

Thanks a lot

Parents
  • I managed to run the TWI, but one big issue was that TXTX is not possible wit repeated start...

    anyway, I configured teh TWIS, receive the commands from the slave, but the IRQ is not getting triggered, any inputs?

    ret = nrfx_twis_init(&m_twis_1_slave, &twis_config_1, (nrfx_twis_event_handler_t)twis_event_handler);
    nrfx_twis_enable(&m_twis_1_slave);
     
    //all ok, ret without Error
     
    ///////////////////////////////////
    //no irq here even if I see the data on the oscilloscope
    static void twis_event_handler(nrfx_twis_evt_t const* const p_event)
    {
    	switch (p_event->type)
    	{
    		case NRFX_TWIS_EVT_READ_REQ:
    			if (p_event->data.buf_req)
    			{
    				// ees_readBegin();
    			}
    
    			break;
    
    		case NRFX_TWIS_EVT_READ_DONE:
    			// ees_readEnd(p_event->data.tx_amount);
    			break;
    
    		case NRFX_TWIS_EVT_WRITE_REQ:
    			if (p_event->data.buf_req)
    			{
    				//    ees_writeBegin();
    			}
    
    			break;
    
    		case NRFX_TWIS_EVT_WRITE_DONE:
    			//  ees_writeEnd(p_event->data.rx_amount);
    			break;
    
    		case NRFX_TWIS_EVT_READ_ERROR:
    		case NRFX_TWIS_EVT_WRITE_ERROR:
    		case NRFX_TWIS_EVT_GENERAL_ERROR:
    			//  m_error_flag = true;
    			break;
    
    		default:
    			break;
    	}
    }

Reply
  • I managed to run the TWI, but one big issue was that TXTX is not possible wit repeated start...

    anyway, I configured teh TWIS, receive the commands from the slave, but the IRQ is not getting triggered, any inputs?

    ret = nrfx_twis_init(&m_twis_1_slave, &twis_config_1, (nrfx_twis_event_handler_t)twis_event_handler);
    nrfx_twis_enable(&m_twis_1_slave);
     
    //all ok, ret without Error
     
    ///////////////////////////////////
    //no irq here even if I see the data on the oscilloscope
    static void twis_event_handler(nrfx_twis_evt_t const* const p_event)
    {
    	switch (p_event->type)
    	{
    		case NRFX_TWIS_EVT_READ_REQ:
    			if (p_event->data.buf_req)
    			{
    				// ees_readBegin();
    			}
    
    			break;
    
    		case NRFX_TWIS_EVT_READ_DONE:
    			// ees_readEnd(p_event->data.tx_amount);
    			break;
    
    		case NRFX_TWIS_EVT_WRITE_REQ:
    			if (p_event->data.buf_req)
    			{
    				//    ees_writeBegin();
    			}
    
    			break;
    
    		case NRFX_TWIS_EVT_WRITE_DONE:
    			//  ees_writeEnd(p_event->data.rx_amount);
    			break;
    
    		case NRFX_TWIS_EVT_READ_ERROR:
    		case NRFX_TWIS_EVT_WRITE_ERROR:
    		case NRFX_TWIS_EVT_GENERAL_ERROR:
    			//  m_error_flag = true;
    			break;
    
    		default:
    			break;
    	}
    }

Children
No Data
Related